File size: 1,054 Bytes
af4d3c9
40c79b0
508c8f2
40c79b0
af4d3c9
 
 
 
 
 
40c79b0
af4d3c9
40c79b0
af4d3c9
f0ea208
af4d3c9
 
40c79b0
 
f0ea208
af4d3c9
508c8f2
 
 
 
 
 
 
af4d3c9
12a4071
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
FROM python:3.11-slim

WORKDIR /home/user

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

RUN pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu

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

RUN pip install --no-cache-dir playwright && \
    mkdir -p /home/user/.cache/ms-playwright && \
    PLAYWRIGHT_BROWSERS_PATH=/home/user/.cache/ms-playwright playwright install chromium --with-deps && \
    rm -rf /var/lib/apt/lists/*

ENV PORT=7860
ENV PLAYWRIGHT_BROWSERS_PATH=/home/user/.cache/ms-playwright
ENV HF_HOME=/home/user/.cache/huggingface
RUN chmod -R 755 /home/user

RUN python -c "from transformers import AutoModelForImageSegmentation; AutoModelForImageSegmentation.from_pretrained('briaai/RMBG-1.4', trust_remote_code=True)"

COPY . .

EXPOSE 7860

CMD ["python", "-m", "hypercorn", "server:app", "-b", "0.0.0.0:7860", "--access-log", "-", "--error-log", "-", "--log-level", "info"]