Clock and crocodile recognition and classification on images using deep learning.
To build a classifier that separates images from the given dataset: a crocodile or a clock. To specify the accuracy obtained of the model.
To classify images, the dataset given was divided into training, validation and test samples in the ratio of 0.7
: 0.15
: 0.15
, respectively. See more in dataset_preparation.ipynb
.
Based on the pre-trained VGG16 neural network, a classifier was constructed using the Keras library with the Tensorflow backend.
The classifier was trained, the accuracy obtained on the test data is 87.5%
. To increase the accuracy of the classification, fine-tuning of the last layer of the pre-trained VGG16 neural network was made. Achieved classification accuracy: 93.75%
on the test data. See NN_Train.ipynb
with a detailed step-by-step description.
As a demonstration, the trained neural network was tested on random images of clocks and crocodiles found on the Internet. See more in NN_Test.ipynb
.
The classifier performed well on the test dataset and even was able to recognize some random images from the Internet. Here are the plans of improving the classifier accuracy:
- Perform data augmentation: generate more images by shifting / rotating / stretching the samples.
- Make more detailed fine-tuning
- Train this classifier on a more complex pre-trained neural network (i.e. InceptionV3)
- Perform feature analysis, when the pre-trained neural network extracts the features, and then the classifier learns on the features separately, which significantly speeds up the learning process.
- If we are not limited only by the given dataset, it would be nice to train the classifier on a larger dataset. Images with clocks and crocodiles can be taken from ImageNet or downloaded from search queries using a python script. This will make the classifier more accurate, since the samples for training and validation will be larger.
- clocks_crocodiles = Initial dataset from the given archive.
- data - Processed dataset, sorted by train, validation and test folders.
- redist - Archives with datasets, convenient for downloading.
- trained_net - Saved trained model for fast loading into your projects. No need to train anew.
To use, you must install all dependency packages for Python3. Use pip3
to quickly and easily install everything you need.
`bash pip3 install -r requirements.txt
`
To train the neural network and evaluate it's accuracy, use NN_Train.ipynb.
To test the trained model on any images, use NN_Test.ipynb
This neural network was trained and tested in the Jupyter Notebook analogue - the Google cloud API with GPU acceleration Google Colaboratory
. It is recommended to train the neural network there, since it is faster. In notebooks (* .ipynb
) there are code cells for normal work with Google Colaboratory. If you work on a local PC, do not execute these cells.
While training a neural network, the author studied too, having completed the course on building deep neural networks using Python from Andrei Sozykin. The author was sometimes inspired from the code shown in example sections in the course materials.