The main problems addressed by this project is to classify images of dogs according to their breed using CNN (Convolutional Neural Networks) and implementing a web application to provide online dog breeds detection. Detecting dog breed is extremely challenging, even for humans:
Brittany vs Welsh Springer Spaniel
Please find here my Medium blog post with a project overview. The Capstone project is divided into the following 2 main sub-projects.
In this project, I've implemented a Convolutional Neural Network (CNN) using transfer learning to detect dog breeds from a photo. The pre-computed network used is Xception. Udacity instructors provided guidelines, notebooks, code templates and base models for this exercise. Please follow dog-project/README.md for more information.
Preloaded networks trained on Imagenet dataset were provided by Udacity instructors. For each model, I’ve applied the methodology above compiling the model using the same parameters I used in my CNN from scratch. After the evaluation I had the following results:
Pre-trained Network | Accuracy score |
---|---|
VGG19 | 71.90 % |
Resnet50 | 81.94 % |
InceptionV3 | 82.30 % |
Xception | 86.36 % |
Given, the good results, the winner was and it had the following architecture:
As can be observed, I’ve used the pre-trained layer and only added a dropout layer, to avoid overfitting, and dense layer with exactly 133 units which is the number of classes to be predicted.
Here, we can find the training, validation and test results:
All code to train, valid and test different networks, saving the model as well as the analysis to evaluate the best network can be found at dog-project/dog_app.ipynb. This notebook template was provided by Udacity and extended by me during the project.
Please also check here my Medium blog post about this project.
Doggo is a Flask web app application to run Dog breed detection models. Based on a photo upload by a user, Doggo runs the following steps:
- Encode uploaded photo for running dog detector, human face detector and dog breed detector models
- If the photo is classified as a dog or a human face, it predicts dog breeds
- For the top n predictions, Doggo calls Wikipedia and dog.ceo to find more information about the predicted breeds
- Return results to user
- Build docker image:
docker build -t doggo .
- The app has already trained models for detecting dog, human faces and dog breeds. In case of update, you need to save the new models at
models
folder - Running the app locally:
docker run -p 5000:80 doggo
- Go to http://0.0.0.0:5000
- core/: All backend code for parsing images, instantiating models, running and formatting predictions, ...
- core/models/: Required mdels such as CNN Dog Breed detector and opencv human face detector model.
- templates/: Flask html files
- doggo.py: Flask app routes
- requirements.txt: Project dependencies
For an uploaded photo, the app runs the model and displays the main dog breed and probability of top n dog breeds:
When the models cannot the detect a dog or a human face in the uploaded photo, Doggo returns the following message:
Must give credit to Udacity for providing the dataset and guidelines to run the models. More information about that can be found at: dog-project/
Doggo is under MIT License.