Getting this error. Even ChatGPT doesn't know why

Import “tensorflow.keras.preprocessing.image” could not be resolved
This is the code block in colab

grader-required-cell
import os
import zipfile
import random
import shutil
import tensorflow as tf
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from shutil import copyfile
import matplotlib.pyplot as plt

Also note that you filed this under DLS Course 4, but I don’t recognize that code as being from any of the DLS C4 assignments. Is this a course assignment in some other course or some personal project that you are working on?

Also note that you mention “colab”. That is not used anywhere in DLS. Maybe in some of the other specializations here, but not DLS. If you are running in Colab, note that the versions of all the packages you get will be different (more up-to-date) than the TensorFlow and other packages used in any of the courses here. The APIs are not guaranteed to be forward compatible if you take a notebook from some course here and try to run it with the very latest and greatest of all the various packages.

Versions fighting?

https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/image

Deprecated: tf.keras.preprocessing.image APIs do not operate on tensors and are not recommended for new code. Prefer loading data withtf.keras.utils.image_dataset_from_directory, and then transforming the outputtf.data.Dataset with preprocessing layers. For more information, see the tutorials for loading images and augmenting images, as well as the preprocessing layer guide.

hi,
Yes. Someone as mention it might be something to do with the depreciation of an API ???

Thank you so much!
I’ll take a closer look at this.

Hey,
Thank u for your help
I’m follow the assignment labs on the course. I’m on course two week 1. Hope I haven’t posted it in the wrong forum.
Someone has mention it could be because of a depreciation of an API

Yes, that is not from DLS course 2. I’m very familiar with DLS C2 and do not recognize that assignment. Are you sure it’s not from one of the TensorFlow specializations?

I guess this too. TF1C2.

All the assignments of TF1 courses open in Colab. Maybe for TF2 and TF3 as well.

As this is not a DLS query, please move this to the relevant course category, so, official mentors for that course can guide you. Check this on how to do this.

I’ve never seen this type of error in DLS.

Not sure if I have or haven’t posted in the right place. Think a solution has been found anyway. Can not delete my original post-I need permission ?

I am glad you found the solution.

BTW, this category is Deep Learning Specialization → Convolutional Neural Networks.
You are taking TensorFlow Developer Professional Certificate → Convolutional Neural Networks in TensorFlow.

I am moving this to the correct category.