fix: stratégie hybride OCR→grounding VLM / icônes→template matching
Résolution 4/4 (100%) validée localement : - Texte OCR (by_text_source="ocr") → grounding Qwen2.5-VL (dist < 0.04) - Icônes sans texte (by_text_source="") → template matching crop 80x80 (dist = 0.000) Le VLM identify element est supprimé pour les icônes (descriptions non-déterministes qui faisaient échouer le grounding). Le template matching est instantané et parfait quand le crop est net (80x80). Ajout de by_text_source dans target_spec pour distinguer OCR vs VLM. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1141,25 +1141,28 @@ def build_replay_from_raw_events(
|
||||
)
|
||||
|
||||
# Déterminer le texte de l'élément cliqué (by_text)
|
||||
# Priorité : vision_info.text > som_element.label > VLM identification
|
||||
# Priorité : vision_info.text > som_element.label
|
||||
# Source "ocr" = fiable (texte réel), "vlm" = bavardage non-fiable
|
||||
element_text = ""
|
||||
element_type = ""
|
||||
text_source = "" # "ocr" ou "vlm"
|
||||
if isinstance(vision_info, dict):
|
||||
element_text = vision_info.get("text", "")
|
||||
element_type = vision_info.get("type", "")
|
||||
if element_text:
|
||||
text_source = "ocr"
|
||||
if not element_text and som_elem and som_elem.get("label"):
|
||||
element_text = som_elem["label"]
|
||||
text_source = "ocr"
|
||||
|
||||
# Si pas de texte (icône sans label), demander au VLM
|
||||
# d'identifier CE QUE c'est à partir du crop
|
||||
if not element_text and anchor_b64:
|
||||
element_text = _vlm_identify_element(
|
||||
anchor_b64, window_title,
|
||||
)
|
||||
# Icônes sans texte OCR → NE PAS utiliser le VLM pour nommer
|
||||
# (descriptions non-déterministes qui font échouer le grounding)
|
||||
# Le template matching du crop 80x80 sera utilisé à la place
|
||||
|
||||
action["target_spec"] = {
|
||||
"anchor_image_base64": anchor_b64,
|
||||
"by_text": element_text, # CE QUE l'élément EST
|
||||
"by_text": element_text,
|
||||
"by_text_source": text_source, # "ocr" = fiable, "" = icône
|
||||
"by_role": element_type or (som_elem.get("source", "") if som_elem else ""),
|
||||
"vlm_description": vlm_description,
|
||||
"window_title": window_title,
|
||||
|
||||
Reference in New Issue
Block a user