Building VGG19 with Keras

Source: Deep Learning on Medium

Nowadays, there are already several CNN models that have been released publicly. These Models has a very deep layer and trained using computers that have high specifications (most of which stand out are their GPU and RAM). One of those models that we will discuss here is VGG19. VGG19 can classify your image in 1000 possible classes.

So using this architecture we will build an model to classify images in Intel Image Classification data set.This data set has 6 classes corresponding to sea,glacier,forest,building,mountain and street.

Data preparation

We Generate batches of tensor image data with real-time data augmentation using ImageDataGenerator in keras.while generating we keep shear_range,zoom_range to 0.2, rescale it to 1./255 and horizontal flip to be true.The following is the code for data generation.


we can build an neural network using keras or we can import it keras which is pretrained on image net. we use catergorical_crossentropy as loss,metrics like categorical_accuracy, top_2_accuracy, top_3_accuracy and sgd optimizer.

Training and evaluating the model

In this we train this model with 12 epochs lets see how it works.

we got an accuracy of 91 percent and the confusion matrix is shown below.

Predicting classes in the test set

we predict the classes of the images and store it into a csv .we also visualize accuracy and loss across epochs.