File size: 1,897 Bytes
969f04d
 
 
beb8bf8
969f04d
feaee3c
 
 
 
969f04d
 
 
feaee3c
 
 
969f04d
 
 
fa4479b
feaee3c
 
 
 
 
969f04d
 
 
feaee3c
 
 
 
fa4479b
969f04d
 
 
feaee3c
 
 
969f04d
 
 
 
 
 
 
 
 
 
 
 
 
 
feaee3c
1ffe0eb
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
# =======================================================
# GPU-enabled base image (CUDA 12.1 + cuDNN 8)
# =======================================================
FROM pytorch/pytorch:2.2.2-cuda12.1-cudnn8-runtime

ENV DEBIAN_FRONTEND=noninteractive \
    PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1

# =======================================================
# Install Gradio first (pinned version)
# =======================================================
ARG GRADIO_FORCE_REINSTALL=1
RUN pip install --no-cache-dir --upgrade gradio==4.44.1

# =======================================================
# System dependencies for OpenCV + dlib runtime
# =======================================================
RUN apt-get update && apt-get install -y --no-install-recommends \
    libgl1 libglib2.0-0 libsm6 libxext6 libxrender1 \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# =======================================================
# Copy application files
# =======================================================
COPY requirements.txt /app/requirements.txt
COPY app.py /app/app.py
COPY models /app/models
COPY shape_predictor_68_face_landmarks.dat /app/

# =======================================================
# Install Python dependencies
# =======================================================
RUN pip install --no-cache-dir tensorflow==2.18.0
RUN pip install --no-cache-dir -r requirements.txt

# 🔧 Replace compiled dlib with prebuilt dlib-bin
RUN pip uninstall -y dlib || true \
 && pip install --no-cache-dir dlib-bin==19.24.2

# =======================================================
# Environment optimizations
# =======================================================
ENV OMP_NUM_THREADS=2 \
    MKL_NUM_THREADS=2 \
    OPENBLAS_NUM_THREADS=2 \
    NUMEXPR_NUM_THREADS=2 \
    TF_CPP_MIN_LOG_LEVEL=2 \
    CUDA_VISIBLE_DEVICES=0

EXPOSE 7860
CMD ["python", "app.py"]