Specify output with .image_dataset_from_directory

Hello,

This is a very simple question but I haven’t been able to find an answer using google.

I want to train a model that takes as input an image and returns another image (which I want to be the same as the first).

I have a directory with my image files in it, I just can’t find how to set the expected images output for training with tf.keras.utils.image_dataset_from_directory

Thank you for your help !

It looks to me like you want to train a convolutional autoencoder. When loading images using tf.keras.utils.image_dataset_from_directory, your images must be stored in the format

main_directory/
...class_a/
......a_image_1.jpg
......a_image_2.jpg
...class_b/
......b_image_1.jpg
......b_image_2.jpg

This will return a tf.data.Dataset having both images and labels. Since you are training an autoencoder, the labels aren’t that important so set label_mode=None to get only the images. During training, you supply your images as both x and y.