medmlx-core
Shared MLX building blocks for MedMLX medical imaging models on Apple Silicon.
- 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,
and the nifti extra supplies nibabel for medmlx_core.volumes.
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.
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. Unlisted model IDs resolve MedMLX/<model_id> at main once on first
use.
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.2
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 |
|---|---|---|---|---|
| medmlx_core-0.3.2.tar.gz | 104.6 kB | Without provenance | Details for medmlx_core-0.3.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| medmlx_core-0.3.2-py3-none-any.whl | Python 3 | none | any | Details for medmlx_core-0.3.2-py3-none-any.whl |
Total release size: 228.6 kB
Release files / medmlx_core-0.3.2.tar.gz
| Download URL | medmlx_core-0.3.2.tar.gz |
|---|---|
| Size | 104.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
df809918a843eed915f4a505f1f779aa94e892f09439cff9d06ab49baee8a0b8
|
|
BLAKE2b-256 checksum How to use checksums |
00ddb9aedeab4680324066d7a73f169182bdec0aab420b7f111808dbc4d4493d
|
| 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.2-py3-none-any.whl
| Download URL | medmlx_core-0.3.2-py3-none-any.whl |
|---|---|
| Size | 124.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dbc9b47baf25a3cbbffa06fd2efe114f1c7815a9e72fa95ae3f3ec0ac20ad976
|
|
BLAKE2b-256 checksum How to use checksums |
608a3a29849517e4077f5ceb477b414abb8c50a7f97463c6f65ec35daa000601
|
| 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.2
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.