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.
MedSAM2 is the work of Jun Ma, Bo Wang and co-authors (WangLab). The model, its training method and the weights are theirs: see the original repository, bowang-lab/MedSAM2, and the paper, arXiv:2504.03600. This repository only repackages their released weights (wanglab/MedSAM2) for MLX on Apple Silicon. Please cite their paper and star their repository if MedSAM2 is useful to you.
Converted from wanglab/MedSAM2 revision e4a6f35edd7e091619cbc0750f462f1574e23955 without retraining. Original parameter names, shapes, and values are preserved.
Quick start
uv venv --python 3.13
source .venv/bin/activate
uv pip install "medsam2-mlx>=0.4.0"
Replace the example input paths with your own files.
from medsam2_mlx import run
result = run(
image_path="ct.nii.gz",
weights_path="models",
checkpoint="MedSAM2_latest.safetensors",
output_dir="outputs",
box_xyxy_pixels=[120, 140, 180, 200],
frame_index=40,
propagation="both",
)
print(result["outputs"])
Download the weights, then pass the folder as weights_path:
uv tool install huggingface-hub
hf download MedMLX/medsam2-mlx --revision 841bcc529f95f33a6bbf11bc87e5be58d485cbc3 --local-dir models
Pass any of the five checkpoint files as checkpoint. The box and frame are examples; use a box around the target on one slice of your image.
Citation
Please cite the original paper:
Ma, J. et al. (2025). MedSAM2: Segment Anything in 3D Medical Images and Videos. arXiv:2504.03600.
If you use MedMLX, please cite the MedMLX paper:
@article{sandoval2026medmlx,
title = {MedMLX: On-Device Medical Imaging AI for Apple Silicon},
author = {Sandoval, J. and Sandoval, A. and Saleem, A.},
journal = {medRxiv},
year = {2026},
doi = {10.64898/2026.10.28.26366762}
}