# Hugging Face Spaces (Docker SDK) image for the VLPS Gradio demo. # Models are pre-downloaded at build time (warmup.py) so first use is fast. FROM python:3.12-slim # System libs needed by OpenCV / EasyOCR. RUN apt-get update && apt-get install -y --no-install-recommends \ libgl1 libglib2.0-0 && \ rm -rf /var/lib/apt/lists/* # HF Spaces runs as a non-root user (uid 1000); keep caches in a writable home. RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH \ HF_HOME=/home/user/.cache/huggingface \ KMP_DUPLICATE_LIB_OK=TRUE \ VLPS_IMAGE_URLS=1 \ GRADIO_ANALYTICS_ENABLED=False WORKDIR /home/user/app # Install Python deps first (better layer caching). # CPU-only torch/torchvision keeps the image small (the CUDA build is several GB and # overflows the free-tier build); the LVLM runs remotely, so no GPU is needed here. COPY --chown=user requirements-space.txt . RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu && \ pip install --no-cache-dir -r requirements-space.txt # Bake model weights into the image. COPY --chown=user warmup.py . RUN python warmup.py # App code. COPY --chown=user src ./src COPY --chown=user web ./web COPY --chown=user core.py server.py ./ EXPOSE 7860 CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "7860"]