Update README.md
Browse files
README.md
CHANGED
|
@@ -1,6 +1,76 @@
|
|
| 1 |
-
# MedSAM2
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# MedSAM2: Medical Segment Anything Model v2
|
| 2 |
+
|
| 3 |
+
## Model Overview
|
| 4 |
+
MedSAM2 is an advanced segmentation model tailored for medical imaging applications. Built upon the foundation of the Segment Anything Model (SAM) architecture, MedSAM2 has been specifically adapted and fine-tuned for various medical imaging modalities including CT, MRI, and ultrasound.
|
| 5 |
+
|
| 6 |
+
## Available Models
|
| 7 |
+
|
| 8 |
+
- **MedSAM2_2411.pt**: Base model trained in November 2024
|
| 9 |
+
- **MedSAM2_US_Heart.pt**: Fine-tuned model specialized for heart ultrasound video segmentation
|
| 10 |
+
- **MedSAM2_MRI_LiverLesion.pt**: Fine-tuned model for liver lesion segmentation in MRI scans
|
| 11 |
+
- **MedSAM2_CTLesion.pt**: Fine-tuned model for general lesion segmentation in CT scans
|
| 12 |
+
- **MedSAM2_latest.pt** (recommended): Latest version trained on a comprehensive combination of public datasets and newly annotated medical imaging data
|
| 13 |
+
|
| 14 |
+
## Downloading Models
|
| 15 |
+
|
| 16 |
+
### Option 1: Download individual models
|
| 17 |
+
You can download the models directly from the Hugging Face repository:
|
| 18 |
+
|
| 19 |
+
```python
|
| 20 |
+
# Using huggingface_hub
|
| 21 |
+
from huggingface_hub import hf_hub_download
|
| 22 |
+
|
| 23 |
+
# Download the recommended latest model
|
| 24 |
+
model_path = hf_hub_download(repo_id="wanglab/MedSAM2", filename="MedSAM2_latest.pt")
|
| 25 |
+
|
| 26 |
+
# Or download a specific fine-tuned model
|
| 27 |
+
heart_us_model_path = hf_hub_download(repo_id="wanglab/MedSAM2", filename="MedSAM2_US_Heart.pt")
|
| 28 |
+
liver_model_path = hf_hub_download(repo_id="wanglab/MedSAM2", filename="MedSAM2_MRI_LiverLesion.pt")
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
### Option 2: Download all models to a specific folder
|
| 32 |
+
```python
|
| 33 |
+
from huggingface_hub import hf_hub_download
|
| 34 |
+
import os
|
| 35 |
+
|
| 36 |
+
# Create checkpoints directory if it doesn't exist
|
| 37 |
+
os.makedirs("checkpoints", exist_ok=True)
|
| 38 |
+
|
| 39 |
+
# List of model filenames
|
| 40 |
+
model_files = [
|
| 41 |
+
"MedSAM2_2411.pt",
|
| 42 |
+
"MedSAM2_US_Heart.pt",
|
| 43 |
+
"MedSAM2_MRI_LiverLesion.pt",
|
| 44 |
+
"MedSAM2_CTLesion.pt",
|
| 45 |
+
"MedSAM2_latest.pt"
|
| 46 |
+
]
|
| 47 |
+
|
| 48 |
+
# Download all models
|
| 49 |
+
for model_file in model_files:
|
| 50 |
+
local_path = os.path.join("checkpoints", model_file)
|
| 51 |
+
hf_hub_download(
|
| 52 |
+
repo_id="wanglab/MedSAM2",
|
| 53 |
+
filename=model_file,
|
| 54 |
+
local_dir="checkpoints",
|
| 55 |
+
local_dir_use_symlinks=False
|
| 56 |
+
)
|
| 57 |
+
print(f"Downloaded {model_file} to {local_path}")
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
Alternatively, you can manually download the models from the [Hugging Face repository page](https://huggingface.co/wanglab/MedSAM2).
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
## Citations
|
| 65 |
+
|
| 66 |
+
```
|
| 67 |
+
# Citation information will be added later
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
## License
|
| 71 |
+
|
| 72 |
+
# License information will be added later
|
| 73 |
+
|
| 74 |
+
## Contact
|
| 75 |
+
|
| 76 |
+
# Contact information will be added later
|