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
Images in the directory are not classified, instead i have seperate .csv file with the classes. So, to map the images with corresponding classes i have written below code.
import pandas as pd
import numpy as np
import tensorflow as tf
from tensorflow.keras import models, layers
import matplotlib.pyplot as plt
from IPython.display import HTML
IMAGE_SIZE=256
BATCH_SIZE=32
EPOCHS=50
LABELS=pd.read_csv('labels.csv')
LABELS_n = LABELS['label'].tolist()
class_names=['Top','Trouser','Pullover','Dress','Coat','Sandal','Shirt','Sneaker','Bag','Ankle boot']
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")