1train_datagen = ImageDataGenerator(rescale=1./255,
2 shear_range=0.2,
3 zoom_range=0.2,
4 horizontal_flip=True,
5 validation_split=0.2) # set validation split
6
7train_generator = train_datagen.flow_from_directory(
8 train_data_dir,
9 target_size=(img_height, img_width),
10 batch_size=batch_size,
11 class_mode='binary',
12 subset='training') # set as training data
13
14validation_generator = train_datagen.flow_from_directory(
15 train_data_dir, # same directory as training data
16 target_size=(img_height, img_width),
17 batch_size=batch_size,
18 class_mode='binary',
19 subset='validation') # set as validation data