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.

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.

For research and education. Outputs require human review.

Metadata

Release files for medmlx-core 0.2.6

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.2.6
File Size Uploaded Provenance Actions
medmlx_core-0.2.6.tar.gz 68.1 kB Without provenance Details for medmlx_core-0.2.6.tar.gz

Built distribution (wheel)

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

Total release size: 153.1 kB

Release files / medmlx_core-0.2.6.tar.gz

Download URL medmlx_core-0.2.6.tar.gz
Size 68.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c058894d50b4b47a6de0afcf598be1eb7924708d0b0491c53193d3f98f4c9f24
BLAKE2b-256 checksum
How to use checksums
870f5ce796655a94edf13a6d57002516ff63d463b95de20956b187d4d1000063
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 / medmlx_core-0.2.6-py3-none-any.whl

Download URL medmlx_core-0.2.6-py3-none-any.whl
Size 85.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e9ef73684ddcb4f1d601782029546f804e05435e16beefa24bba6a04bb5ec7d
BLAKE2b-256 checksum
How to use checksums
360f409812a0e3cd7cadac25de84f97d845569f7a3c141ef8eaeab3771e9b7eb
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 medmlx-core 0.2.6

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