Spaces:
Runtime error
Runtime error
| FROM python:3.10-slim | |
| ENV DEBIAN_FRONTEND=noninteractive \ | |
| PIP_NO_CACHE_DIR=1 \ | |
| PYTHONDONTWRITEBYTECODE=1 \ | |
| PYTHONUNBUFFERED=1 \ | |
| HF_HUB_DISABLE_TELEMETRY=1 \ | |
| HF_HUB_ENABLE_HF_TRANSFER=0 | |
| WORKDIR /app | |
| # + build tools because insightface may compile on this platform | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| git ffmpeg \ | |
| libgl1 libsm6 libxext6 \ | |
| build-essential \ | |
| gcc g++ \ | |
| cmake \ | |
| pkg-config \ | |
| python3-dev \ | |
| && rm -rf /var/lib/apt/lists/* | |
| COPY requirements-full.txt /app/requirements-full.txt | |
| # Important: upgrade build tooling first | |
| RUN pip install --upgrade pip setuptools wheel | |
| RUN pip install -r /app/requirements-full.txt | |
| COPY . /app | |
| # Download InsightFace buffalo_l ONNX files from HF DATASET (files in dataset root) | |
| RUN python - << 'PY' | |
| import os, shutil | |
| from huggingface_hub import snapshot_download | |
| repo_id = "vadim71/faceswap-models" | |
| print("[INFO] Downloading InsightFace buffalo_l files from dataset:", repo_id) | |
| local_dir = "/tmp/buffalo_l_download" | |
| needed = ["1k3d68.onnx","2d106det.onnx","det_10g.onnx","genderage.onnx","w600k_r50.onnx"] | |
| snapshot_download( | |
| repo_id=repo_id, | |
| repo_type="dataset", | |
| allow_patterns=needed, | |
| local_dir=local_dir, | |
| local_dir_use_symlinks=False, | |
| ) | |
| dst = "/root/.insightface/models/buffalo_l" | |
| os.makedirs(dst, exist_ok=True) | |
| for f in needed: | |
| p = os.path.join(local_dir, f) | |
| if not os.path.exists(p): | |
| raise RuntimeError(f"Missing in dataset root: {f}") | |
| shutil.copy2(p, os.path.join(dst, f)) | |
| print("[OK] buffalo_l copied to", dst) | |
| PY | |
| # Hard checks | |
| RUN test -f /app/inswapper_128.onnx && \ | |
| test -f /app/GFPGANv1.3.pth && \ | |
| test -f /root/.insightface/models/buffalo_l/w600k_r50.onnx && \ | |
| test -f /root/.insightface/models/buffalo_l/det_10g.onnx | |
| EXPOSE 7860 | |
| CMD ["python", "app.py"] |