I am trying to create a multilabel classification model with keras. As such I have all my images in one folder. Furthermore, I have a CSV file containing a path to each image followed by multiple possible labels
Example of my CSV:
path, x1, x2, x3
img/img_00000001.jpg,1,0,1
img/img_00000002.jpg,0,0,1
...
I am trying to read in my images using flow_from_directory and provide the respective labels via the CSV. My so far looks like this:
image_path= "C:/user/Images"
data_generator = ImageDataGenerator(rescale=1./255,
validation_split=0.20)
train_generator = data_generator.flow_from_directory(image_path, target_size=(IMAGE_HEIGHT, IMAGE_SIZE), shuffle=True, seed=13,
class_mode='binary', batch_size=BATCH_SIZE, subset="training")
validation_generator = data_generator.flow_from_directory(image_path, target_size=(IMAGE_HEIGHT, IMAGE_SIZE), shuffle=False, seed=13,
class_mode='binary', batch_size=BATCH_SIZE, subset="validation")
A solution to a similar problem is suggested here: How to manually specify class labels in keras flow_from_directory? providing this code:
def multiclass_flow_from_directory(flow_from_directory_gen, multiclasses_getter):
for x, y in flow_from_directory_gen:
yield x, multiclasses_getter(x, y)
However, I cant figure out how to implement the multiclasses_getter() such that it works.