DepthPro-Api / Dockerfile
zeidImigine's picture
Update Dockerfile
95d4877 verified
# ──────────────────────────────────────────────────────────────
# Depth Pro (Apple) β€” HuggingFace Space (Docker SDK)
# CPU-only | transformers>=4.49.0 | zΓ©ro dΓ©pendance complexe
# ──────────────────────────────────────────────────────────────
FROM python:3.10-slim
ENV DEBIAN_FRONTEND=noninteractive \
PYTHONUNBUFFERED=1 \
HF_HOME=/app/.cache/huggingface
WORKDIR /app
# 1) Torch CPU-only (Γ©vite 2Go de CUDA inutile)
RUN pip install --no-cache-dir \
torch==2.3.0+cpu \
torchvision==0.18.0+cpu \
--index-url https://download.pytorch.org/whl/cpu
# 2) Reste des dΓ©pendances
RUN pip install --no-cache-dir \
fastapi==0.111.0 \
"uvicorn[standard]==0.29.0" \
python-multipart==0.0.9 \
transformers==4.49.0 \
numpy==1.26.4 \
Pillow==10.3.0
# 3) PrΓ©-tΓ©lΓ©charger les poids Depth Pro au build
# (~1.3 Go β€” Γ©vite le cold-start Γ  chaque dΓ©marrage)
RUN python -c "\
from transformers import DepthProImageProcessorFast, DepthProForDepthEstimation; \
print('TΓ©lΓ©chargement Depth Pro ...'); \
DepthProImageProcessorFast.from_pretrained('apple/DepthPro-hf'); \
DepthProForDepthEstimation.from_pretrained('apple/DepthPro-hf'); \
print('Poids en cache OK.')"
COPY app.py .
EXPOSE 7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]