text_plain_output_1.png
from tensorflow.keras.applications.inception_v3 import InceptionV3

from tensorflow.keras.callbacks import EarlyStopping

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

import pandas as pd

import tensorflow as tf

sub = pd.read_csv('../input/cassava-leaf-disease-classification/sample_submission.csv')
train = pd.read_csv('../input/cassava-leaf-disease-classification/train.csv')
train['label'] = train['label'].astype('str')

from tensorflow.keras.applications.inception_v3 import InceptionV3
pretrained_base = InceptionV3(weights='imagenet', include_top=False, input_shape=(150, 150, 3))
pretrained_base.trainable = False

from tensorflow.keras.callbacks import EarlyStopping
early_stopping = EarlyStopping(min_delta=0.001, patience=8, restore_best_weights=True)
model = tf.keras.models.Sequential([pretrained_base, tf.keras.layers.Flatten(), tf.keras.layers.Dense(64, activation='relu'), tf.keras.layers.Dense(5, activation='softmax')])
model.summary()
model.compile(loss='categorical_crossentropy', optimizer=tf.keras.optimizers.Adam(lr=0.001), metrics=['accuracy'])

train_datagen = ImageDataGenerator(rescale=1.0 / 255, shear_range=0.2, zoom_range=0.2, horizontal_flip=True)
train_data = train_datagen.flow_from_dataframe(dataframe=train, directory='../input/cassava-leaf-disease-classification/train_images', x_col='image_id', y_col='label', batch_size=16, target_size=(150, 150))
validation_data = train_datagen.flow_from_dataframe(dataframe=train, directory='../input/cassava-leaf-disease-classification/train_images', x_col='image_id', y_col='label', batch_size=16, target_size=(150, 150))

history = model.fit(train_data, epochs=10, validation_data=validation_data, callbacks=[early_stopping])