mrdbourke / tensorflow-deep-learning

All course materials for the Zero to Mastery Deep Learning with TensorFlow course.
https://dbourke.link/ZTMTFcourse
MIT License
5.14k stars 2.53k forks source link

plotting augmented_img broken #399

Open sched088 opened 2 years ago

sched088 commented 2 years ago

When plotting augmented_img we obtain the same image as the original random image. This was confirmed by rerunning the original class notebook.

yhunlu commented 1 year ago

view a random image and compare it with augmented images

import matplotlib.pyplot as plt import matplotlib.image as mpimg import os import random target_class = random.choice(train_data_1_percent.class_names) target_dir = os.path.join(train_path_1per, target_class) random_image = random.choice(os.listdir(target_dir)) random_image_path = os.path.join(target_dir, random_image)

read and plot in the random image

img = mpimg.imread(random_image_path) plt.imshow(img) plt.title(f"Original image: {target_class}") plt.axis(False);

plot augmented image

augmented_img = data_augmentation(img, training=True) plt.figure() plt.imshow(tf.squeeze(augmented_img)/255.) plt.title(f"Augmented image: {target_class}") plt.axis(False);