---
language: en
license: cc-by-sa-4.0
library_name: torch
tags:
- medical
- segmentation
- sam
- medical-imaging
- ct
- mri
- ultrasound
pipeline_tag: image-segmentation
datasets:
- medical
---
# MedSAM2: Segment Anything in 3D Medical Images and Videos
## Authors
Jun Ma* 1,2,
Zongxin Yang* 3,
Sumin Kim2,4,5,
Bihui Chen2,4,5,
Mohammed Baharoon2,3,5,
Adibvafa Fallahpour2,4,5,
Reza Asakereh4,7,
Hongwei Lyu4,
Bo Wang† 1,2,4,5,6
* Equal contribution † Corresponding author
1AI Collaborative Centre, University Health Network, Toronto, Canada
2Vector Institute for Artificial Intelligence, Toronto, Canada
3Department of Biomedical Informatics, Harvard Medical School, Harvard University, Boston, USA
4Peter Munk Cardiac Centre, University Health Network, Toronto, Canada
5Department of Computer Science, University of Toronto, Toronto, Canada
6Department of Laboratory Medicine and Pathobiology, University of Toronto, Toronto, Canada
7Roche Canada and Genentech
## Highlights
- A promptable foundation model for 3D medical image and video segmentation
- Trained on 455,000+ 3D image-mask pairs and 76,000+ annotated video frames
- Versatile segmentation capability across diverse organs and pathologies
- Extensive user studies in large-scale lesion and video datasets demonstrate that MedSAM2 substantially facilitates annotation workflows
## Model Overview
MedSAM2 is a promptable segmentation segmentation model tailored for medical imaging applications. Built upon the foundation of the [Segment Anything Model (SAM) 2.1](https://github.com/facebookresearch/sam2), MedSAM2 has been specifically adapted and fine-tuned for various 3D medical images and videos.
## Available Models
- **MedSAM2_2411.pt**: Base model trained in November 2024
- **MedSAM2_US_Heart.pt**: Fine-tuned model specialized for heart ultrasound video segmentation
- **MedSAM2_MRI_LiverLesion.pt**: Fine-tuned model for liver lesion segmentation in MRI scans
- **MedSAM2_CTLesion.pt**: Fine-tuned model for general lesion segmentation in CT scans
- **MedSAM2_latest.pt** (recommended): Latest version trained on the combination of public datasets and newly annotated medical imaging data
## Downloading Models
### Option 1: Download individual models
You can download the models directly from the Hugging Face repository:
```python
# Using huggingface_hub
from huggingface_hub import hf_hub_download
# Download the recommended latest model
model_path = hf_hub_download(repo_id="wanglab/MedSAM2", filename="MedSAM2_latest.pt")
# Or download a specific fine-tuned model
heart_us_model_path = hf_hub_download(repo_id="wanglab/MedSAM2", filename="MedSAM2_US_Heart.pt")
liver_model_path = hf_hub_download(repo_id="wanglab/MedSAM2", filename="MedSAM2_MRI_LiverLesion.pt")
```
### Option 2: Download all models to a specific folder
```python
from huggingface_hub import hf_hub_download
import os
# Create checkpoints directory if it doesn't exist
os.makedirs("checkpoints", exist_ok=True)
# List of model filenames
model_files = [
"MedSAM2_2411.pt",
"MedSAM2_US_Heart.pt",
"MedSAM2_MRI_LiverLesion.pt",
"MedSAM2_CTLesion.pt",
"MedSAM2_latest.pt"
]
# Download all models
for model_file in model_files:
local_path = os.path.join("checkpoints", model_file)
hf_hub_download(
repo_id="wanglab/MedSAM2",
filename=model_file,
local_dir="checkpoints",
local_dir_use_symlinks=False
)
print(f"Downloaded {model_file} to {local_path}")
```
Alternatively, you can manually download the models from the [Hugging Face repository page](https://huggingface.co/wanglab/MedSAM2).
## Citations
```
@article{MedSAM2,
title={MedSAM2: Segment Anything in 3D Medical Images and Videos},
author={Ma, Jun and Yang, Zongxin and Kim, Sumin and Chen, Bihui and Baharoon, Mohammed and Fallahpour, Adibvafa and Asakereh, Reza and Lyu, Hongwei and Wang, Bo},
journal={arXiv preprint arXiv:2504.03600},
year={2025}
}
```
## License
The model weights can only be used for research and education purposes.