File size: 1,855 Bytes
3154e32
 
 
 
 
 
 
 
 
 
 
56cf22e
3154e32
 
 
56cf22e
 
 
 
 
3154e32
 
 
56cf22e
 
 
 
 
3154e32
 
 
56cf22e
c157490
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56cf22e
c157490
 
3154e32
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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"]