Spaces:
Running
Running
| FROM python:3.9-slim | |
| WORKDIR /app | |
| # System deps (minimal and safe) | |
| # libgl1 and libglib2.0-0 are required for OpenCV | |
| # libgomp1 is required for PaddlePaddle math operations | |
| RUN apt-get update && apt-get install -y \ | |
| libgl1 \ | |
| libglib2.0-0 \ | |
| libgomp1 \ | |
| git \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Upgrade pip stack | |
| RUN pip install --no-cache-dir --upgrade pip setuptools wheel | |
| # 🔒 HARD PIN numpy BEFORE paddle | |
| # This prevents the binary incompatibility with newer numpy 2.x | |
| RUN pip install --no-cache-dir "numpy==1.26.4" | |
| # PaddlePaddle CPU (stable version 2.6.2 matches well with OCR 2.7.x) | |
| RUN pip install --no-cache-dir paddlepaddle==2.6.2 | |
| # PaddleOCR + API stack | |
| # 2.7.3 is a "Golden" version: very stable, no weird dependency bugs | |
| RUN pip install --no-cache-dir \ | |
| paddleocr==2.7.3 \ | |
| opencv-python-headless==4.11.0.86 \ | |
| fastapi \ | |
| uvicorn \ | |
| python-multipart \ | |
| pillow | |
| # Copy app code | |
| COPY main.py . | |
| # 🚫 DO NOT preload models during build | |
| # NOTE: The first time you send a request, it will take ~20-40s to | |
| # download the detection and classification models. | |
| # Subsequent requests will be fast. | |
| CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] |