Skip to content Skip to sidebar Skip to footer

Keyerror: 'class' While Using Imagedatagenerator.flow_from_dataframe

I am trying to create data generator using ImageDataGenerator.flow_from_dataframe but facing keyerror: class Before using flow_from_dataframe, i created a pivot of training datafra

Solution 1:

Can you try this, basically setting class_mode to other

columns=["any", "epidural", "intraparenchymal","intraventricular", "subarachnoid", "subdural"]
train_generator=datagen.flow_from_dataframe(
directory="/kaggle/input/rsna-intracranial-hemorrhage-detection/stage_1_train_images",
x_col="filename",
y_col=columns,
class_mode="other"target_size=(300, 300)
batch_size=64,
subset="training")

Solution 2:

Do not pivot the table. Just pass the y_col as the Label field, and put the list of unique values in class parameter. Set the class_mode as categorical. Also, it'd be x_col and y_col respectively. Keras automatically performs the one-hot encoding and does the rest.

Solution 3:

Post a Comment for "Keyerror: 'class' While Using Imagedatagenerator.flow_from_dataframe"