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.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 medmlx-core 0.2.7
File Size Uploaded Provenance Actions
medmlx_core-0.2.7.tar.gz 68.2 kB Without provenance Details for medmlx_core-0.2.7.tar.gz

Built distribution (wheel)

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

Total release size: 153.3 kB

Release files / medmlx_core-0.2.7.tar.gz

Download URL medmlx_core-0.2.7.tar.gz
Size 68.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1fd1b5c5c0c8452b6df84d5e01be4744e2c548b58ebefad30c8af2e2b90fb615
BLAKE2b-256 checksum
How to use checksums
7cf99f571032f79d1940d45b2a5e926cc124e7ca155c630a800408c640a3b684
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.2.7-py3-none-any.whl

Download URL medmlx_core-0.2.7-py3-none-any.whl
Size 85.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b3ddbfe4421ddca16491c0978648d5afb516e8a6a70c96310873239712b63227
BLAKE2b-256 checksum
How to use checksums
2aa3d2e9aeaf6cbb934ac95237f40e36570bf1e76fdc76e4a708b59f302e4f50
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.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