FROM python:3.10-slim # System dependencies (gcc/g++ needed for pycocotools) RUN apt-get update && apt-get install -y \ libgl1 \ libglib2.0-0 \ gcc \ g++ \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Install PyTorch CPU first (use --extra-index-url for CPU wheels) RUN pip install --no-cache-dir \ torch==1.13.1+cpu \ torchvision==0.14.1+cpu \ --extra-index-url https://download.pytorch.org/whl/cpu # Install mmcv (lite version - pure Python, no C++ compilation) RUN pip install --no-cache-dir mmcv==1.7.2 # Create mmcv.ops shim using torchvision COPY setup_mmcv_shim.py . RUN python setup_mmcv_shim.py # Install remaining dependencies RUN pip install --no-cache-dir \ gradio>=5.0.0 \ opencv-python-headless>=4.8.0 \ "numpy>=1.24.0,<2.0.0" \ easyocr>=1.7.0 \ scikit-image>=0.21.0 \ scipy>=1.9.0 \ bresenham \ terminaltables \ matplotlib \ pycocotools # Copy application code COPY . . # HF Spaces expects port 7860 EXPOSE 7860 CMD ["python", "api_server.py"]