biomedparse-mlx
Segment 3D medical images from text prompts with Microsoft BiomedParse v2 and native MLX.
| Input | Output |
|---|---|
| Medical image + text prompts | Labeled segmentation |
| Model | Weights download | Peak MLX memory | Measured on |
|---|---|---|---|
biomedparse-v2 |
1.5 GB | 3.8 GB | Four organ prompts on a 768×768×101 abdominal CT |
Install
uv venv --python 3.13
source .venv/bin/activate
uv pip install "biomedparse-mlx>=0.3.1"
Run
from biomedparse_mlx import run
result = run(
image_path="scan.nii.gz",
modality="ct",
ct_site="abdomen",
prompt="Visualization of the liver in abdominal CT imaging",
labels=[6],
output_dir="outputs/liver",
)
print(result["outputs"]["mask"])
Weights download from MedMLX/biomedparse-v2-mlx on first use; medmlx setup biomedparse-v2
downloads them ahead of time. To use your own copy, pass a folder containing
biomedparse-v2.safetensors and tokenizer.json as weights_path.
Inputs and outputs
| Argument | Meaning |
|---|---|
image_path |
A volume (.npy, upstream .npz with imgs, .nii or .nii.gz) or a 2D image (PNG, JPEG, BMP, TIFF or DICOM) |
prompt |
One text prompt or a list of them |
output_dir |
Directory for the outputs; created if missing |
labels |
Distinct label per prompt, 1 to 65535; defaults to 1, 2, … in prompt order |
modality, ct_site |
Required for raw NIfTI and DICOM: "ct" with a site (abdomen, lung, pelvis, liver, colon or pancreas), or "other" |
weights_path |
Optional model folder |
slice_batch_size, prompt_batch_size |
Slices per model call (default 2) and maximum prompts per decoder group (default all) |
existence_threshold, seed |
Existence-probability cutoff (default 0.5) and attention-sampling seed (default 0) |
instance_segmentation |
Also split touching same-class structures into instances (volumes only) |
overwrite |
False by default; existing outputs are replaced only when True |
| Input | Preprocessing |
|---|---|
.npy, .npz |
Must already hold upstream's modality-specific preprocessing in the 0–255 range |
| Raw NIfTI, DICOM | Windowed per slice with upstream's formulas: six fixed CT Hounsfield windows by site, or a 0.5–99.5 percentile window for other modalities |
The slicing axis follows upstream's fixed shape heuristic.
| Input | Outputs |
|---|---|
| Volume | segmentation.npz (segs: uint16 labels on the input grid; existence: prompt-by-slice probabilities) and run.json (role metadata) with the source revision, prompts and settings. NIfTI input also gets segmentation.nii.gz on the source affine. instance_segmentation=True adds an instances array (and instances.nii.gz) |
| 2D image | segmentation.npz with per-prompt masks, probabilities and existence, following upstream's inference_2d.py |
- Several prompts on a volume are merged with per-slice mask NMS and an argmax against a 0.5 background. On a 2D image, masks of different prompts can overlap.
- Instances use upstream's edge-refined connected-component split.
- 2D images: the released checkpoint is trained for 3D modalities, so 2D accuracy is not established.
- Reproducibility: keep the seed, backend, prompt order, image shape and batch settings fixed. MLX and Torch use different random streams.
Command line
biomedparse-mlx segment \
--image-path scan.npy --weights-path weights \
--prompt 'Visualization of the liver in abdominal CT imaging' --labels 6 \
--output-dir outputs/liver
segment-2d does the same for a 2D image and takes no --slice-batch-size or
--instance-segmentation. Give several values after --prompt and --labels for several
structures; the other options are the run arguments with hyphens, and boolean options
take --overwrite or --no-overwrite.
Python API
biomedparse_mlx.pipeline.segment_volumeandbiomedparse_mlx.image2d.segment_imagerun the same pipeline on preprocessed arrays;segment_volumealso takes progress and cancellation callbacks.- For interactive prompt changes,
model.encode_images(images)returns image features thatmodel.decode_prompts(encoded, prompt_features, prompt_batch_size=2)reuses without recomputing the backbone. Features from another model instance are rejected. - Prompt batching bounds prompt-specific decoder activations and random-sampling fields, not total memory. Image features are shared by all prompts.
Use with MedMLX
Use the MedMLX MCP server to run biomedparse-v2 from an MCP client. Weights download on first use.
uv tool install --python 3.13 "medmlx[segment,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 biomedparse-v2.
For AI agents: prefer the MedMLX MCP tools (
list_models,describe_model,model_readiness,run_model,get_job) over writing Python against this package.
License
Apache-2.0. See third-party notices. Model weights retain their publisher terms. BiomedParse weights are CC-BY-NC-SA-4.0.
Metadata
Release files for biomedparse-mlx 0.3.1
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 |
|---|---|---|---|---|
| biomedparse_mlx-0.3.1.tar.gz | 51.0 kB | Without provenance | Details for biomedparse_mlx-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| biomedparse_mlx-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for biomedparse_mlx-0.3.1-py3-none-any.whl |
Total release size: 113.3 kB
Release files / biomedparse_mlx-0.3.1.tar.gz
| Download URL | biomedparse_mlx-0.3.1.tar.gz |
|---|---|
| Size | 51.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2dc00fe00f0e8a2233e6e570eabd91644244498dfcb93c089c1896977a6fd9ed
|
|
BLAKE2b-256 checksum How to use checksums |
1d7d5ec18ad99b3c2df9ce6e6a0c0a33df6b21934405b354afa8a2fe9889e3d3
|
| 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 / biomedparse_mlx-0.3.1-py3-none-any.whl
| Download URL | biomedparse_mlx-0.3.1-py3-none-any.whl |
|---|---|
| Size | 62.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c9e72aa1a5e687bdf62556b834a2cba033741e5369a05a826e51025cf7ab3741
|
|
BLAKE2b-256 checksum How to use checksums |
78110b2a7705dacf9782c1423b3b7f0f0ae7d3e6f182d5c13beb9770be5c32ff
|
| 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 biomedparse-mlx 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.