Skip to main content

lung-nodule-mlx

Detect lung nodule candidates in 3D chest CT with MONAI RetinaNet and native MLX.

PyPI Python License Apple Silicon Hugging Face MedMLX

Model weights · MedMLX

Lung nodule candidates detected in chest CT
Input Output
3D chest CT · NIfTI Candidate boxes and scores in RAS mm

Weights: 85 MB download. Peak MLX memory: 10.7 GB for a 512×512×147 chest CT resampled to the model 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 lung-nodule for you.

uv tool install --python 3.13 "medmlx[vision,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 lung-nodule.

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 "lung-nodule-mlx>=0.2.7"

Run

from lung_nodule_mlx.medmlx import run

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

Omitting weights_path downloads MedMLX/retinanet-lung-nodule-mlx into the shared MedMLX cache on first use; interrupted downloads resume and later runs work offline. With MedMLX installed, medmlx setup lung-nodule downloads it ahead of time. To use your own copy, pass a folder containing network.safetensors as weights_path. 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 scalar 3D chest CT in NIfTI, in Hounsfield units, with mm, meter or micron spatial units
output_dir Directory for detections.json and bundle_detections.json; created if missing
weights_path Optional folder containing network.safetensors, or the file itself
overwrite False by default; existing outputs are never replaced
resample_raw_input False expects the bundle's 0.703125 × 0.703125 × 1.25 mm grid; True resamples first

Keep resample_raw_input=True for ordinary CT. The default follows the bundle's pre-resampled mode: it reorients to RAS and scales intensities, but does not check or correct voxel spacing. Spatial units are converted to millimetres; unknown units are rejected. DICOM series are not read.

detections.json holds medmlx.detections.v1 candidate boxes (cccwhd, class 0 nodule) in RAS millimetres with their scores; bundle_detections.json holds the MONAI bundle rows in patient LPS. Boxes map through the affine with MONAI's opposite-corner convention, so on oblique affines they differ from a box enclosing all eight corners. run returns {"outputs": {...}, "details": {...}} with the detection count, shapes, prepared affine, MLX device and memory use. Invalid inputs raise InvalidInputError; missing or mismatched weights raise AssetNotReadyError.

Python API

from pathlib import Path

from medmlx_core.runtime import import_mlx
from lung_nodule_mlx import RetinaNet, boxes_to_world, detections, predict_maps
from lung_nodule_mlx.medmlx import prepare_image

image, affine = prepare_image(Path("ct.nii.gz"), resample_raw_input=True)
mx = import_mlx()
network = RetinaNet(mx.load("network.safetensors"), mx=mx)
maps, padded_shape = predict_maps(image, network)
boxes, scores, labels = detections(maps, padded_shape, image.shape[2:])
world_ras = boxes_to_world(boxes, affine)

Arrays are float32 NCDHW in MONAI's (i, j, k) order, and detections returns voxel boxes. Box selection uses stable NumPy top-k and needs no compiler; tied scores keep their original order, so overlapping boxes can differ from MONAI runs when scores tie. 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 lung-nodule-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 lung-nodule-mlx 0.2.7
File Size Uploaded Provenance Actions
lung_nodule_mlx-0.2.7.tar.gz 27.1 kB Without provenance Details for lung_nodule_mlx-0.2.7.tar.gz

Built distribution (wheel)

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

Total release size: 67.8 kB

Release files / lung_nodule_mlx-0.2.7.tar.gz

Download URL lung_nodule_mlx-0.2.7.tar.gz
Size 27.1 kB
Tags Source
SHA-256 checksum
How to use checksums
03e402d9e656806398bd8fa6736cadff2684dd6b5cff641751b3df54dd52c17e
BLAKE2b-256 checksum
How to use checksums
25ec57182cc9c13f18bda2b50684471e4f681a7739d98524383dfe93507d2522
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 / lung_nodule_mlx-0.2.7-py3-none-any.whl

Download URL lung_nodule_mlx-0.2.7-py3-none-any.whl
Size 40.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ae971fad2e37ca486430be4c6476ffe89e17a19f5808d95ac3e5478ba028692c
BLAKE2b-256 checksum
How to use checksums
2c6a6a8b83a4c8988b5e2ea48f6824365e9e5b51a82d53ee90dba03f0a5ac823
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 lung-nodule-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.

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