The dataset consists of image files (license plates) which contain the ground truth text of the license plates. I also got the file path to the images as well as the labels of the license plate in a csv file (e.g. s01_l01/I00001.png,7C2 64F8). That means, that the license plates' labels exist of 37 different characters (A-Z, 0-9 and a blank space).
Now, I would like to use the ImageDataGenerator method to read in the images with this code:
from tensorflow.keras.preprocessing.image import ImageDataGenerator
datagen=ImageDataGenerator(rescale=1./255)
train_generator=datagen.flow_from_dataframe(dataframe=df, directory="/content/gdrive/My Drive/data/2017-IWT4S-CarsReId_LP-dataset", x_col="FileName", y_col="Label", class_mode="categorical", target_size=(224,224), batch_size=128)
It returns:
Found 105824 validated image filenames belonging to 7066 classes.
So, the image data generator one hot encodes the labels one by one and because I have 7066 different license plates I get the 7066 classes. So, I think it works fine but that's not the result I would like to get. I would like the ImageDataGeberator to extract me the one hot encoded labels per character and not per label. Because, imagine the case, we get a completely new license plate with another ground truth text, it will not recognize it because it's not assignable to the 7066 classes.
What do I have to modify in my code or is the objective I want to reach not achievable with ImageDataGenerator?