
# vit-base-oxford-iiit-pets

This model is a fine-tuned version of [google/vit-base-patch16-224](https://huggingface.co/google/vit-base-patch16-224) on the [Oxford-IIIT Pets dataset](https://huggingface.co/datasets/pcuenq/oxford-pets). It has been trained to classify 37 breeds of cats and dogs.

It achieves the following results on the validation set:

- **Loss**: 0.2648  
- **Accuracy**: 0.9459

## Model description

This model is based on ViT (Vision Transformer), a transformer-based architecture for image classification that treats image patches as input tokens, enabling the use of pure transformer architectures on vision tasks.

Fine-tuning was done using the `transformers` Trainer API from Hugging Face.

## Intended uses & limitations

**You can use this model for:**

- Classifying breeds of cats and dogs from the Oxford-IIIT Pets dataset.
- Fine-tuning on other animal classification datasets.
- Serving as a strong vision transformer baseline for academic or benchmarking purposes.

**Limitations:**

- Performance may degrade on images outside of the pet domain.
- Not optimized for mobile or edge devices.

## Training and evaluation data

Dataset used: [`pcuenq/oxford-pets`](https://huggingface.co/datasets/pcuenq/oxford-pets)

- 7,390 training images
- 739 validation images
- 37 breed classes

## Training procedure

### Hyperparameters

- **Learning rate**: 5e-05  
- **Train batch size**: 32  
- **Eval batch size**: 8  
- **Seed**: 42  
- **Optimizer**: AdamW  
- **Scheduler**: Linear  
- **Epochs**: 10  

### Training results

| Training Loss | Epoch | Step | Validation Loss | Accuracy |
|:-------------:|:-----:|:----:|:---------------:|:--------:|
| 0.3673        | 1.0   | 185  | 0.3645          | 0.9080   |
| 0.3068        | 2.0   | 370  | 0.3329          | 0.9161   |
| 0.2836        | 3.0   | 555  | 0.3129          | 0.9175   |
| 0.2556        | 4.0   | 740  | 0.2980          | 0.9202   |
| 0.2411        | 5.0   | 925  | 0.2872          | 0.9215   |
| 0.2256        | 6.0   | 1110 | 0.2805          | 0.9215   |
| 0.2378        | 7.0   | 1295 | 0.2751          | 0.9215   |
| 0.2176        | 8.0   | 1480 | 0.2717          | 0.9215   |
| 0.2206        | 9.0   | 1665 | 0.2696          | 0.9215   |
| 0.2173        | 10.0  | 1850 | 0.2690          | 0.9215   |

## Zero-shot evaluation results

Using a CLIP-based benchmark on the same dataset, the following zero-shot performance was observed:

- **Accuracy**: 0.8800  
- **Precision**: 0.8768  
- **Recall**: 0.8800  

## Framework versions

- **Transformers**: 4.50.3  
- **PyTorch**: 2.5.1+cu121  
- **Datasets**: 3.5.0  
- **Tokenizers**: 0.21.1

siamese birman shiba inu staffordshire bull terrier basset hound bombay japanese chin chihuahua german shorthaired pomeranian beagle english cocker spaniel american pit bull terrier ragdoll persian egyptian mau miniature pinscher sphynx maine coon keeshond yorkshire terrier havanese leonberger wheaten terrier american bulldog english setter boxer newfoundland bengal samoyed british shorthair great pyrenees abyssinian pug saint bernard russian blue scottish terrier