🐢 Dog Breed Classifier

Model Card

A custom Convolutional Neural Network (CNN) trained to classify dog images into 90+ breeds.


Model Details

  • Model Name: Dog-Breed-Img-Classifier
  • Model Type: Image Classification
  • Framework: TensorFlow / Keras
  • Language: Python
  • License: MIT
  • Author: Dimesh Anthoney
  • Repository: GitHub
  • Demo: Streamlit App (via Hugging Face Spaces)

Overview

The Dog-Breed-Img-Classifier can identify 90+ dog breeds such as Rottweiler, Beagle, Golden Retriever, and more.

It was inspired by a KothaEd YouTube tutorial, but extended with:
βœ… Custom dataset of 8,040 images
βœ… Preprocessing pipelines (resizing, normalization, batching, shuffling)
βœ… Top-5 prediction support
βœ… Streamlit Web App deployment


Model Architecture

  • Input: Images resized to 224x224 pixels
  • Layers:
    • Rescaling layer
    • Multiple Conv2D + MaxPooling2D blocks
    • Flatten + Dropout
    • Dense layer(s) + Softmax output
  • Optimizer: Adam
  • Loss Function: Sparse Categorical Crossentropy
  • Training: 20 epochs with data augmentation (flips, rotations, zooms, rescaling)
  • Metrics: Accuracy, Top-5 Accuracy

Training Data

  • Dataset: 90+ dog breed classes
  • Total Images: ~8,040
  • Split: Train (6,XXX), Validation (8XX), Test (~8XX)
  • Preprocessing: Resizing, normalization, shuffling, batching, augmentation

Performance

  • Accuracy: ~81%
  • Top-5 Predictions: Supported (e.g., "Rottweiler β€” 98.67%")
  • Evaluation Metrics: Confusion Matrix, Precision, Recall, F1-score

Usage

πŸš€ Web Demo (Recommended)

Try the live Streamlit App on Hugging Face Spaces:
πŸ‘‰ (add your Hugging Face Spaces link here once deployed)

Users can:

  • Upload dog images (.jpg, .jpeg, .png)
  • See Top-5 predicted breeds with confidence scores

πŸ–₯ Local Setup

Install dependencies:

pip install tensorflow streamlit numpy pandas matplotlib pillow huggingface_hub

Run the Streamlit app locally:

streamlit run app.py
import numpy as np
import tensorflow as tf
from tensorflow.keras.models import load_model
from PIL import Image

# Load model from Hugging Face Hub
from huggingface_hub import hf_hub_download
model_path = hf_hub_download(
    repo_id="dimeshanthoney/dog-breed-classifier",
    filename="Image_classify.keras"
)
model = load_model(model_path)

# Preprocess image
img = Image.open("beagle.jpg").resize((224,224))
img_array = tf.keras.utils.img_to_array(img) / 255.0
img_array = np.expand_dims(img_array, axis=0)

# Predict
predictions = model.predict(img_array)
class_names = [...]  # your 90+ dog breed classes
top_idx = np.argmax(predictions[0])
print(f"Predicted breed: {class_names[top_idx]} ({predictions[0][top_idx]*100:.2f}%)")

Limitations

  • Performance may vary with images very different from the training dataset.

  • Streamlit app in hosted Spaces has file size and performance limitations.

Credits

  • Original Tutorial Inspiration: KothaEd (YouTube)

  • Enhancements: Custom dataset, 20-epoch training, Top-5 evaluation, Hugging Face + Streamlit integration by Dimesh Anthoney

Citation

  • If you use this model, please cite this repository and acknowledge the original tutorial by KothaEd.

Author

Name: Dimesh Anthoney

Downloads last month
164
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support