nnU-Net T1 lesion segmentation

A packaged nnU-Net v2 2D model and Python inference script for lesion segmentation from one 3D T1 MRI volume. The output is a binary NIfTI lesion mask (0 background, 1 lesion), with the input shape, affine, and header preserved. This model performs segmentation; it does not generate T2 or FLAIR images.

The repository includes the original inference code, the validation-selected checkpoint_best.pth, and the nnU-Net plans and dataset configuration. Patient images and lesion labels are excluded from this release.

Download

python -m pip install huggingface_hub
hf download MatheoWang/nnunet-t1-inference --local-dir nnunet-t1-inference
cd nnunet-t1-inference

Alternatively, download the full repository using Python:

from huggingface_hub import snapshot_download

snapshot_download(
    repo_id="MatheoWang/nnunet-t1-inference",
    local_dir="nnunet-t1-inference",
)

Install

conda create -n nnunet-t1-infer python=3.12 -y
conda activate nnunet-t1-infer
python -m pip install torch==2.4.1 --index-url https://download.pytorch.org/whl/cu124
python -m pip install -r requirements.txt

The supplied environment uses PyTorch 2.4.1 with CUDA 12.4 and nnunetv2==2.5.1. The remaining pinned dependencies are listed in requirements.txt.

Run

python infer.py --input /path/to/T1.nii.gz --output /path/to/T1_seg.nii.gz

The input must be one 3D .nii or .nii.gz T1 volume. A CUDA GPU is used by default; add --device cpu to request CPU inference. Add --overwrite to replace an existing output file.

Inference must use the supplied infer.py and packaged model folder. The script prepares model input with in-plane spacing 512 / max(shape[0], shape[1]) and slice spacing 5.0, then restores the output to the input geometry. This preprocessing is specific to this release and should be considered when assessing use with other data.

Model and reported evaluation

The following values come from the supplied MODEL_INFO.json; they have not been independently reproduced for this release.

Item Value
Architecture nnU-Net v2, 2D
Dataset identifier Dataset602_MS60T1
Fold 0
Checkpoint checkpoint_best.pth
Checkpoint selection Maximum validation mean patient Dice
Validation mean patient Dice 0.27339643772645883
Test mean patient Dice 0.2179664566183155

The supplied dataset configuration defines one T1 input channel, background and lesion classes, and 51 training cases. This release provides research inference artifacts; no clinical validation documentation is supplied.

Repository contents

infer.py
requirements.txt
MODEL_INFO.json
SHA256SUMS
model/nnUNet_results/Dataset602_MS60T1/nnUNetTrainer__nnUNetPlans__2d/
  dataset.json
  dataset_fingerprint.json
  plans.json
  fold_0/checkpoint_best.pth

Patient imaging examples from the source package are not distributed. Supply your own authorized T1 NIfTI input.

Integrity

sha256sum --check SHA256SUMS

The checkpoint is provided unchanged from the source package. Its SHA-256 is:

d159aa82a988a17d2d069f1d921b13617f56533525e35fce060a81965c9017b8

License

The supplied package did not include a license. No additional license is assigned in this release.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support