Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,3 +1,142 @@
|
|
| 1 |
-
---
|
| 2 |
-
|
| 3 |
-
--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: pytorch # raw PyTorch checkpoint + this repo's code, not a transformers/timm model — see §"How to Get Started". FILL_ME if you package it differently (e.g. wrap in a transformers custom-code repo).
|
| 3 |
+
pipeline_tag: image-feature-extraction
|
| 4 |
+
license: cc-by-nc-sa-4.0
|
| 5 |
+
tags:
|
| 6 |
+
- mri
|
| 7 |
+
- brain-mri
|
| 8 |
+
- medical-imaging
|
| 9 |
+
- 3d
|
| 10 |
+
- volumetric
|
| 11 |
+
- self-supervised
|
| 12 |
+
- vision-transformer
|
| 13 |
+
- fomo300k
|
| 14 |
+
datasets:
|
| 15 |
+
- FOMO-MRI/FOMO300K
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# Dinov3D-Neuro: A 3D ViT-B/16³ for Brain MRI trained using DINOv3-style SSL
|
| 19 |
+
|
| 20 |
+
> **Provenance statement.** This model uses the **DINOv3 architecture and self-supervised
|
| 21 |
+
> training objective**, adapted to 3D volumetric input via the
|
| 22 |
+
> [`asagilmore/dinov3d`](https://github.com/asagilmore/dinov3d) codebase, itself a fork of
|
| 23 |
+
> [`facebookresearch/dinov3`](https://github.com/facebookresearch/dinov3). Dinov3D was **trained
|
| 24 |
+
> from scratch on brain MRI data and contains no weights from Meta's DINOv3 checkpoints**. It
|
| 25 |
+
> is not affiliated with, endorsed by, or sponsored by Meta.
|
| 26 |
+
|
| 27 |
+
---
|
| 28 |
+
|
| 29 |
+
## Model Details
|
| 30 |
+
|
| 31 |
+
### Model Description
|
| 32 |
+
|
| 33 |
+
A 3D Vision Transformer encoder pretrained with a DINOv3 self-supervised objective
|
| 34 |
+
(DINO + iBOT + KoLeo) with Gram anchoring added in later training phases, and a
|
| 35 |
+
final high resolution adaptation phase (In Progress!). The model was trained on single-channel
|
| 36 |
+
brain MRI volumes from the FOMO300K dataset of various contrasts (T1w, T2w, FLAIR, ...).
|
| 37 |
+
Given a preprocessed volume, the model returns a CLS token and a grid of patch tokens (792-dim each).
|
| 38 |
+
|
| 39 |
+
- **Developed by:** Asa Gilmore, Dr. Ariel Rokem.
|
| 40 |
+
- **Model type:** 3D Vision Transformer (self-supervised feature encoder)
|
| 41 |
+
- **Architecture:** DINOv3 ViT, adapted to 3D — `vit3d_base`: embedding dim 792, 12 layers, 12
|
| 42 |
+
heads (head dim 66), MLP FFN (ratio 4), LayerScale init 1e-5, drop path rate 0.3, 3-axis RoPE
|
| 43 |
+
position embedding (base 100.0, `separate` per-axis coordinate normalization), **0 register
|
| 44 |
+
("storage") tokens**, LayerNorm.
|
| 45 |
+
- **Parameters:** ~93.7M (measured by instantiating `vit3d_base`)
|
| 46 |
+
- **Input:** Single-channel ("grayscale") 3D volume, shape `1 × D × H × W`, resampled to
|
| 47 |
+
**1 mm isotropic** spacing and padded to a multiple of the patch size (16) per axis. Trained
|
| 48 |
+
with 128³ global / 48³ local crops (base pretrain + Gram-anchoring phases), later adapted to
|
| 49 |
+
192³ global / 64³ local crops in a high-resolution phase — see [Training Details](#training-details).
|
| 50 |
+
- **Output:** 792-dimensional embeddings: 1 CLS token + `(D/16)·(H/16)·(W/16)` patch tokens (no
|
| 51 |
+
register tokens). `model.forward_features(x)` returns a dict including
|
| 52 |
+
`x_norm_clstoken` (`B×792`) and `x_norm_patchtokens` (`B×N×792`).
|
| 53 |
+
- **Precision of released weights:** fp32 (as stored in the `.pth` checkpoint;
|
| 54 |
+
training itself used bf16 param dtype / fp32 reduce dtype under FSDP2 mixed precision).
|
| 55 |
+
- **License:** CC BY-NC-SA 4.0 (inherited from FOMO300K — see [Licensing](#licensing-and-attribution)). FILL_ME — confirm this is the license you intend before publishing; it is not yet stated anywhere else in this repo.
|
| 56 |
+
- **Trained from scratch:** Yes — no pretrained initialization of any kind
|
| 57 |
+
|
| 58 |
+
### Model Sources
|
| 59 |
+
|
| 60 |
+
- **Repository:** [`asagilmore/dinov3d`](https://github.com/asagilmore/dinov3d) (training/modeling code, this repo)
|
| 61 |
+
- **Paper:** None — no technical report exists yet for this model. FILL_ME if one is written.
|
| 62 |
+
- **Architecture reference:** [DINOv3](https://arxiv.org/abs/2508.10104) (Siméoni et al., 2025)
|
| 63 |
+
|
| 64 |
+
### Relationship to DINOv3
|
| 65 |
+
|
| 66 |
+
*Adapted code:* This model uses code adapted from
|
| 67 |
+
[`facebookresearch/dinov3`](https://github.com/facebookresearch/dinov3), which is licensed
|
| 68 |
+
under the [DINOv3 License](https://ai.meta.com/resources/models-and-libraries/dinov3-license).
|
| 69 |
+
|
| 70 |
+
**weights** are original work trained from scratch on brain MRI and are licensed separately
|
| 71 |
+
under CC BY-NC-SA 4.0.
|
| 72 |
+
|
| 73 |
+
**Modifications made for 3D:**
|
| 74 |
+
|
| 75 |
+
| Component | 2D DINOv3 | This model |
|
| 76 |
+
|---|---|---|
|
| 77 |
+
| Patch embedding | Conv2d, 16×16 | Conv3d, 16×16×16 (`in_chans=1`, single-channel MRI) |
|
| 78 |
+
| Positional encoding | 2-axis RoPE | 3-axis (D/H/W) axial RoPE, base θ = 100.0, `separate` coordinate normalization |
|
| 79 |
+
| Register tokens | 4 | 0 (`n_storage_tokens: 0`) |
|
| 80 |
+
| Global/local crops | 2D multi-crop | 3D multi-crop: 128³ global / 48³ local (base + Gram phases), later 192³ / 64³ (high-res phase); 8 local crops per global crop |
|
| 81 |
+
| Color augmentation | color jitter, RGB mean/std normalization | none — single-channel intensities are z-score normalized once during preprocessing instead |
|
| 82 |
+
| Objective terms | DINO + iBOT + Koleo + Gram anchoring | Same four terms, applied in stages — see [Training Details](#training-details) |
|
| 83 |
+
|
| 84 |
+
Data augmentation has also been reworked with domain specific augmentations for brain MRI,
|
| 85 |
+
more details on data augmentation can be found in the code repo.
|
| 86 |
+
|
| 87 |
+
---
|
| 88 |
+
|
| 89 |
+
## Uses
|
| 90 |
+
|
| 91 |
+
Evaluation and downstream adaptation is still in progress, check back later to
|
| 92 |
+
see more details.
|
| 93 |
+
|
| 94 |
+
## How to Get Started with the Model
|
| 95 |
+
|
| 96 |
+
This model is distributed as a raw PyTorch checkpoint plus the code in this repo, as
|
| 97 |
+
well as sharded checkpoints at the end of each training phase.
|
| 98 |
+
|
| 99 |
+
The teacher checkpoints can be loaded following the inference instructions in the repo,
|
| 100 |
+
and the sharded checkpoints can be used to restart training for fine-tuning experiments.
|
| 101 |
+
|
| 102 |
+
The teacher checkpoints can be found in the eval folder. We include all checkpoints captured
|
| 103 |
+
during training, but reccomend using the latest one, unless doing experiments to
|
| 104 |
+
evaluate performance over training iterations.
|
| 105 |
+
|
| 106 |
+
The ckpt directory contains the sharded checkpoints, which we include at the end of
|
| 107 |
+
each training phase.
|
| 108 |
+
|
| 109 |
+
---
|
| 110 |
+
|
| 111 |
+
## Training Details
|
| 112 |
+
|
| 113 |
+
### Training Data
|
| 114 |
+
|
| 115 |
+
**Dataset:** [FOMO-MRI/FOMO300K](https://huggingface.co/datasets/FOMO-MRI/FOMO300K)
|
| 116 |
+
(Cerri et al., 2026) — a large-scale heterogeneous corpus of brain MRI aggregated from public
|
| 117 |
+
sources, spanning T1, MPRAGE, T2, T2*, FLAIR, SWI, T1c, PD, DWI, and ADC sequences, and
|
| 118 |
+
including both clinical- and research-grade acquisitions. It is a superset of OpenMind and
|
| 119 |
+
FOMO50K/FOMO60K.
|
| 120 |
+
|
| 121 |
+
We filtered the fomo300k dataset to include only single channel anatomical scans.
|
| 122 |
+
The repo contains a fomo300k.json file listing all subjects used.
|
| 123 |
+
|
| 124 |
+
### Preprocessing
|
| 125 |
+
|
| 126 |
+
FOMO300K is distributed as NIfTI without co-registration or skull-stripping.
|
| 127 |
+
|
| 128 |
+
- Resampling: 1 mm³ isotropic (`Spacingd`, bilinear/trilinear interpolation, `border` padding),
|
| 129 |
+
applied at load time via `InferenceAugmentation3d` / the training data pipeline
|
| 130 |
+
- Padding: to the nearest multiple of patch size (16) per axis, filled with the volume's
|
| 131 |
+
minimum intensity value (`DivisiblePadd(..., mode="minimum")`)
|
| 132 |
+
- Intensity normalization: per-volume z-score (`NormalizeIntensityd(nonzero=True,
|
| 133 |
+
channel_wise=True)`), plus empty-signal filling (`SignalFillEmptyd`) — done once ahead of
|
| 134 |
+
time when building the preprocessed dataset (`scripts/preproccess_fomo300k.py`), not
|
| 135 |
+
per-forward-pass
|
| 136 |
+
- Augmentations (training only): 3D multi-crop (128³ global / 48³ local scaled up to 192³/64³
|
| 137 |
+
in the high-res phase; crop scale ranges 0.32–1.0 global, 0.05–0.32 local; 8 local crops per
|
| 138 |
+
sample), random flips. No color jitter (single-channel intensities, not RGB).
|
| 139 |
+
|
| 140 |
+
### Training Hyperparameters
|
| 141 |
+
|
| 142 |
+
All training hyperparameters can be found in the config.yaml file in this HF repo.
|