Merge pull request 'Fix image detection after print-to-logging migration' (#22) from fix/app-image-detection into main

Reviewed-on: #22
This commit was merged in pull request #22.
This commit is contained in:
2026-03-19 19:15:44 +00:00

5
app.py
View File

@@ -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]]: def run_prompt_pipeline(prompt_text: str) -> tuple[Path | None, str, list[str]]:
save_path = "generated_card.png"
cmd = [ cmd = [
sys.executable, "prompt_to_card_pipeline.py", sys.executable, "prompt_to_card_pipeline.py",
prompt_text, 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", "--template", "clean-text-to-keywords/json_template_example.json",
"--generator-module", "card_generator_adapter.py", "--generator-module", "card_generator_adapter.py",
"--device", "cuda", "--device", "cuda",
"--save-path", "generated_card.png", "--save-path", save_path,
"--print-json", "--print-json",
] ]
@@ -63,6 +64,8 @@ def run_prompt_pipeline(prompt_text: str) -> tuple[Path | None, str, list[str]]:
if result.returncode != 0: if result.returncode != 0:
return None, full_output.strip() or "Erreur inconnue pendant le pipeline.", cmd return None, full_output.strip() or "Erreur inconnue pendant le pipeline.", cmd
image_path = APP_DIR / save_path
if not image_path.exists():
image_path = _extract_image_from_stdout(result.stdout or "") image_path = _extract_image_from_stdout(result.stdout or "")
return image_path, full_output.strip(), cmd return image_path, full_output.strip(), cmd