File size: 1,483 Bytes
90e92b9
 
 
 
546b3e9
90e92b9
 
 
3f71436
 
 
 
 
90e92b9
 
546b3e9
ccf96cc
 
546b3e9
 
ccf96cc
90e92b9
3f71436
 
 
 
 
323edcf
 
 
2bacef8
90e92b9
 
 
 
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
FROM python:3.10-slim

WORKDIR /app

RUN apt-get update && apt-get install -y --no-install-recommends libgl1 libglib2.0-0 wget \
    && rm -rf /var/lib/apt/lists/*

COPY requirements.txt .

# PyTorch CPU-only por separado (lo necesitan easyocr y simple-lama-inpainting).
RUN pip install --no-cache-dir torch==2.0.1 torchvision==0.15.2 \
    --index-url https://download.pytorch.org/whl/cpu

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

# Descarga el modelo BiRefNet durante el build, para que el servidor
# quede autocontenido. Apunta a tu propio repo de Hugging Face en vez de
# GitHub, para no depender de que un tercero mantenga el link activo.
RUN mkdir -p /root/.u2net && \
    wget -q -O /root/.u2net/birefnet-general.onnx \
      https://huggingface.co/zgrafic/r/resolve/main/BiRefNet-general-epoch_244.onnx

# Descarga los modelos de OCR y de reconstrucción de fondo (LaMa),
# para el endpoint /extract-text.
RUN python -c "import easyocr; easyocr.Reader(['es', 'en'], gpu=False)"
RUN python -c "from simple_lama_inpainting import SimpleLama; SimpleLama()"

# Descarga el modelo de identificación de fuentes (licencia MIT).
RUN python -c "from transformers import AutoImageProcessor, AutoModelForImageClassification; AutoImageProcessor.from_pretrained('gaborcselle/font-identifier'); AutoModelForImageClassification.from_pretrained('gaborcselle/font-identifier')"

COPY app.py bot.py .

EXPOSE 7860

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