text_plain_output_1.png
from tensorflow.keras.applications.vgg16 import VGG16

from tensorflow.keras.layers import Dropout, Flatten, Dense, BatchNormalization

from tensorflow.keras.preprocessing.image import ImageDataGenerator

import os

import tensorflow as tf

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))

from tensorflow.keras.applications.vgg16 import VGG16
vgg16 = VGG16(input_shape=(image_width, image_height, 3), include_top=False, weights='imagenet')
for layer in vgg16.layers:
    layer.trainable = False
vgg16.summary()

import tensorflow as tf
from tensorflow.keras.layers import Dropout, Flatten, Dense, BatchNormalization
model_using_vgg16 = tf.keras.models.Sequential([vgg16, Flatten(), Dense(512, activation='relu'), BatchNormalization(), Dropout(0.5), Dense(64, activation='relu'), BatchNormalization(), Dropout(0.5), Dense(6, activation='softmax')])
model_using_vgg16.summary()

model_using_vgg16.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['acc'])

history = model_using_vgg16.fit_generator(train_generator, validation_data=test_generator, epochs=10)