Spaces:
Running
Running
| FROM python:3.10-slim-bookworm | |
| WORKDIR /app | |
| # System dependencies | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| gcc \ | |
| g++ \ | |
| libglib2.0-0 \ | |
| libsm6 \ | |
| libxext6 \ | |
| libxrender-dev \ | |
| libgl1-mesa-glx \ | |
| wget \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Upgrade pip | |
| RUN pip install --no-cache-dir --upgrade pip setuptools wheel | |
| # Install PyTorch CPU version FIRST (separate layer for better caching) | |
| RUN pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu | |
| # Copy and install the rest of the requirements | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Pre-download models (more reliable with retries + quiet) | |
| RUN mkdir -p /app/models && \ | |
| cd /app/models && \ | |
| wget -q --tries=3 --timeout=30 -O GFPGANv1.4.pth \ | |
| https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.4.pth && \ | |
| wget -q --tries=3 --timeout=30 -O inswapper_128.onnx \ | |
| https://huggingface.co/ashleykleynhans/inswapper/resolve/main/inswapper_128.onnx && \ | |
| ls -lh /app/models && \ | |
| cd /app | |
| # Copy app code (put this last) | |
| COPY . . | |
| EXPOSE 7860 | |
| CMD ["python", "-u", "app.py"] |