Spaces:
Sleeping
Sleeping
| 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"] | |