swinv2-tiny-patch4-window8-256-galaxy10-decals-head-v2
microsoft/swinv2-tiny-patch4-window8-256 adapted to galaxy morphology classification on Galaxy10 DECaLS (10 classes) by head-only fine-tuning (backbone frozen, linear head trained), under the revised protocol of the paper When foundation models meet astronomical data (Astronomy and Computing, revised version, 2026). One of the 80 configurations (40 pretrained backbones x two adaptation regimes) of the collection Vision Foundation Models Benchmark.
This repository contains the complete model: the backbone weights are those of the base checkpoint (frozen during training, including the statistics of its normalisation layers) and the classification head is the trained one.
Results (held-out test set, 1,774 images)
| Accuracy (%) | Weighted F1 (%) | |
|---|---|---|
| This checkpoint (seed 42, epoch 30 of 30) | 47.91 | 44.57 |
| Mean +/- s.d. over three seeds (42, 1, 2) | 48.44 +/- 0.51 | 45.17 +/- 0.53 |
Scores are computed at the epoch of minimum validation loss. The per-epoch metrics of all runs, the tables of the paper and the data split are in the dataset vision-foundation-models-benchmark-runs.
Training protocol
- Data: Galaxy10 DECaLS (17,736 images). The public test split (1,774 images) is the held-out test set; the public train split is divided, with stratification by class, into 14,188 training and 1,774 validation images (indices in the dataset repository above). The validation set is used only to select the epoch.
- Recipe (identical for the 40 backbones): AdamW (betas 0.9/0.999, eps 1e-8, weight decay 0.1, gradient clipping 1.0), learning rate 1e-4, linear schedule with 10% warm-up, batches of 32 images with gradient accumulation over 8 steps (effective batch 256), 30 epochs, single precision (fp32, TF32 disabled), one GPU. Augmentation: random resized crop to the input resolution and random horizontal flip. Evaluation: resize and centre crop to 256x256 px, normalisation of the checkpoint's image processor. Seed 42 (seeds 1 and 2 give the mean and s.d. above).
- Regime: head-only fine-tuning (backbone frozen, linear head trained). The head is a single linear layer with ten outputs.
- Selection: epoch of minimum validation loss (epoch 30 here); the weights of this repository are those of that epoch.
- Software: PyTorch 2.3.0, transformers 4.37.2, datasets 2.19.1, torchvision 0.18.0.
Per-epoch metrics (seed 42)
| Epoch | Val. loss | Val. acc. | Test acc. | Test weighted F1 |
|---|---|---|---|---|
| 1 | 2.2841 | 10.03 | 9.81 | 7.45 |
| 2 | 2.1044 | 25.37 | 23.84 | 16.18 |
| 3 | 1.9388 | 31.06 | 31.96 | 24.91 |
| 4 | 1.8168 | 35.17 | 36.08 | 29.36 |
| 5 | 1.7466 | 37.66 | 38.33 | 32.26 |
| 6 | 1.6888 | 40.42 | 40.92 | 35.40 |
| 7 | 1.6498 | 41.32 | 41.09 | 34.98 |
| 8 | 1.6202 | 42.05 | 42.62 | 37.29 |
| 9 | 1.5949 | 42.62 | 43.80 | 38.79 |
| 10 | 1.5709 | 43.46 | 44.76 | 40.10 |
| 11 | 1.5557 | 43.74 | 45.26 | 40.92 |
| 12 | 1.5368 | 44.98 | 46.56 | 42.79 |
| 13 | 1.5246 | 44.81 | 46.62 | 42.56 |
| 14 | 1.5133 | 45.49 | 47.18 | 43.39 |
| 15 | 1.5096 | 44.87 | 47.01 | 43.07 |
| 16 | 1.4964 | 46.05 | 47.24 | 43.19 |
| 17 | 1.4877 | 46.79 | 47.41 | 43.33 |
| 18 | 1.4811 | 46.79 | 47.91 | 43.95 |
| 19 | 1.4766 | 47.63 | 47.29 | 43.49 |
| 20 | 1.4749 | 47.29 | 47.75 | 44.11 |
| 21 | 1.4697 | 47.75 | 47.75 | 44.00 |
| 22 | 1.4652 | 47.80 | 47.69 | 44.17 |
| 23 | 1.4612 | 47.75 | 47.75 | 44.14 |
| 24 | 1.4567 | 48.14 | 47.75 | 44.28 |
| 25 | 1.4547 | 48.53 | 47.97 | 44.65 |
| 26 | 1.4531 | 48.42 | 47.80 | 44.43 |
| 27 | 1.4517 | 48.48 | 47.86 | 44.51 |
| 28 | 1.4511 | 48.25 | 47.97 | 44.60 |
| 29 | 1.4506 | 48.48 | 47.91 | 44.55 |
| 30 (selected) | 1.4504 | 48.48 | 47.91 | 44.57 |
How to use
from transformers import AutoImageProcessor, AutoModelForImageClassification
from torchvision.transforms import Compose, Resize, CenterCrop, ToTensor, Normalize
model = AutoModelForImageClassification.from_pretrained("matthieulel/swinv2-tiny-patch4-window8-256-galaxy10-decals-head-v2").eval()
processor = AutoImageProcessor.from_pretrained("matthieulel/swinv2-tiny-patch4-window8-256-galaxy10-decals-head-v2")
# Pre-processing used in the paper: resize and centre-crop to 256x256 px, then the processor's normalisation
transform = Compose([Resize(256), CenterCrop((256, 256)), ToTensor(), Normalize(processor.image_mean, processor.image_std)])
# logits = model(pixel_values=transform(image).unsqueeze(0)).logits
Integrity check
The model stored in this repository was reloaded and run on the first 96 test images: predictions identical to the saved logits of the selected epoch for 100.0% of them (maximum absolute logit difference 2.35e-06).
Citation
Paper under revision for Astronomy and Computing; citation to be completed upon publication.