Spaces:
Running
Running
Align with healthy gemini-eraser-ai space: remove CLIPSeg/transformers, use RealESRGAN_x4plus.pth from GitHub
c6cbe1c | FROM python:3.11-slim | |
| # ─── System dependencies ─────────────────────────────────────────────────────── | |
| # libglib2.0-0 is required by opencv-python-headless on Linux | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| libglib2.0-0 \ | |
| libgl1 \ | |
| git \ | |
| wget \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # ─── Hugging Face Spaces requires all files owned by user 1000 ──────────────── | |
| RUN useradd -m -u 1000 appuser | |
| WORKDIR /app | |
| # Copy and install Python dependencies first (layer caching optimization) | |
| COPY --chown=appuser:appuser requirements.txt . | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir -r requirements.txt | |
| # Copy application code | |
| COPY --chown=appuser:appuser . . | |
| # ─── Pre-bake Real-ESRGAN super-resolution model weights (~130MB total) ──────── | |
| # Real-ESRGAN is a state-of-the-art model that genuinely reconstructs texture | |
| # detail (skin, hair, fabric, foliage) — far superior to FSRCNN interpolation. | |
| # x2plus: original resolution → 2× (for "High" PRO tier) | |
| # x4plus: original resolution → 4× (for "Max" PRO tier, ultra-sharp) | |
| RUN mkdir -p /app/weights && \ | |
| wget -q -O /app/weights/RealESRGAN_x2plus.pth \ | |
| "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.1/RealESRGAN_x2plus.pth" && \ | |
| wget -q -O /app/weights/RealESRGAN_x4plus.pth \ | |
| "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth" && \ | |
| echo "✅ Real-ESRGAN models downloaded." | |
| # ─── Pre-download the LaMa model weights into the image ─────────────────────── | |
| # This bakes the ~200MB model into the Docker image so it cold-starts instantly | |
| # on every Hugging Face Space restart without re-downloading. | |
| RUN python -c "from simple_lama_inpainting import SimpleLama; print('Model download complete:', SimpleLama())" | |
| # Pre-download the FastSAM model weights into the image | |
| RUN python -c "from ultralytics import FastSAM; FastSAM('FastSAM-s.pt')" | |
| # Switch to non-root user (required by Hugging Face Spaces) | |
| USER 1000 | |
| # Hugging Face Spaces expects port 7860 | |
| ENV PORT=7860 | |
| EXPOSE 7860 | |
| # Start the server | |
| CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"] | |