File size: 1,218 Bytes
5dab1e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# A-EYE hybrid backend + web UI for Hugging Face Docker Spaces (CPU).
FROM python:3.11-slim

ENV PYTHONUNBUFFERED=1 \
    PIP_NO_CACHE_DIR=1

# HF Docker Spaces run the container as UID 1000.
RUN useradd -m -u 1000 appuser
ENV HOME=/home/appuser \
    HF_HOME=/home/appuser/.cache/huggingface

WORKDIR /app

COPY requirements.txt .
# CPU-only torch keeps the image small (default pip wheel bundles CUDA).
RUN pip install --upgrade pip \
    && pip install torch==2.8.0 torchvision==0.23.0 --index-url https://download.pytorch.org/whl/cpu \
    && pip install -r requirements.txt

# Bake the frozen CLIP-L backbone into the image so cold starts skip the ~1.7GB
# download (checkpoints only store the trainable heads).
RUN python -c "from transformers import CLIPVisionModelWithProjection as M; M.from_pretrained('openai/clip-vit-large-patch14')" \
    && chown -R appuser:appuser /home/appuser/.cache

COPY --chown=appuser:appuser . .

USER appuser

ENV AEYE_DEVICE=cpu \
    VERDICT_MODEL_PATH=/app/models/best49.pt \
    HEATMAP_MODEL_PATH=/app/models/best63.pt \
    HF_HUB_OFFLINE=1 \
    TRANSFORMERS_OFFLINE=1

EXPOSE 7860
CMD ["python", "-m", "uvicorn", "main_hybrid:app", "--host", "0.0.0.0", "--port", "7860"]