feat: upgrade to BiRefNet SOTA background removal model

- Switch default model from U2-Net to BiRefNet (state-of-the-art)
- Add 6 model options: BiRefNet, BiRefNet Lite, BiRefNet Portrait,
  BRIA RMBG, IS-Net, U2-Net
- Add animated progress bar with stage indicators (loading model,
  analyzing, removing, refining edges) and elapsed timer
- Add intuitive background color presets (Transparent, White, Black,
  Red, Green, Blue) as clickable buttons + custom color picker
- Handle background color compositing in Python (PIL alpha composite)
- Add checkerboard pattern to before/after slider for transparency
- Pre-bake BiRefNet model (973MB) in Docker image for instant use
This commit is contained in:
Siddharth Kumar Sah
2026-03-22 19:51:35 +08:00
parent 22b08c0475
commit 77ee8469d8
3 changed files with 140 additions and 42 deletions
+5 -3
View File
@@ -71,10 +71,12 @@ RUN /opt/venv/bin/pip install --no-cache-dir --upgrade pip && \
# This makes the Docker image fully self-contained — works offline
RUN /opt/venv/bin/python3 -c "\
from rembg import new_session; \
print('Downloading u2net model...'); \
print('Downloading BiRefNet model (SOTA)...'); \
new_session('birefnet-general'); \
print('Downloading u2net model (fallback)...'); \
new_session('u2net'); \
print('u2net model ready') \
" 2>/dev/null || echo "WARNING: Could not pre-download u2net model"
print('Background removal models ready') \
" 2>/dev/null || echo "WARNING: Could not pre-download rembg models"
RUN /opt/venv/bin/python3 -c "\
try: \