segresnet-mlx
Segment renal arteries, veins, ureters, tumors and parenchyma in multiphase CT with MONAI SegResNet and native MLX.
Weights · Upstream bundle · MedMLX
Three-phase CT from CPTAC-CCRCC case C3N-00380 (The Cancer Imaging Archive, CC BY 4.0), segmented on a crop around each kidney. The 3D view smooths surfaces and hides fragments under 0.5 mL and labels more than 20 mm from the kidney.
| Input | Output |
|---|---|
| Arterial, venous and excretory CT · NIfTI | Renal labels on the input grid |
| Model | Weights download | Peak MLX memory | Measured on |
|---|---|---|---|
segresnet-renal-cect |
76 MB | 4.0 GB | 478×277×161 three-phase CT |
Install
uv venv --python 3.13
source .venv/bin/activate
uv pip install "segresnet-mlx>=0.6.0"
Run
from segresnet_mlx import run
result = run(
image_paths={
"arterial": "arterial.nii.gz",
"venous": "venous.nii.gz",
"excretory": "excretory.nii.gz",
},
output_dir="out",
)
print(result["outputs"]["mask"])
Weights download from MedMLX/segresnet-renal-cect-mlx
on first use; medmlx setup segresnet-renal-cect downloads ahead of time. For local
weights, pass weights_path as a folder containing segresnet-renal-cect.safetensors.
Inputs and outputs
| Argument | Meaning |
|---|---|
image_paths |
{"arterial": ..., "venous": ..., "excretory": ...}: CT phases in NIfTI, on one voxel grid |
output_dir |
Directory for mask.nii.gz; created if missing |
weights_path |
Optional folder containing segresnet-renal-cect.safetensors |
overwrite |
False by default; an existing mask is replaced only when True |
precision |
source-fp32 (default), compensated-fp32 or compensated-fp48 |
streaming |
False by default; True keeps blending intermediates and logits in temporary mapped files |
scratch_dir |
Parent directory for the streaming files; defaults to the system temporary directory |
- Field of view: the model was trained on CT cropped to the kidney region. Crop around each kidney with a margin of about 15 mm; on a wider field of view it can label vertebral bodies or liver as neoplasm.
- Input: finite 3D volumes on one voxel grid. Meter and micron headers are converted to millimeters, and an unspecified unit is taken as millimeters.
- Mask: float32 on the input grid as the reader interprets its header, with labels 1 artery, 2 vein, 3 ureter, 4 neoplasm and 5 parenchyma. Where classes overlap, the lower label wins.
precision |
Arithmetic |
|---|---|
source-fp32 (default) |
The default float32 precision |
compensated-fp32 |
Convolution and GroupNorm accumulate in paired Metal floats, with float32 layer outputs |
compensated-fp48 |
The pairs carry through the hidden layers and stitching runs in float64 on the host |
- Return value:
{"outputs": {"mask": path}, "artifacts": {"mask": ...}, "details": {...}}. Themaskartifact names the labels and the input grid;detailsholds run metadata. - Errors: invalid inputs raise
InvalidInputError; missing or mismatched weights raiseAssetNotReadyError; inference failures raiseModelExecutionError. - Streaming: temporary files are removed on success and failure. The final label volume stays in memory.
Python API
from pathlib import Path
import numpy as np
from segresnet_mlx import BUNDLE_CONFIGS, SegResNetSpec, forward_patch, load_network, predict_logits
spec = SegResNetSpec(3, 6, 32, upsample_mode="deconv") # renal CECT network
network = load_network(Path("segresnet-renal-cect.safetensors"), spec=spec)
patch = np.zeros((1, 3, 32, 32, 32), dtype=np.float32)
logits = forward_patch(network, patch) # float32 NCDHW -> float32 NumPy logits
config = BUNDLE_CONFIGS["renalStructures_CECT_segmentation"]
volume_logits = predict_logits(patch, config, network=network) # stitched sliding windows
forward_patchneeds spatial sizes divisible by2 ** len(spec.blocks_up).predict_logitstakes preprocessed arrays of any size and stitches the bundle's sliding windows. Neither normalizes intensities, applies activations or maps labels.load_networkchecks tensor names, shapes and finite float32 values againstrequired_shapes(spec)and raisesAssetNotReadyErroron a mismatch.WindowTelemetryandBundlePredictorrecord bounded progress and timing.
Use with MedMLX
Use the MedMLX MCP server to run segresnet-renal-cect 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 segresnet-renal-cect.
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 segresnet-mlx 0.6.0
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 |
|---|---|---|---|---|
| segresnet_mlx-0.6.0.tar.gz | 32.8 kB | Without provenance | Details for segresnet_mlx-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| segresnet_mlx-0.6.0-py3-none-any.whl | Python 3 | none | any | Details for segresnet_mlx-0.6.0-py3-none-any.whl |
Total release size: 72.5 kB
Release files / segresnet_mlx-0.6.0.tar.gz
| Download URL | segresnet_mlx-0.6.0.tar.gz |
|---|---|
| Size | 32.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
15f819b80cd04728f47ba0f5d0ba62698310c7c6de0ad6431fcfdfa4bd04d8c9
|
|
BLAKE2b-256 checksum How to use checksums |
ac1aa8e9d0dfdebef3a2ee6724dbcb1d297be031e0da7ef0c6f58d27c765744e
|
| 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 / segresnet_mlx-0.6.0-py3-none-any.whl
| Download URL | segresnet_mlx-0.6.0-py3-none-any.whl |
|---|---|
| Size | 39.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1e542f2a0ce5179794cf99325482e2f8469de3f4e9878f827ba592b89c333ea1
|
|
BLAKE2b-256 checksum How to use checksums |
0a09cfbd5a7ae9c323fe13d5f2c3f01632505d3fa4547207f9ae437c154e54ff
|
| 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 segresnet-mlx 0.6.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.