Skip to content

Instantly share code, notes, and snippets.

@Akash-Rawat
Created July 28, 2021 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Akash-Rawat/fb62d52b880f0e9dec76972ef23bd134 to your computer and use it in GitHub Desktop.
Save Akash-Rawat/fb62d52b880f0e9dec76972ef23bd134 to your computer and use it in GitHub Desktop.
train_generator = ImageDataGenerator(
preprocessing_function=tf.keras.applications.mobilenet_v2.preprocess_input,
validation_split=0.2
)
test_generator = tf.keras.preprocessing.image.ImageDataGenerator(
preprocessing_function=tf.keras.applications.mobilenet_v2.preprocess_input
)
train_images = train_generator.flow_from_dataframe(
dataframe=train_df,
x_col='Filepath',
y_col='Label',
target_size=(64, 64),
color_mode='rgb',
class_mode='categorical',
batch_size=32,
shuffle=True,
seed=0,
subset='training',
rotation_range=30,
zoom_range=0.15,
width_shift_range=0.2,
height_shift_range=0.2,
shear_range=0.15,
horizontal_flip=True,
fill_mode="nearest"
)
test_images = test_generator.flow_from_dataframe(
dataframe=test_df,
x_col='Filepath',
y_col='Label',
target_size=(64, 64),
color_mode='rgb',
class_mode='categorical',
batch_size=32,
shuffle=False
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment