From 94b927c06b6a58031adacff7973487456e143026 Mon Sep 17 00:00:00 2001 From: Louis Labeyrie Date: Thu, 19 Mar 2026 18:42:25 +0100 Subject: [PATCH 1/2] fix: broken subprocess command and tuple unpacking in app.py Fix two critical bugs that made the Streamlit app completely non-functional: 1. Split subprocess command into properly separated list elements and use sys.executable instead of hardcoded "python" (#1) 2. Unpack all 3 return values from run_prompt_pipeline() (#2) Closes #1, closes #2 --- app.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index 76c50be..0324803 100644 --- a/app.py +++ b/app.py @@ -33,10 +33,16 @@ def _extract_image_from_stdout(stdout: str) -> Path | None: def run_prompt_pipeline(prompt_text: str) -> tuple[Path | None, str, list[str]]: cmd = [ - "python prompt_to_card_pipeline.py ", + sys.executable, "prompt_to_card_pipeline.py", prompt_text, - "--text-cleaner-path text-cleaner/text_cleaning_pipeline.py --infer-script-path clean-text-to-keywords/infer_json_usage.py --checkpoint pokemon_card_lora --template clean-text-to-keywords/json_template_example.json --generator-module card_generator_adapter.py --device cuda --save-path generated_card.png --print-json" - + "--text-cleaner-path", "text-cleaner/text_cleaning_pipeline.py", + "--infer-script-path", "clean-text-to-keywords/infer_json_usage.py", + "--checkpoint", "pokemon_card_lora", + "--template", "clean-text-to-keywords/json_template_example.json", + "--generator-module", "card_generator_adapter.py", + "--device", "cuda", + "--save-path", "generated_card.png", + "--print-json", ] result = subprocess.run( @@ -116,7 +122,7 @@ if generate: st.warning("Veuillez entrer une description avant de générer.") else: with st.spinner("Génération de la carte Pokémon..."): - image, logs = run_prompt_pipeline(raw_text) + image, logs, _cmd = run_prompt_pipeline(raw_text) if image is not None: st.image(image, caption="Carte Pokémon générée", width="stretch") From 577308af17df088e7fd939ee17db0d18990a9a9f Mon Sep 17 00:00:00 2001 From: Louis Labeyrie Date: Thu, 19 Mar 2026 19:12:29 +0100 Subject: [PATCH 2/2] fix: extract image path from prefixed stdout line _extract_image_from_stdout() failed to find the generated image because the pipeline prints "Card generated and saved to: generated_card.png" but the function only tried the full line as a path. Now also tries the part after the last colon. --- app.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/app.py b/app.py index 0324803..0b4b828 100644 --- a/app.py +++ b/app.py @@ -16,16 +16,21 @@ IMAGE_EXTENSIONS = (".png", ".jpg", ".jpeg", ".webp", ".bmp") def _extract_image_from_stdout(stdout: str) -> Path | None: for line in reversed(stdout.splitlines()): - text = line.strip().strip("\"'") - if not text: - continue + # Try the whole line, then the part after the last colon + # (handles "Card generated and saved to: generated_card.png") + raw = line.strip().strip("\"'") + candidates = [raw] + if ":" in raw: + candidates.append(raw.rsplit(":", 1)[1].strip().strip("\"'")) - candidate = Path(text) - if not candidate.is_absolute(): - candidate = APP_DIR / candidate - - if candidate.suffix.lower() in IMAGE_EXTENSIONS and candidate.exists(): - return candidate + for text in candidates: + if not text: + continue + candidate = Path(text) + if not candidate.is_absolute(): + candidate = APP_DIR / candidate + if candidate.suffix.lower() in IMAGE_EXTENSIONS and candidate.exists(): + return candidate return None