Instructions to use nidl-neurospin/open-simclr-resnet50 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Flair
How to use nidl-neurospin/open-simclr-resnet50 with Flair:
from flair.data import Sentence from flair.models import SequenceTagger tagger = SequenceTagger.load("nidl-neurospin/open-simclr-resnet50") sentence = Sentence("George Washington went to Washington.") tagger.predict(sentence) print(sentence) - Notebooks
- Google Colab
- Kaggle
Open-SimCLR ResNet-50 β Open Foundation Model for 3D Brain MRI
An open model of nidl: a 3D ResNet-50 pretrained with SimCLR, with nidl only, on open data. Its data, code, training recipe and weights are all public, so that anyone can reproduce it, compare a new method with it under the same conditions, or build upon it.
- Pretraining recipe: https://neurospin-deepinsight.github.io/nidl/auto_examples/plot_open_models_pretraining.html
- Pretraining data: OpenMind, quasi-raw images
- nidl documentation: https://neurospin-deepinsight.github.io/nidl
Pretraining
SimCLR on the train split of OpenMind: 63,992 quasi-raw T1w, T2w and FLAIR volumes of 31,775 participants from 787 OpenNeuro datasets, skull-stripped, bias-corrected and linearly registered to MNI152 at 1 mm. The model was trained for 100 epochs on one NVIDIA H100 GPU, with batches of 64 images, in bf16-mixed precision.
| Optimizer | adamW, learning rate 0.0001, weight decay 0.0005 |
| Schedule | linear warmup for 10 epochs from 1e-06, then cosine decay to 0 |
| Epochs | 100 (999 steps each) |
All the hyper-parameters are in config.json, from which from_config builds the same estimator, randomly initialized. The data loading and the augmentations are given by the pretraining recipe.
Model configuration
| Estimator | nidl.estimators.ssl.SimCLR |
| Encoder | 3D ResNet-50, resnet50 |
| Encoder parameters | 50.4M |
| Features | 2048-dimensional |
| Input shape | 1 Γ 128 Γ 128 Γ 128 |
| Preprocessing | Resize to 121 Γ 145 Γ 121, CropOrPad to 128Β³, ZNormalization |
The weights hold all the parameters of the estimator: the encoder and the projection head. The pretraining can thus be continued, and the model fine-tuned.
Expected input
Quasi-raw brain MRI, as in OpenMind or OpenBHB: skull-stripped, bias-corrected and linearly registered to MNI152 at 1 mm, of shape 182 Γ 218 Γ 182. The preprocessing resizes the whole volume to 121 Γ 145 Γ 121, crops or pads it to 128 Γ 128 Γ 128 and standardizes it.
Usage
pip install nidl[pretrained]
from torch.utils.data import DataLoader
from nidl.estimators.ssl import SimCLR
model = SimCLR.from_pretrained("nidl-neurospin/open-simclr-resnet50")
preprocess = model.get_preprocessing()
# volumes: arrays of shape (1, 182, 218, 182), prepared as described above
loader = DataLoader([preprocess(volume) for volume in volumes], batch_size=4)
features = model.transform(loader) # shape (n_volumes, 2048)
To pretrain it again from scratch, see the pretraining recipe.
Evaluation
On the OpenBHB test set (757 participants), a ridge regression on the frozen features of the quasi-raw images predicts the age with an MAE of 3.86 years (RΒ² 0.77), see the example on OpenBHB.
Citation
If you use this model, please cite OpenMind and SimCLR:
@inproceedings{wald2025openmind,
title={An OpenMind for 3D medical vision self-supervised learning},
author={Wald, Tassilo and Ulrich, Constantin and Suprijadi, Jonathan and Ziegler, Sebastian and Nohel, Michal and Peretzke, Robin and K{\"o}hler, Gregor and Maier-Hein, Klaus H.},
booktitle={International Conference on Computer Vision (ICCV)},
year={2025}
}
@inproceedings{chen2020simple,
title={A Simple Framework for Contrastive Learning of Visual Representations},
author={Chen, Ting and Kornblith, Simon and Norouzi, Mohammad and Hinton, Geoffrey},
booktitle={International Conference on Machine Learning (ICML)},
year={2020}
}
License
The weights are released under the CC-BY 4.0 license. The OpenMind images keep the licenses of their OpenNeuro datasets.
- Downloads last month
- 49