text_plain_output_1.png image_output_2.png image_output_1.png
from tensorflow.keras.preprocessing.image import ImageDataGenerator

import os

import os
def list_files(startpath):
    for root, dirs, files in os.walk(startpath):
        level = root.replace(startpath, '').count(os.sep)
        indent = ' ' * 4 * level
        subindent = ' ' * 4 * (level + 1)

train_dir = '../input/seg_train/seg_train/'

test_dir = '../input/seg_test/seg_test/'

from tensorflow.keras.preprocessing.image import ImageDataGenerator
image_width, image_height = (150, 150)
train_datagen = ImageDataGenerator(rescale=1.0 / 255, rotation_range=40, width_shift_range=0.2, height_shift_range=0.2, shear_range=0.2, zoom_range=0.2, horizontal_flip=True, fill_mode='nearest')
test_datagen = ImageDataGenerator(rescale=1.0 / 255.0)
train_generator = train_datagen.flow_from_directory(train_dir, batch_size=128, class_mode='categorical', target_size=(image_width, image_height))
test_generator = test_datagen.flow_from_directory(test_dir, batch_size=128, class_mode='categorical', target_size=(image_width, image_height))