Add SAM (Segment Anything) via Replicate API and update Docker

- Implement SAM object selection via Replicate API
  - Click on any object to select it with AI precision
  - Falls back to flood-fill if Replicate API unavailable
- Update Dockerfile for rembg dependencies
  - Add required system libraries (libsm6, libxext6, etc)
  - Pre-download rembg model during build
  - Create data directories for models and patches
This commit is contained in:
Claude
2026-01-25 16:24:08 +00:00
parent 909bb41f8a
commit 4c2574ace4
2 changed files with 90 additions and 7 deletions
+11 -3
View File
@@ -2,10 +2,15 @@ FROM python:3.11-slim
WORKDIR /app
# Install system dependencies
# Install system dependencies for OpenCV, rembg, and image processing
RUN apt-get update && apt-get install -y \
libgl1 \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
libgomp1 \
wget \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements
@@ -14,11 +19,14 @@ COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Pre-download rembg model (u2net) to avoid first-run delay
RUN python -c "from rembg import remove; print('rembg model downloaded')" || true
# Copy application
COPY . .
# Create data directory
RUN mkdir -p /app/data/projects
# Create data directories
RUN mkdir -p /app/data/projects /app/data/patches /app/data/models
# Expose port
EXPOSE 8000