File size: 942 Bytes
56749a4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM python:3.12-slim

# HF Spaces runs containers as a non-root user; create one and give it a writable
# HF cache so the baked-in model is readable at runtime.
RUN useradd -m -u 1000 user
ENV HF_HOME=/home/user/.cache/huggingface \
    PYTHONUNBUFFERED=1
WORKDIR /home/user/app

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

ARG SIGLIP_MODEL_ID=onnx-community/siglip2-base-patch16-256-ONNX
ENV SIGLIP_MODEL_ID=${SIGLIP_MODEL_ID}
COPY text_encoder.py app.py ./

USER user
# Bake the 283 MB text tower + tokenizer into the image so a post-sleep wake
# never re-downloads from HuggingFace.
RUN python -c "import os; \
from huggingface_hub import hf_hub_download; \
from transformers import AutoTokenizer; \
m = os.environ['SIGLIP_MODEL_ID']; \
hf_hub_download(m, 'onnx/text_model_quantized.onnx'); \
AutoTokenizer.from_pretrained(m)"

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