Skip to content

JAYASIMMA/Dog_Breed_Prediction_using-_CNN

Repository files navigation

Dog Breed Detection Model

This project focuses on building a Deep Learning model that classifies dog breeds from images using TensorFlow and Keras. The model can identify multiple dog breeds with high accuracy and is suitable for deployment in desktop or web applications.


Model Overview

  • Title: Dog Breed Detection Model
  • Type: Image Classification
  • Framework: TensorFlow / Keras
  • Input Shape: 224x224x3
  • Output: Dog breed name with confidence score
  • Classes: 31 different dog breeds

Dataset Structure


dataset/
├── Akita\_Inu/
│   ├── image1.jpg
│   └── ...
├── German\_Shepherd/
│   ├── image1.jpg
│   └── ...
...
└── Yorkshire\_Terrier/

Each folder inside dataset/ represents one dog breed.


Preprocessing Steps

  • Resize all images to 224x224
  • Normalize pixel values to [0, 1]
  • Augmentation techniques (optional):
    • Rotation
    • Zoom
    • Flip

Model Architecture

model = tf.keras.Sequential([
    tf.keras.layers.InputLayer(input_shape=(224, 224, 3)),
    tf.keras.layers.Rescaling(1./255),
    tf.keras.layers.Conv2D(32, 3, activation='relu'),
    tf.keras.layers.MaxPooling2D(),
    tf.keras.layers.Conv2D(64, 3, activation='relu'),
    tf.keras.layers.MaxPooling2D(),
    tf.keras.layers.Conv2D(128, 3, activation='relu'),
    tf.keras.layers.GlobalAveragePooling2D(),
    tf.keras.layers.Dense(128, activation='relu'),
    tf.keras.layers.Dense(num_classes, activation='softmax')
])

Training Configuration

  • Optimizer: Adam
  • Loss Function: Categorical Crossentropy
  • Metrics: Accuracy
  • Epochs: 20–30
  • Batch Size: 32

Evaluation

  • Validation Accuracy: ~92% (may vary with dataset size/quality)
  • Confusion Matrix: Used to analyze breed-level performance

Output Files

  • dog_breed_classifier.h5 – trained model file
  • class_indices.json – dictionary mapping indices to breed names
{
  "Akita_Inu": 0,
  "German_Shepherd": 1,
  ...
}

Requirements

tensorflow
numpy
pillow
scikit-learn
matplotlib

Install via:

pip install -r requirements.txt

How to Train

from tensorflow.keras.preprocessing.image import ImageDataGenerator
from sklearn.model_selection import train_test_split

# Load, preprocess, and split data
# Create model
# Compile
# Fit model
# Save .h5 and .json

Exporting Model

model.save("dog_breed_classifier.h5")

with open("class_indices.json", "w") as f:
    json.dump(train_generator.class_indices, f)

Usage

This model can be directly integrated into:

  • Gradio apps
  • Tkinter desktop apps
  • Web APIs using Flask or FastAPI
  • Android apps via TensorFlow Lite

Author

Developed by [Jayasimma D]


License

This project is open-source and available for personal, academic, or commercial use (with attribution).

About

This project focuses on building a Deep Learning model that classifies dog breeds from images using TensorFlow and Keras. The model can identify multiple dog breeds with high accuracy and is suitable for deployment in desktop or web applications.

Resources

Stars

Watchers

Forks

Contributors

Languages