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.
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.4.1"

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; medmlx setup unest downloads them ahead of time. For local weights, 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. Meter and micron spatial units are converted to millimeters; unspecified is taken as millimeters.

  • Mask: float32 labels on the input grid as the reader interprets its header:

    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.

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.4.1

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.4.1
File Size Uploaded Provenance Actions
unest_mlx-0.4.1.tar.gz 27.7 kB Without provenance Details for unest_mlx-0.4.1.tar.gz

Built distribution (wheel)

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

Total release size: 63.1 kB

Release files / unest_mlx-0.4.1.tar.gz

Download URL unest_mlx-0.4.1.tar.gz
Size 27.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5eb18135a9c35d30096fbd32c35512363c4485841a3b9772b738b13d13e69444
BLAKE2b-256 checksum
How to use checksums
16371e66cfffd47b9c51b9fb38b4f9beb754a16e6edc8009336f189e38bf59f1
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.4.1-py3-none-any.whl

Download URL unest_mlx-0.4.1-py3-none-any.whl
Size 35.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
efe1efaa04d0ef911eedb8ad3aa2b122bd0db8a8bbd4d996bae1f46e0119adec
BLAKE2b-256 checksum
How to use checksums
8d04bb4a249c50f190e53a926cfeb8582214913d73fd8f099e9464d3997e2ebc
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.4.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.

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