Skip to content

Instantly share code, notes, and snippets.

@naiborhujosua
Created August 4, 2022 12:45
Show Gist options
  • Save naiborhujosua/f88f6172365c1fdd7487be6a69f7402d to your computer and use it in GitHub Desktop.
Save naiborhujosua/f88f6172365c1fdd7487be6a69f7402d to your computer and use it in GitHub Desktop.
Exporting data
# Dataset split
train_dir = "/content/zw4p9kj6nt-2/data_splitting/Train/"
valid_dir ="/content/zw4p9kj6nt-2/data_splitting/Pred/"
test_dir = "/content/zw4p9kj6nt-2/data_splitting/Test/"
# Create data inputs
IMG_SIZE = (224, 224) # define image size
train_data = tf.keras.preprocessing.image_dataset_from_directory(directory=train_dir,
image_size=IMG_SIZE,
label_mode="categorical", # what type are the labels?
batch_size=32) # batch_size is 32 by default, this is generally a good number
val_data = tf.keras.preprocessing.image_dataset_from_directory(directory=valid_dir,
image_size=IMG_SIZE,
label_mode="categorical")
test_data = tf.keras.preprocessing.image_dataset_from_directory(directory=test_dir,
image_size=IMG_SIZE,
label_mode="categorical",shuffle=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment