{"id":22069305,"url":"https://github.com/bingogome/samm","last_synced_at":"2025-07-24T08:34:44.024Z","repository":{"id":152749759,"uuid":"625067062","full_name":"bingogome/samm","owner":"bingogome","description":"A 3D Slicer integration to Meta's SAM.","archived":false,"fork":false,"pushed_at":"2024-03-30T23:57:55.000Z","size":37774,"stargazers_count":243,"open_issues_count":9,"forks_count":34,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-11-21T03:45:08.932Z","etag":null,"topics":["pytorch","sam"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/2304.05622","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bingogome.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-08T01:21:39.000Z","updated_at":"2024-11-21T02:56:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"7a745c51-8fc3-4c98-914a-a43921ea53c9","html_url":"https://github.com/bingogome/samm","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bingogome%2Fsamm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bingogome%2Fsamm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bingogome%2Fsamm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bingogome%2Fsamm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bingogome","download_url":"https://codeload.github.com/bingogome/samm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227421467,"owners_count":17775011,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pytorch","sam"],"created_at":"2024-11-30T20:04:52.199Z","updated_at":"2024-11-30T20:08:01.121Z","avatar_url":"https://github.com/bingogome.png","language":"Jupyter Notebook","funding_links":[],"categories":["Paper List"],"sub_categories":["Follow-up Papers"],"readme":"# Segment Any Medical-Model (SAMM): A 3D Slicer integration to Meta's SAM.\n\n[paper](https://arxiv.org/abs/2304.05622) [paper](https://arxiv.org/abs/2403.18114)\n\\\n[demo](https://www.youtube.com/watch?v=tZRG7JljEBU)\n\\\n[Laboratory of Biomechanical and Image Guided Surgical Systems](https://bigss.lcsr.jhu.edu/), [Johns Hopkins University](https://www.jhu.edu/)\n\\\n![Results](https://github.com/bingogome/samm/blob/main/3dbbox.png)\n[![The Video](https://github.com/bingogome/samm/blob/main/thumbnail.png)](https://youtu.be/tZRG7JljEBU)\n[![The Video](https://github.com/bingogome/samm/blob/main/thumbnail2.png)](https://youtu.be/tZRG7JljEBU)\n\n# Table of contents\n- [Segment Any Medical-Model (SAMM): A 3D Slicer integration to Meta's SAM.](#segment-any-medical-model-samm-a-3d-slicer-integration-to-metas-sam)\n- [Table of contents](#table-of-contents)\n  - [Introduction ](#introduction-)\n  - [Before You Try ](#before-you-try-)\n  - [How to Use ](#how-to-use-)\n    - [Features ](#features-)\n    - [Add Your Own SAM Vriant ](#add-your-own-sam-vriant-)\n  - [Installation Guide ](#installation-guide-)\n    - [Prerequisite ](#prerequisite-)\n    - [TLDR version](#tldr-version)\n  - [Citation ](#citation-)\n\n## Introduction \u003ca name=\"introduction\"\u003e\u003c/a\u003e\nWhat are SAM, SAMM and SAMME?\n* SAM is the vision foundation model developed by Meta, [Segment Anything](https://segment-anything.com).\n* SAMM is an engineering integration of SAM to 3D Slicer, intended for medical image segmentation. The name is the abbreviation of Segment Any Medical Model.\n* SAMME is an extended version of SAMM supporting not only the vanilla SAM, but new variants from the community.\n\\\nWhy SAMM and SAMME?\n* SAMM was a side project for fun initially (you can tell from the name). Later we got some interests from people because hey it's a new model and it's cool. Accurate image segmentation is crucial for medical image analysis as it enables clinicians to extract meaningful information from the image. It also allows for the detection of subtle changes in the tissue or organ of interest, which is essential for monitoring disease progression and treatment response. \n* This later became aiming to develop an integration for [Segment Anything Model (SAM)](https://github.com/facebookresearch/segment-anything) and [3D Slicer](https://www.slicer.org/) for future development and validation of the potentials of transferring Foundation Model to the medical image analysis field. [More and more variants](https://github.com/YichiZhang98/SAM4MIS) of SAM emerged, so we thought it's probably worth it to have a platform supporting the addition of new SAMs.\n* [YichiZhang98](https://github.com/YichiZhang98/SAM4MIS) has compiled a nice history of SAM for medical images.\n\\\n\n## Before You Try \u003ca name=\"before-you-try\"\u003e\u003c/a\u003e\nMake sure you have more than 8GB of VRAM so that it doesn't crash. \\\n\n## How to Use \u003ca name=\"how-to-use\"\u003e\u003c/a\u003e\nAlso see the [Installation Guide](#installation-guide). \n\\\nWatch this [video](https://www.youtube.com/watch?v=tZRG7JljEBU). Here are some key points demonstrated in the video.\n* 00:00 Start Server\n* 00:20 Pick a Model\n* 00:22 Calculate Embeddings\n* 00:37 3D Bounding Box\n* 01:20 Switch Models\n* 01:41 Fix Bad Results by Adjust Brightness and Contrast\n* 02:33 2D Bounding Box\n* 02:45 Prompt Propagation\n* 03:05 Change Prompting View\n* 03:27 Point Prompts\n\n### Features \u003ca name=\"features\"\u003e\u003c/a\u003e\n- 3 View Inference\n- Embedding saving\n- Data type\n  - Volume\n  - 2D Image\n  - RGB Image (WIP)\n- models\n  - vit_b\n  - vit_h\n  - vit_l\n  - vit_t - [MobileSAM](https://github.com/ChaoningZhang/MobileSAM)\n  - vit_b - [MedSAM](https://github.com/bowang-lab/MedSAM)\n- interactions\n  - positive and negative points\n  - 2D bounding box\n  - 3D bounding box \n  - combination\n  - automatic segmentation\n- training (WIP)\n\n### Add Your Own SAM Vriant \u003ca name=\"add-your-own-sam-variant\"\u003e\u003c/a\u003e\nThe 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.\n\n## Installation Guide \u003ca name=\"installation-guide\"\u003e\u003c/a\u003e\nWorks both on Linux and Windows. Has Mac support, but not tested yet.\n\n### Prerequisite \u003ca name=\"prerequisite\"\u003e\u003c/a\u003e\nThis assumes Cuda, cv2 and pytorch are in your environment.\n\n### TLDR version\n```bash\ngit clone git@github.com:bingogome/samm.git\nconda create --name samm\nconda activate samm\npip install git+https://github.com/facebookresearch/segment-anything.git\npip install opencv-python pycocotools matplotlib onnxruntime onnx timm\ngit clone https://github.com/bowang-lab/MedSAM\npip install -e MedSAM\npip install git+https://github.com/ChaoningZhang/MobileSAM.git\n```\nIf you are using Windows, it's okay if you don't install pycocotools.\n\n```bash\ncd samm/samm-python-terminal\nmkdir samm-workspace\n```\nThen, move the check point files in the `samm-workspace` folder.\n\nStart 3D Slicer, in the Python Console:\n\n```python\nslicer.util.pip_install(\"pyyaml\")\nslicer.util.pip_install(\"pyzmq\")\nslicer.util.pip_install(\"tqdm\")\n```\n\n`SD Slicer` \u0026rarr; `Developer Tools` \u0026rarr; `Extension Wizard`.\n\n`Extension Tools` \u0026rarr; `Select Extension` \u0026rarr; import the samm/samm folder. \n\nBack to terminal, cd to root folder `samm`\n\n```bash\npython ./samm-python-terminal/sam_server.py\n``` \n\nIf 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\n\nFollow the [demo](https://www.youtube.com/watch?v=tZRG7JljEBU) and Segment Any Medical Model away!\n\n## Citation \u003ca name=\"citation\"\u003e\u003c/a\u003e\nIf you use SAMM in your research, please consider use the following BibTeX entry.\n\n```bibtex\n@article{liu2024segment,\n  title={Segment Any Medical Model Extended},\n  author={Liu, Yihao and Zhang, Jiaming and Diaz-Pinto, Andres and Li, Haowei and Martin-Gomez, Alejandro and Kheradmand, Amir and Armand, Mehran},\n  journal={arXiv preprint arXiv:2403.18114},\n  year={2024}\n}\n@article{liu2023samm,\n  title={SAMM (Segment Any Medical Model): A 3D Slicer Integration to SAM},\n  author={Liu, Yihao and Zhang, Jiaming and She, Zhangcong and Kheradmand, Amir and Armand, Mehran},\n  journal={arXiv preprint arXiv:2304.05622},\n  year={2023}\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbingogome%2Fsamm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbingogome%2Fsamm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbingogome%2Fsamm/lists"}