Spaces:
Sleeping
Download README.md from deeAdora/pet_classifier: direct link, hf CLI and curl.
- Browser
- Download file 2.54 kB
-
https://huggingface.co/spaces/deeAdora/pet_classifier/resolve/main/README.md
- Command line
-
hf download hf://spaces/deeAdora/pet_classifier/README.md
-
curl -L -o README.md https://huggingface.co/spaces/deeAdora/pet_classifier/resolve/main/README.md
A newer version of the Gradio SDK is available: 6.32.0
title: Pet Breed Classifier
colorFrom: green
colorTo: yellow
sdk: gradio
sdk_version: 6.30.0
python_version: '3.14'
app_file: app.py
pinned: false
Please note I created a folder called codeWithNotes, these include notes to discribe what each CLASS and function is doing. The notes are enclosed the '# region # endregion'
These comments can be collapsed in the IDE by clicking the small arrow to the left of the comment (next to the line number)
Pet Breed Classifier
An image classification web application that identifies the breed of a pet from a photograph and reports whether the animal is a cat or a dog.
Problem Statement
- Task type: Multi-class image classification.
- Dataset: Oxford-IIIT Pet (
torchvision.datasets.OxfordIIITPet). - Input: An RGB photograph of a cat or dog, resized and normalized to a fixed tensor size.
- Output: A predicted breed from 37 classes (25 dog breeds and 12 cat breeds), plus the species derived from the predicted breed.
- Core challenge: Breeds within a species are visually similar, and the dataset provides roughly 100 images per class with variation in pose, lighting, and background.
Application Outputs
- Top three predicted breeds with confidence scores.
- Detected species (cat or dog).
- Single-image inference latency in seconds.
Repository Structure
app.py Gradio application entry point
pet_breed_model.pth Trained model weights (state_dict)
requirements.txt Runtime dependencies for deployment
src/model.py Model architecture
src/dataset.py Transforms, splits, and DataLoaders
src/utils.py Species mapping, timed inference, and metrics helpers
notebooks/train.ipynb Training and evaluation workflow
images/ Sample photos shown as examples in the web interface
Local Setup
The project uses Python 3.14 and uv.
uv sync
uv run python app.py
Training
Training is performed in notebooks/train.ipynb on a Google Colab NVIDIA T4 GPU. The resulting weights are saved to pet_breed_model.pth and loaded by app.py for CPU inference.
Tried training with both CNN and ResNet18 model to compare. ImageNet-1K dataset on which standard ResNet-18 weights are pretrained is specifically trained with 1.28 million images. Which the weights being pretrained, this means we ar enot starting from scratch. The CNN filter is learning from square 1, making it need a lot more images to be more accurate.