Well I have created a model and I am trying to reach its labels and I want to create a label map for this dataset. I have created the data set in the code below
train_ds = tf.keras.utils.image_dataset_from_directory(
data_dir,
validation_split = 0.2,
subset = "training",
seed = 123,
image_size = (img_height, img_width),
batch_size = batch_size)
val_ds = tf.keras.utils.image_dataset_from_directory(
data_dir,
validation_split = 0.2,
subset = "validation",
seed = 123,
image_size = (img_height, img_width),
batch_size = batch_size)
I am trying it like this in Jupyter Notebook
train_ds.class_names
It should give an output for the class names, but it gives an error like this:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In [29], line 1
----> 1 train_ds.class_names
AttributeError: 'PrefetchDataset' object has no attribute 'class_names'
What should I do? I used the same class_names method before in the same code, it was working but now it gives an error like this. Can you help me?
I have used an array and give it to the labels as class names. This solved my problem.