# MedSAM2 **Repository Path**: pan-Irving/MedSAM2 ## Basic Information - **Project Name**: MedSAM2 - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-05-27 - **Last Updated**: 2025-05-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # MedSAM2 Segment Anything in 3D Medical Images and Videos
Paper Project Code HuggingFace Model
Dataset List CT_DeepLesion-MedSAM2 LLD-MMRI-MedSAM2 3D Slicer
Gradio App CT-Seg-Demo Video-Seg-Demo BibTeX
Welcome to join our [mailing list](https://forms.gle/bLxGb5SEpdLCUChQ7) to get updates. We’re also actively looking to collaborate on annotating new large-scale 3D datasets. If you have unlabeled medical images or videos and want to share them with the community, let’s connect! ## Installation - Create a virtual environment: `conda create -n medsam2 python=3.12 -y` and `conda activate medsam2` - Install [PyTorch](https://pytorch.org/get-started/locally/): `pip3 install torch torchvision` (Linux CUDA 12.4) - Download code `git clone https://github.com/bowang-lab/MedSAM2.git && cd MedSAM2` and run `pip install -e ".[dev]"` - Download checkpoints: `sh download.sh` - Optional: Please install the following dependencies for gradio ```bash sudo apt-get update sudo apt-get install ffmpeg pip install gradio==3.38.0 pip install numpy==1.26.3 pip install ffmpeg-python pip install moviepy ``` ## Download annotated datasets - [CT_DeepLesion-MedSAM2](https://huggingface.co/datasets/wanglab/CT_DeepLesion-MedSAM2) - [LLD-MMRI-MedSAM2](https://huggingface.co/datasets/wanglab/LLD-MMRI-MedSAM2) Note: Please also cite the raw [DeepLesion](https://doi.org/10.1117/1.JMI.5.3.036501) and [LLD-MMRI](https://www.sciencedirect.com/science/article/pii/S0893608025001078) dataset paper when using these datasets. - [RVENET](https://rvenet.github.io/dataset/): Waiting for authors' approval to release the mask. ## Inference ### 3D medical image segmentation - [Colab](https://colab.research.google.com/drive/1MKna9Sg9c78LNcrVyG58cQQmaePZq2k2?usp=sharing): [MedSAM2_inference_CT_Lesion_Demo.ipynb](notebooks/MedSAM2_inference_CT_Lesion.ipynb) - CMD ```bash python medsam2_infer_3D_CT.py -i CT_DeepLesion/images -o CT_DeepLesion/segmentation ``` ### Medical video segmentation - [Colab](https://colab.research.google.com/drive/16niRHqdDZMCGV7lKuagNq_r_CEHtKY1f?usp=sharing): [MedSAM2_Inference_Video_Demo.ipynb](notebooks/MedSAM2_Inference_Video.ipynb) - CMD ```bash python medsam2_infer_video.py -i input_video_path -m input_mask_path -o output_video_path ``` ### Gradio demo ```bash python app.py ``` ## Training Specify dataset path in `sam2/configs/sam2.1_hiera_tiny_finetune512.yaml` ```bash sbatch multi_node_train.sh ``` ## Acknowledgements - We highly appreciate all the challenge organizers and dataset owners for providing the public datasets to the community. - We thank Meta AI for making the source code of [SAM2](https://github.com/facebookresearch/sam2) publicly available. Please also cite this paper when using MedSAM2. ## Bibtex ```bash @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} } ``` Please also cite SAM2 ``` @article{ravi2024sam2, title={SAM 2: Segment Anything in Images and Videos}, author={Ravi, Nikhila and Gabeur, Valentin and Hu, Yuan-Ting and Hu, Ronghang and Ryali, Chaitanya and Ma, Tengyu and Khedr, Haitham and R{\"a}dle, Roman and Rolland, Chloe and Gustafson, Laura and Mintun, Eric and Pan, Junting and Alwala, Kalyan Vasudev and Carion, Nicolas and Wu, Chao-Yuan and Girshick, Ross and Doll{\'a}r, Piotr and Feichtenhofer, Christoph}, journal={arXiv preprint arXiv:2408.00714}, url={https://arxiv.org/abs/2408.00714}, year={2024} } ```