This model has been pre-trained for the ImageNet Large Visual Recognition Challenge using the data from 2012, and it can differentiate between 1,000 different classes, like Dalmatian, dishwasher etc. The program applies Transfer Learning to this existing model and re-trains it to classify a new set of images.
This is a generic setup and can be used to classify almost any kind of image. I created a small demo that classifies two image data sets - my photos and my girlfriend's photos, and returns a prediction score denoting the possibility of it being my image or my girlfriend's image.
Prepare the image data sets
In order to start the transfer learning process, a folder named
training_dataset needs to be created in the root of the project folder. This folder will contain the image data sets for all the subjects, for whom the classification is to be performed.
training_dataset folder and add the images for all the data sets in the following manner -
/ | | ---- /training_dataset | | | | | ---- /arun | | arun1.jpg | | arun2.jpg | | ... | | | | | ---- /erica | erica1.jpg | erica2.jpg | ... | |
This enables classification of images between the
erica data sets.
Make sure to include multiple variants of the subject (side profiles, zoomed in images etc.), the more the images, the better is the result.
Initiate transfer learning
Go to the project directory and run -
$ bash train.sh
This script installs the
Inception model and initiates the re-training process for the specified image data sets.
Once the process is complete, it will return a training accuracy somewhere between
85% - 100%.
retrained graphs and
retrained labels will be saved in a folder named
This opens up the file dialog using which you can select your input file.
Once the input file is selected, the classifier will output the predictions for each data set. A prediction score between
1 is considered to be optimal.
Arun Michael Dsouza
Copyright (c) 2017 Arun Michael Dsouza
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.