Spaces:
Sleeping
Sleeping
| # Image Processor Pro — Hugging Face Spaces (Docker SDK). | |
| # Mirrors the Python 3.9 environment the app was built and tested on locally. | |
| FROM python:3.9-slim | |
| # Shared libs that opencv-python needs at runtime. | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| libgl1 \ | |
| libglib2.0-0 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Hugging Face Spaces runs the container as uid 1000. | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH \ | |
| PYTHONUNBUFFERED=1 \ | |
| HF_HUB_DISABLE_TELEMETRY=1 | |
| WORKDIR /home/user/app | |
| # Install CPU-only PyTorch explicitly so we don't pull the ~2 GB CUDA build. | |
| RUN pip install --no-cache-dir --upgrade pip \ | |
| && pip install --no-cache-dir \ | |
| torch==2.8.0 torchvision==0.23.0 \ | |
| --index-url https://download.pytorch.org/whl/cpu | |
| # Then the application dependencies (Flask, OpenCV, LaMa, ...). | |
| COPY --chown=user:user requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Application code (see .dockerignore for what is excluded). | |
| COPY --chown=user:user . . | |
| # Bake the LaMa weights into the image so the first request after a cold start | |
| # doesn't have to download ~200 MB. | |
| RUN python -c "from simple_lama_inpainting.utils import download_model; \ | |
| from simple_lama_inpainting.models.model import LAMA_MODEL_URL; download_model(LAMA_MODEL_URL)" | |
| # HF Spaces routes traffic to this port (also declared as app_port in README.md). | |
| EXPOSE 7860 | |
| CMD ["python", "webapp.py", "--host", "0.0.0.0", "--port", "7860"] | |