I'm doing an assignment creating a cv model with 6 different classes.
I've loaded my dataset as per this example:
https://keras.io/examples/vision/image_classification_from_scratch/
but now want to visualise the data by showing 6 examples of each of the 6 classes. I keep running into indexing errors and am not sure how to resolve this! Any help would be much appreciated. My code is as follows:
train_ds = tf.keras.preprocessing.image_dataset_from_directory(
"model-data",
validation_split=0.2,
subset="training",
seed=888,
image_size=image_size,
batch_size=batch_size,
)
for a in range(6):
axes=[]
fig=plt.figure()
for images, labels in train_ds.take(-1):
items = np.where(labels==a)[0]
plt.title("6 Examples of " + class_names[a])
for i in range(6):
axes.append( fig.add_subplot(2, 3, i+1))
plt.imshow(images[items[i]].numpy().astype("uint8"))
fig.tight_layout()
plt.show()