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.
- 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/
├── Akita\_Inu/
│ ├── image1.jpg
│ └── ...
├── German\_Shepherd/
│ ├── image1.jpg
│ └── ...
...
└── Yorkshire\_Terrier/
Each folder inside
dataset/represents one dog breed.
- Resize all images to 224x224
- Normalize pixel values to
[0, 1] - Augmentation techniques (optional):
- Rotation
- Zoom
- Flip
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')
])- Optimizer: Adam
- Loss Function: Categorical Crossentropy
- Metrics: Accuracy
- Epochs: 20–30
- Batch Size: 32
- Validation Accuracy: ~92% (may vary with dataset size/quality)
- Confusion Matrix: Used to analyze breed-level performance
dog_breed_classifier.h5– trained model fileclass_indices.json– dictionary mapping indices to breed names
{
"Akita_Inu": 0,
"German_Shepherd": 1,
...
}tensorflow
numpy
pillow
scikit-learn
matplotlibInstall via:
pip install -r requirements.txtfrom 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 .jsonmodel.save("dog_breed_classifier.h5")
with open("class_indices.json", "w") as f:
json.dump(train_generator.class_indices, f)This model can be directly integrated into:
- Gradio apps
- Tkinter desktop apps
- Web APIs using Flask or FastAPI
- Android apps via TensorFlow Lite
Developed by [Jayasimma D]
This project is open-source and available for personal, academic, or commercial use (with attribution).