From e03daea1f3cb2318f70fddeac4e8eb347f122422 Mon Sep 17 00:00:00 2001 From: Louis Labeyrie Date: Thu, 19 Mar 2026 20:14:17 +0100 Subject: [PATCH] Fix image detection after print-to-logging migration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit app.py relied on parsing stdout for the save path printed by the pipeline. After PR #21 replaced that print with logger.info(), the stdout parsing returned None, causing "Aucune image générée détectée". Now check the known save path directly (APP_DIR / save_path) and only fall back to stdout parsing if the file isn't found. --- app.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 0b4b828..cce9f23 100644 --- a/app.py +++ b/app.py @@ -37,6 +37,7 @@ def _extract_image_from_stdout(stdout: str) -> Path | None: def run_prompt_pipeline(prompt_text: str) -> tuple[Path | None, str, list[str]]: + save_path = "generated_card.png" cmd = [ sys.executable, "prompt_to_card_pipeline.py", prompt_text, @@ -46,7 +47,7 @@ def run_prompt_pipeline(prompt_text: str) -> tuple[Path | None, str, list[str]]: "--template", "clean-text-to-keywords/json_template_example.json", "--generator-module", "card_generator_adapter.py", "--device", "cuda", - "--save-path", "generated_card.png", + "--save-path", save_path, "--print-json", ] @@ -63,7 +64,9 @@ def run_prompt_pipeline(prompt_text: str) -> tuple[Path | None, str, list[str]]: if result.returncode != 0: return None, full_output.strip() or "Erreur inconnue pendant le pipeline.", cmd - image_path = _extract_image_from_stdout(result.stdout or "") + image_path = APP_DIR / save_path + if not image_path.exists(): + image_path = _extract_image_from_stdout(result.stdout or "") return image_path, full_output.strip(), cmd # ------------------------------------------------------------------ #