https://github.com/bowang-lab/medsam
Segment Anything in Medical Images
Science Score: 46.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
✓Academic publication links
Links to: zenodo.org -
✓Committers with academic emails
2 of 11 committers (18.2%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.6%) to scientific vocabulary
Repository
Segment Anything in Medical Images
Basic Info
- Host: GitHub
- Owner: bowang-lab
- License: apache-2.0
- Language: Jupyter Notebook
- Default Branch: main
- Homepage: https://www.nature.com/articles/s41467-024-44824-z
- Size: 60.5 MB
Statistics
- Stars: 3,527
- Watchers: 27
- Forks: 493
- Open Issues: 5
- Releases: 1
Metadata Files
README.md
MedSAM
This is the official repository for MedSAM: Segment Anything in Medical Images.
Welcome to join our mailing list to get updates.
News
- 2025.04.07: Release MedSAM2 for 3D and video segmentation.
- 2025.02: Welcome to join CVPR 2025 Challenges: Interactive and Text-guided 3D Biomedical Image Segmentation
- 2024.01.15: Welcome to join CVPR 2024 Challenge: MedSAM on Laptop
- 2024.01.15: Release LiteMedSAM and 3D Slicer Plugin, 10x faster than MedSAM!
Installation
- Create a virtual environment
conda create -n medsam python=3.10 -yand activate itconda activate medsam - Install Pytorch 2.0
git clone https://github.com/bowang-lab/MedSAM- Enter the MedSAM folder
cd MedSAMand runpip install -e .
Get Started
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
bash
python MedSAM_Inference.py # segment the demo image
Segment other images with the following flags
bash
-i input_img
-o output path
--box bounding box of the segmentation target
- Jupyter-notebook
We provide a step-by-step tutorial on CoLab
You can also run it locally with tutorial_quickstart.ipynb.
- GUI
Install PyQt5 with pip: pip install PyQt5 or conda: conda install -c anaconda pyqt
bash
python gui.py
Load the image to the GUI and specify segmentation targets by drawing bounding boxes.
https://github.com/bowang-lab/MedSAM/assets/19947331/a8d94b4d-0221-4d09-a43a-1251842487ee
Model Training
Data preprocessing
Download SAM checkpoint and place it at work_dir/SAM/sam_vit_b_01ec64.pth .
Download the demo dataset and unzip it to data/FLARE22Train/.
This dataset contains 50 abdomen CT scans and each scan contains an annotation mask with 13 organs. The names of the organ label are available at MICCAI FLARE2022.
Run pre-processing
Install cc3d: pip install connected-components-3d
bash
python pre_CT_MR.py
- split dataset: 80% for training and 20% for testing
- adjust CT scans to soft tissue window level (40) and width (400)
- max-min normalization
- resample image size to
1024x1024 - save the pre-processed images and labels as
npyfiles
Training on multiple GPUs (Recommend)
The model was trained on five A100 nodes and each node has four GPUs (80G) (20 A100 GPUs in total). Please use the slurm script to start the training process.
bash
sbatch train_multi_gpus.sh
When the training process is done, please convert the checkpoint to SAM's format for convenient inference.
bash
python utils/ckpt_convert.py # Please set the corresponding checkpoint path first
Training on one GPU
bash
python train_one_gpu.py
Acknowledgements
- 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
Reference
@article{MedSAM,
title={Segment Anything in Medical Images},
author={Ma, Jun and He, Yuting and Li, Feifei and Han, Lin and You, Chenyu and Wang, Bo},
journal={Nature Communications},
volume={15},
pages={654},
year={2024}
}
Owner
- Name: WangLab @ U of T
- Login: bowang-lab
- Kind: organization
- Location: 190 Elizabeth St, Toronto, ON M5G 2C4 Canada
- Website: https://wanglab.ml
- Repositories: 11
- Profile: https://github.com/bowang-lab
BoWang's Lab at University of Toronto
GitHub Events
Total
- Issues event: 120
- Watch event: 802
- Issue comment event: 84
- Push event: 5
- Pull request review event: 1
- Pull request event: 3
- Fork event: 130
Last Year
- Issues event: 120
- Watch event: 802
- Issue comment event: 84
- Push event: 5
- Pull request review event: 1
- Pull request event: 3
- Fork event: 130
Committers
Last synced: 10 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Jun | 1****4@q****m | 84 |
| Fraol Gelana | f****a@g****m | 17 |
| Lin Han | me@l****l | 10 |
| Pse1234 | 7****4 | 4 |
| sarrabenyahia | 9****a | 1 |
| ff98li | f****i@m****a | 1 |
| Zehui Lin | z****t@o****m | 1 |
| Kalina Slavkova | k****v@u****u | 1 |
| Ajinkya Kulkarni | k****a@g****m | 1 |
| ctrlaltf2 | c****2@p****h | 1 |
| Khoa-NT | t****4@g****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 254
- Total pull requests: 20
- Average time to close issues: 14 days
- Average time to close pull requests: 21 days
- Total issue authors: 215
- Total pull request authors: 13
- Average comments per issue: 1.92
- Average comments per pull request: 0.25
- Merged pull requests: 13
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 82
- Pull requests: 3
- Average time to close issues: 20 days
- Average time to close pull requests: about 3 hours
- Issue authors: 74
- Pull request authors: 2
- Average comments per issue: 1.07
- Average comments per pull request: 0.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- mehrnia (5)
- PANHAOC (3)
- ariharasudhanm (3)
- mlszy928 (3)
- panboshui (3)
- biyuefeng (2)
- GewelsJI (2)
- hnyll (2)
- Youzhuqinghuan (2)
- MyFirst905 (2)
- 1687412531 (2)
- Ulteraa (2)
- Biopticon (2)
- liubaoning111 (2)
- xiawei20161308104 (2)
Pull Request Authors
- linhandev (3)
- GoobleNeat (3)
- JoseAngelGarciaSanchez (3)
- FrexG (3)
- oikosohn (2)
- Zehui-Lin (2)
- kslav (2)
- BBQtime (2)
- ff98li (2)
- junautogroup (1)
- ctrlaltf2 (1)
- chinmay5 (1)
- sarrabenyahia (1)
- hamzaMahdi (1)
- ajinkya-kulkarni (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 2
- Total downloads: unknown
-
Total dependent packages: 0
(may contain duplicates) -
Total dependent repositories: 0
(may contain duplicates) - Total versions: 2
proxy.golang.org: github.com/bowang-lab/MedSAM
- Documentation: https://pkg.go.dev/github.com/bowang-lab/MedSAM#section-documentation
- License: apache-2.0
-
Latest release: v1.0.0
published over 2 years ago
Rankings
proxy.golang.org: github.com/bowang-lab/medsam
- Documentation: https://pkg.go.dev/github.com/bowang-lab/medsam#section-documentation
- License: apache-2.0
-
Latest release: v1.0.0
published over 2 years ago