Skip to main content

medmlx-core

Shared MLX building blocks for MedMLX medical imaging models on Apple Silicon.

Models and weights

  • 3D convolutions, resampling and sliding-window inference
  • Tensor layouts, precision helpers and checkpoint conversion
  • Saved-graph inference and registration geometry

Apple Silicon · Metal · Python 3.13 / 3.14 · uv

Quick start

uv venv --python 3.13
source .venv/bin/activate
uv pip install medmlx-core

Run a volume through overlapping patches:

import numpy as np
from medmlx_core import sliding_window_inference

volume = np.ones((1, 1, 32, 32, 32), dtype=np.float32)
output = sliding_window_inference(
    volume,
    roi_size=(16, 16, 16),
    sw_batch_size=1,
    predictor=lambda patch: patch * 2,
)
print(output.shape)  # (1, 1, 32, 32, 32)

Arrays use batch, channel, depth, height and width axes. Replace the predictor with your model.

Run a converted graph:

from pathlib import Path
import mlx.core as mx
from medmlx_core.graph.runtime import Session

session = Session.load(Path("my-model"))
logits, = session(mx.zeros((1, 4, 64, 64, 64), dtype=mx.float32))

Graph inference needs no PyTorch. The conversion extra supplies PyTorch for checkpoint conversion.

Automatic model folders

Registered runtimes call weights_dir(model_id) when their optional weights_path is omitted:

from medmlx_core.weights import weights_dir, weights_revision

folder = weights_dir("mlx-segment-ct")
revision = weights_revision(folder)

The published model repository, or the relevant files within it, downloads on first use and is reused offline afterwards. Partial downloads resume. The returned folder contains plain files; the runner selects its own files and records the revision in run details. Explicit user folders bypass downloads and retain their supplied paths.

Unreleased: Registered bundles use the weight revisions documented by their runtime releases and linked model cards. Hub main updates do not change those downloads or their label maps. SAM3 retains its existing pin. Unlisted model IDs still resolve MedMLX/<model_id> at main once on first use.

Unreleased: A folder without a matching revision marker can be reused after weights_dir checks every selected file against the installed Hub commit's LFS SHA-256 or Git blob hash. Missing or mismatched files use the resumable download path. Verified files from the older top-level cache layout are copied into the current layout, preserving the originals; copies keep later refreshes independent. refresh=True forces a download. This verification needs network access once; the completed folder is reused offline afterwards.

Check the cache without downloading:

from medmlx_core.weights import cached_weights, weights_revision

folder = cached_weights("mlx-segment-ct")  # Path or None
revision = None if folder is None else weights_revision(folder)

cached_weights uses the same cache paths and completion checks as weights_dir, including pinned revisions and companion files. It respects MEDMLX_ASSET_CACHE and takes no locks, creates no directories and writes no files. Models without automatic weights return None.

Pass progress=callback for status strings, or download_progress=callback for DownloadProgress dictionaries with message, model_id, bytes and total_bytes. Byte counts include resumed file bytes. Totals can grow as the Hub discovers files; unknown totals are None. Updates arrive at most twice a second per model, plus a final event when the download stops, including on interruption. Hub progress bars stay silent.

License

Apache-2.0; license and third-party notices are included in the distribution.

Metadata

Release files for medmlx-core 0.3.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 medmlx-core 0.3.1
File Size Uploaded Provenance Actions
medmlx_core-0.3.1.tar.gz 75.5 kB Without provenance Details for medmlx_core-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for medmlx-core 0.3.1
File Interpreter ABI Platform Actions
medmlx_core-0.3.1-py3-none-any.whl Python 3 none any Details for medmlx_core-0.3.1-py3-none-any.whl

Total release size: 168.5 kB

Release files / medmlx_core-0.3.1.tar.gz

Download URL medmlx_core-0.3.1.tar.gz
Size 75.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ddfb852659a6d20669d6eefd92331b1ea770f958ba24c52863c75b182fe10944
BLAKE2b-256 checksum
How to use checksums
6cdb546cc6d3511cca9248aa0146daabb5bc4af8093f2a9eb4d3a7589857d737
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 / medmlx_core-0.3.1-py3-none-any.whl

Download URL medmlx_core-0.3.1-py3-none-any.whl
Size 93.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d3a4fec93b5eb3d6238bf36f91f23f1fc97149ecfe8461a15e8e5f154d3c78e1
BLAKE2b-256 checksum
How to use checksums
a5303248054523a8b7c963f5edbb8ddd4d487a61731cb3a794eafdbad48fbc3a
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 medmlx-core 0.3.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