Downloads · 30 days
0
djhua0103/dog-breed-resnet50
dog-breed-resnet50 is a machine learning model from djhua0103. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
Downloads · 30 days
0
Access
Public
Updated Dec 8, 2025
Repo size
286 MB
Likes
0
Public
Click a slice to open those files.
.pth286 MB · 100%
From the Hugging Face model README
🐶 Dog Breed Classification – ResNet50
A high-accuracy dog breed classifier trained on 120 breeds
📌 Overview
This repository contains a fine-tuned ResNet50 model for dog breed classification. Given an input dog image, the model predicts the most likely breed among 120 classes.
This model is designed for:
🐕 Dog breed classification
🖼️ Image understanding & retrieval
🧪 Educational deep-learning projects
🚀 Plug-and-play inference in Streamlit / Python / FastAPI
🧠 Model Architecture
Backbone: ResNet50 (ImageNet pretrained)
Head: Fully-connected layer with softmax
Loss: Cross Entropy
Optimizer: AdamW
Training Epochs: 15
Input Size: 224×224
Number of classes: {len(id2breed)}
📁 Files Included File Description resnet50_dog.pth Trained model weights id2breed.json Mapping {class_index → breed_name} README.md Model card (this file)
The mapping file is essential for converting numerical model outputs into human-readable breed names.
🔍 Inference Example (Python) import torch from torchvision import transforms from PIL import Image from huggingface_hub import hf_hub_download import json
repo_id = "djhua0103/dog-breed-resnet50"
ckpt_path = hf_hub_download(repo_id, "resnet50_dog_best.pth") json_path = hf_hub_download(repo_id, "id2breed.json")
with open(json_path, "r") as f: id2breed = json.load(f)
from torchvision.models import resnet50 model = resnet50(weights=None) model.fc = torch.nn.Linear(model.fc.in_features, len(id2breed)) model.load_state_dict(torch.load(ckpt_path, map_location="cpu")) model.eval()
transform = transforms.Compose([ transforms.Resize((224,224)), transforms.ToTensor() ])
img = Image.open("dog.jpg") x = transform(img).unsqueeze(0)
with torch.no_grad(): logits = model(x) prob = logits.softmax(dim=1) idx = prob.argmax().item() breed = id2breed[str(idx)]
print("Predicted breed:", breed)
🚀 Use in Streamlit
This model can be easily integrated into any Streamlit app:
from huggingface_hub import hf_hub_download from multimodal_dog.models.classifier import DogClassifier
model = DogClassifier.from_hf(device="cpu") breed, confidence = model.predict(image_tensor)
📊 Dataset
The dataset is based on the Kaggle Dogs Dataset (https://www.kaggle.com/competitions/dog-breed-identification/), containing images of 120 dog breeds. Labels are derived from labels.csv and converted into class indices using alphabetical ordering.
🏷️ Labels
All breed names are stored in id2breed.json.
📘 License
Specify your license (MIT / Apache / custom).
🙌 Acknowledgements
ResNet50 from PyTorch
Hugging Face Hub
Dataset provider (Kaggle / Stanford Dogs)