When I try to read the images from directory order is not preserved. Please find the below screenshots for reference.
Below is the code
train_set = tf.keras.preprocessing.image_dataset_from_directory(
“train”, shuffle=False,
color_mode=‘grayscale’,
#class_names=class_names,
labels=LABELS_n,
#label_mode=‘int’,
seed=None,
image_size=(IMAGE_SIZE, IMAGE_SIZE),
batch_size=BATCH_SIZE)
plt.figure(figsize=(25, 25))
for image_batch, labels_batch in train_set.take(1):
for i in range(32):
ax = plt.subplot(8, 4, i + 1)
plt.imshow(image_batch[i].numpy())
plt.title(class_names[labels_batch[i]])
plt.axis(“off”)
because of this wrong ordering, my train set is wrongly tagged with classes.
Any help is highly
from_tensorflow.PNG1328×366 67.5 KB


image1174×76 8.68 KB

appreciated.