Kingfish404 / segment-anything-webui

Yet another SAM webui + CLIP

Home Page:https://segment-anything-webui.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Segment Anything web UI

demo

This is a web interface for the Segment Anything.

Usage

Environment Require: Python >= 3.8.13, Node >= 18.15.0 (LTS), CUDA or MPS(optional)

  1. Fowllow the instructions in the Segment Anything and CLIP to install SAM and CLIP. And prepare webui environment:
# e.g. for Segment Anything
pip install git+https://github.com/facebookresearch/segment-anything.git
pip install opencv-python pycocotools matplotlib onnxruntime onnx

mkdir model
# download the model to `model/`
wget https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth -O model/sam_vit_b_01ec64.pth
# https://dl.fbaipublicfiles.com/segment_anything/sam_vit_l_0b3195.pth
# https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth

# e.g. for CLIP
pip install torch torchvision
pip install ftfy regex tqdm
pip install git+https://github.com/openai/CLIP.git

# python server as backend
pip3 install torch numpy 'uvicorn[standard]' fastapi pydantic python-multipart Pillow click
# or 
cd scripts && pip3 install -r requirements.txt
# webui frontend
npm i
  1. run the server and webui on different terminals:
python3 scripts/server.py   # webui backend
npm run dev                 # interactive webui frontend

Or

docker compose up

Advanced

Change the .env.local file to change the server address.

The model server can be run on a remote GUI server, and the webui can be run on a local machine.

The API in server.py is Pure Function. Though it is slow (Encoding Image Each Request), it is easy to deploy and maintain.

Reference

License

MIT

About

Yet another SAM webui + CLIP

https://segment-anything-webui.vercel.app


Languages

Language:TypeScript 79.6%Language:Python 17.6%Language:JavaScript 2.1%Language:CSS 0.5%Language:Dockerfile 0.3%