Skip to content

End-to-end notebook for classifying 120 dog breeds using deep learning. Features data preprocessing, transfer learning (MobileNetV2), model training, evaluation, visualization, and Kaggle-ready submission—all with TensorFlow 2.x and TensorFlow Hub.

License

Notifications You must be signed in to change notification settings

brej-29/Logicmojo-AIML-Assignments-DogBreedClassificationTensorFlow

Repository files navigation

🐶 DOG BREED CLASSIFICATION

Deep Learning for Accurate Multi-Class Dog Breed Identification



Built with the tools and technologies:

Python | TensorFlow 2.x | TensorFlow Hub | Keras | Pandas | NumPy | Matplotlib | scikit-learn | Jupyter Notebook

Table of Contents


Overview

This project presents an end-to-end deep learning pipeline for multi-class dog breed classification, leveraging transfer learning with TensorFlow and TensorFlow Hub. The notebook demonstrates:

  • Data loading, inspection, and preprocessing for image and label data
  • Exploratory data analysis and visualization of class distributions
  • One-hot encoding of 120 dog breed labels
  • Efficient image preprocessing and batching using TensorFlow's tf.data API
  • Model construction using a pre-trained MobileNetV2 as a feature extractor
  • Training with callbacks (TensorBoard, EarlyStopping) and validation monitoring
  • Model evaluation, prediction visualization, and interpretability
  • Saving, loading, and deploying trained models
  • Preparing Kaggle-compatible CSV submissions and making predictions on custom images

Project Highlights

  • Dataset: Kaggle Dog Breed Identification (10,222 training images, 120 breeds)
  • Transfer Learning: MobileNetV2 from TensorFlow Hub for robust feature extraction
  • Data Augmentation: Techniques to improve generalization and prevent overfitting
  • Evaluation Metric: Log Loss, with probabilistic outputs for each class
  • Visualization: Batch image grids, prediction confidence plots, and TensorBoard logs
  • Reproducibility: Modular code for easy adaptation and deployment

Getting Started

Prerequisites

To run this notebook, you will need the following libraries installed:

  • tensorflow (2.x)
  • tensorflow_hub
  • tf_keras
  • pandas
  • numpy
  • matplotlib
  • scikit-learn
  • os
  • IPython

Installation

You can install all necessary libraries using pip:

pip install tensorflow tensorflow_hub tf_keras pandas numpy matplotlib scikit-learn

Usage

  1. Clone the repository:
    git clone https://github.com/brej-29/dog-breed-classification.git
  2. Navigate to the project directory:
    cd dog-breed-classification
  3. Open the Jupyter Notebook:
    jupyter notebook DogBreedClassification.ipynb
  4. Follow the notebook cells:
    • Unzip and inspect the Kaggle dataset.
    • Import core libraries (TensorFlow, TensorFlow Hub, Keras, Pandas, NumPy, Matplotlib, scikit-learn).
    • Check for GPU availability for faster training.
    • Load and explore the dataset, visualize class distributions, and inspect images.
    • Prepare labels (one-hot encoding for 120 breeds).
    • Split data into training and validation sets.
    • Preprocess images (resize, normalize) and create efficient data batches using TensorFlow's tf.data API.
    • Visualize batched data for sanity checks.
    • Build the model using transfer learning (MobileNetV2 from TensorFlow Hub).
    • Set up callbacks (TensorBoard, EarlyStopping) for monitoring and regularization.
    • Train the model on a subset, then on the full dataset.
    • Evaluate and visualize predictions, including confidence plots and batch visualizations.
    • Save and reload trained models for reproducibility.
    • Make predictions on test data and prepare a Kaggle-compatible CSV for submission.
    • Run inference on your own custom images and visualize results.

Data Exploration & Preprocessing

  • Load and inspect the Kaggle Dog Breed Identification dataset.
  • Visualize class imbalance and breed frequencies.
  • One-hot encode breed labels for multi-class classification.
  • Preprocess images: resize to 224x224, normalize, and convert to tensors.
  • Create efficient data pipelines with batching and shuffling for training, validation, and test sets.

Modeling & Evaluation

  • Build a transfer learning model using MobileNetV2 as a feature extractor and a dense softmax output layer.
  • Compile with categorical cross-entropy loss and Adam optimizer.
  • Use TensorBoard and EarlyStopping callbacks.
  • Train and validate the model, visualize predictions and confidence scores.
  • Prepare predictions for Kaggle submission and evaluate on custom images.

Model Deployment

  • Save trained models in HDF5 format for future inference or retraining.
  • Functions provided for loading and evaluating saved models.
  • Example code for making predictions on new, custom images.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Contact

If you have any questions or feedback, feel free to reach out via my LinkedIn Profile

About

End-to-end notebook for classifying 120 dog breeds using deep learning. Features data preprocessing, transfer learning (MobileNetV2), model training, evaluation, visualization, and Kaggle-ready submission—all with TensorFlow 2.x and TensorFlow Hub.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published