Skip to main content

unest-mlx

Segment kidney cortex, medulla and collecting system in contrast-enhanced CT with UNesT and native MLX.

PyPI Python License Apple Silicon Hugging Face MedMLX

Contrast CT → kidney cortex, medulla and collecting system, with a detailed renal view.

Contrast CT → kidney cortex, medulla and collecting system, with a detailed renal view.

Input Output
Contrast-enhanced CT · NIfTI Renal labels on the input grid
Model Weights download Peak MLX memory Measured on
unest 349 MB 7.2 GB 478×277×161 contrast CT

Install

uv venv --python 3.13
source .venv/bin/activate
uv pip install "unest-mlx>=0.3.0"

Run

from unest_mlx import run

result = run(image_path="ct.nii.gz", output_dir="out")
print(result["outputs"]["mask"])

Weights download from MedMLX/unest-renal-ct-mlx on first use. Use medmlx setup unest to download ahead of time. To use your own copy, pass the folder containing unest.safetensors as weights_path.

Inputs and outputs

Argument Meaning
image_path One 3D CT in NIfTI (.nii or .nii.gz), in Hounsfield units
output_dir Directory for mask.nii.gz
weights_path Optional folder containing unest.safetensors
overwrite False by default, which refuses to replace an existing mask
sw_batch_size Windows per network call, 4 by default; fewer lower peak memory
  • Input: arterial or portal-venous contrast-enhanced CT. On the non-contrast scans we tried, the kidneys were missed. Spatial units must be millimetres or unspecified; metres and microns are not converted.

  • Mask: float32 labels on the input grid as the NIfTI reader corrects it:

    Label Structure
    0 Background
    1 Kidney cortex
    2 Medulla
    3 Pelvicalyceal system
  • Return value: {"outputs": {"mask": path}, "artifacts": {"mask": ...}, "details": {...}}. The mask artifact is a label map on the input grid with the four labels above; details holds label counts, shapes, orientation, sliding-window settings, MLX device and elapsed time.

  • Errors: invalid inputs raise InvalidInputError; missing or mismatched weights raise AssetNotReadyError with the download location.

Python API

import mlx.core as mx
import numpy as np
from unest_mlx import UNesT, UNesTPredictor, validate_weights

loaded = mx.load("unest.safetensors")
weights = validate_weights({key: np.array(value) for key, value in loaded.items()})
network = UNesT({key: mx.array(value) for key, value in weights.items()}, mx=mx)
predictor = UNesTPredictor(network, mx=mx)

volume = np.zeros((1, 1, 96, 96, 96), dtype=np.float32)  # preprocessed CT, Bx1xDxHxW
logits = predictor(volume)  # NumPy float32, Bx4xDxHxW
  • UNesTPredictor uses the upstream 96³ windows with overlap 0.5 and constant blending; sw_batch_size defaults to four.
  • Inference requires Apple Silicon with Metal.

Use with MedMLX

Use the MedMLX MCP server to run unest from an MCP client. Weights download on first use.

uv tool install --python 3.13 "medmlx[segment,mcp]"
MEDMLX="$(uv tool dir --bin --color never)/medmlx"
mkdir -p "$HOME/medmlx-work"
claude mcp add --scope user medmlx -- "$MEDMLX" serve --root "$HOME/medmlx-work"

For Codex, use codex mcp add medmlx -- "$MEDMLX" serve --root "$HOME/medmlx-work". Other MCP clients take the same command and arguments. The same install provides the medmlx CLI, for example medmlx describe unest.

For AI agents: prefer the MedMLX MCP tools (list_models, describe_model, model_readiness, run_model, get_job) over writing Python against this package.

License

Apache-2.0. See third-party notices. Model weights retain their publisher terms.

Metadata

Release files for unest-mlx 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for unest-mlx 0.3.0
File Size Uploaded Provenance Actions
unest_mlx-0.3.0.tar.gz 30.1 kB Without provenance Details for unest_mlx-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for unest-mlx 0.3.0
File Interpreter ABI Platform Actions
unest_mlx-0.3.0-py3-none-any.whl Python 3 none any Details for unest_mlx-0.3.0-py3-none-any.whl

Total release size: 68.3 kB

Release files / unest_mlx-0.3.0.tar.gz

Download URL unest_mlx-0.3.0.tar.gz
Size 30.1 kB
Tags Source
SHA-256 checksum
How to use checksums
05b94546f5fe5d257b856fa771bf3119fdcf82264cff0186e56690554eedd0fc
BLAKE2b-256 checksum
How to use checksums
08fe011a5c486a38c9aee4c0435677891d0e2773337215f6a5b8c7dd591b0d49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","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 / unest_mlx-0.3.0-py3-none-any.whl

Download URL unest_mlx-0.3.0-py3-none-any.whl
Size 38.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db2ada32895e7d1980f7b35693fd11b2541291d0fcc1cd9062d55acfddf3877a
BLAKE2b-256 checksum
How to use checksums
a44293728a91055bd48d4650d7d977ad3d91e03cee2e668c8a012a7aa8e9e49a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","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 unest-mlx 0.3.0

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page