Dog Breed Classification using Deep Learning

Dog Breed Classification using Deep Learning
Photo by Emma Gilberg on Dribbble

Task

In this project, we will be classifying the breed of the dog from the given photo of a dog as input.

Dataset- https://cainvas-static.s3.amazonaws.com/media/user_data/AmrutaKoshe/dog_photos.zip

The dataset consists of 5 selected different breeds of dogs. Each folder is named after a breed and contains around 120 images of that breed. Based on the given image, we need to classify the breed as one of the 5 breeds present.

The 5 different breeds are-

5 different breeds

Preprocessing –

  • First, import all the required libraries –

  • Download the data and unzip it to access the images and labels from your notebook.

  • List all the folder names in your dataset and check the number of classifications to make (number of breeds present)

output:

[\'bulldog\', \'pug\', \'rottweiler\', \'german shepherds\', \'labrador\']
5
  • To understand our dataset better, display some images
display some images, to understand data set

Split the training dataset into train and validation set

  • Perform data augmentation by using ImageDataGenerator so that we can acquire more relevant data from the existing images by making minor alterations to the dataset.

  • Divide the training dataset into train set and validation set.

Output:

Found 459 images belonging to 5 classes.
Found 112 images belonging to 5 classes.

Training the model

  • compile and fit the model

Output:

Epoch 1/170
14/14 [==============================] - 2s 116ms/step - loss: 1.6112 - accuracy: 0.2277 - val_loss: 1.6012 - val_accuracy: 0.2411
Epoch 2/170
14/14 [==============================] - 1s 99ms/step - loss: 1.6091 - accuracy: 0.2482 - val_loss: 1.6041 - val_accuracy: 0.2411
Epoch 3/170
14/14 [==============================] - 1s 99ms/step - loss: 1.6014 - accuracy: 0.2365 - val_loss: 1.6013 - val_accuracy: 0.2411
...
...
...
Epoch 168/170
14/14 [==============================] - 1s 99ms/step - loss: 0.3052 - accuracy: 0.8899 - val_loss: 0.9355 - val_accuracy: 0.7054
Epoch 169/170
14/14 [==============================] - 1s 99ms/step - loss: 0.3965 - accuracy: 0.8454 - val_loss: 1.0105 - val_accuracy: 0.7054
Epoch 170/170
14/14 [==============================] - 1s 103ms/step - loss: 0.2919 - accuracy: 0.8839 - val_loss: 0.7971 - val_accuracy: 0.7768

Model Performance

 

Training and validation accuracy

Making Predictions

  • Chose an image from the test set

 

Output:

Prediction is bulldog.

Conclusion

Hence, we have trained a sequential model to predict the breed of a dog with the image of the dog as the input.

Notebook link: https://cainvas.ai-tech.systems/notebooks/details/?path=AmrutaKoshe/dog%20photos.ipynb

Credit: Amruta Koshe

Also Read: Gemstone Classification using Deep Learning