Upgrade rembg to use BiRefNet model (state-of-the-art)

- Use onnxruntime>=1.17.0 (fixed executable stack issues, no execstack needed)
- Use rembg>=2.0.70 with BiRefNet model support
- Update all remove-background endpoints to use birefnet-general model
- BiRefNet provides better edge detection and matting quality than u2net
- Falls back to default model if BiRefNet unavailable
This commit is contained in:
Claude
2026-01-27 14:34:28 +00:00
parent 44bc5ed2f5
commit 2ab9ed7559
3 changed files with 34 additions and 18 deletions
+3 -3
View File
@@ -22,6 +22,7 @@ FROM python:3.11-slim
WORKDIR /app
# Install system dependencies for OpenCV, rembg, SAM, and image processing
# Note: onnxruntime 1.17+ fixed executable stack issues, no longer need execstack
RUN apt-get update && apt-get install -y \
libgl1 \
libglib2.0-0 \
@@ -37,9 +38,8 @@ RUN apt-get update && apt-get install -y \
COPY backend/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Try to pre-download rembg model, but don't fail build if onnxruntime has issues
# (onnxruntime can have executable stack issues in some Docker environments)
# If this fails, Remove Background feature will be disabled
# Verify rembg loads correctly (model downloads on first use)
# rembg now supports BiRefNet models which are state-of-the-art for background removal
RUN python -c "from rembg import remove; print('rembg ready')" || echo "WARNING: rembg not available - Remove Background will be disabled"
# Copy backend application