Duplicate from wanglab/MedSAM2
Browse filesCo-authored-by: Adibvafa Fallahpour <adibvafa@users.noreply.huggingface.co>
- .gitattributes +35 -0
- MedSAM2_2411.pt +3 -0
- MedSAM2_CTLesion.pt +3 -0
- MedSAM2_MRI_LiverLesion.pt +3 -0
- MedSAM2_US_Heart.pt +3 -0
- MedSAM2_latest.pt +3 -0
- README.md +161 -0
- config.json +3 -0
- eff_medsam2_small_FLARE25_RECIST_baseline.pt +3 -0
- eff_medsam2_tiny_FLARE25_RECIST_baseline.pt +3 -0
- medsam2_FLARE25_RECIST_baseline.pt +3 -0
.gitattributes
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
MedSAM2_2411.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:dcd946a4d934f553236866fc7e8af77f7e931430e9c044f4ac9d6a723630a870
|
| 3 |
+
size 156039179
|
MedSAM2_CTLesion.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:78f7e125418dfd6fec22f4afe90bcd85cb1d4423d0a9df36f7a87ed63aa1a5f5
|
| 3 |
+
size 156041079
|
MedSAM2_MRI_LiverLesion.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3632fc77def3a136d7ae8d734613472d187a803b4a1846370b45419622072b2b
|
| 3 |
+
size 156044532
|
MedSAM2_US_Heart.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:295c0ff8912c99947c364287bbecd1cd36963f0c0ac67a042d292f0dedf8d933
|
| 3 |
+
size 156041079
|
MedSAM2_latest.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c92743b99f00d078bf32a3afcc38aaa9faf1c1692dffe3eaa7a90938c1991060
|
| 3 |
+
size 156040129
|
README.md
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
datasets:
|
| 3 |
+
- medical
|
| 4 |
+
language: en
|
| 5 |
+
library_name: torch
|
| 6 |
+
license: cc-by-sa-4.0
|
| 7 |
+
pipeline_tag: image-segmentation
|
| 8 |
+
tags:
|
| 9 |
+
- medical
|
| 10 |
+
- segmentation
|
| 11 |
+
- sam
|
| 12 |
+
- medical-imaging
|
| 13 |
+
- ct
|
| 14 |
+
- mri
|
| 15 |
+
- ultrasound
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
<div align="center">
|
| 19 |
+
|
| 20 |
+
<img src="https://github.com/user-attachments/assets/18937bf5-619d-4ae6-a64c-d9900369a7e0" alt="MedSAM2 - Logo" width="30%">
|
| 21 |
+
|
| 22 |
+
**Segment Anything in 3D Medical Images and Videos**
|
| 23 |
+
|
| 24 |
+
</div>
|
| 25 |
+
|
| 26 |
+
<div align="center">
|
| 27 |
+
<table align="center">
|
| 28 |
+
<tr>
|
| 29 |
+
<td><a href="https://arxiv.org/abs/2504.03600" target="_blank"><img src="https://img.shields.io/badge/arXiv-Paper-FF6B6B?style=for-the-badge&logo=arxiv&logoColor=white" alt="Paper"></a></td>
|
| 30 |
+
<td><a href="https://medsam2.github.io/" target="_blank"><img src="https://img.shields.io/badge/Project-Page-4285F4?style=for-the-badge&logoColor=white" alt="Project"></a></td>
|
| 31 |
+
<td><a href="https://github.com/bowang-lab/MedSAM2" target="_blank"><img src="https://img.shields.io/badge/GitHub-Code-181717?style=for-the-badge&logo=github&logoColor=white" alt="Code"></a></td>
|
| 32 |
+
<td><a href="https://huggingface.co/wanglab/MedSAM2" target="_blank"><img src="https://img.shields.io/badge/HuggingFace-Model-FFBF00?style=for-the-badge&logo=huggingface&logoColor=white" alt="HuggingFace Model"></a></td>
|
| 33 |
+
</tr>
|
| 34 |
+
<tr>
|
| 35 |
+
<td><a href="https://medsam-datasetlist.github.io/" target="_blank"><img src="https://img.shields.io/badge/Dataset-List-00B89E?style=for-the-badge" alt="Dataset List"></a></td>
|
| 36 |
+
<td><a href="https://huggingface.co/datasets/wanglab/CT_DeepLesion-MedSAM2" target="_blank"><img src="https://img.shields.io/badge/Dataset-CT__DeepLesion-28A745?style=for-the-badge" alt="CT_DeepLesion-MedSAM2"></a></td>
|
| 37 |
+
<td><a href="https://huggingface.co/datasets/wanglab/LLD-MMRI-MedSAM2" target="_blank"><img src="https://img.shields.io/badge/Dataset-LLD--MMRI-FF6B6B?style=for-the-badge" alt="LLD-MMRI-MedSAM2"></a></td>
|
| 38 |
+
<td><a href="https://github.com/bowang-lab/MedSAMSlicer/tree/MedSAM2" target="_blank"><img src="https://img.shields.io/badge/3D_Slicer-Plugin-e2006a?style=for-the-badge" alt="3D Slicer"></a></td>
|
| 39 |
+
</tr>
|
| 40 |
+
<tr>
|
| 41 |
+
<td><a href="https://github.com/bowang-lab/MedSAM2/blob/main/app.py" target="_blank"><img src="https://img.shields.io/badge/Gradio-Demo-F9D371?style=for-the-badge&logo=gradio&logoColor=white" alt="Gradio App"></a></td>
|
| 42 |
+
<td><a href="https://colab.research.google.com/drive/1MKna9Sg9c78LNcrVyG58cQQmaePZq2k2?usp=sharing" target="_blank"><img src="https://img.shields.io/badge/Colab-CT--Seg--Demo-F9AB00?style=for-the-badge&logo=googlecolab&logoColor=white" alt="CT-Seg-Demo"></a></td>
|
| 43 |
+
<td><a href="https://colab.research.google.com/drive/16niRHqdDZMCGV7lKuagNq_r_CEHtKY1f?usp=sharing" target="_blank"><img src="https://img.shields.io/badge/Colab-Video--Seg--Demo-F9AB00?style=for-the-badge&logo=googlecolab&logoColor=white" alt="Video-Seg-Demo"></a></td>
|
| 44 |
+
<td><a href="https://github.com/bowang-lab/MedSAM2?tab=readme-ov-file#bibtex" target="_blank"><img src="https://img.shields.io/badge/Paper-BibTeX-9370DB?style=for-the-badge&logoColor=white" alt="BibTeX"></a></td>
|
| 45 |
+
</tr>
|
| 46 |
+
</table>
|
| 47 |
+
</div>
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
## Authors
|
| 52 |
+
|
| 53 |
+
<p align="center">
|
| 54 |
+
<a href="https://scholar.google.com.hk/citations?hl=en&user=bW1UV4IAAAAJ&view_op=list_works&sortby=pubdate">Jun Ma</a><sup>* 1,2</sup>,
|
| 55 |
+
<a href="https://scholar.google.com/citations?user=8IE0CfwAAAAJ&hl=en">Zongxin Yang</a><sup>* 3</sup>,
|
| 56 |
+
Sumin Kim<sup>2,4,5</sup>,
|
| 57 |
+
Bihui Chen<sup>2,4,5</sup>,
|
| 58 |
+
<a href="https://scholar.google.com.hk/citations?user=U-LgNOwAAAAJ&hl=en&oi=sra">Mohammed Baharoon</a><sup>2,3,5</sup>,<br>
|
| 59 |
+
<a href="https://scholar.google.com.hk/citations?user=4qvKTooAAAAJ&hl=en&oi=sra">Adibvafa Fallahpour</a><sup>2,4,5</sup>,
|
| 60 |
+
<a href="https://scholar.google.com.hk/citations?user=UlTJ-pAAAAAJ&hl=en&oi=sra">Reza Asakereh</a><sup>4,7</sup>,
|
| 61 |
+
Hongwei Lyu<sup>4</sup>,
|
| 62 |
+
<a href="https://wanglab.ai/index.html">Bo Wang</a><sup>† 1,2,4,5,6</sup>
|
| 63 |
+
</p>
|
| 64 |
+
|
| 65 |
+
<p align="center">
|
| 66 |
+
<sup>*</sup> Equal contribution <sup>†</sup> Corresponding author
|
| 67 |
+
</p>
|
| 68 |
+
|
| 69 |
+
<p align="center">
|
| 70 |
+
<sup>1</sup>AI Collaborative Centre, University Health Network, Toronto, Canada<br>
|
| 71 |
+
<sup>2</sup>Vector Institute for Artificial Intelligence, Toronto, Canada<br>
|
| 72 |
+
<sup>3</sup>Department of Biomedical Informatics, Harvard Medical School, Harvard University, Boston, USA<br>
|
| 73 |
+
<sup>4</sup>Peter Munk Cardiac Centre, University Health Network, Toronto, Canada<br>
|
| 74 |
+
<sup>5</sup>Department of Computer Science, University of Toronto, Toronto, Canada<br>
|
| 75 |
+
<sup>6</sup>Department of Laboratory Medicine and Pathobiology, University of Toronto, Toronto, Canada<br>
|
| 76 |
+
<sup>7</sup>Roche Canada and Genentech
|
| 77 |
+
</p>
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
## Highlights
|
| 81 |
+
|
| 82 |
+
- A promptable foundation model for 3D medical image and video segmentation
|
| 83 |
+
- Trained on 455,000+ 3D image-mask pairs and 76,000+ annotated video frames
|
| 84 |
+
- Versatile segmentation capability across diverse organs and pathologies
|
| 85 |
+
- Extensive user studies in large-scale lesion and video datasets demonstrate that MedSAM2 substantially facilitates annotation workflows
|
| 86 |
+
|
| 87 |
+
## Model Overview
|
| 88 |
+
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.
|
| 89 |
+
|
| 90 |
+
## Available Models
|
| 91 |
+
|
| 92 |
+
- **MedSAM2_2411.pt**: Base model trained in November 2024
|
| 93 |
+
- **MedSAM2_US_Heart.pt**: Fine-tuned model specialized for heart ultrasound video segmentation
|
| 94 |
+
- **MedSAM2_MRI_LiverLesion.pt**: Fine-tuned model for liver lesion segmentation in MRI scans
|
| 95 |
+
- **MedSAM2_CTLesion.pt**: Fine-tuned model for general lesion segmentation in CT scans
|
| 96 |
+
- **MedSAM2_latest.pt** (recommended): Latest version trained on the combination of public datasets and newly annotated medical imaging data
|
| 97 |
+
|
| 98 |
+
## Downloading Models
|
| 99 |
+
|
| 100 |
+
### Option 1: Download individual models
|
| 101 |
+
You can download the models directly from the Hugging Face repository:
|
| 102 |
+
|
| 103 |
+
```python
|
| 104 |
+
# Using huggingface_hub
|
| 105 |
+
from huggingface_hub import hf_hub_download
|
| 106 |
+
|
| 107 |
+
# Download the recommended latest model
|
| 108 |
+
model_path = hf_hub_download(repo_id="wanglab/MedSAM2", filename="MedSAM2_latest.pt")
|
| 109 |
+
|
| 110 |
+
# Or download a specific fine-tuned model
|
| 111 |
+
heart_us_model_path = hf_hub_download(repo_id="wanglab/MedSAM2", filename="MedSAM2_US_Heart.pt")
|
| 112 |
+
liver_model_path = hf_hub_download(repo_id="wanglab/MedSAM2", filename="MedSAM2_MRI_LiverLesion.pt")
|
| 113 |
+
```
|
| 114 |
+
|
| 115 |
+
### Option 2: Download all models to a specific folder
|
| 116 |
+
```python
|
| 117 |
+
from huggingface_hub import hf_hub_download
|
| 118 |
+
import os
|
| 119 |
+
|
| 120 |
+
# Create checkpoints directory if it doesn't exist
|
| 121 |
+
os.makedirs("checkpoints", exist_ok=True)
|
| 122 |
+
|
| 123 |
+
# List of model filenames
|
| 124 |
+
model_files = [
|
| 125 |
+
"MedSAM2_2411.pt",
|
| 126 |
+
"MedSAM2_US_Heart.pt",
|
| 127 |
+
"MedSAM2_MRI_LiverLesion.pt",
|
| 128 |
+
"MedSAM2_CTLesion.pt",
|
| 129 |
+
"MedSAM2_latest.pt"
|
| 130 |
+
]
|
| 131 |
+
|
| 132 |
+
# Download all models
|
| 133 |
+
for model_file in model_files:
|
| 134 |
+
local_path = os.path.join("checkpoints", model_file)
|
| 135 |
+
hf_hub_download(
|
| 136 |
+
repo_id="wanglab/MedSAM2",
|
| 137 |
+
filename=model_file,
|
| 138 |
+
local_dir="checkpoints",
|
| 139 |
+
local_dir_use_symlinks=False
|
| 140 |
+
)
|
| 141 |
+
print(f"Downloaded {model_file} to {local_path}")
|
| 142 |
+
```
|
| 143 |
+
|
| 144 |
+
Alternatively, you can manually download the models from the [Hugging Face repository page](https://huggingface.co/wanglab/MedSAM2).
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
## Citations
|
| 149 |
+
|
| 150 |
+
```
|
| 151 |
+
@article{MedSAM2,
|
| 152 |
+
title={MedSAM2: Segment Anything in 3D Medical Images and Videos},
|
| 153 |
+
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},
|
| 154 |
+
journal={arXiv preprint arXiv:2504.03600},
|
| 155 |
+
year={2025}
|
| 156 |
+
}
|
| 157 |
+
```
|
| 158 |
+
|
| 159 |
+
## License
|
| 160 |
+
|
| 161 |
+
The model weights can only be used for research and education purposes.
|
config.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_name_or_path": "wanglab/MedSAM2"
|
| 3 |
+
}
|
eff_medsam2_small_FLARE25_RECIST_baseline.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c1a54157f93df34f3eb702d19e0a03b2159be8c1a12beb1972088123aa70e073
|
| 3 |
+
size 136422106
|
eff_medsam2_tiny_FLARE25_RECIST_baseline.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:78cd67f41c1c2953026bd6e70a7648998079d08cb6ab0f75bbe289039695c103
|
| 3 |
+
size 71662031
|
medsam2_FLARE25_RECIST_baseline.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:890e6e10924984c7b704a1984362c53a56dc0ee27c796a34eb49c83a1dc4a144
|
| 3 |
+
size 156048332
|