From ad7ff3bce4b7bfcde862ce273d3ce6b9181dafdb Mon Sep 17 00:00:00 2001 From: Dom Date: Wed, 18 Mar 2026 22:57:36 +0100 Subject: [PATCH] =?UTF-8?q?perf:=20r=C3=A9duire=20crops=20VLM=2080?= =?UTF-8?q?=E2=86=9230=20+=20fix=20bridge=20learned=20workflows=20path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 30 crops suffisent pour les éléments UI principaux - ~6min/screenshot au lieu de 17min (3x plus rapide) - Bridge cherche aussi dans live_sessions/workflows/ Co-Authored-By: Claude Opus 4.6 (1M context) --- core/detection/ui_detector.py | 2 +- .../services/learned_workflow_bridge.py | 23 +++++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/core/detection/ui_detector.py b/core/detection/ui_detector.py index f5011ef2b..b2dc1aa06 100644 --- a/core/detection/ui_detector.py +++ b/core/detection/ui_detector.py @@ -217,7 +217,7 @@ class UIDetector: # des centaines d'appels VLM inutiles (~2-3s chacun). # On garde max 80 candidats — suffisant pour obtenir ~50 éléments # après filtrage par confiance, tout en gardant un temps raisonnable. - max_candidates = 80 + max_candidates = 30 # 30 suffisent pour les éléments principaux (~6min/screenshot au lieu de 17) if len(regions) > max_candidates: # Trier par confiance décroissante, puis par surface décroissante regions.sort(key=lambda r: (r.confidence, r.w * r.h), reverse=True) diff --git a/visual_workflow_builder/backend/services/learned_workflow_bridge.py b/visual_workflow_builder/backend/services/learned_workflow_bridge.py index 28bc20b0f..8bcfe0bb5 100644 --- a/visual_workflow_builder/backend/services/learned_workflow_bridge.py +++ b/visual_workflow_builder/backend/services/learned_workflow_bridge.py @@ -553,8 +553,14 @@ def list_learned_workflows_from_disk() -> List[Dict[str, Any]]: Retourne une liste de dicts avec les métadonnées de base. """ - base_dir = Path(_ROOT) / "data" / "training" / "workflows" - if not base_dir.exists(): + # Chercher dans les deux emplacements possibles + base_dirs = [ + Path(_ROOT) / "data" / "training" / "workflows", + Path(_ROOT) / "data" / "training" / "live_sessions" / "workflows", + ] + + existing_dirs = [d for d in base_dirs if d.exists()] + if not existing_dirs: return [] workflows = [] @@ -578,13 +584,12 @@ def list_learned_workflows_from_disk() -> List[Dict[str, Any]]: except Exception as e: logger.warning("Erreur lecture %s : %s", f, e) - # Racine - _scan_dir(base_dir) - - # Sous-dossiers machine - for machine_dir in sorted(base_dir.iterdir()): - if machine_dir.is_dir(): - _scan_dir(machine_dir, machine_id=machine_dir.name) + # Scanner tous les répertoires trouvés + for base_dir in existing_dirs: + _scan_dir(base_dir) + for machine_dir in sorted(base_dir.iterdir()): + if machine_dir.is_dir(): + _scan_dir(machine_dir, machine_id=machine_dir.name) return workflows