Is there a way to feed images of different classes, all in one directory, with their corresponding classes to in Keras?

Viewed 103

I am trying to perform image classification on a mixed dataset of five classes. all images are in the same directory. I want to use the handy image_dataset_from_directory method of keras.preprocessing. But since the files are all in one directory it only detects one class for all of them. I also used labels parameter setting it to a list of length equal to the number of images I have containing the labels, but it only reads them in one class.

train_ds = tf.keras.preprocessing.image_dataset_from_directory(
    "trainset",
    labels = trainlabels,
    image_size=image_size,
    batch_size=batch_size,
)



Found 4987 files belonging to 1 classes.

0 Answers
Related