Companion Animal Species & Breed Classifier
A fine-grained image classification model for identifying animal species and breeds across 211 classes, with a focus on animals commonly encountered as companion animals or animals that may come under human care.
The model is based on MobileNetV3-Large and supports both PyTorch and ONNX inference.
Model status: Research / Experimental Task: Fine-grained image classification Classes: 211 Input size: 224 × 224 pixels
Model Overview
This model performs fine-grained classification across four major animal groups, together with an unknown class:
| Animal group | Classes |
|---|---|
| 🐦 Birds | 26 |
| 🐱 Cats | 63 |
| 🐶 Dogs | 120 |
| 🐰 Rabbit | 1 |
| ❓ Unknown | 1 |
| Total | 211 |
The bird classes intentionally include species that are not conventionally considered companion animals, such as eagles, falcons, crows, ducks, and turkeys.
Their inclusion reflects the intended broader use case of the dataset: an animal may come under human care because it was found, injured, rescued, temporarily housed, or otherwise placed under human supervision.
Therefore, "companion animal" in this project is a practical dataset scope rather than a strict biological or legal classification.
Architecture
The model uses:
MobileNetV3-Large
Input Image
│
▼
Resize → 224 × 224
│
▼
ImageNet Normalization
│
▼
MobileNetV3-Large
│
▼
211-Class Classification Head
│
▼
Predicted Class
Model Configuration
| Parameter | Value |
|---|---|
| Architecture | mobilenet_v3_large |
| Number of classes | 211 |
| Input resolution | 224 × 224 |
| Framework | PyTorch |
| Export format | ONNX |
| Validation accuracy | 56.38% |
The model metadata specifies the following normalization parameters:
Mean = [0.485, 0.456, 0.406]
Std = [0.229, 0.224, 0.225]
Dataset
The model was trained using the (Companion & Human-Care Animal Dataset)[https://huggingface.co/datasets/Pezhvak98/companion-human-care-animal-dataset] , a composite dataset assembled from multiple publicly available datasets and sources.
Dataset Resolution
The source dataset images were standardized to:
192 × 192 pixels
For this model, images are subsequently processed to:
224 × 224 pixels
Therefore, the dataset image resolution and model input resolution are intentionally different.
Classes
The classifier contains 211 output classes.
The class naming convention used by the original training pipeline is preserved exactly.
In particular, dog classes use the do_ prefix:
do_golden_retriever
do_german_shepherd
do_labrador_retriever
do_pomeranian
do_rottweiler
...
The model's complete class-to-index and index-to-class mappings are provided in:
class_to_idx.json
idx_to_class.json
These files should be used when converting the model's output index into a human-readable class label.
Evaluation
The model was evaluated on 15,042 samples.
Overall Results
| Metric | Result |
|---|---|
| Top-1 Accuracy | 56.35% |
| Top-5 Accuracy | 83.48% |
| Species-level Accuracy | 99.45% |
| Evaluation Samples | 15,042 |
The evaluation results are provided in:
evaluation_results.json
Interpreting the Results
The difference between species-level accuracy and fine-grained Top-1 accuracy is important.
The model achieves:
99.45% species-level accuracy
while achieving:
56.35% Top-1 accuracy across 211 fine-grained classes.
This indicates that the model is substantially more reliable at distinguishing broad animal groups than at distinguishing visually similar breeds or fine-grained categories.
The Top-5 accuracy of 83.48% also indicates that the correct class is frequently among the model's five highest-ranked predictions even when it is not the first prediction.
Performance and Design Considerations
This model was developed with a specific practical objective in mind: achieving a useful balance between classification performance, inference speed, and computational requirements on the target hardware.
MobileNetV3-Large was intentionally selected instead of a larger and more computationally demanding architecture to keep inference lightweight and practical for deployment on relatively resource-constrained systems.
With 56.35% Top-1 accuracy, 83.48% Top-5 accuracy, and 99.45% species-level accuracy, the model achieved the level of performance required for the intended application. At that point, further optimization or experimentation aimed solely at increasing classification accuracy was outside the project's requirements and was therefore not pursued.
As a result, this model should be considered a purpose-built practical solution rather than an accuracy-maximized benchmark model. Performance may vary depending on the dataset, image quality, hardware, and application requirements. If higher fine-grained classification accuracy is required, users may consider further training, class balancing, additional data, or a larger model architecture.
Known Dataset Characteristics
The dataset is not class-balanced.
There are substantial differences in the number of images available for different classes. For example, some cat categories contain significantly more evaluation samples than many other classes.
Consequently, overall accuracy should not be interpreted as equally representative of every class.
Per-class evaluation information is available in:
evaluation_results.json
Inference
PyTorch
The repository contains two PyTorch model variants:
best_model.pth
best_model_state_dict.pth
best_model.pth contains the saved best model, while best_model_state_dict.pth contains the model weights/state dictionary.
The exact model architecture should be recreated as MobileNetV3-Large with a 211-class output layer before loading the state dictionary.
Example preprocessing:
from PIL import Image
from torchvision import transforms
transform = transforms.Compose([
transforms.Resize((224, 224)),
transforms.ToTensor(),
transforms.Normalize(
mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225]
)
])
image = Image.open("image.jpg").convert("RGB")
tensor = transform(image).unsqueeze(0)
After inference, the predicted class index can be resolved using:
idx_to_class.json
ONNX
Two ONNX versions are provided:
model.onnx
model_simplified.onnx
The repository also contains:
model.onnx.data
which should be kept together with model.onnx if the ONNX model references external data.
The ONNX versions allow the model to be used independently of the PyTorch runtime with compatible ONNX Runtime environments.
Model Files
| File | Description |
|---|---|
best_model.pth | Best saved PyTorch model |
best_model_state_dict.pth | PyTorch model state dictionary |
Last_checkpoint.pth | Training checkpoint |
model.onnx | ONNX model |
model.onnx.data | External ONNX model data |
model_simplified.onnx | Simplified ONNX model |
class_to_idx.json | Class name → numeric index mapping |
idx_to_class.json | Numeric index → class name mapping |
model_metadata.json | Model configuration and metadata |
evaluation_results.json | Evaluation and per-class results |
training_curves.png | Training curves |
Intended Use
This model is intended primarily for:
- Computer vision research
- Machine learning experimentation
- Animal classification
- Fine-grained animal breed recognition
- Companion-animal applications
- Animal rescue and care applications
- Educational projects
- Prototyping image-classification systems
The model can be used as a component of a larger animal recognition pipeline.
Limitations
This model should not be treated as a definitive biological identification system.
In particular:
- Fine-grained classification between visually similar breeds can be difficult.
- Performance varies substantially between classes.
- The training dataset is highly imbalanced.
- Some classes contain relatively few samples.
- Images outside the represented classes may be incorrectly assigned to one of the known classes.
- The
unknowncategory does not guarantee reliable open-set recognition. - The model should not be used as the sole basis for veterinary, wildlife-management, legal, or animal-control decisions.
- The presence of a bird or other non-traditional companion animal in the dataset does not imply that the animal is legally or practically suitable as a pet.
For real-world applications, predictions should preferably be combined with confidence thresholds, human review, and additional validation.
Unknown Class
The model includes an explicit:
unknown
class.
This category was constructed using unrelated images from ImageNet-O and is intended to provide examples outside the primary animal categories.
However, this should not be interpreted as a complete open-set recognition mechanism.
A high-confidence prediction for one of the 211 classes does not necessarily prove that an input image belongs to that class.
License and Third-Party Data
This model repository contains a model trained from a composite dataset assembled from multiple third-party sources.
The underlying source images remain subject to their original licenses, copyrights, and terms.
This repository does not claim ownership of the original third-party images and does not relicense those images.
Users should independently review the licenses and usage conditions of the original datasets before using the model or redistributing materials derived from them.
For additional information, see the accompanying LICENSE file.
Citation
If you use this model in a project, research work, or publication, please cite the project as:
Companion Animal Species & Breed Classifier
Mohammad Meftahi, 2026
Hugging Face:
https://huggingface.co/Pezhvak98/companion-animal-species-breed-classifier
Dataset:
https://huggingface.co/datasets/Pezhvak98/companion-human-care-animal-dataset
Acknowledgements
This project would not have been possible without the publicly available datasets used as source material for constructing the training dataset.
The original datasets and their respective contributors are acknowledged through the dataset documentation and their original licensing terms.
Author
Mohammad Meftahi
2026
This project is part of an ongoing exploration of computer vision, machine learning, and practical animal recognition systems.