Model details

Item Value
Framework nnU-Net v2 (nnunetv2, run pip show nnunetv2)
Dataset ID 501 (Dataset501_BraTSGen)
Configuration 3d_fullres
Plans nnUNetResEncUNetMPlans
Trainer nnUNetTrainer_BrainMask (custom, see below)
Folds 5-fold cross-validation, folds 0-4
Checkpoint checkpoint_final.pth

Input

Four co-registered, skull-stripped MRI sequences per case in NIfTI format (.nii.gz), named with the nnU-Net channel suffix:

Channel File suffix Sequence
0 _0000.nii.gz T1n
1 _0001.nii.gz T1c
2 _0002.nii.gz T2w
3 _0003.nii.gz T2-FLAIR

The channel order must match dataset.json inside the zip. Example for one case:

input_folder/
  case001_0000.nii.gz
  case001_0001.nii.gz
  case001_0002.nii.gz
  case001_0003.nii.gz

Output

A single label map per case (case001.nii.gz):

Label Region
0 Background
1 necrotic tumor core, NCR
2 peritumoral edema, ED
3 enhancing tumor, ET

Custom trainer: nnUNetTrainer_BrainMask

The model was trained with nnUNetTrainer_BrainMask, a subclass of the default nnUNetTrainer. The architecture, training schedule, optimizer and augmentation are unchanged. It only changes the loss function, so the network learns from brain tissue and is explicitly discouraged from predicting tumor outside the brain.

How the labels are set up. Training uses nnU-Net's region-based mode with three overlapping regions: whole tumor (WT), tumor core (TC) and enhancing tumor (ET), each predicted with a sigmoid output. Every voxel outside the brain mask is given the ignore label (4) in the training labels.

The loss.

loss = Dice + BCE over WT, TC, ET, computed only inside the brain
     + 2.0 * mean BCE(logit, 0) over all outside-brain voxels and regions
  • The first term is nnU-Net's standard Dice + BCE loss. Because outside-brain voxels carry the ignore label, nnU-Net leaves them out of this term, so the overlap loss is driven only by brain tissue.
  • The second term is an extra penalty. On ignored voxels nnU-Net would normally apply no loss at all, so this term pushes the tumor probability to 0 for every region outside the brain. It has twice the weight of the inside BCE term (OUTSIDE_WEIGHT = 2.0).
  • Both terms are applied at every deep-supervision level, with nnU-Net's usual deep-supervision weights. At inference time no brain mask or extra input is needed. The four MRI sequences are enough. The trainer class only has to be present in your nnU-Net installation so the checkpoint can be loaded (see step 3 under "How to use").

The file also defines nnUNetTrainer_BrainMask_pilot and nnUNetTrainer_BrainMask_smoke, short-run variants used only for timing and smoke tests. They are not needed for this model.

How to use

1. Install nnU-Net v2

pip install nnunetv2 huggingface_hub

Set the nnU-Net environment variables (add these to ~/.bashrc to make them permanent):

export nnUNet_raw="/path/to/nnUNet_raw"
export nnUNet_preprocessed="/path/to/nnUNet_preprocessed"
export nnUNet_results="/path/to/nnUNet_results"

2. Download the model (and the custom trainer, if used)

hf download TODO-username/TODO-repo-name Dataset501_BraTSGen.zip nnUNetTrainer_BrainMask.py --local-dir .

3. Add the custom trainer to your nnU-Net install

nnU-Net finds trainers by class name inside its own package, so the trainer file must be copied there before inference:

NNUNET_DIR=$(python -c "import nnunetv2, os; print(os.path.dirname(nnunetv2.__file__))")
cp nnUNetTrainer_BrainMask.py "$NNUNET_DIR/training/nnUNetTrainer/"

4. Install the pretrained model

nnUNetv2_install_pretrained_model_from_zip Dataset501_BraTSGen.zip

5. Run inference

nnUNetv2_predict \
  -i /path/to/input_folder \
  -o /path/to/output_folder \
  -d 501 \
  -c 3d_fullres \
  -tr nnUNetTrainer_BrainMask \
  -p nnUNetResEncUNetMPlans \
  -f 0 1 2 3 4 \
  -chk checkpoint_final.pth

Using all folds ensembles their predictions. Use -f 0 for faster single-fold inference. A GPU is strongly recommended; add -device cpu to run without one (much slower).

Intended use and limitations

  • For research use only. This model is not a medical device and has not been validated for clinical decision-making.
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