# View an image import matplotlib.image as mpimg import random def plot_example_image(target_class): # target directory target_folder = f'rps/{target_class}' # random image random_image = random.sample(os.listdir(target_folder), 1) # plot image img = mpimg.imread(target_folder + "/" + random_image[0]) plt.imshow(img) plt.title(f"Class: {target_class}") plt.axis("off") print(f"Type: {type(img)}") print(f"Shape: {img.shape}") print(f"Colour channels: {img.shape[2]}") print(f"Size: {img.size / 1000}KB") print(f"Max value: {img.max()}") print(f"Min value: {img.min()}") print(f"Image name: {random_image[0]}") return img
Hosted onDeepnote