小编10A*_*ane的帖子

'ImageDataGenerator' 对象没有属性 'flow_from_dataframe'

我正在尝试为癌症检测 Kaggle 挑战构建一个图像分类器。这是我正在使用的代码。

`train_datagen = ImageDataGenerator(rescale=1./255,
                                   validation_split=0.15
)

test_datagen = ImageDataGenerator(rescale=1./255)

train_path = MAIN_DIR + '/CancerTrain'
valid_path = MAIN_DIR + '/CancerTrain'



train_generator = train_datagen.flow_from_dataframe(
                dataframe = train_labels,
                directory=train_path,
                x_col = 'id',
                y_col = 'label',
                has_ext=False,
                subset='training',
                target_size=(96, 96),
                batch_size=64,
                class_mode='binary'
                )

validation_generator = train_datagen.flow_from_dataframe(
                dataframe=df,
                directory=valid_path,
                x_col = 'id',
                y_col = 'label',
                has_ext=False,
                subset='validation', # This is the trick to properly separate train and validation dataset
                target_size=(96, 96),
                batch_size=64,
                shuffle=False,
                class_mode='binary'
                )`
Run Code Online (Sandbox Code Playgroud)

但是,每当我运行它时,我都会收到此错误:

`AttributeError                            Traceback (most recent call last)
<ipython-input-22-eb9c70d0ad1c> …
Run Code Online (Sandbox Code Playgroud)

python machine-learning computer-vision python-3.x

6
推荐指数
1
解决办法
5990
查看次数