File size: 1,162 Bytes
ce2cd37
c51558e
ce2cd37
c51558e
ce2cd37
 
 
 
 
c51558e
 
ce2cd37
 
c51558e
 
ce2cd37
 
 
0a4d26a
ce2cd37
0a4d26a
ce2cd37
 
 
c51558e
ce2cd37
c51558e
ce2cd37
0a4d26a
ce2cd37
 
c51558e
 
 
ce2cd37
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
FROM python:3.10-slim

ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    HF_HOME=/home/appuser/.cache/huggingface \
    TOKENIZERS_PARALLELISM=false \
    OMP_NUM_THREADS=2 \
    MKL_NUM_THREADS=2 \
    PORT=7860

RUN apt-get update && apt-get install -y --no-install-recommends \
    ca-certificates \
    libgomp1 \
    && rm -rf /var/lib/apt/lists/*

RUN useradd --create-home --uid 1000 appuser \
    && mkdir -p /app /home/appuser/.cache/huggingface \
    && chown -R appuser:appuser /app /home/appuser/.cache

WORKDIR /app

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

COPY --chown=appuser:appuser app.py .

USER appuser

# Store the weights in the Docker image so restarts only load from local disk.
RUN python -c "from transformers import AutoModelForZeroShotObjectDetection, AutoProcessor; model_id='IDEA-Research/grounding-dino-base'; AutoProcessor.from_pretrained(model_id); AutoModelForZeroShotObjectDetection.from_pretrained(model_id, low_cpu_mem_usage=True)"

EXPOSE 7860

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