Predict the bird breed using CNN

source: notebook, data

Predict the bird breed using CNN

We will train a model with the help of pytorch, CNN to predict the bird breed in an image.

To know what CNN is and how it works, check the references in the bottom of the story.

source: notebook, data

Lets see how data augmentation and with the use of per-trained models (transfer learning) helps in better and fast result.

An overlook of the data: Data set of 200 bird species. 27503 training images, 1000 test images(5 per species) and 1000 validation images(5 per species.
 All images are 224 X 224 X 3 (3 channels, RGB) color images in jpg format.

Steps:

  1. We will split the data into train and validation set using the random_split method from tensor’s torch.utils.data package.
  2. Convert the spitted data to DataLoader, which consists helper API.
  3. We have created 2 datasets, one by normalizing the datasets and second without normalization.

Data normalization helps in giving equal weight-age to all the channels (R,B,G) while training the weights.

  1. Load the batch of data to GPU.
  2. Train the model. (10 epochs, 20 epochs)

NOTE: I am not resting the weights while traing it with other

Results

10 epochs:

With an CNN model, get the accuracy : 41%

With an CNN models on normalize data with get the accuracy : 39%

By using predefined models we get accuracy up to: 50% (In only 4–5 epochs)

We achieved the same accuracy without data per-processing (data normalization) but if analyze the graph the model is over-fitted.As only training error rate is decreasing but validation error rate is increasing with each epoch.

Training without data per-processing
Training with data normalization
Training with use of per-processed model, varying learning rate

20 epochs:

With an CNN model, get the accuracy : 74%

With an CNN models on normalize data with get the accuracy : 78%

By using predefined models we get accuracy up to: 75%

Train with CNN, 20 epochs
Train with normalized data, 20 epochs
Pre-trained model, 20 epoch

Will soon update the blog with more epoch results, its working and other interesting experiments. Better way is to clone the notebook and try it yourself. :)