- nouveau module src/scalper/inpaint.py : protocol Inpainter, SimpleInpainter (remplissage par couleur de fond, ex-comportement) et LamaInpainter (big-lama advimman/lama via port ONNX Carve/LaMa-ONNX, onnxruntime CPU) : crop carre 512x512 avec contexte par region, masque polygone OCR (poly) ou rectangle dilate, composite uniquement des pixels masques a la resolution d'origine ; modele telecharge une fois (208 Mo, sha256 verifie) dans SCALPER_LAMA_CACHE, SCALPER_LAMA_MODEL pour un fichier local - selection par SCALPER_INPAINT_ENGINE / --inpaint-engine / "inpaint_engine" (simple|lama|auto, defaut auto = lama si onnxruntime installe) - typeset.py : inpainting de toute l'image via l'Inpainter puis retypographie de la traduction (Pillow) ; ocr.py : PaddleOCR expose le quadrilatere poly - pipeline/cli/server : parametre inpaint_engine cable de bout en bout - packaging : extra .[inpaint-lama] (onnxruntime+numpy), Dockerfile, entrypoint.sh (SCALPER_LAMA_CACHE=/app/data/.lama), docker-compose (SCALPER_INPAINT_ENGINE=lama), .env.example, README - tests : tests/test_inpaint.py (moteurs, masque, crop, telechargement sha256, LaMa avec session factice + test reel optionnel SCALPER_TEST_LAMA_MODEL) Verifie en reel sur une page du out/ : 0 pixel modifie hors masques, contraste du texte efface dans les boites, traduction reinseree par-dessus (~2,2 s/region en CPU). Suite complete : 74 passed, 1 skipped. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
30 lines
934 B
Docker
30 lines
934 B
Docker
FROM python:3.12-slim
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
tesseract-ocr fonts-dejavu-core \
|
|
libgl1 libglib2.0-0 libgomp1 \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app
|
|
|
|
COPY pyproject.toml README.md ./
|
|
COPY src ./src
|
|
|
|
RUN pip install --no-cache-dir ".[ocr,ocr-paddle,inpaint-lama]"
|
|
|
|
RUN useradd -m scalper && mkdir -p /app/data /app/out && chown -R scalper:scalper /app
|
|
|
|
# Le conteneur démarre en root : l'entrypoint chown les répertoires montés
|
|
# (bind mounts root côté hôte, ex. Coolify) puis droppe les privilèges (setpriv).
|
|
COPY entrypoint.sh /entrypoint.sh
|
|
RUN chmod +x /entrypoint.sh
|
|
|
|
ENV PYTHONUNBUFFERED=1
|
|
EXPOSE 8000
|
|
|
|
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
|
|
CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/healthz')" || exit 1
|
|
|
|
ENTRYPOINT ["/entrypoint.sh"]
|
|
CMD ["scalper", "serve", "--host", "0.0.0.0", "--port", "8000"]
|