"""
# tensorflow "classes" not working on flow_from_dataframe #47281
[GitHub Issue](https://github.com/tensorflow/tensorflow/issues/47281)

Please correct me if I am wrong. Thanks! 
"""
# This Python 3 environment comes with many helpful analytics libraries installed
# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python
# For example, here's several helpful packages to load

import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import glob
# Input data files are available in the read-only "../input/" directory
# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory

import os
# for dirname, _, filenames in os.walk('/kaggle/input'):
#     for filename in filenames:
#         print(os.path.join(dirname, filename))

# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using "Save & Run All" 
# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session
"""
## Load classmap 
"""
class_map = pd.read_csv('/kaggle/input/cnn-who-is-she/CNN_who_is_she/classmap.csv')
class_dict = dict(list(zip(class_map.classname, class_map.classnum)))
class_dict.keys()
"""
## Load training image path
"""
img_path = glob.glob('/kaggle/input/cnn-who-is-she/CNN_who_is_she/training_set/training_set/*/*.png') 
class_y = []
for i in img_path:
    y = i.split('/')[7]
    class_y.append(y)
df = pd.DataFrame({'img_path':img_path, 'class':class_y})
df
"""
## ImageDataGenerator
"""
from tensorflow.keras.preprocessing.image import ImageDataGenerator
train_datagen = ImageDataGenerator( 
                                    rescale=1./255,
                                    rotation_range=10,
                                    width_shift_range=0.05,
                                    height_shift_range=0.05,
                                    horizontal_flip=True,
                                    vertical_flip=False,
                                    fill_mode='wrap'
                                 )
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)
"""
## Question
- The classes parameter works on `flow_from_directory` but not `flow_from_dataframe` in TF 2.4. 
- The `train_generator.class_indices` output are not correspond my classes lists.
"""
# class indices from `train_datagen.flow_from_dataframe`
train_generator.class_indices
# Here is the result I want
class_dict