Fix image detection after print-to-logging migration #22
5
app.py
5
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,6 +64,8 @@ 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 = 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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user