Skip to content

Garima5/Dog-breed-classifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Dog-breed-classifier

Deep learning project - dog breed classifier - Coded a CNN from scratch to classify dog breeds and then improved performance using transfer learning

Summary

Create an application where user supplies images. If a dog is detected in the image, the model gives the nearest detected dog breed. If a human is detected, the model gives the nearest resembling dog breed to that human face.

Steps

  • Step 0: Import Datasets
  • Step 1: Detect Humans
  • Step 2: Detect Dogs
  • Step 3: Create a CNN to Classify Dog Breeds (from Scratch)
  • Step 4: Create a CNN to Classify Dog Breeds (using Transfer Learning)
  • Step 5: Write the Algorithm
  • Step 6: Test the Algorithm

Libraries Used

  • Numpy
  • glob : Use Unix shell rules to find filenames matching a pattern.
  • Pytorch
  • Opencv
  • matplotlib
  • PIL - The Python Imaging Library adds image processing capabilities to your Python interpreter.

Step 0

Load data using glob and numpy

Step 1 - Detecting human faces

Use OpenCV's implementation of Haar feature-based cascade classifiers to detect human faces in images.

Important points to keep in mind

  1. Before using any of the face detectors, it is standard procedure to convert the images to grayscale.
  2. In the code, faces is a numpy array of detected faces, where each row corresponds to a detected face. Each detected face is a 1D array with four entries that specifies the bounding box of the detected face. The first two entries in the array (extracted in the above code as x and y) specify the horizontal and vertical positions of the top left corner of the bounding box. The last two entries in the array (extracted here as w and h) specify the width and height of the box.

Step 2 - Detecting dogs

Using transforms from Pytorch's functionalities and transfer learning trough VGG16 model, find if a dog is detected in the image or not. The function gives the index that has the probability among all the classes. Since the indexes between 151 and 268 correspond to dog breeds, hence if the maximum index returned follows in this range, the images contains a dog.

Step 3 - Create a CNN to Classify Dog Breeds (from Scratch)

Code a convulation neural network to classify dog breeds from scratch.

Challenges undertaken to create the CNN from scratch to classify dog breed classifier

  1. Code a CNN from scratch, without using transfer learning and must attain a test accuracy of at least 10%
  2. The task of assigning breed to dogs from images is considered exceptionally challenging. To illustrate, consider that even a human would have trouble distinguishing between a Brittany and a Welsh Springer Spaniel.
  3. Similarly, labradors come in yellow, chocolate, and black. My algorithm will have to conquer this high intra-class variation to determine how to classify all of these different shades as the same breed.

Step 4 - Create a CNN to Classify Dog Breeds (using Transfer Learning)

Used transfer learning from VGG16 model to classify dog breeds and obtained accuracy> 60%

About

Deep learning project- dog breed classifier

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published