nnunet-mlx
nnU-Net v2 inference in native MLX for Apple Silicon. Run existing nnU-Net models locally on Mac.
- Convert and run pretrained nnU-Net v2 model folders
- 2D and 3D
PlainConvUNetandResidualEncoderUNet - FP32 using MLX; PyTorch is only needed to convert
.pthcheckpoints
Part of MedMLX. Technical notes · Compatibility
Quick start · Input and output · Technical details · License
Requirements
Apple Silicon Mac with Metal, uv, and conda or mamba (setup uses it to build a pinned Python 3.13 environment).
Quick start
Prepare the source checkout:
git clone https://github.com/MedMLX/nnunet-mlx.git
cd nnunet-mlx
make env # creates .venv with MLX on Metal
uv pip install --python .venv/bin/python -e '.[conversion]' # to convert .pth checkpoints
Use .venv/bin/nnunet-mlx, or activate .venv. Every command accepts --help.
Convert an upstream nnU-Net model folder once:
nnunet-mlx convert model-folder \
--source-model-folder /path/to/upstream-model \
--output-model-folder mlx-model
Predict one case, passing one --input per modality in channel order:
nnunet-mlx model predict \
--model-folder mlx-model \
--input case_0000.nii.gz \
--output-prefix predictions/case
Use nnunet-mlx model predict-folder for a whole folder. Add --overwrite to replace
existing output, or --continue-existing to skip finished cases.
Only convert checkpoints you trust: .pth files are pickles. See SECURITY.md.
Python
from nnunet_mlx import ModelFolderPredictor, load_model_bundle
bundle = load_model_bundle("mlx-model", configuration="3d_fullres")
predictor = ModelFolderPredictor(bundle)
result = predictor.predict_case(
["case_0000.nii.gz"], "predictions/case", save_probabilities=False, overwrite=False,
)
For a single-channel 3D class model,
predictor.predict_nifti(image) accepts a NiBabel NIfTI-1 image and returns local
labels on its original grid without intermediate files. Fold logits stay on Metal
except where restoration needs the host route (separate-Z or non-linear
resampling). Cascades and regions use the file APIs above.
The model is also discoverable by medmlx
as nnunet; see docs/technical.md for the runner.
Input and output
Supply one NIfTI file per input channel in the model's channel order. Prediction commands write segmentation files under the selected output prefix or directory; probability export is optional. Supported models and configurations are listed below and in the compatibility notes.
| Area | Supported |
|---|---|
| Networks | 2D and 3D PlainConvUNet and ResidualEncoderUNet |
| Configurations | 2d, 3d_lowres, 3d_fullres, cascades |
| Inference | Gaussian sliding window, mirroring, fold and configuration ensembles, probabilities |
| Precision | FP32 |
Anything else fails with a clear error rather than falling back. Pretrained-model support varies; see Compatibility.
Technical details
Targets nnU-Net v2.8.1 and dynamic-network-architectures v0.4.4. Networks, conversion and the prediction path are compared against the upstream PyTorch implementation on seeded-weight and synthetic inputs and on selected released models (see Compatibility); agreement on other models or data is not implied. Development, parity testing, the PancCTMultiTalentV2 staging recipe and the runner contract are in docs/technical.md; see also Architecture and Roadmap.
Intended use
Intended for research and education, not clinical diagnosis or treatment decisions. Outputs require human review.
License
Apache-2.0; see LICENSE and THIRD_PARTY_NOTICES.md. Kernels derived from MLX keep their MIT license. Pretrained nnU-Net weights have their own licenses and are not distributed here. Please cite via CITATION.cff and cite nnU-Net.
Implementation mapping
Central implementation map records upstream-to-native changes, source references and qualification scope.
Metadata
Release files for nnunet-mlx 0.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nnunet_mlx-0.5.1.tar.gz | 122.5 kB | Without provenance | Details for nnunet_mlx-0.5.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nnunet_mlx-0.5.1-py3-none-any.whl | Python 3 | none | any | Details for nnunet_mlx-0.5.1-py3-none-any.whl |
Total release size: 278.6 kB
Release files / nnunet_mlx-0.5.1.tar.gz
| Download URL | nnunet_mlx-0.5.1.tar.gz |
|---|---|
| Size | 122.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cd925210732741601ce0d24248034159db44147f50c4b2481673d07282e75b85
|
|
BLAKE2b-256 checksum How to use checksums |
8068afc0884cb1b4ca4f0d60fa124de855dcb106664ba19b91f1a2a4e451c4b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / nnunet_mlx-0.5.1-py3-none-any.whl
| Download URL | nnunet_mlx-0.5.1-py3-none-any.whl |
|---|---|
| Size | 156.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8132bc65b839aeedc9c750134909f303044e020ebfec92ecdee5d98d34cb14f8
|
|
BLAKE2b-256 checksum How to use checksums |
4ca29ff17f88c424ebbfece6664469d6b1d5747be29f5d376f9fe8a09cd62412
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for nnunet-mlx 0.5.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.