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.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; 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. Spatial units must be millimeters or unspecified; meters and microns are not converted.

  • 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.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.4.0
File Size Uploaded Provenance Actions
unest_mlx-0.4.0.tar.gz 27.8 kB Without provenance Details for unest_mlx-0.4.0.tar.gz

Built distribution (wheel)

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

Total release size: 63.2 kB

Release files / unest_mlx-0.4.0.tar.gz

Download URL unest_mlx-0.4.0.tar.gz
Size 27.8 kB
Tags Source
SHA-256 checksum
How to use checksums
18ebef7d4ab2c9d79a3cbb2622af0885cf44198be31a63e003fea50740568528
BLAKE2b-256 checksum
How to use checksums
e6646c94d90efc8b2cf07e7b478ccbba643e4ea1c963ec2d9792a0064f152fbb
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.0-py3-none-any.whl

Download URL unest_mlx-0.4.0-py3-none-any.whl
Size 35.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
32ad7e0da5691e377d0a52b0a0dc2bff122b1c50cfc0b706b12030499977dad1
BLAKE2b-256 checksum
How to use checksums
c66c1c3ae5e3c25d816b12ed4cda04efbace5edbb2cd624905d994b92852b612
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.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