MedSAM2 / README.md
adibvafa's picture
Update README.md
c0940c2 verified
|
raw
history blame
2.96 kB
metadata
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: Medical Segment Anything Model v2

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, 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:

# 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

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.

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.