tensorflow: "classes" not working on flow_from_dataframe

The classes parameter works on flow_from_directory but not flow_from_dataframe in TF 2.4.

train_generator = train_datagen.flow_from_dataframe(dataframe=df,
                                                    x_col="img_path",
                                                    y_col="class",
                                                    classes=["rika", "risa","yui", "akane","neru"],
                                                    target_size=(200, 200),
                                                    batch_size=32,
                                                    class_mode='categorical', shuffle=False)

The train_generator.class_indices output are not correspond my classes lists.

Please correct me if I am wrong. Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

I will update this thread when the fix is in hopefully by end of this week. Thanks!

@andy6804tw, I already see the issue has been moved to keras repo by us, please track the issue here https://github.com/keras-team/keras/issues/15206

It is working as per the alphabetical order of classes and the mapping of classes is working as expected, please find the gist here. Thanks!

@ymodak was wondering if you happened to implement this fix? or a workaround? Was just scratching my head for a few hours not realizing it was ignoring the classes variable I was specifying.

Thanks!

@ymodak, Was able to reproduce the issue with TF v2.3, TF v2.4 and TF-nightly. Please find the gist of it here. Thanks!

@andy6804tw, In order to reproduce the issue reported here, could you please provide the complete code and the dataset you are using. Thanks!

The classes correspond to the directory names in alphabetical order. Therefore you see that order.