retvim-demo2 / Dockerfile
Earther's picture
chore: trigger fresh space rebuild 2026-03-28
261c1e4
Raw
History Blame Contribute Delete
1.56 kB
# ── Stage: RetViM HuggingFace Space ──────────────────────────────────────────
# rebuild trigger: 2026-03-28
FROM python:3.11-slim
WORKDIR /app
# System dependencies for Pillow / OpenCV / matplotlib
RUN apt-get update && apt-get install -y --no-install-recommends \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
libgl1 \
libgomp1 \
&& rm -rf /var/lib/apt/lists/*
# ── Install PyTorch CPU-only first (saves ~1.8 GB vs default CUDA wheel) ─────
# HF free-tier Spaces have no GPU, so CPU-only is both correct and fast.
RUN pip install --no-cache-dir \
torch==2.2.0 \
torchvision==0.17.0 \
--index-url https://download.pytorch.org/whl/cpu
# ── Remaining Python dependencies (layer-cached before code copy) ─────────────
RUN pip install --no-cache-dir \
"fastapi==0.104.1" \
"uvicorn[standard]==0.24.0" \
"timm>=0.9.10" \
"Pillow>=10.1.0" \
"numpy>=1.26.2,<2" \
"matplotlib>=3.8.2" \
"scikit-learn>=1.3.2" \
"scipy>=1.11.4" \
"python-multipart==0.0.6" \
"einops==0.7.0" \
"python-dotenv==1.0.0"
# Copy application source + frontend HTML
COPY *.py .
COPY retvim-final.html .
# Copy model weights (tracked via Git LFS)
COPY real_weights.pth .
# Copy research figure images for /images static route
COPY images/ images/
# HuggingFace Spaces listens on 7860
EXPOSE 7860
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]