FROM python:3.10-slim WORKDIR /app # System dependencies for OpenCV RUN apt-get update && apt-get install -y \ libgl1 \ libglib2.0-0 \ git \ && rm -rf /var/lib/apt/lists/* # Clone the MiVOLO repository RUN git clone https://github.com/WildChlamydia/MiVOLO.git /app/mivolo_repo # Install PyTorch CPU-only (much lighter than full GPU build) RUN pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu # Install remaining API dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy our API entrypoint and the uploaded checkpoint file COPY app.py . COPY *.pth.tar ./ # Hugging Face Spaces use port 7860 EXPOSE 7860 # NOTE: We do NOT pre-load models here to avoid OOM during build. # Models download on the first API request at runtime (16GB RAM available). CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]