File size: 2,173 Bytes
f721589
f0482f1
7a5a98a
f0482f1
566d75f
f76887e
f721589
f0482f1
 
 
 
 
 
 
 
fbb6c1a
 
 
 
f1b0b27
ee3a08a
8f19f34
 
 
 
f721589
 
 
 
8f19f34
abec69f
 
 
8f19f34
 
 
 
 
abec69f
 
 
 
 
 
 
8f19f34
f0482f1
 
7a5a98a
f0482f1
7a5a98a
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
FROM python:3.11-slim

# System deps for OpenCV and MediaPipe
RUN apt-get update && apt-get install -y --no-install-recommends \
    libgl1 libglib2.0-0 libsm6 libxext6 libxrender1 wget unzip git \
    libegl1 libgles2 libgomp1 \
    g++ && \
    rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# MiVOLO was tried for age regression but its codepath imports
# functions removed from modern timm (remap_checkpoint). Reverted to
# InsightFace's bundled genderage head with piecewise calibration —
# see _calibrate_age in analyzers/insightface_analyzer.py.

# Pre-download MediaPipe model at build time so first request is fast.
# Hugging Face models (Ethnicity ViT, SegFormer, HSEmotion, ObstructionViT,
# HairTypeViT) and the InsightFace buffalo_l bundle are pulled lazily on
# first request and cached in /root/.cache for the lifetime of the
# container.
RUN mkdir -p models && \
    wget -q -O models/face_landmarker.task \
    "https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/latest/face_landmarker.task"

# Pre-download InsightFace buffalo_l bundle (detection + recognition +
# 106 landmarks) so the first /analyze call doesn't pay the ~280MB
# download. The bundle auto-extracts under ~/.insightface/models/ on
# first use.
RUN mkdir -p /root/.insightface/models && \
    wget -q -O /root/.insightface/models/buffalo_l.zip \
    "https://github.com/deepinsight/insightface/releases/download/v0.7/buffalo_l.zip" && \
    cd /root/.insightface/models && unzip -q buffalo_l.zip -d buffalo_l && rm buffalo_l.zip

# MiVOLO checkpoint is too large for the Docker image (~300 MB) — it's
# lazy-downloaded from HF Hub on first AgeAnalyzer init, via
# AGE_HF_REPO_ID (defaults to iitolstykh/mivolo_d1). To bundle it at
# build time instead, uncomment the lines below and pin the filename.
# RUN mkdir -p models && \
#     wget -q -O models/mivolo_d1.pth.tar \
#     "https://huggingface.co/iitolstykh/mivolo_d1/resolve/main/mivolo_d1.pth.tar"

COPY . .

EXPOSE 7860

CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]