Created
October 1, 2022 04:14
-
-
Save jkmackie/f4b51bafcb65e65cb398d220870b5b95 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from keras.applications.vgg16 import VGG16 | |
#Create dataset. The file_paths method shows train_ds and val_ds are mutually exclusive. | |
train_ds = tf.keras.utils.image_dataset_from_directory( | |
'./images/train/', | |
labels='inferred', | |
shuffle=True, | |
seed=8, | |
image_size=(224, 224), | |
batch_size=32) | |
val_ds = tf.keras.utils.image_dataset_from_directory( | |
'./images/valid/', | |
labels='inferred', | |
shuffle=True, | |
seed=8, | |
image_size=(224, 224), | |
batch_size=32) | |
class_names = train_ds.class_names | |
plt.figure(figsize=(10, 10)) | |
for images, labels in train_ds.take(1): | |
for i in range(6): | |
ax = plt.subplot(3, 3, i + 1) | |
plt.imshow(images[i].numpy().astype("uint8")) #uint is 0 to 255. | |
plt.title(class_names[labels[i]]); plt.axis("off"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment