This is the official repository for MedSAM: Segment Anything in Medical Images.
- Create a virtual environment
conda create -n medsam python=3.10 -y
and activate itconda activate medsam
- Install Pytorch 2.0
git clone https://github.com/bowang-lab/MedSAM
- Enter the MedSAM folder
cd MedSAM
and runpip install -e .
Download the model checkpoint and place it at e.g., work_dir/MedSAM/medsam_vit_b
We provide three ways to quickly test the model on your images
- Command line
python MedSAM_Inference.py # segment the demo image
You can also segment other images with the following flags
-i input_img
-o output path
--box bounding box of the segmentation target
-
Jupyter-notebook We provide a step-by-step tutorial based on CoLab You can also run it locally with
MedSAM_Inference.ipynb
. -
GUI
python gui.py
Your can load the image to the GUI and specify segmentation targets by drawing bounding boxes seg_demo
Training tutorial will be available soon
- We highly appreciate all the challenge organizers and dataset owners for providing the public dataset to the community.
- We thank Meta AI for making the source code of segment anything publicly available.
- We also thank Alexandre Bonnet for sharing this great blog
@article{MedSAM,
title={Segment Anything in Medical Images},
author={Ma, Jun and He, Yuting and Li, Feifei and Han, Lin and You, Chenyu and and Wang, Bo},
journal={arXiv preprint arXiv:2304.12306},
year={2023}
}