Arahman-ai
fix: pre-download YOLOv8 models at build time to avoid 403 on HuggingFace
0f3ae75
Raw
History Blame Contribute Delete
1.07 kB
FROM python:3.11-slim
# System dependencies
RUN apt-get update && apt-get install -y \
libgl1 \
libglib2.0-0 \
libsm6 \
libxrender1 \
libxext6 \
ffmpeg \
git \
curl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir \
opencv-python-headless \
ultralytics \
Pillow \
streamlit \
numpy \
pandas \
python-dotenv \
loguru \
pydantic \
boto3 \
google-cloud-storage
# Pre-download YOLOv8 models at build time (avoids runtime 403)
RUN python -c "from ultralytics import YOLO; YOLO('yolov8n.pt'); YOLO('yolov8s.pt'); print('Models downloaded!')"
# Copy project files
COPY . .
# HuggingFace Spaces port
EXPOSE 7860
ENV STREAMLIT_SERVER_PORT=7860
ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
ENV STREAMLIT_SERVER_HEADLESS=true
ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
CMD ["streamlit", "run", "dashboard/app.py", \
"--server.port=7860", \
"--server.address=0.0.0.0", \
"--server.headless=true"]