Skip to content

GrahamPellegrini/Dog-Breed-Classification

Repository files navigation

Dog Breed Classification – ImageNet

CCE3207 Course PyTorch ImageNet Dogs Dataset

End-to-end pipeline for dog breed classification using deep learning in PyTorch, applied to the ImageNet Dogs dataset. This project was developed as part of the study unit CCE3207 – Introduction to Computer Vision under the supervision of Dr. Christian Galea.


Project Overview

This project implements a full training and evaluation pipeline for a deep learning-based dog breed classification model. The pipeline includes:

  • Exploratory data analysis
  • Custom dataset loading with bounding box cropping
  • Transfer learning using pretrained CNNs
  • Model training, validation, and evaluation
  • Final predictions on unseen data

The project is implemented within a single annotated Jupyter notebook, demonstrating practical computer vision techniques and model interpretability strategies.


Problem Statement

The task involves classifying dog breeds from images in the ImageNet Dogs subset. Each image is annotated with a bounding box and a breed label. The challenges addressed include:

  • Handling class imbalance across 120+ breeds
  • Automating image preprocessing and augmentation
  • Efficient training using GPU acceleration
  • Managing large-scale image datasets using PyTorch Dataset and DataLoader

Folder Structure

.
├── Assignment/
│   ├── assignment.ipynb       # Main Jupyter notebook (contains full pipeline)
│   ├── labels.txt             # Mapping of class indices to dog breed labels
│   └── model/                 # Saved model folders (per experiment)
│       ├── resnet18/
│       ├── efficientnet_b0/
│       └── ...
└── README.md

Key Features

  • Data Exploration: Insights into class distribution, image sizes, and bounding box statistics.
  • Custom Dataset Class: Crops and resizes images based on bounding boxes for accurate feature learning.
  • Transfer Learning: Fine-tunes pretrained ResNet and EfficientNet backbones on dog breeds.
  • Evaluation Metrics: Accuracy, confusion matrix, and top-k classification score analysis.
  • Model Selection: Compares multiple CNN backbones and training hyperparameters.

Dependencies

The project uses the following Python libraries:

  • PyTorch, torchvision
  • OpenCV, Pillow, xml
  • matplotlib, numpy, os

All code was executed using GPU acceleration on the Networks lab systems provided by the university.


How to Run

  1. Clone the repository:
git clone https://github.com/GrahamPellegrini/Dog-Breed-Classification.git
  1. Open assignment.ipynb in JupyterLab or VSCode.

  2. Ensure the dataset is available under a valid path:

/opt/nfs/shared/images/ImageNetDogs

Alternatively, update the notebook to point to a custom dataset path of your choice.

  1. Run all notebook cells sequentially to train and evaluate models.

Results Snapshot

The following summarizes the performance of all models tested throughout the project:

Model Accuracy Loss Observations
Simple-CNN 5.63% 3.68 Baseline implementation with minimal layers
Improved-CNN 12.41% 4.29 Added depth, batch norm, and bottlenecking
Deep-CNN 42.98% 2.17 Modular 5-layer CNN, stronger generalisation
VGG16-BN 54.27% 2.98 Pretrained model, signs of overfitting
VGG16-1 (Adam+Scheduler) 70.18% 1.53 Frozen conv layers, slower convergence
VGG16-2 (SGD Optimizer) 79.43% 0.69 Best model: stable training, minimal overfitting

Final deployment candidate: VGG16-2 for its accuracy and stable validation trends.

Training logs and saved weights available under model/ directory.



Author

Graham Pellegrini
B.Eng. (Hons) Computer Engineering
University of Malta
GitHub: @GrahamPellegrini