| FROM python:3.11-slim | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| git \ | |
| ffmpeg \ | |
| build-essential \ | |
| curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Install uv | |
| COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv | |
| # Set working directory | |
| WORKDIR /app | |
| # Clone ByteTrack | |
| RUN git clone https://github.com/ifzhang/ByteTrack.git | |
| # Fix ByteTrack dependencies and code | |
| WORKDIR /app/ByteTrack | |
| RUN sed -i '/lap/d' requirements.txt && \ | |
| sed -i '/onnx-simplifier/d' requirements.txt && \ | |
| sed -i '/numpy/d' requirements.txt && \ | |
| sed -i '/motmetrics/d' requirements.txt && \ | |
| sed -i 's/opencv_python/opencv-python-headless/g' requirements.txt | |
| # Relax onnx versions | |
| RUN sed -i 's/onnx==1.8.1/onnx>=1.9.0/g' requirements.txt && \ | |
| sed -i 's/onnxruntime==1.8.0/onnxruntime>=1.8.0/g' requirements.txt | |
| # Fix np.float in python files using safe script | |
| COPY fix_code.py /app/ByteTrack/ | |
| RUN python fix_code.py && rm fix_code.py | |
| # Pre-install build dependencies (Required for cython_bbox calculation) | |
| RUN uv pip install --system cython numpy | |
| # Install packages that usually require compilation or have tricky deps | |
| RUN uv pip install --system cython_bbox lapx | |
| # Install ByteTrack | |
| RUN uv pip install --system -r requirements.txt | |
| RUN uv pip install --system --no-build-isolation -e . | |
| WORKDIR /app | |
| # Copy project files | |
| COPY pyproject.toml . | |
| COPY app.py . | |
| COPY tracker.py . | |
| COPY utils.py . | |
| COPY speed_config.py . | |
| # Install project dependencies | |
| RUN uv pip install --system -r pyproject.toml | |
| # Expose port (Hugging Face Spaces uses 7860) | |
| EXPOSE 7860 | |
| # Run the app | |
| CMD ["uv", "run", "app.py"] | |