Home

Awesome

Segment Any Medical-Model (SAMM): A 3D Slicer integration to Meta's SAM.

paper paper
demo
Laboratory of Biomechanical and Image Guided Surgical Systems, Johns Hopkins University
Results The Video The Video

Table of contents

Introduction <a name="introduction"></a>

What are SAM, SAMM and SAMME?

Before You Try <a name="before-you-try"></a>

Make sure you have more than 8GB of VRAM so that it doesn't crash. \

How to Use <a name="how-to-use"></a>

Also see the Installation Guide.
Watch this video. Here are some key points demonstrated in the video.

Features <a name="features"></a>

Add Your Own SAM Vriant <a name="add-your-own-sam-variant"></a>

The inference can run in real time (on a 3090) once the embeddings of the images are calculated and loaded. If you'd like to add your own SAM variant, make sure the implementation keeps the Predictor class intact or uses the same interface to call. Make sure the architecture follows the similar component make ups as in the vanilla SAM.

Installation Guide <a name="installation-guide"></a>

Works both on Linux and Windows. Has Mac support, but not tested yet.

Prerequisite <a name="prerequisite"></a>

This assumes Cuda, cv2 and pytorch are in your environment.

TLDR version

git clone git@github.com:bingogome/samm.git
conda create --name samm
conda activate samm
pip install git+https://github.com/facebookresearch/segment-anything.git
pip install opencv-python pycocotools matplotlib onnxruntime onnx timm
git clone https://github.com/bowang-lab/MedSAM
pip install -e MedSAM
pip install git+https://github.com/ChaoningZhang/MobileSAM.git

If you are using Windows, it's okay if you don't install pycocotools.

cd samm/samm-python-terminal
mkdir samm-workspace

Then, move the check point files in the samm-workspace folder.

Start 3D Slicer, in the Python Console:

slicer.util.pip_install("pyyaml")
slicer.util.pip_install("pyzmq")
slicer.util.pip_install("tqdm")

SD SlicerDeveloper ToolsExtension Wizard.

Extension ToolsSelect Extension → import the samm/samm folder.

Back to terminal, cd to root folder samm

python ./samm-python-terminal/sam_server.py

If it throws an error missing "sam_vit_h_4b8939.pth", move segment-anything/notebooks/sam_vit_h_4b8939.pth to samm/samm-python-terminal/samm-workspace

Follow the demo and Segment Any Medical Model away!

Citation <a name="citation"></a>

If you use SAMM in your research, please consider use the following BibTeX entry.

@article{liu2024segment,
  title={Segment Any Medical Model Extended},
  author={Liu, Yihao and Zhang, Jiaming and Diaz-Pinto, Andres and Li, Haowei and Martin-Gomez, Alejandro and Kheradmand, Amir and Armand, Mehran},
  journal={arXiv preprint arXiv:2403.18114},
  year={2024}
}
@article{liu2023samm,
  title={SAMM (Segment Any Medical Model): A 3D Slicer Integration to SAM},
  author={Liu, Yihao and Zhang, Jiaming and She, Zhangcong and Kheradmand, Amir and Armand, Mehran},
  journal={arXiv preprint arXiv:2304.05622},
  year={2023}
}