Repository navigation
Releases
nnunet-mlx 0.9.0
Breaking changes
Requires medmlx-core 0.3, and runs return its RunResult. outputs maps each role to the file written, artifacts describes each file's kind, coordinate space and labels, and run facts move to details.
Each named model has its own module with one run. Multi-image models take image_paths keyed by channel name instead of an ordered list, and the arithmetic option is now precision.
-from nnunet_mlx.named_models import autopet
-autopet(image_paths=[ct, pet], output_dir=out, arithmetic="native")
+from nnunet_mlx.named_models.autopet import run
+run(image_paths={"ct": ct, "pet": pet}, output_dir=out, precision="native")load_model() and NnUNetModel replace prepare() and PreparedModel. The loaded model's run takes the same case arguments, and close() releases it.
Fixes
Converted models are rebuilt when their metadata changes or a payload is missing. Conversion cache paths stay inside each model entry, and properties pickles with altered NumPy dtypes are rejected.
Predictions publish all files or none. Cascade and spline preprocessing now match nnU-Net, and saved probability grids are checked against the prediction grid.
Lower memory
Mirrored test-time augmentation evaluates one view at a time. On an M5 Max, a 27-tile liver crop peaked at 4.9 GB instead of 11.6 GB with bitwise-identical logits.
Faster
Torch-compatible resampling runs on Metal without dense coordinate grids, and largest-component postprocessing is faster. A 512³ CT output was bitwise identical to the previous path.
nnunet-mlx 0.8.0
Breaking changes
nnunet-fp16 labels now match nnU-Net where two classes nearly tie. Restored logits stay float16 through resampling and round as nnU-Net 2.8.1 does, so labels can change at near-tied voxels when restoration resamples. Float32 models using separate-z resampling with order_z > 0 can also change by one float32 rounding step. --continue-existing recomputes outputs written by earlier versions.
Fixes
A dataset.json with a huge or sparse label ID is rejected right away. Validation no longer allocates a range as large as the largest label value.
New
prepare() loads an nnU-Net model once for repeated cases. It returns a PreparedModel whose run takes the one-shot runner's case arguments, and close() releases it. nnunet-liver uses it for MedMLX cohorts.
ModelFolderPredictor.predict_nifti_probabilities returns labels and probabilities without writing files. Labels are on the source grid and float32 probabilities on the reader grid.
Lower memory
File prediction streams labels when the crop needs no resampling. Single-fold 3-D predictions no longer build a full score volume first; ensembles, region models, 2-D models and resampled grids restore scores as before.
Probability export and 2-D volume prediction write into one output array. Softmax normalizes in place in 16 MiB blocks instead of building cropped and uncropped copies, and 2-D models write each slice into a preallocated volume.
nnunet-mlx 0.7.2
Fixes
SIAM can no longer overwrite the scan it segments. An output path that points at the input scan, directly or through a link, is rejected, and masks are written to a private staging folder and moved into place without following output links.
New
medmlx now checks that each nnU-Net model fits in available memory before running it. The runtime declares peaks of 9.0 GB (nnunet-liver), 14.5 GB (nnunet-pancreas), 4.8 GB (nnunet-autopet), 7.5 GB (nnunet-brats2021) and 16 GB (siam), and the README lists download sizes and measured peaks.
nnunet-mlx 0.7.1
New
siam segments head tissues from any MRI contrast or CT. It runs SIAM v0.3 by Valabregue et al. (romainVala/SIAM, paper): 17 labels from scalp and skull to the deep nuclei, plus an Anomalies label for pathology. Weights download on first use from MedMLX/siam; a typical head MRI needs about 16 GB of memory.
from nnunet_mlx.named_models import siam
result = siam(image_path="head.nii.gz", output_dir="out")nnunet-mlx predict runs models you trained with nnU-Net. It takes nnUNetv2_predict's options, converts the PyTorch checkpoints on first use and caches the result; nnunet-mlx convert writes a converted folder to keep or share. Trainer variants that build the network from the plans and pre-2.4 plans are supported.
uv pip install "nnunet-mlx[convert]"
nnunet-mlx predict -i imagesTs -o predictions -d 3 -c 3d_fullresnnunet-mlx 0.7.0
Breaking changes
Liver and AutoPET runners moved to named_models, and every runner returns outputs["mask"]. MedMLX model IDs are unchanged.
-from nnunet_mlx.medmlx import liver, autopet
+from nnunet_mlx.named_models import liver, autopet
-labels = result["outputs"]["segmentation"]
+labels = result["outputs"]["mask"]BraTS averages all five released folds by default, as upstream does. Pass brats(fold=0) for the old result. Bundles downloaded before November 2 hold only fold 0, so refresh them first:
medmlx setup nnunet-brats2021 --refresh
medmlx setup nnunet-autopet --refresh # AutoPET's folds 1-4Unused prediction APIs removed. ArrayPredictor's NumPy and iterator methods, Prediction, logits_to_segmentation and PreprocessedDataset are gone; use ModelFolderPredictor, and read_segmentation instead of read_sitk_segmentation.
Faster
Native 3-D inference is faster. A full liver CT (AMOS22, M5 Max) takes 466 s instead of 634 s, with an identical label map. Measurements
nnunet-mlx 0.6.4
First release: run pretrained nnU-Net v2 models locally on Apple Silicon with native MLX.