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
- 1.Meta SAM
- 2.Meta SAM2
- 3.mobile_sam
- 4.ONNX mode
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
- .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
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.
This project is released under the Apache-2.0 license
We extend our heartfelt thanks to the developers and contributors of Label-Studio, playgroud, SAM.
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}
}