Last active
June 26, 2023 14:06
-
-
Save RishiRajak/0be86a58617a11107bde0fb2ba5a8c66 to your computer and use it in GitHub Desktop.
Preprocess images
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
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