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

Model weights · 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

Use with MedMLX

The MedMLX MCP server is the lowest-friction way to use this model. It installs this runtime, downloads its weights on first use, and lets an AI agent describe, check and run unest for you.

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.

Install

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

Run

from unest_mlx.medmlx import run

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

Omitting weights_path downloads MedMLX/unest-renal-ct-mlx into the shared MedMLX cache on first use; interrupted downloads resume and later runs work offline. With MedMLX installed, medmlx setup unest downloads it ahead of time. To use your own copy, pass a folder containing unest.safetensors as weights_path. Standalone checkpoint-file paths are still accepted. details.weights_revision records the downloaded commit, or null for a folder without a MedMLX download record.

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 .safetensors file or a folder containing it
overwrite False by default; an existing mask is never replaced

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

The mask holds float32 labels 0 background, 1 kidney cortex, 2 medulla and 3 pelvicalyceal system, on the input grid as the NIfTI reader corrects it. run returns {"outputs": {"mask": path}, "details": {...}}, with label counts, shapes, orientation, sliding-window settings, MLX device and elapsed time. Invalid inputs raise InvalidInputError; missing or mismatched weights raise AssetNotReadyError with the download location.

Python API

from medmlx_core.runtime import import_mlx
from unest_mlx import UNesT, UNesTPredictor, validate_weights

mx = import_mlx()
weights = validate_weights(payload)  # flat mapping of float32 NumPy arrays
network = UNesT({key: mx.array(value) for key, value in weights.items()}, mx=mx)
logits = network(windows)  # Bx1x96x96x96 -> Bx4x96x96x96
volume_logits = UNesTPredictor(network, mx=mx)(image)  # Bx1xDxHxW preprocessed volume

UNesTPredictor uses the upstream 96³ windows with overlap 0.5 and constant blending; sw_batch_size defaults to four. Inference needs Apple Silicon with Metal and has no CPU fallback.

License

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

For research and education. Outputs require human review.

Metadata

Release files for unest-mlx 0.2.7

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.2.7
File Size Uploaded Provenance Actions
unest_mlx-0.2.7.tar.gz 29.3 kB Without provenance Details for unest_mlx-0.2.7.tar.gz

Built distribution (wheel)

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

Total release size: 66.4 kB

Release files / unest_mlx-0.2.7.tar.gz

Download URL unest_mlx-0.2.7.tar.gz
Size 29.3 kB
Tags Source
SHA-256 checksum
How to use checksums
440634762ac95c7ca7a9be3e8d0c288f640b2b574377e0e75ad3ddf11ea662f5
BLAKE2b-256 checksum
How to use checksums
92bb9e4bb13c390cec3860f3ff251601aa4e1d5f17cb508e9287f0c2dcbf38bf
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 / unest_mlx-0.2.7-py3-none-any.whl

Download URL unest_mlx-0.2.7-py3-none-any.whl
Size 37.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ad7919b7efcf55233e6ed3037f31aa232ef35d842dd5fdac3a1dc2c7400b583
BLAKE2b-256 checksum
How to use checksums
818e717a0262f0b011c427139e1522b88e3c723eebc0f4e973b67945091a8af1
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 unest-mlx 0.2.7

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.

Release history Release notifications | RSS feed

This release

0.2.7 This release

2 release files No provenance

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