Skip to main content

lesiondiffusion-mlx

Add synthetic lesions to CT with native MLX, with controls for organ, size, placement and phenotype.

Docs · MedMLX

Liver CT before and after lesion generation; the contour marks the generated lesion.

Liver CT before and after lesion generation; the contour marks the generated lesion.

Input Output
CT + aligned binary organ mask Synthetic CT and lesion mask

Apple Silicon · Metal · Python 3.13 / 3.14 · uv

Quick start

uv venv --python 3.13
source .venv/bin/activate
repo="https://github.com/MedMLX/lesiondiffusion-mlx"
uv pip install \
  "lesiondiffusion-mlx[conversion] @ git+$repo" \
  huggingface-hub

Get LMNet.ckpt, LINet.ckpt and VQ.ckpt from the upstream weights folder. Convert once, then generate:

from pathlib import Path

from huggingface_hub import hf_hub_download
from lesiondiffusion_mlx import write_conversion

tokenizer = hf_hub_download("microsoft/BiomedCLIP-PubMedBERT_256-vit_base_patch16_224", "tokenizer.json")
write_conversion(
    checkpoints={"lmnet": Path("LMNet.ckpt"), "linet": Path("LINet.ckpt"), "vq": Path("VQ.ckpt")},
    tokenizer_path=Path(tokenizer),
    output_dir=Path("lesiondiffusion-weights"),
)
from lesiondiffusion_mlx.medmlx import run

result = run(
    image_path="ct_1mm_ras.nii.gz",
    organ_mask_path="liver_mask.nii.gz",
    weights_path="lesiondiffusion-weights",
    output_dir="out",
    organ="liver",
    lesion_type="tumor",
    bbox_size_mm=[30, 30, 20],
    placement="inside_parenchyma",
)
print(result["outputs"]["synthetic_image"])

Inputs must support the documented crop sizes. Outputs use a RAS 1 mm grid; voxels outside the lesion can change. Synthetic output is not ground truth.

License

Apache-2.0. See third-party notices. Model weights retain their publisher terms.

For research and education. Outputs require human review.

Metadata

Release files for lesiondiffusion-mlx 0.2.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 lesiondiffusion-mlx 0.2.1
File Size Uploaded Provenance Actions
lesiondiffusion_mlx-0.2.1.tar.gz 51.3 kB Without provenance Details for lesiondiffusion_mlx-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lesiondiffusion-mlx 0.2.1
File Interpreter ABI Platform Actions
lesiondiffusion_mlx-0.2.1-py3-none-any.whl Python 3 none any Details for lesiondiffusion_mlx-0.2.1-py3-none-any.whl

Total release size: 109.1 kB

Release files / lesiondiffusion_mlx-0.2.1.tar.gz

Download URL lesiondiffusion_mlx-0.2.1.tar.gz
Size 51.3 kB
Tags Source
SHA-256 checksum
How to use checksums
78592cfe98c0bec7f0a32f82c4953c1cf9068a1f3832952ac391307f4627e1a2
BLAKE2b-256 checksum
How to use checksums
c2967214a4dddfe5ac468fda5c97131edb0d2a781f72debea715d8dfdcbbfda9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / lesiondiffusion_mlx-0.2.1-py3-none-any.whl

Download URL lesiondiffusion_mlx-0.2.1-py3-none-any.whl
Size 57.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
03b02a04ea13712c5b4b24571b2195bf603a63fab6c54833613a133c367c2b1c
BLAKE2b-256 checksum
How to use checksums
33b3b684fc7afbdd56e87ba45ad8443364072013914d72f7002d077b98b27cb3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Security for lesiondiffusion-mlx 0.2.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.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files No provenance

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