ImportError: cannot import name 'ImageDataGenerator' from 'keras.preprocessing.image' (/opt/conda/lib/python3.10/site-packages/keras/preprocessing/image/init.py)
Occurred when running in Kaggle. The issue is not present when running in google collab
It should ideally run without throwing any error
Instead of this:
from keras.preprocessing.image import ImageDataGenerator
Tried this and working as expected:
from tensorflow.keras.preprocessing.image import ImageDataGenerator
Same problem with me and then I change it and it's working!
For keras-3.0.5 & tensorflow-2.16.1 the way for importing ImageDataGenerator is
from keras.src.legacy.preprocessing.image import ImageDataGenerator
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With