Spaces:
Sleeping
Sleeping
File size: 1,657 Bytes
a989250 709056c 0b87e11 dcb572b 0b87e11 a989250 471a3f4 dcb572b 471a3f4 dcb572b a989250 40c4474 dcb572b 40c4474 dcb572b 183ba2e 40c4474 dcb572b 1808a06 a989250 dcb572b ea5606b | 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 | FROM python:3.9-slim
RUN apt-get update && apt-get install -y \
libgl1 \
libglib2.0-0 \
wget \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
RUN useradd -m -u 1000 user
RUN mkdir -p /home/user/.deepface/weights && \
mkdir -p /app/faces_db && \
mkdir -p /app/data && \
mkdir -p /app/core /app/api /app/services /app/static /app/templates && \
chown -R user:user /app && \
chown -R user:user /home/user/.deepface
# Pre-download SOTA weights (ArcFace, Facenet512, & RetinaFace) to ensure zero-lag startup
RUN wget https://github.com/serengil/deepface_models/releases/download/v1.0/arcface_weights.h5 \
-O /home/user/.deepface/weights/arcface_weights.h5 && \
wget https://github.com/serengil/deepface_models/releases/download/v1.0/facenet512_weights.h5 \
-O /home/user/.deepface/weights/facenet512_weights.h5 && \
wget https://github.com/serengil/deepface_models/releases/download/v1.0/retinaface.h5 \
-O /home/user/.deepface/weights/retinaface.h5
USER user
ENV PATH="/home/user/.local/bin:$PATH"
COPY --chown=user requirements.txt .
# 1. Install base libraries
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# 2. Install DeepFace helpers
RUN pip install --no-cache-dir gdown fire tqdm Pillow requests Flask gunicorn
# 3. CRITICAL: Install deepface and retina-face without pulling conflicting deps
RUN pip install --no-cache-dir retina-face deepface --no-deps
COPY --chown=user . .
# Ensure all subdirectories are treated as packages
RUN touch core/__init__.py api/__init__.py services/__init__.py
# Run FastAPI app
CMD ["python", "app.py"]
|