Question on loading my own data

I’m pretty new so sorry if my question is elementary.

I am trying to basally replicate the Fashion MNIST tutorial but with my own images. My own images are only in two classes: ‘candle’ and ‘no candle’.

I load my data using the following:

ds_train = tf.keras.preprocessing.image_dataset_from_directory(
‘C:/Users/Eric/Desktop/Candle Data’,
labels=‘inferred’,
label_mode=“int”,
color_mode=‘grayscale’,
batch_size=4,
image_size=(256, 256),
shuffle=True,
seed=123,
)

I think that this is an ok as far as how to load my images although I am not certain.

The image files are on my computer in two folders named: ‘Candle’ and ‘No Candle’ at the location above.

In the tutorial they define the following:

train_images and train_labels

Then the images and labels are used to make the model:

model.fit(train_images, train_labels, epochs=10)

I think that I have loaded the images to ‘ds_train’ but I don’t have the labels. When I created ‘ds_train’ I used the ‘infered’ labels but I don’t know if that created the necessary labels or not.

How should I define the labels for my images, or have I done this already?

Thank you for any help

You can read what each of the parameters means here: tf.keras.utils.image_dataset_from_directory  |  TensorFlow Core v2.8.0
At present, the algorithm in your code assigns integer class labels to images that it finds in the nested folders of the root folder with data.
Both images and labels are stored in the Dataset object (ds_train), which you can pass to model.fit()

1 Like

Thank you for your help. In the end I didn’t have the class names defined correctly (this was easier to fix than I thought) and I had a mismatched size. Thank you