Fix image detection and LoRA loading to match training notebook
app.py: check the known save path directly instead of parsing stdout (broken after PR #21 removed the print statement). card_generator_adapter.py: two mismatches with the training notebook: 1. LoRA loading used pipe.load_lora_weights() (diffusers format) but the adapter was saved with PEFT's save_pretrained() — keys didn't match. Now uses PeftModel.from_pretrained() + merge_and_unload(). 2. Conditioning built a natural language prompt, but the LoRA was trained on json.dumps(meta). Now uses JSON serialization to match.
This commit is contained in:
7
app.py
7
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
|
||||
|
||||
# ------------------------------------------------------------------ #
|
||||
|
||||
Reference in New Issue
Block a user