Downloads · 30 days
0
flaviodell/oxford-pets-resnet50
oxford-pets-resnet50 is a image classification model from flaviodell. Use it when you need a label for an image. The card lists the license as mit.
Fine-tuned ResNet50 on the Oxford-IIIT Pet dataset for 37-class breed classification.
Downloads · 30 days
0
Access
Public
Updated Apr 10, 2026
Repo size
95.5 MB
Likes
0
Public
Click a slice to open those files.
.pth95.3 MB · 100%
From the Hugging Face model README
Fine-tuned ResNet50 on the Oxford-IIIT Pet dataset for 37-class breed classification.
| Metric | Value |
|---|---|
| Test accuracy | 0.9008 |
| Test F1 macro | 0.8989 |
| Best val accuracy | 0.9185 |
import torch
import torchvision.models as models
import torchvision.transforms as transforms
from PIL import Image
from huggingface_hub import hf_hub_download
# Download checkpoint
checkpoint_path = hf_hub_download(
repo_id="flaviodell/oxford-pets-resnet50",
filename="best_model.pth"
)
# Load model
checkpoint = torch.load(checkpoint_path, map_location="cpu")
model = models.resnet50()
in_features = model.fc.in_features
model.fc = torch.nn.Sequential(
torch.nn.Dropout(p=0.3),
torch.nn.Linear(in_features, 37)
)
model.load_state_dict(checkpoint["model_state"])
model.eval()
# Inference
transform = transforms.Compose([
transforms.Resize((224, 224)),
transforms.ToTensor(),
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
])
image = Image.open("your_image.jpg").convert("RGB")
tensor = transform(image).unsqueeze(0)
with torch.no_grad():
output = model(tensor)
pred_idx = output.argmax(dim=1).item()
print(checkpoint["classes"][pred_idx])
['Abyssinian', 'American Bulldog', 'American Pit Bull Terrier', 'Basset Hound', 'Beagle', 'Bengal', 'Birman', 'Bombay', 'Boxer', 'British Shorthair', 'Chihuahua', 'Egyptian Mau', 'English Cocker Spaniel', 'English Setter', 'German Shorthaired', 'Great Pyrenees', 'Havanese', 'Japanese Chin', 'Keeshond', 'Leonberger', 'Maine Coon', 'Miniature Pinscher', 'Newfoundland', 'Persian', 'Pomeranian', 'Pug', 'Ragdoll', 'Russian Blue', 'Saint Bernard', 'Samoyed', 'Scottish Terrier', 'Shiba Inu', 'Siamese', 'Sphynx', 'Staffordshire Bull Terrier', 'Wheaten Terrier', 'Yorkshire Terrier']