- Installation
- Project Overview
- Project Instructions
- Strategy to solve the problem
- Metrics
- EDA and Models
- Results published in a Medium blog post.
- Licensing, Authors, and Acknowledgements
There should be no necessary libraries to run the code here beyond the Anaconda distribution of Python.
The code should run with no issues using Python versions 3.*.
List of libraries used:
- from sklearn.datasets import load_files
- from keras.utils import np_utils
- import numpy as np
- from glob import glob
- from keras.callbacks import ModelCheckpoint
- import random
- import cv2
- import matplotlib.pyplot as plt
- from keras.applications.resnet50 import ResNet50
- from keras.preprocessing import image
- from tqdm import tqdm
- from keras.applications.resnet50 import preprocess_input, decode_predictions
- from PIL import ImageFile
- from keras.layers import Conv2D, MaxPooling2D, GlobalAveragePooling2D
- from keras.layers import Dropout, Flatten, Dense
- from keras.models import Sequential
- from keras.callbacks import ModelCheckpoint
- from extract_bottleneck_features import *
This project uses Convolutional Neural Networks (CNNs). In this project, I have learned how to build a pipeline to process real-world, user-supplied images.
Given an image of a dog, the algorithm will identify an estimate of the canine’s breed.
If supplied an image of a human, the code will identify the resembling dog breed.
Here is an example!
- Clone the repository and navigate to the downloaded folder.
git clone https://github.com/LLI-hub/CNN_Dog_Breed.git
cd dog-project
-
Download the dog dataset. Unzip the folder and place it in the repo, at location
path/to/dog-project/dogImages
. -
Download the human dataset. Unzip the folder and place it in the repo, at location
path/to/dog-project/lfw
. If you are using a Windows machine, you are encouraged to use 7zip to extract the folder. -
Download the VGG-16 bottleneck features for the dog dataset. Place it in the repo, at location
path/to/dog-project/bottleneck_features
. -
Open the notebook.
jupyter notebook dog_app.ipynb
The Latin phrase “Divide et impera” is attributed to Julius Cesar and is the strategy followed in this proyect.
The idea is create a single output that tell us:
- If there are a human in the image.
- If there are a dog in the image.
- The dog breed.
So I have used 3 different models:
- A model to identify if there is a human face in the image.
- A model to identify if there is a dog in the image.
- A model to identify the dog breed.
All the models are evaluated using the accuracy. On the human model the accuracy will be: (times a human is detected in an image where there is a human/ total images showing a human used to test the model). On the dog model the accuracy will be: (times a dog is detected in an image where there is a dog/ total images showing a dog used to test the model). On the dog breed model: Times the breed is correctly assigned / Number of images used to test the model.
Jupyter notebook named dog_app.ipynb
The notebook is separated in 6 steps.
- Import Datasets
- Detect Humans
- Detect Dogs
- Create a CNN to Classify Dog Breeds (from Scratch)
- Use a CNN to Classify Dog Breeds (using Transfer Learning)
- Create a CNN to Classify Dog Breeds (using Transfer Learning)
- Write your Algorithm
- Test Your Algorithm
The main findings of the code can be found at the Medium blog post available here.
Must give credit to Udacity for the data and the base Jupyter File.
You can find the Licensing for the data and other descriptive information at the link available here.