fix: timeout VLM 15→60s + OCR zone élargie autour de l'ancre
Some checks failed
security-audit / Bandit (scan statique) (push) Successful in 12s
security-audit / pip-audit (CVE dépendances) (push) Successful in 10s
security-audit / Scan secrets (grep) (push) Successful in 8s
tests / Lint (ruff + black) (push) Successful in 14s
tests / Tests unitaires (sans GPU) (push) Failing after 14s
tests / Tests sécurité (critique) (push) Has been skipped
Some checks failed
security-audit / Bandit (scan statique) (push) Successful in 12s
security-audit / pip-audit (CVE dépendances) (push) Successful in 10s
security-audit / Scan secrets (grep) (push) Successful in 8s
tests / Lint (ruff + black) (push) Successful in 14s
tests / Tests unitaires (sans GPU) (push) Failing after 14s
tests / Tests sécurité (critique) (push) Has been skipped
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -199,11 +199,21 @@ def select_anchor():
|
|||||||
thumbnail.save(thumbnail_path, 'PNG')
|
thumbnail.save(thumbnail_path, 'PNG')
|
||||||
|
|
||||||
# ── Analyse automatique du crop : OCR + VLM ────────────────────
|
# ── Analyse automatique du crop : OCR + VLM ────────────────────
|
||||||
|
# Zone élargie autour de l'ancre pour capturer le texte à côté
|
||||||
|
margin = 50
|
||||||
|
expanded = img.crop((
|
||||||
|
max(0, x - margin),
|
||||||
|
max(0, y - margin),
|
||||||
|
min(img.width, x + w + margin * 3),
|
||||||
|
min(img.height, y + h + margin)
|
||||||
|
))
|
||||||
target_text = ""
|
target_text = ""
|
||||||
ocr_description = ""
|
ocr_description = ""
|
||||||
try:
|
try:
|
||||||
from services.ocr_service import ocr_extract_text
|
from services.ocr_service import ocr_extract_text
|
||||||
target_text = ocr_extract_text(thumbnail).strip()
|
target_text = ocr_extract_text(expanded).strip()
|
||||||
|
if not target_text:
|
||||||
|
target_text = ocr_extract_text(thumbnail).strip()
|
||||||
print(f"🔍 [OCR] Texte extrait de l'ancre: '{target_text}'")
|
print(f"🔍 [OCR] Texte extrait de l'ancre: '{target_text}'")
|
||||||
|
|
||||||
# Si le texte OCR est trop court ou vide, décrire via VLM
|
# Si le texte OCR est trop court ou vide, décrire via VLM
|
||||||
@@ -226,7 +236,7 @@ def select_anchor():
|
|||||||
"stream": False,
|
"stream": False,
|
||||||
"options": {"temperature": 0.1, "num_predict": 15}
|
"options": {"temperature": 0.1, "num_predict": 15}
|
||||||
},
|
},
|
||||||
timeout=15
|
timeout=60
|
||||||
)
|
)
|
||||||
if resp.status_code == 200:
|
if resp.status_code == 200:
|
||||||
ocr_description = resp.json().get("response", "").strip()
|
ocr_description = resp.json().get("response", "").strip()
|
||||||
|
|||||||
Reference in New Issue
Block a user