Project IA Deep Learning - Supervised

DataSet Dogs vs. Cats - Kaggle

Philippe Jadoul - december 2020

Dogs vs. Cats (Kaggle) - Network CNN - Convolution Neural Network

Reseau neuronal convoluty - Wikipedia

https://fr.wikipedia.org/wiki/Réseau_neuronal_convolutif

Imports

library.jpg

Import my_fonctions

Tests All

trainkaggle.jpg

Load the dataset: Train - Dogs vs. Cats - Kaggle

dataset.png

Plot Dogs & Cats - Initial Photos

Distribution Data First Image of DataSet

Create Filename & Category Dictionaries in Pandas - data Train

Verify Filename & Category Dictionaries in Pandas - data Train

Create Filename Dictionaries in Pandas - data Test Validate

Verify Filename Dictionaries in Pandas - data Test validate

Create Filename Dictionaries in Pandas - data Test (no labels)

Verify Filename Dictionaries in Pandas - data Test

List targets_names - Labels of Classes

validation-set.jpg

Create Validation DataSet df - 20%

training-validation-data-generator.jpg

Images Properties

Training Params

train_images_datagen - ImageDataGenerator (Data Augmentation - Keras)

train_images_generator - flow_from_dataframe (Keras) - with (train_images_df)

Distribution Data First Image From ImageDataGenerator - (train_images_generator)

train_images_validate_datagen - ImageDataGenerator (Data Augmentation - Keras)

train_images_validate_generator - flow_from_dataframe (Keras) - with (train_images_validate_df)

Distribution Data First Image From ImageDataGenerator - (train_images_validate_generator)

test_images_validate_datagen - ImageDataGenerator (Keras)

test_images_validate_generator - flow_from_dataframe (Keras) - with (test_images_validate_df)

Distribution Data First Image From ImageDataGenerator - (test_images_validate_generator)

test_images_datagen - ImageDataGenerator (Keras)

test_images_generator - flow_from_dataframe (Keras) - with (test_images_df)

Distribution Data First Image From ImageDataGenerator - (test_images_generator)

Function Save Model - save_model(model_name, model_format)

Function Compile Model - compile_model(Optimizer, Learning_rate, Opt)

Function Show Predicted Image - show_img_predict(resultat, targets_n)

Function Show Predicted Images Series - img_predict_n(resultat,predict,targets_n)

create-model.jpg

Model def From (DataFlair)

Model def Type VGG16 of Keras (non-adaptavive - fixe)

Model def Type VGG16 from API Keras (adaptavive )

type-callbacks.jpg

Define the Callbacks and

Define the Callbacks and Leraning Rate - Callback_list_1 (not save model after training)

Define the Callbacks - Callback_list_2 (save best model during the training)

Define the Callbacks - Callback_list_3 (save model after training) - Max val_accuracy

step-size-training.jpg

load-model.jpg

Load The Model Type DataFlair

compile-model.jpg

Compiling the sequentail model - CNN

Compile Model DataFlair With Optimizer RMSprop - opt = None

Model Summary

train-evaluate.jpg

Training the Model From DataFlair

First Training - Batch 64 - Epochs 50 - Optimizer RMSprop - Callback_list_1 (min_lr = 0.00001)

Graph

Plotting History Graph

fit1_fig10__dataflair_RMSprop_cb1.png

fit1_fig11__dataflair_RMSprop_cb1.png

Save the Training Model - fit1dataflair RMSprop_cb1.h5

Delete Model DataFlair

Conclusions :

Second Training - Optimizer RMSprop - Callback_list_1 (min_lr = 0.00001)

Re-Load The Training Model Type DataFlair - 'fit1dataflair RMSprop_cb1.h5'

Re-Training the Model From DataFlair - fit1dataflair RMSprop_cb1.h5'

Graph

Save the Training Model - fit2dataflair RMSprop_cb1.h5

Re-Delete Model DataFlair

Conclusions :

load-model.jpg

Model def Type VGG16 of Keras (non-adaptavive - fixe)

compile-model.jpg

Compile Model VGG16 from API Keras (non-adaptavive ) With Optimizer Adam - Lr = 0.0001 - opt = True

Model Summary

train-evaluate.jpg

Training the Model VGG16 from API Keras (non-adaptavive )

First Training - Batch 64 - Epochs 50 - Optimizer Adam - Learning Rate 0.0001 - Callback_list_2

Graph

Plotting History Graph

evaluate-model.jpg

Evaluate Model VGG16 from API Keras (non-adaptavive ) With Optimizer RMSprop - opt = None

Delete the model

Conclusions :

Load the Training Model

Model Summary

Evaluate the Models

Make predictions

With the model trained, you can use it to make predictions about some images.

accuracy of the prediction first img in %

First Predicted Img

Predictions about some images.

Delete Model VGG16 of Keras (non-adaptavive - fixe)

load-model.jpg

Model Type VGG16 from API Keras (adaptavive )

compile-model.jpg

Compile Model VGG16 from API Keras (adaptavive ) With Optimizer Adam - Lr = 0.0001 - opt = True

Model Summary

train-evaluate.jpg

Training the Model VGG16 from API Keras (adaptavive )

First Training - Batch 64 - Epochs 50 - Optimizer Adam - Learning Rate 0.0001 - Callback_list_2

Graph

evaluate-model.jpg

Evaluate Model VGG16 from API Keras (adaptavive ) With Optimizer RMSprop - opt = None

Delete the model

Conclusions :

Load the Training Model

Model Summary

Evaluate the Models

Make predictions

With the model trained, you can use it to make predictions about some images.

accuracy of the prediction first img in %

First Predicted Img

Predictions about some images.