FROM python:3.10-slim WORKDIR /app ENV DEBIAN_FRONTEND=noninteractive ENV TZ=UTC ENV FORCE_CUDA=0 ENV TORCH_CUDA_ARCH_LIST="" ENV HF_HOME=/app/hf_cache RUN apt-get update && apt-get install -y \ git gcc g++ ninja-build cmake \ libglib2.0-0 libsm6 libxext6 \ libgl1 libgomp1 \ python3-dev build-essential \ && rm -rf /var/lib/apt/lists/* # Pin numpy<2 before anything else RUN pip install --no-cache-dir "numpy<2" RUN pip install --no-cache-dir \ torch==2.1.0+cpu \ torchvision==0.16.0+cpu \ --index-url https://download.pytorch.org/whl/cpu RUN pip install --no-cache-dir \ 'git+https://github.com/facebookresearch/detectron2.git' \ --no-build-isolation # Upgrade Gradio to 4.x to fix the Jinja2 unhashable dict bug # Pin Jinja2 explicitly to avoid future breakage RUN pip install --no-cache-dir \ "gradio>=4.44.1" \ "huggingface_hub>=0.19.4" \ "opencv-python-headless" \ "Pillow>=9.0,<12.0" \ "jinja2>=3.1.2,<4.0" # Force numpy back to <2 in case any step above upgraded it RUN pip install --no-cache-dir "numpy<2" --force-reinstall RUN mkdir -p /app/hf_cache && \ useradd -m -u 1000 user && \ chown -R user:user /app USER user COPY --chown=user . /app EXPOSE 7860 # Fix: use the actual filename, not a markdown hyperlink CMD ["python", "app.py"]