In-domain self-supervised pretraining versus ImageNet initialisation for chest radiograph classification: all checkpoints
This repository contains every checkpoint of the study "In-domain self-supervised pretraining versus ImageNet initialisation for label-scarce chest radiograph classification" (K. Mahmood, M. Ramzan, Q. Abbas, A. Alshanqiti, S. Albouq, S. Alhazmi; manuscript under submission to BMC Medical Imaging; the citation will be added on publication).
- 10 in-domain self-supervised encoders: SimCLR (ResNet50, 100 epochs) and masked autoencoder (MAE; ViT-S/16, 75% masking, 300 epochs), each pretrained 5 times (seeds 42, 123, 456, 789, 2026) on the 18,677 unlabelled RSNA training images only.
- 90 fine-tuned three-class classifiers: 2 backbones × 3 initialisations (random, supervised ImageNet-1k, in-domain SSL) × 3 label budgets (1%, 10%, 100% of the training labels) × 5 paired runs.
Code, data splits and results: https://github.com/Kashif-Mahmood007/rsna-cxr-ssl-initialisation · archived on Zenodo: https://doi.org/10.5281/zenodo.24543664
Task and data
Three-class classification of frontal chest radiographs from the RSNA Pneumonia Detection Challenge (stage 2 training set, 26,684 images): 0 = Normal, 1 = No Lung Opacity / Not Normal, 2 = Lung Opacity.
The data were split by patient identifier and by exact and near-duplicate images (256-bit perceptual hash) into 18,677 training, 2,668 validation and 5,339 test images. No images are included in this repository; obtain the data from the RSNA challenge page under its terms.
Repository layout
ssl_encoders/{simclr_resnet50|mae_vit_s16}_seed{S}/
encoder_final.pt original checkpoint (SHA-256 below and in manifests/ssl_manifest.json)
encoder.safetensors the same encoder weights in safetensors format
config.json, history.json pretraining settings and per-epoch loss
finetuned/{1pct|10pct|100pct}/
{model}_seed{S}.safetensors classifier weights (float16), selected on validation macro-F1
{model}_seed{S}_result.json training record (learning rate, best step, validation scores)
manifests/ ssl_manifest.json, finetune_manifest.json, lr_choice.json
SHA256SUMS.txt SHA-256 of every file in this repository
{model} is one of resnet50_scratch, resnet50_imagenet, resnet50_simclr, vit_s16_scratch, vit_s16_imagenet, vit_s16_mae.
Run k of a model used training seed k, label draw k and (for SSL models) the encoder pretrained with seed k, so runs with the same seed are paired across models.
Test results (macro-F1 on the RSNA test set, mean ± SD over 5 runs)
| Model | 1% labels | 10% labels | 100% labels |
|---|---|---|---|
| ResNet50, random init | 0.524 ± 0.042 | 0.650 ± 0.006 | 0.705 ± 0.003 |
| ResNet50, ImageNet init | 0.618 ± 0.007 | 0.662 ± 0.015 | 0.726 ± 0.010 |
| ResNet50, SimCLR init (in-domain SSL) | 0.629 ± 0.008 | 0.667 ± 0.005 | 0.705 ± 0.006 |
| ViT-S/16, random init | 0.483 ± 0.026 | 0.580 ± 0.010 | 0.642 ± 0.004 |
| ViT-S/16, ImageNet init | 0.609 ± 0.010 | 0.665 ± 0.011 | 0.722 ± 0.005 |
| ViT-S/16, MAE init (in-domain SSL) | 0.578 ± 0.021 | 0.652 ± 0.011 | 0.699 ± 0.004 |
These are the values reported in the paper. Robustness, calibration, external transfer (Kermany paediatric dataset) and subgroup results are in the paper and its Additional file 1.
How to use
Preprocessing (as in training): decode the radiograph to 8-bit grayscale, zero-pad to a square, resize to 224×224 (Lanczos), scale to [0, 1], copy to 3 channels and normalise with the ImageNet mean (0.485, 0.456, 0.406) and SD (0.229, 0.224, 0.225).
Fine-tuned classifiers load directly into timm:
import timm, torch
from huggingface_hub import hf_hub_download
from safetensors.torch import load_file
repo = "Kashif-Mahmood007/rsna-cxr-ssl-initialisation"
path = hf_hub_download(repo, "finetuned/100pct/resnet50_imagenet_seed42.safetensors")
model = timm.create_model("resnet50", pretrained=False, num_classes=3) # ViT: "vit_small_patch16_224"
model.load_state_dict(load_file(path))
model.eval()
classes = ["Normal", "No Lung Opacity / Not Normal", "Lung Opacity"]
SSL encoders are loaded into a classifier with build_classifier from the study library medssl_lib.py (see the code repository):
import medssl_lib as L
enc = hf_hub_download(repo, "ssl_encoders/simclr_resnet50_seed42/encoder_final.pt")
model, info = L.build_classifier("resnet50", "ssl", 3, enc) # MAE: L.build_classifier("vit_s16", "ssl", 3, enc)
Training summary
- SSL pretraining: AdamW, batch 128, 10 warm-up epochs then cosine decay, mixed precision. SimCLR: NT-Xent loss, temperature 0.2, learning rate 5e-4. MAE: 75% of 196 patches masked, decoder 256-dim / 4 blocks, learning rate 7.5e-5. Last-epoch encoder kept; no labels used.
- Fine-tuning (identical recipe for all models): AdamW (weight decay 0.05), head learning rate 10× the backbone rate, 5% warm-up then cosine decay, batch 32, step budgets 1,200 / 3,000 / 15,000 for 1% / 10% / 100% labels, early stopping on validation macro-F1. Backbone learning rate chosen per model on validation data from {3e-5, 1e-4, 3e-4, 1e-3} (see
manifests/lr_choice.json). - ImageNet initialisation used the
timmweightsresnet50.tv_in1kandvit_small_patch16_224.augreg_in1k.
Encoders and checksums
| Encoder | Backbone | Epochs | Seed | SHA-256 of encoder_final.pt |
|---|---|---|---|---|
ssl_encoders/mae_vit_s16_seed123 |
ViT-S/16 | 300 | 123 | 30a3b89d06517fd02d20040fcbaa9a4c45cf5712357bf63628807c9219057747 |
ssl_encoders/mae_vit_s16_seed2026 |
ViT-S/16 | 300 | 2026 | 8d6274729f5defd16b1d927dee8772da77c38fdfa209c1470427ba7a28a3bba8 |
ssl_encoders/mae_vit_s16_seed42 |
ViT-S/16 | 300 | 42 | d3dfcb9d1ac1b5fdb073acdbcf8754af14e6378e6292e4d78e2e0f07705c25a8 |
ssl_encoders/mae_vit_s16_seed456 |
ViT-S/16 | 300 | 456 | a3f1cb0a821f56399c996874241d1876c02951a2ab2134ba093d3a1f8791a16f |
ssl_encoders/mae_vit_s16_seed789 |
ViT-S/16 | 300 | 789 | 7f6b3ac08e9b6f34a76bc51048c86508639d6f930ef06a05a4b1c7193161016c |
ssl_encoders/simclr_resnet50_seed123 |
ResNet50 | 100 | 123 | fe60d4010e58c49ac13465925dadcb2f1ddcffdd53c4e9844566bc8272266b6c |
ssl_encoders/simclr_resnet50_seed2026 |
ResNet50 | 100 | 2026 | b9ae08032cd8b9b31cb05c99e3a2fb7ba026158d8f34f997dbfd1a0d7318b2e5 |
ssl_encoders/simclr_resnet50_seed42 |
ResNet50 | 100 | 42 | d9c9e20771093cc824fca1b5b08091d4cd29767f86d46cd342d89ef32dd9ffb4 |
ssl_encoders/simclr_resnet50_seed456 |
ResNet50 | 100 | 456 | 36d3348deb32af293f47656fdd766661dbc1dc3b096b50aaa33d0c4f883be6d6 |
ssl_encoders/simclr_resnet50_seed789 |
ResNet50 | 100 | 789 | ee4621700f1dd2f4a8ec3c6c6ab861a7dabe845e401bc079accbff4886843160 |
Intended use and limitations
- Research use only. These models are not medical devices and must not be used for diagnosis or any clinical decision.
- They were trained on adult radiographs from one public dataset (RSNA / NIH ChestX-ray8). Performance on other hospitals, scanners, populations or label definitions is not guaranteed; on the external paediatric Kermany set, transfer varied strongly between runs at small label budgets.
- Lung Opacity sensitivity was the weakest aspect of every model (0.42–0.60 across models and budgets).
- View position (PA/AP) is strongly associated with the label in this dataset and may act as a shortcut.
Licence
The weights are released under CC BY-NC 4.0 (attribution, non-commercial). They were trained on the RSNA Pneumonia Detection Challenge data; users must also respect the data providers' terms of use.
Citation
The citation will be added when the paper is published. Until then, please cite this repository:
Mahmood K, Ramzan M, Abbas Q, Alshanqiti A, Albouq S, Alhazmi S. In-domain self-supervised pretraining versus ImageNet initialisation for label-scarce chest radiograph classification: model checkpoints. Hugging Face; 2026. https://huggingface.co/Kashif-Mahmood007/rsna-cxr-ssl-initialisation
and the code release:
Mahmood K, Ramzan M, Abbas Q, Alshanqiti A, Albouq S, Alhazmi S. In-domain self-supervised pretraining versus ImageNet initialisation for label-scarce chest radiograph classification: code and data splits. Zenodo; 2026. https://doi.org/10.5281/zenodo.24543664