Instructions to use MedMLX/medsam2-mlx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use MedMLX/medsam2-mlx with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] hf download MedMLX/medsam2-mlx --local-dir medsam2-mlx
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
MedSAM2 weights for MLX
Five MedSAM2 checkpoints for the sam2.1_hiera_t512 graph in medsam2-mlx: MedSAM2_latest, MedSAM2_2411, MedSAM2_CTLesion, MedSAM2_MRI_LiverLesion, and MedSAM2_US_Heart. Each is a float32 safetensors file.
Converted from wanglab/MedSAM2 revision e4a6f35edd7e091619cbc0750f462f1574e23955 without retraining. Original parameter names, shapes, and values are preserved. Credit Jun Ma, Zongxin Yang, Sumin Kim, Bihui Chen, Mohammed Baharoon, Adibvafa Fallahpour, Reza Asakereh, Hongwei Lyu, and Bo Wang for MedSAM2. Cite their paper.
Quick start
uv venv --python 3.13
source .venv/bin/activate
uv pip install "medsam2-mlx>=0.2.8"
uv tool install huggingface-hub
hf download MedMLX/medsam2-mlx --revision 841bcc529f95f33a6bbf11bc87e5be58d485cbc3 --local-dir models
Replace the example input paths with your own files.
from medsam2_mlx.medmlx import run
result = run(
image_path='ct.nii.gz',
weights_path='models/MedSAM2_latest.safetensors',
output_dir='outputs',
box_xyxy=[120, 140, 180, 200],
frame_idx=40,
propagation='both',
)
print(result["outputs"])
Pass any of the five checkpoint files as weights_path. The box and frame are examples; use a box around the target on one slice of your image.
The upstream model card identifies the weights as CC BY-SA 4.0 and states that they may only be used for research and education. See the license terms and upstream model card. Outputs require human review.
Citation
If you use MedMLX, please cite the MedMLX paper:
@article{sandoval2026medmlx,
title = {MedMLX: On-Device Medical Imaging AI for Apple Silicon},
author = {Sandoval, A. and Sandoval, J. and Saleem, A.},
journal = {medRxiv},
year = {2026},
doi = {10.64898/2026.10.28.26366762}
}
Quantized
Model tree for MedMLX/medsam2-mlx
Base model
wanglab/MedSAM2