File size: 2,416 Bytes
d7dc237
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f612253
d7dc237
 
f612253
d7dc237
 
 
 
 
 
 
 
 
 
 
 
 
 
f612253
 
d7dc237
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
---
license: apache-2.0
tags:
- image-classification
- dog-breeds
- fine-grained
- arcface
- convnext
- pytorch
datasets:
- stanford-dogs
metrics:
- accuracy
pipeline_tag: image-classification
model-index:
- name: Petus Breed Classifier (convnextv2_tiny)
  results:
  - task:
      type: image-classification
    dataset:
      name: Stanford Dogs
      type: stanford-dogs
    metrics:
    - name: Top-1 Accuracy (Val)
      type: accuracy
      value: 91.8
    - name: Top-5 Accuracy (Val)
      type: accuracy
      value: 98.7
---

# Petus Breed Classifier (convnextv2_tiny)

Dog breed classifier trained on Stanford Dogs (120 breeds) using **convnextv2_tiny** backbone with **ArcFace** angular margin loss and progressive resizing.

## Model Details

| Property | Value |
|----------|-------|
| Backbone | convnextv2_tiny |
| Loss | ArcFace (s=30.0, m=0.3) |
| Parameters | 28,323,200 |
| Input Size | 336px |
| Val Top-1 | **91.8%** |
| Val Top-5 | **98.7%** |
| Training | 2-phase (frozen head → unfrozen backbone) |
| Progressive Resize | 224 → 336px |

## Training Recipe (v3)

1. **Phase 1**: Frozen backbone, train ArcFace head only (2 epochs)
2. **Phase 2**: Unfreeze backbone with 1/100th LR, cosine annealing (48 epochs)
   - 3-epoch linear LR warmup after unfreeze
   - Progressive resize from 224→336 mid-training
   - ArcFace angular margin loss (no MixUp/CutMix needed)
   - Early stopping with patience=10

## Usage

```python
import torch
from torchvision import transforms
from PIL import Image

# Load model
checkpoint = torch.load("convnextv2_tiny_best.pt", map_location="cpu")

# Preprocess
transform = transforms.Compose([
    transforms.Resize(384),  # 336 * 1.14
    transforms.CenterCrop(336),
    transforms.ToTensor(),
    transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
])

image = Image.open("dog.jpg").convert("RGB")
input_tensor = transform(image).unsqueeze(0)

# Inference
model.eval()
with torch.no_grad():
    logits = model(input_tensor)
    pred = logits.argmax(dim=1).item()
    confidence = logits.softmax(dim=1).max().item()
```

## Breeds

120 dog breeds from the Stanford Dogs dataset (synsets from ImageNet).

## Citation

```bibtex
@misc{petus-breed-ml,
  author = {199 Biotechnologies},
  title = {Petus Breed Classifier},
  year = {2026},
  url = {https://github.com/199-biotechnologies/petus-breed-ml}
}
```

## License

Apache 2.0