Instructions to use ERISLab/TGDA with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- timm
How to use ERISLab/TGDA with timm:
import timm model = timm.create_model("hf-hub:ERISLab/TGDA", pretrained=True) - Notebooks
- Google Colab
- Kaggle
Add model card
Browse files
README.md
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
pipeline_tag: image-classification
|
| 3 |
+
library_name: pytorch
|
| 4 |
+
tags:
|
| 5 |
+
- fine-grained-image-recognition
|
| 6 |
+
- image-classification
|
| 7 |
+
- teacher-guided-data-augmentation
|
| 8 |
+
- timm
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# TGDA: fine-grained image recognition from scratch with teacher-guided data augmentation
|
| 12 |
+
|
| 13 |
+
These are the checkpoints behind *Fine-Grained Image Recognition from Scratch with Teacher-Guided Data Augmentation* ([arXiv:2507.12157](https://arxiv.org/abs/2507.12157)). Students trained from scratch learn from a fine-grained teacher (a ResNet-101 trained with counterfactual attention learning, CAL), which also guides data-aware augmentation of the student's inputs. Code: [arkel23/TGDA](https://github.com/arkel23/TGDA).
|
| 14 |
+
|
| 15 |
+
249 checkpoints, one per configuration, each the last epoch of one training seed. Each file
|
| 16 |
+
is a `torch.save` dict with `config` (the full training configuration), `model` (the state dict),
|
| 17 |
+
`accuracy` and `epoch`, with no optimizer state. File names are the runs' experiment-log names,
|
| 18 |
+
ending in the serial. Load them with [fgir-zoo](https://github.com/arkel23/fgir-zoo).
|
| 19 |
+
|
| 20 |
+
## Layout
|
| 21 |
+
|
| 22 |
+
| Folder | Serials | What | Files |
|
| 23 |
+
|---|---|---|---|
|
| 24 |
+
| `sota_448` | 301-304 | Main state-of-the-art table: ResNet-18/34/50/101 students, TGDA with TrivialAugment, label smoothing and stochastic depth | 12 |
|
| 25 |
+
| `lrnet_128` | 201-204 | Main LRNet table: low-resolution students at 128 px from a 448 px teacher | 24 |
|
| 26 |
+
| `vitfs_448` | 100, 101 | Efficient ViTs and the ViTFS variants, teacher and student at 448 px | 54 |
|
| 27 |
+
| `vitfs_224_t448` | 102 | Teacher at 448 px, student at 224 px | 15 |
|
| 28 |
+
| `vitfs_224` | 103 | Teacher and student at 224 px | 9 |
|
| 29 |
+
| `vitfs_128` | 109 | ViTFS tiny/micro/nano students at 128 px from a 448 px teacher | 8 |
|
| 30 |
+
| `vit_ce_448` | 107 | The serial-101 models trained with cross-entropy only (no teacher) | 35 |
|
| 31 |
+
| `vitfs_transfer` | 104-106 | A TGDA-trained student transferred to two new datasets with cross-entropy | 8 |
|
| 32 |
+
| `ablations_128` | 212, 214, 221-223, 241-248, 251, 261-263, 271-278, 281 | Ablations: TGDA without extra regularization, one- vs two-stage training, augmentation type, teacher type, transfer | 73 |
|
| 33 |
+
| `scratch_vs_pt_448` | 320, 321, 331 | 200 epochs from scratch with cross-entropy or KD, and ImageNet-pretrained with KD | 9 |
|
| 34 |
+
| `sweeps_128` | 0, 1 | KD weight and temperature sweeps on CUB | 2 |
|
| 35 |
+
|
| 36 |
+
`manifest.csv` lists every file with its dataset, student, teacher, serial, seed, image size,
|
| 37 |
+
class count, accuracy, SHA-256 and size.
|
| 38 |
+
|
| 39 |
+
## Load a checkpoint and classify an image
|
| 40 |
+
|
| 41 |
+
```python
|
| 42 |
+
import torch
|
| 43 |
+
from PIL import Image
|
| 44 |
+
from torchvision import transforms
|
| 45 |
+
from fgir_zoo import tgda
|
| 46 |
+
|
| 47 |
+
model = tgda.create_model('sota_448/cub_resnet18_resnet101_cal_tgda_301')
|
| 48 |
+
cfg = model.config
|
| 49 |
+
tf = transforms.Compose([
|
| 50 |
+
transforms.Resize((cfg.test_resize_size, cfg.test_resize_size),
|
| 51 |
+
interpolation=transforms.InterpolationMode.BICUBIC),
|
| 52 |
+
transforms.CenterCrop(cfg.student_image_size or cfg.image_size),
|
| 53 |
+
transforms.ToTensor(),
|
| 54 |
+
transforms.Normalize((0.485, 0.456, 0.406), (0.229, 0.224, 0.225)),
|
| 55 |
+
])
|
| 56 |
+
# a CUB-200-2011 test image, class index 50 (051.Horned_Grebe)
|
| 57 |
+
x = tf(Image.open('Horned_Grebe_0050_34561.jpg').convert('RGB')).unsqueeze(0)
|
| 58 |
+
with torch.no_grad():
|
| 59 |
+
logits = model(x)
|
| 60 |
+
print(logits.argmax(-1).item(), logits.softmax(-1).max().item()) # 50 0.9855
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
## Accuracy of the released checkpoints
|
| 64 |
+
|
| 65 |
+
Top-1 accuracy (%) stored in each file, on the dataset's test split at the end of training.
|
| 66 |
+
Each value is one seed; the paper reports its own aggregates, so its tables can differ slightly.
|
| 67 |
+
|
| 68 |
+
### `sota_448`
|
| 69 |
+
|
| 70 |
+
| Model | aircraft | cars | cub |
|
| 71 |
+
|---|---|---|---|
|
| 72 |
+
| `resnet101 <- resnet101` | 94.81 | 95.19 | 89.25 |
|
| 73 |
+
| `resnet18 <- resnet101` | 93.73 | 94.86 | 87.49 |
|
| 74 |
+
| `resnet34 <- resnet101` | 94.24 | 95.04 | 88.40 |
|
| 75 |
+
| `resnet50 <- resnet101` | 94.78 | 95.16 | 88.95 |
|
| 76 |
+
|
| 77 |
+
### `lrnet_128`
|
| 78 |
+
|
| 79 |
+
| Model | aircraft | cars | cub |
|
| 80 |
+
|---|---|---|---|
|
| 81 |
+
| `lrnet14 <- resnet101` | 89.02 | 92.74 | 80.48 |
|
| 82 |
+
| `lrnet18 <- resnet101` | 90.67 | 93.21 | 82.48 |
|
| 83 |
+
| `lrnet26 <- resnet101` | 91.30 | 93.57 | 82.65 |
|
| 84 |
+
| `lrnet50 <- resnet101` | 91.81 | 93.74 | 84.12 |
|
| 85 |
+
| `resnet101 <- resnet101` | 88.57 | 92.19 | 81.48 |
|
| 86 |
+
| `resnet18 <- resnet101` | 86.95 | 91.18 | 77.68 |
|
| 87 |
+
| `resnet34 <- resnet101` | 85.45 | 91.03 | 78.81 |
|
| 88 |
+
| `resnet50 <- resnet101` | 90.19 | 92.96 | 82.74 |
|
| 89 |
+
|
| 90 |
+
### `vitfs_448`
|
| 91 |
+
|
| 92 |
+
| Model | aircraft | cars | cub |
|
| 93 |
+
|---|---|---|---|
|
| 94 |
+
| `efficientvit_m2 <- resnet101` | 92.50 | 94.11 | 85.42 |
|
| 95 |
+
| `efficientvit_m3 <- resnet101` | 92.80 | 94.50 | 85.48 |
|
| 96 |
+
| `lcnet_035 <- resnet101` | 91.42 | 91.12 | 78.43 |
|
| 97 |
+
| `levit_128s <- resnet101` | 88.66 | 91.98 | 81.24 |
|
| 98 |
+
| `mobilevit_s <- resnet101` | 92.68 | 93.79 | 83.48 |
|
| 99 |
+
| `mobilevitv2_100 <- resnet101` | 94.36 | 94.57 | 87.59 |
|
| 100 |
+
| `mobilevitv2_125 <- resnet101` | 93.64 | 94.63 | 87.35 |
|
| 101 |
+
| `nest_tiny <- resnet101` | 89.89 | 93.25 | 85.48 |
|
| 102 |
+
| `pvt_v2_b0 <- resnet101` | 91.84 | 93.79 | 86.93 |
|
| 103 |
+
| `pvt_v2_b1 <- resnet101` | 92.53 | 94.29 | 86.85 |
|
| 104 |
+
| `swin_tiny_patch4_window7_224 <- resnet101` | 89.62 | 93.35 | 82.40 |
|
| 105 |
+
| `tiny_vit_5m_224 <- resnet101` | 93.37 | 94.43 | 88.45 |
|
| 106 |
+
| `vit_t16 <- resnet101` | 61.00 | | 58.70 |
|
| 107 |
+
| `vitfs_tiny_patch16_clc_gap_reg4_dinov2_bn <- resnet101` | 90.58 | 94.01 | 85.47 |
|
| 108 |
+
| `vitfs_tiny_patch16_gap_224 <- resnet101` | 85.30 | | 82.72 |
|
| 109 |
+
| `vitfs_tiny_patch16_gap_reg4_dinov2_bn_init <- resnet101` | 92.20 | 94.48 | 86.26 |
|
| 110 |
+
| `vitfs_tiny_patch16_gap_reg4_dinov2_init <- resnet101` | 89.32 | 93.07 | 83.72 |
|
| 111 |
+
| `vitfs_tiny_patch16_kvm_gap_reg4_dinov2_bn <- resnet101` | | 94.25 | 83.91 |
|
| 112 |
+
|
| 113 |
+
### `vitfs_224_t448`
|
| 114 |
+
|
| 115 |
+
| Model | aircraft | cars | cub |
|
| 116 |
+
|---|---|---|---|
|
| 117 |
+
| `vit_t16 <- resnet101` | 55.06 | 51.29 | 49.48 |
|
| 118 |
+
| `vitfs_micro_patch16_gap_reg4_dinov2_bn <- resnet101` | 88.81 | 92.41 | 78.25 |
|
| 119 |
+
| `vitfs_nano_patch16_gap_reg4_dinov2_bn <- resnet101` | 85.06 | 90.44 | 70.88 |
|
| 120 |
+
| `vitfs_tiny_patch16_gap_reg4_dinov2_bn_init <- resnet101` | 90.49 | 93.91 | 81.20 |
|
| 121 |
+
| `vitfs_tiny_patch16_gap_reg4_dinov2_init <- resnet101` | 86.35 | 92.71 | 77.94 |
|
| 122 |
+
|
| 123 |
+
### `vitfs_224`
|
| 124 |
+
|
| 125 |
+
| Model | aircraft | cars | cub |
|
| 126 |
+
|---|---|---|---|
|
| 127 |
+
| `vitfs_tiny_patch16_gap_224 <- resnet101` | 52.63 | 86.16 | 75.61 |
|
| 128 |
+
| `vitfs_tiny_patch16_gap_reg4_dinov2_bn_init <- resnet101` | 60.13 | 92.64 | 79.89 |
|
| 129 |
+
| `vitfs_tiny_patch16_gap_reg4_dinov2_init <- resnet101` | 47.76 | 86.57 | 76.46 |
|
| 130 |
+
|
| 131 |
+
### `vitfs_128`
|
| 132 |
+
|
| 133 |
+
| Model | aircraft | cars | cub |
|
| 134 |
+
|---|---|---|---|
|
| 135 |
+
| `vitfs_micro_patch16_gap_reg4_dinov2_bn <- resnet101` | 79.21 | 88.45 | 66.40 |
|
| 136 |
+
| `vitfs_nano_patch16_gap_reg4_dinov2_bn <- resnet101` | 77.47 | 83.97 | 61.32 |
|
| 137 |
+
| `vitfs_tiny_patch16_gap_reg4_dinov2_bn_init <- resnet101` | 81.10 | 90.24 | |
|
| 138 |
+
|
| 139 |
+
### `vit_ce_448`
|
| 140 |
+
|
| 141 |
+
| Model | aircraft | cars | cub |
|
| 142 |
+
|---|---|---|---|
|
| 143 |
+
| `efficientvit_m2` | 87.49 | 83.75 | 73.25 |
|
| 144 |
+
| `efficientvit_m3` | 87.46 | 80.19 | 72.82 |
|
| 145 |
+
| `levit_128s` | 82.27 | 87.07 | 69.59 |
|
| 146 |
+
| `mobilevit_s` | 88.36 | 91.20 | 72.01 |
|
| 147 |
+
| `mobilevitv2_100` | 89.11 | 90.57 | 78.60 |
|
| 148 |
+
| `mobilevitv2_125` | 87.85 | 90.34 | 81.50 |
|
| 149 |
+
| `nest_tiny` | 82.99 | 81.23 | 71.13 |
|
| 150 |
+
| `pvt_v2_b0` | 86.41 | 89.76 | 75.09 |
|
| 151 |
+
| `pvt_v2_b1` | 85.63 | | |
|
| 152 |
+
| `swin_tiny_patch4_window7_224` | | 63.26 | |
|
| 153 |
+
| `vit_t16` | 45.60 | 26.38 | 30.81 |
|
| 154 |
+
| `vitfs_tiny_patch16_gap_224` | | | 0.78 |
|
| 155 |
+
| `vitfs_tiny_patch16_gap_reg4_dinov2_bn_init` | | 88.41 | 69.92 |
|
| 156 |
+
| `vitfs_tiny_patch16_gap_reg4_dinov2_init` | 76.84 | 81.35 | 60.30 |
|
| 157 |
+
|
| 158 |
+
### `vitfs_transfer`
|
| 159 |
+
|
| 160 |
+
| Model | aircraft | cars | cub |
|
| 161 |
+
|---|---|---|---|
|
| 162 |
+
| `vit_t16` | 50.23 | 39.12 | |
|
| 163 |
+
| `vitfs_tiny_patch16_gap_reg4_dinov2_bn_init` | 87.19 | 90.70 | 82.52 |
|
| 164 |
+
|
| 165 |
+
### `ablations_128`
|
| 166 |
+
|
| 167 |
+
| Model | aircraft | cars | cub |
|
| 168 |
+
|---|---|---|---|
|
| 169 |
+
| `lrnet14` | 86.05 | 89.34 | 65.10 |
|
| 170 |
+
| `lrnet14 <- resnet101` | 85.30 | 93.06 | 81.79 |
|
| 171 |
+
| `resnet101d <- resnet101` | 88.18 | 92.54 | |
|
| 172 |
+
| `resnet18` | 73.72 | 82.13 | 56.54 |
|
| 173 |
+
| `resnet18 <- resnet101` | 82.03 | 88.22 | 75.34 |
|
| 174 |
+
| `resnet34d <- resnet101` | 87.46 | 91.64 | 78.65 |
|
| 175 |
+
|
| 176 |
+
### `scratch_vs_pt_448`
|
| 177 |
+
|
| 178 |
+
| Model | aircraft | cars | cub |
|
| 179 |
+
|---|---|---|---|
|
| 180 |
+
| `resnet101` | 83.08 | 84.36 | 66.41 |
|
| 181 |
+
| `resnet101 <- resnet101` | 93.91 | 94.60 | 87.63 |
|
| 182 |
+
|
| 183 |
+
### `sweeps_128`
|
| 184 |
+
|
| 185 |
+
| Model | cub |
|
| 186 |
+
|---|---|
|
| 187 |
+
| `resnet18 <- resnet101` | 80.34 |
|
| 188 |
+
|
| 189 |
+
## Requirements
|
| 190 |
+
|
| 191 |
+
- `fgir-zoo` (`pip install git+https://github.com/arkel23/fgir-zoo.git`), which pins
|
| 192 |
+
`timm==0.9.12`
|
| 193 |
+
- `torch` (checked with 2.5.1)
|
| 194 |
+
|
| 195 |
+
## Citation
|
| 196 |
+
|
| 197 |
+
```bibtex
|
| 198 |
+
@misc{rios_tgda_2025,
|
| 199 |
+
title = {Fine-Grained Image Recognition from Scratch with Teacher-Guided Data Augmentation},
|
| 200 |
+
author = {Rios, Edwin Arkel and Mikael, Fernando and Gosal, Oswin and Oyerinde, Femiloye and
|
| 201 |
+
Liang, Hao-Chun and Lai, Bo-Cheng and Hu, Min-Chun},
|
| 202 |
+
year = {2025},
|
| 203 |
+
eprint = {2507.12157},
|
| 204 |
+
archivePrefix = {arXiv},
|
| 205 |
+
primaryClass = {cs.CV},
|
| 206 |
+
doi = {10.48550/arXiv.2507.12157},
|
| 207 |
+
url = {https://arxiv.org/abs/2507.12157}
|
| 208 |
+
}
|
| 209 |
+
```
|