visual-search-api2 / Dockerfile
AdarshDRC's picture
fix: face not detecting
f52e620
Raw
History Blame
2.79 kB
# Dockerfile — Enterprise Lens V3
# InsightFace models download on first run (not at build time)
# This avoids build timeout and network issues during Docker build
FROM python:3.10-slim
WORKDIR /app
# ── System deps ──────────────────────────────────────────────────
RUN apt-get update && apt-get install -y --no-install-recommends \
libgl1 libglib2.0-0 libgomp1 git \
build-essential cmake g++ \
libopenblas-dev liblapack-dev \
wget ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# ── Step 1: Build tools (MUST be before insightface) ─────────────
RUN pip install --no-cache-dir \
"numpy<2.0" \
"setuptools>=65" \
wheel \
cython \
scikit-build \
cmake
# ── Step 2: onnxruntime (MUST be before insightface) ─────────────
RUN pip install --no-cache-dir onnxruntime
# ── Step 3: insightface ───────────────────────────────────────────
RUN pip install --no-cache-dir --prefer-binary "insightface>=0.7.3"
# ── Step 4: Remaining requirements ───────────────────────────────
COPY requirements.txt .
RUN pip install --no-cache-dir --prefer-binary -r requirements.txt
# ── Copy app code ─────────────────────────────────────────────────
COPY . .
RUN mkdir -p temp_uploads saved_images && chmod -R 777 temp_uploads saved_images
# ── Pre-download ONLY transformers + YOLO at build time ──────────
# InsightFace models download on first startup (cached after that)
RUN python - <<'EOF'
import os
os.environ["TRANSFORMERS_VERBOSITY"] = "error"
print("Pre-downloading SigLIP...")
from transformers import AutoProcessor, AutoModel
AutoProcessor.from_pretrained("google/siglip-base-patch16-224", use_fast=True)
AutoModel.from_pretrained("google/siglip-base-patch16-224")
print("SigLIP done")
print("Pre-downloading DINOv2...")
from transformers import AutoImageProcessor
AutoImageProcessor.from_pretrained("facebook/dinov2-base")
AutoModel.from_pretrained("facebook/dinov2-base")
print("DINOv2 done")
print("Pre-downloading YOLO seg...")
from ultralytics import YOLO
YOLO("yolo11n-seg.pt")
print("YOLO done")
print("Build complete! InsightFace models download on first startup.")
EOF
EXPOSE 7860
ENV WEB_CONCURRENCY=1
CMD uvicorn main:app \
--host 0.0.0.0 \
--port 7860 \
--workers ${WEB_CONCURRENCY} \
--timeout-keep-alive 75