sam2 Docker & Self-Hosted Deployment

GitHub

The repository provides code for running inference with the Meta Segment Anything Model 2 (SAM 2), links for downloading the trained model checkpoints, and...

20,014 stars Jupyter Notebook 1 file ยท ~4,126 tokens
RAW Compose
1. Pull Image (DOCKERHUB) docker pull sam2/frontend
2. Docker Run (1-Click Launch) docker run -d --name sam2 -p 7262:7262 --restart always sam2/frontend
3. Podman Run podman run -d --name sam2 -p 7262:7262 --restart always sam2/frontend
4. Skopeo Inspect (Zero-Pull Manifest) skopeo inspect docker://docker.io/sam2/frontend:latest
5. ORAS Pull (OCI Artifact) oras pull sam2/frontend
6. Compose Deployment docker compose up -d
docker-compose.yaml
Download .yml
services:
  frontend:
    image: sam2/frontend
    build:
      context: ./demo/frontend
      dockerfile: frontend.Dockerfile
    ports:
      - 7262:80

  backend:
    image: sam2/backend
    build:
      context: .
      dockerfile: backend.Dockerfile
    ports:
      - 7263:5000
    volumes:
      - ./demo/data/:/data/:rw
    environment:
      - SERVER_ENVIRONMENT=DEV
      - GUNICORN_WORKERS=1
      # Inference API needs to have at least 2 threads to handle an incoming
      # parallel cancel propagation request
      - GUNICORN_THREADS=2
      - GUNICORN_PORT=5000
      - API_URL=http://localhost:7263
      - DEFAULT_VIDEO_PATH=gallery/05_default_juggle.mp4
      # # ffmpeg/video encode settings
      - FFMPEG_NUM_THREADS=1
      - VIDEO_ENCODE_CODEC=libx264
      - VIDEO_ENCODE_CRF=23
      - VIDEO_ENCODE_FPS=24
      - VIDEO_ENCODE_MAX_WIDTH=1280
      - VIDEO_ENCODE_MAX_HEIGHT=720
      - VIDEO_ENCODE_VERBOSE=False
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities: [gpu]