Skip to content

Instantly share code, notes, and snippets.

@netsatsawat
Created June 18, 2019 05:53
Show Gist options
  • Save netsatsawat/5b86ee1f679fc59c68c293728f71dfb0 to your computer and use it in GitHub Desktop.
Save netsatsawat/5b86ee1f679fc59c68c293728f71dfb0 to your computer and use it in GitHub Desktop.
Use to demonstrate the ImageDataGenerator class and flow_from_directory() method
training_datagen = tf.keras.preprocessing.image.ImageDataGenerator(rescale=1./255.,
rotation_range=30,
zoom_range=0.3,
width_shift_range=0.2,
height_shift_range=0.2,
fill_mode='nearest',
horizontal_flip=True)
validation_datagen = tf.keras.preprocessing.image.ImageDataGenerator(rescale=1./255.)
testing_datagen = tf.keras.preprocessing.image.ImageDataGenerator(rescale=1./255.)
training_generator = training_datagen.flow_from_directory('../data/Train/',
target_size=IMAGE_SIZE,
batch_size=32,
color_mode='rgb',
shuffle=True,
seed=SEED)
validatation_generator = validation_datagen.flow_from_directory('../data/Eval/',
target_size=IMAGE_SIZE,
batch_size=32,
color_mode='rgb',
shuffle=True,
seed=SEED)
testing_generator = testing_datagen.flow_from_directory('../data/Test/',
target_size=IMAGE_SIZE,
batch_size=1,
shuffle=False,
color_mode='rgb',
seed=SEED)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment