text_plain_output_1.png
from glob import glob

from keras.applications import InceptionV3

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

from keras.models import Sequential

from keras.preprocessing.image import ImageDataGenerator, load_img, img_to_array

train_path = '../input/100-bird-species/285 birds/train'
test_path = '../input/100-bird-species/285 birds/test'
validation_path = '../input/100-bird-species/285 birds/valid'

className = glob(train_path + '/*')
NumberofClass = len(className)

train_datagen = ImageDataGenerator(rescale=1 / 255)
validation_datagen = ImageDataGenerator(rescale=1 / 255)
test_datagen = ImageDataGenerator(rescale=1 / 255)

batch_size = 256
train_datagen = ImageDataGenerator(rescale=1 / 255, shear_range=0.3, horizontal_flip=True, zoom_range=0.3)
val_datagen = ImageDataGenerator(rescale=1 / 255)
train_generator = train_datagen.flow_from_directory(train_path, target_size=(224, 224), batch_size=batch_size, color_mode='rgb', class_mode='categorical')
val_generator = val_datagen.flow_from_directory(validation_path, target_size=(224, 224), batch_size=batch_size, color_mode='rgb', class_mode='categorical')

IncV3 = InceptionV3(include_top=False, weights='imagenet', input_shape=(224, 224, 3))

model = Sequential()
model.add(IncV3)
for layer in model.layers:
    layer.trainable = False
model.add(Flatten())
model.add(Dense(units=2048, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(units=NumberofClass, activation='softmax'))

model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])

history = model.fit(train_generator, validation_data=val_generator, epochs=10, batch_size=batch_size)