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.2

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.2
File Size Uploaded Provenance Actions
lesiondiffusion_mlx-0.2.2.tar.gz 51.3 kB Without provenance Details for lesiondiffusion_mlx-0.2.2.tar.gz

Built distribution (wheel)

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

Total release size: 109.1 kB

Release files / lesiondiffusion_mlx-0.2.2.tar.gz

Download URL lesiondiffusion_mlx-0.2.2.tar.gz
Size 51.3 kB
Tags Source
SHA-256 checksum
How to use checksums
8d443cde99b76235b76fb53d67c7358b1fc367b425e7f59228d99c4b46567f31
BLAKE2b-256 checksum
How to use checksums
2c9be605ee35f14c266293b097177f87b0674977012a4aa4181dae513f778bf3
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.2-py3-none-any.whl

Download URL lesiondiffusion_mlx-0.2.2-py3-none-any.whl
Size 57.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cf9c0235dd37012eeba11e4dd05a806b9de33b53fd2f4f392002d80ad9d934de
BLAKE2b-256 checksum
How to use checksums
baece9e3bed21c0642ab4a7c889b74cd6e99c7649dd34c911fda86bfc7bb79b5
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.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.

Release history Release notifications | RSS feed

This release

0.2.2 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