# Hugging Face Spaces — Docker deployment # SDK: docker | app_port: 7860 # # Build context is the repo root. # Only backend/ and models/ are copied in; DataSet/ is intentionally excluded. FROM python:3.11-slim # System libraries required by opencv-python-headless RUN apt-get update && apt-get install -y --no-install-recommends \ libglib2.0-0 \ libgl1 \ && rm -rf /var/lib/apt/lists/* # HF Spaces runs containers as uid 1000 by default RUN useradd -m -u 1000 appuser WORKDIR /app # Install CPU-only PyTorch first so pip does not download the large CUDA wheels RUN pip install --no-cache-dir \ torch==2.2.2+cpu \ torchvision==0.17.2+cpu \ --index-url https://download.pytorch.org/whl/cpu # Install remaining API dependencies COPY requirements-hf.txt requirements-hf.txt RUN pip install --no-cache-dir -r requirements-hf.txt # Copy only what the API needs at runtime COPY --chown=appuser:appuser backend/ backend/ COPY --chown=appuser:appuser models/ models/ USER appuser EXPOSE 7860 CMD ["python", "-m", "uvicorn", "backend.app.main:app", \ "--host", "0.0.0.0", "--port", "7860"]