from keras_preprocessing.image import ImageDataGenerator
validation_generator = valid_datagen.flow_from_dataframe(val_data,
directory='./tiny-imagenet-200/val/images/',
x_col='Files',y_col='Class',target_size=(64,64),
color_mode='rgb',class_mode='categorical',batch_size=256,
shuffle=True,seed=42)
運行上述代碼出現:AttributeError: 'ImageDataGenerator' object has no attribute 'flow_from_dataframe
我的第一感覺是keras版本問題,然後更新一下keras試一下!
方法一:更新keras版本
pip install --upgrade keras
pip install --upgrade keras=2.1.0(指定版本)
然而對於我的問題還是沒解決,可能是其他原因!
方法二:重新安裝keras-preprocessing(先卸載之前的,再重新安裝)
(1)
1、pip uninstall keras-preprocessing
2、pip install keras-preprocessing
或者(這個沒能解決我的問題!我的是用上面的方式解決的)
(2)
pip install git+https://github.com/keras-team/keras-preprocessing.git
然後再按照下面方式調用
from keras_preprocessing.image import ImageDataGenerator