File size: 1,633 Bytes
c26f873 8b303ba c26f873 8b303ba c26f873 8b303ba c26f873 42e845b b958c76 42e845b 209084a c26f873 d44acb9 c26f873 209084a f255cbf 209084a c26f873 bb3ea41 c26f873 8b303ba c26f873 8b303ba c26f873 8b303ba c26f873 8b303ba c26f873 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | 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"]
|