HKUSTMDI / mdi-sam-server

MDI machine learning SAM model server. Segment WSI(whole slide image) , simple images.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MDI SAM Server

Medical Data Inteligence Lab

Cheng ZHANG

architechture

MDI annotation platform SAM1 & SAM2 (and other SAM Family models) real-time recognition server ⚡ . You can use this server to generate the mask of image that you post with points (negative, positive), box, or both. You can install the server as label studio machine learning backend.

Currently support:

  • (1) Real time annotation: multi-point annotation, single rectangle annotation
  • (2) Prompt with different positive and negative values
  • (3) the Whole Slide Image recognition

WSI (the whole slide image) segmentation annotation

point & rectangle模式



Supporting models:

Installation

The Python used in the development process of this version is 3.10. Please use this version or an updated version.

# install the package
pip install -e .

# init .env and download models
sh init.sh

How to use

  • .env file Please pay attention to .env file if you can't run the server.
#!/bin/bash
# if you want to predict WSI file, please fill in the blank variables.
SAM_CHOICE=SAM2
SDPC_TILE_PREFIX=  
SDPC_TILE_IMAGEURL=
SVS_TILE_PREFIX=
SVS_TILE_IMAGEURL=
LOCAL_TILE_URL="./tiles" 
DOWNLOAD_RETRY="3"
LOCAL_STORAGE="~/.cache/label-studio/"
TEST_TILE_STORAGE="./tile_image/"
  • Using server command, please run pip install -e . firstly.
# variables explanation:
# SAM_CHOICE: SAM model type chioce
# SAM2_CHECKPOINT: SAM model checkpoint
# SAM2_CONFIG: SAM2 config
# --env-path: enviroment value config
#...

SAM_CHOICE=SAM2 \
  SAM2_CHECKPOINT=./models/sam2_hiera_base_plus.pt \
  SAM2_CONFIG=sam2_hiera_b+.yaml  \
  mdi_sam_server run --port 9011 --log-level INFO --env-path /home/mdi/zhangcheng-dev/mdi-sam-server/.env
  • Use shell
# variables:
# SAM_DRAW_MODE: draw the image in ${TEST_TILE_STORAGE}
# if you don't want use draw mode, set SAM_DRAW_MODE=""

cd src/

SAM_DRAW_MODE=true \
  SAM_CHOICE=SAM2 \
  SAM2_CHECKPOINT=../models/sam2_hiera_large.pt \
  SAM2_CONFIG=sam2_hiera_l.yaml \
  python run_server.py run  --port 9014 --log-level INFO --env-path
  • Explanation: The request body adopts JSON mode, and the request header contains a token for verification Request header: Content Type: application/JSON; token:xxxx

Contact

If you find this project helpful, please give it a ⭐, and for any questions or issues, feel free to create an issue or email czhangcn@connect.ust.hk.

License

This project is released under the Apache-2.0 license

Acknowledgement

We extend our heartfelt thanks to the developers and contributors of Label-Studio, playgroud, SAM.

Citation

If you use this software in your research, please cite it as below:

@misc{mdi-sam-server,
  year = {2024}
  author = {Cheng ZHANG},
  publisher = {Github},
  journal = {Github repository},
  title = {{MDI SAM Server}: MDI machine learning SAM model service},
  url = {https://github.com/HKUSTMDI/mdi-sam-server},
  organization = {HKUSTMDI}
}

About

MDI machine learning SAM model server. Segment WSI(whole slide image) , simple images.

License:Apache License 2.0


Languages

Language:Python 93.3%Language:Shell 5.3%Language:Dockerfile 1.4%