Skip to content

Instantly share code, notes, and snippets.

@RishiRajak
Last active June 26, 2023 14:06
Show Gist options
  • Save RishiRajak/0be86a58617a11107bde0fb2ba5a8c66 to your computer and use it in GitHub Desktop.
Save RishiRajak/0be86a58617a11107bde0fb2ba5a8c66 to your computer and use it in GitHub Desktop.
Preprocess images
def datapreprocessing(dataframe,bsize):
from tensorflow.keras.preprocessing.image import ImageDataGenerator
train_gen = ImageDataGenerator(zoom_range=0.5,
rescale=1.0/255,
horizontal_flip=True,
rotation_range=40,)
train_generator = train_gen.flow_from_dataframe(
dataframe,
x_col= dataframe.columns[0],
y_col=dataframe.columns[1],
target_size=(150,150),
batch_size=bsize,
color_mode="rgb",
shuffle=True,
class_mode='categorical')
return train_generator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment