Skip to content

biotune-ai/medsam-api

Repository files navigation

medSAM model REST API service

Standalone FastAPI service that serves the medSAM model.

1. setup environement variables

refer to examples/ - you will need to create .env (and .env.docker if you are using Docker) and place them in the root of the project folder.

tip: copy-paste the existing example files, remove the .example at then end, and add the correct variables per your configuration

2a. set up and run the service

set up a dedicated virtual environment to run the service

# (install uv)
# curl -LsSf https://astral.sh/uv/install.sh | sh
# https://docs.astral.sh/uv/getting-started/installation/

uv python install 3.11

uv sync

install pre-commit git hook scripts

uv run pre-commit install

start the service

# development
uv run fastapi dev --host 127.0.0.1 --port 54003 service.py

# production
uv run uvicorn service:app --host 127.0.0.1 --port 54003
# OR
uv run fastapi run --host 127.0.0.1 --port 54003 service.py

2b. run in a Docker container

build the Docker image

docker build -t medsam-model .

run the Docker container service

docker compose up

manually request segmentation for an image

# e.g. local
IMAGE_PATH="minio/{bucket_name}/{image_filename}"
# e.g. docker
IMAGE_PATH="local/{image_filename}"

# curl command once IMAGE_PATH has been set - saves image in data/ folder
curl -X GET "http://127.0.0.1:54003/process/${IMAGE_PATH}" -H "accept: application/json"

service documentation: http://127.0.0.1:54003/docs

NOTE: The service is designed to run locally and currently doesn't incorporate authentication or other security features.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors