Skip to content

LLI-hub/CNN_Dog_Breed

Repository files navigation

CNN_Dog_Breed

by Iván Lucas López

Table of Contents

  1. Installation
  2. Project Overview
  3. Project Instructions
  4. Strategy to solve the problem
  5. Metrics
  6. EDA and Models
  7. Results published in a Medium blog post.
  8. Licensing, Authors, and Acknowledgements

Installation

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 *

Project Overview

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!

Sample Output

Project Instructions

Instructions to run this proyect

  1. Clone the repository and navigate to the downloaded folder.
git clone https://github.com/LLI-hub/CNN_Dog_Breed.git
cd dog-project
  1. Download the dog dataset. Unzip the folder and place it in the repo, at location path/to/dog-project/dogImages.

  2. 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.

  3. Download the VGG-16 bottleneck features for the dog dataset. Place it in the repo, at location path/to/dog-project/bottleneck_features.

  4. Open the notebook.

jupyter notebook dog_app.ipynb

Strategy to solve the problem

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.

Metrics

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.

EDA and Models

Jupyter notebook named dog_app.ipynb

The notebook is separated in 6 steps.

  1. Import Datasets
  2. Detect Humans
  3. Detect Dogs
  4. Create a CNN to Classify Dog Breeds (from Scratch)
  5. Use a CNN to Classify Dog Breeds (using Transfer Learning)
  6. Create a CNN to Classify Dog Breeds (using Transfer Learning)
  7. Write your Algorithm
  8. Test Your Algorithm

Results published in a Medium blog post

The main findings of the code can be found at the Medium blog post available here.

Licensing, Authors, Acknowledgements

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published