Upload folder using huggingface_hub
Browse files- README.md +138 -0
- mass_base.pth +3 -0
README.md
CHANGED
|
@@ -1,3 +1,141 @@
|
|
| 1 |
---
|
| 2 |
license: mit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
+
library_name: pytorch
|
| 4 |
+
tags:
|
| 5 |
+
- medical-image-segmentation
|
| 6 |
+
- 3d-medical-imaging
|
| 7 |
+
- self-supervised-learning
|
| 8 |
+
- in-context-segmentation
|
| 9 |
+
- pytorch
|
| 10 |
+
- arxiv:2603.13660
|
| 11 |
+
pipeline_tag: image-segmentation
|
| 12 |
---
|
| 13 |
+
|
| 14 |
+
# MASS Base Checkpoint
|
| 15 |
+
|
| 16 |
+
This repository hosts `mass_base.pth`, the base checkpoint for **MASS: Learning
|
| 17 |
+
Generalizable 3D Medical Image Representations from Mask-Guided
|
| 18 |
+
Self-Supervision**.
|
| 19 |
+
|
| 20 |
+
MASS is a mask-guided self-supervised learning framework for 3D medical images.
|
| 21 |
+
The released checkpoint was trained with the data used in our paper and the Iris
|
| 22 |
+
in-context segmentation architecture. It uses automatically generated
|
| 23 |
+
class-agnostic masks for pretraining and does **not** use expert ground-truth
|
| 24 |
+
annotations during pretraining.
|
| 25 |
+
|
| 26 |
+
## What This Checkpoint Is For
|
| 27 |
+
|
| 28 |
+
`mass_base.pth` can be used with the official MASS codebase for:
|
| 29 |
+
|
| 30 |
+
- training-free in-context segmentation with reference image-mask examples;
|
| 31 |
+
- initialization for downstream segmentation finetuning;
|
| 32 |
+
- frozen-encoder or finetuned encoder classification experiments.
|
| 33 |
+
|
| 34 |
+
This is a PyTorch checkpoint for the MASS/Iris architecture, not a standalone
|
| 35 |
+
Transformers model. Please use it with the code release:
|
| 36 |
+
|
| 37 |
+
- GitHub: https://github.com/Stanford-AIMI/MASS
|
| 38 |
+
- Project page: https://yhygao.github.io/MASS_page/
|
| 39 |
+
- Paper: https://arxiv.org/abs/2603.13660
|
| 40 |
+
|
| 41 |
+
## Download
|
| 42 |
+
|
| 43 |
+
Using the Hugging Face CLI:
|
| 44 |
+
|
| 45 |
+
```bash
|
| 46 |
+
hf download StanfordAIMI/MASS mass_base.pth --local-dir checkpoints
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
Using Python:
|
| 50 |
+
|
| 51 |
+
```python
|
| 52 |
+
from huggingface_hub import hf_hub_download
|
| 53 |
+
|
| 54 |
+
checkpoint_path = hf_hub_download("StanfordAIMI/MASS", "mass_base.pth")
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
## Raw NIfTI In-Context Inference
|
| 58 |
+
|
| 59 |
+
```bash
|
| 60 |
+
python inference.py \
|
| 61 |
+
--checkpoint checkpoints/mass_base.pth \
|
| 62 |
+
--test-image /path/to/test_image.nii.gz \
|
| 63 |
+
--reference-image /path/to/reference_image.nii.gz \
|
| 64 |
+
--reference-mask /path/to/reference_mask.nii.gz \
|
| 65 |
+
--output outputs/test_image_seg.nii.gz \
|
| 66 |
+
--gpu 0 \
|
| 67 |
+
--use-ema \
|
| 68 |
+
--modality ct \
|
| 69 |
+
--orientation RAS \
|
| 70 |
+
--target-spacing 1.5 1.5 1.5 \
|
| 71 |
+
--window-size 128 128 128 \
|
| 72 |
+
--overlap 0.5
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
Please make sure the input NIfTI metadata is complete and reliable, especially
|
| 76 |
+
orientation and spacing. `mass_base.pth` was trained after standardizing images
|
| 77 |
+
to RAS orientation, so using `--orientation RAS` is recommended.
|
| 78 |
+
|
| 79 |
+
## Downstream Segmentation Finetuning
|
| 80 |
+
|
| 81 |
+
```bash
|
| 82 |
+
python train.py \
|
| 83 |
+
--config config/downstream/segmentation_finetune_example.yaml \
|
| 84 |
+
--gpu 0 \
|
| 85 |
+
--name segmentation_finetune_example \
|
| 86 |
+
--override \
|
| 87 |
+
finetuning.pretrained_checkpoint=checkpoints/mass_base.pth \
|
| 88 |
+
data.train.data_root=/path/to/mass_h5 \
|
| 89 |
+
data.val.data_root=/path/to/mass_h5 \
|
| 90 |
+
data.train.datasets='[example_segmentation]' \
|
| 91 |
+
data.val.datasets='[example_segmentation]'
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
## Classification Linear Probing
|
| 95 |
+
|
| 96 |
+
```bash
|
| 97 |
+
python train.py \
|
| 98 |
+
--config config/downstream/classification_linear_probe_example.yaml \
|
| 99 |
+
--gpu 0 \
|
| 100 |
+
--name classification_linear_probe_example \
|
| 101 |
+
--override \
|
| 102 |
+
classification.encoder.pretrained_checkpoint=checkpoints/mass_base.pth \
|
| 103 |
+
classification.num_classes=2 \
|
| 104 |
+
data.train.data_root=/path/to/classification_data \
|
| 105 |
+
data.val.data_root=/path/to/classification_data \
|
| 106 |
+
data.train.datasets='[example_classification]' \
|
| 107 |
+
data.val.datasets='[example_classification]'
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
## Training Details
|
| 111 |
+
|
| 112 |
+
- Architecture: Iris in-context segmentation architecture.
|
| 113 |
+
- Pretraining objective: MASS mask-guided self-supervised learning.
|
| 114 |
+
- Supervision during pretraining: automatically generated class-agnostic masks.
|
| 115 |
+
- Expert annotations during pretraining: none.
|
| 116 |
+
- Modalities: 3D CT, MRI, and PET volumes used in the MASS paper.
|
| 117 |
+
|
| 118 |
+
The MASS objective is compatible with other in-context segmentation
|
| 119 |
+
architectures. The official codebase includes preprocessing and pretraining
|
| 120 |
+
utilities for training MASS on your own data.
|
| 121 |
+
|
| 122 |
+
## Limitations
|
| 123 |
+
|
| 124 |
+
- This checkpoint is intended for research use.
|
| 125 |
+
- It is not a medical device and should not be used for clinical decision-making.
|
| 126 |
+
- Raw NIfTI inference depends on reliable image metadata and preprocessing
|
| 127 |
+
choices. Cases with missing or incorrect spacing/orientation metadata should be
|
| 128 |
+
inspected carefully.
|
| 129 |
+
- Task-specific finetuning or validation is recommended before using the model on
|
| 130 |
+
a new dataset or anatomy.
|
| 131 |
+
|
| 132 |
+
## Citation
|
| 133 |
+
|
| 134 |
+
```bibtex
|
| 135 |
+
@article{gao2026learning,
|
| 136 |
+
title={Learning Generalizable 3D Medical Image Representations from Mask-Guided Self-Supervision},
|
| 137 |
+
author={Gao, Yunhe and Zhang, Yabin and Wang, Chong and Liu, Jiaming and Varma, Maya and Delbrouck, Jean-Benoit and Chaudhari, Akshay and Langlotz, Curtis},
|
| 138 |
+
journal={arXiv preprint arXiv:2603.13660},
|
| 139 |
+
year={2026}
|
| 140 |
+
}
|
| 141 |
+
```
|
mass_base.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8f27f19e5bd6013f792a2319207d6ec8652229cf4f89d1f29233ff12e9342b32
|
| 3 |
+
size 967276762
|