From 2d1a533660629501b846672997336f3fe25a6811 Mon Sep 17 00:00:00 2001 From: Yihao Liu Date: Mon, 10 Apr 2023 19:17:24 -0400 Subject: [PATCH] updated readme --- README.md | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 3c9b0e2..86c1b26 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,38 @@ Accurate image segmentation is crucial for medical image analysis as it enables Our project, **Segment Any Medical-Model** aims 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 Large Language Model to the medical image analysis field. +## Installation and How-To-Use +### TLDR version + +```bash +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 +``` + +Start 3D Slicer, in the Python Console: + +```python +import pip +pip.main(['install', 'pyyaml']) +pip.main(['install', 'pyzmq']) +``` + +SD Slicer -> `Developer Tools` → `Extension Wizard`. + +`Extension Tools` -> `Select Extension' -> import the samm/samm folder. + +Back to terminal, cd to samm (upper level) + +Run ./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](https://www.youtube.com/watch?v=vZK45noZVIA) and Segment Any Medical Model away! -## Installation ### Install samm @@ -26,8 +55,6 @@ Install this repo: git clone git@github.com:bingogome/samm.git ``` -​ - ### Create Virtual Environment It's essential to have a clean virtual environment to avoid any potential conflicts. Therefore, you'd better to create a new environment for running the rest part of the code. @@ -43,8 +70,6 @@ conda activate samm Note: The given python script in this [folder](/samm-python-terminal) has to be executed in samm venv. - - ### Install SAM The code requires `python>=3.8`, as well as `pytorch>=1.7` and `torchvision>=0.8`. Please follow the instructions [here](https://pytorch.org/get-started/locally/) to install both PyTorch and TorchVision dependencies. Installing both PyTorch and TorchVision with CUDA support is strongly recommended. @@ -62,22 +87,18 @@ git clone git@github.com:facebookresearch/segment-anything.git cd segment-anything; pip install -e . ``` -The following optional dependencies are necessary for mask post-processing, saving masks in COCO format, the example notebooks, and exporting the model in ONNX format. `jupyter` is also required to run the example notebooks. +Then, ``` pip install opencv-python pycocotools matplotlib onnxruntime onnx ``` - - - ### Install 3D Slicer Follow this [page](https://slicer.readthedocs.io/en/latest/user_guide/getting_started.html) to download a compatible version of 3D Slicer and install it in your local environment. - ### Install the SAMM Extension to 3D Slicer The source code of the extension is contained in [samm](/samm).