Monkey Species Classification using Convolutional Neural Networks and Fastai library

I just finished watching lesson 1 of Practical Deep Learning for Coders, v3 . At the end of the lesson Jeremy encouraged us to try our hands on a project of our own. This is my attempt at the same.

Dataset Used —10 Monkey Species.

I chose this dataset for primarily two reasons. One, this required fine-grained classification, which is what we learned in lesson 1. And Second, it seemed silly and fun, which is what I was aiming for.

Okay, Let’s get started!

Dataset

The dataset consists of two files, training and validation. Each folder contains 10 subfolders labeled as n0-n9, each corresponding a species form Wikipedia’s monkey cladogram. Images are 400 x 300 px or larger and JPEG format (almost 1400 images).

Label mappings:
n0 - alouatta_palliata
n1 - erythrocebus_patas
n2 - cacajao_calvus
n3 - macaca_fuscata
n4 - cebuella_pygmea
n5 - cebus_capucinus
n6 - mico_argentatus
n7 - saimiri_sciureus
n8 - aotus_nigriceps
n9 - trachypithecus_johnii

Code

Import necessary modules.

Looking At Data.

Set path = ‘path to dataset’.

Create the data object.

Classes to predict.

Training: resnet34

Create the learner object.

Train and save the model.

Error rate is just 0.007353 :)

Results

Plot the confusion matrix to help understand the results.

Categories that the model most confused with one another.

Conclusion

This model with an error rate of 0.007353 and just two images miss-classified, is a pretty accurate model.

We were able to achieve this accuracy (~99.99) with just some simple steps and without any fine-tuning, which is just amazing.