From 221659a58d2410c000b4037f2680c129bd63b8f2 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Sat, 27 Jun 2026 21:49:15 +0200 Subject: [PATCH] Naturalize Krea single appearance phrasing --- krea_normal_formatter.py | 17 +++++++++++++++-- tools/prompt_smoke.py | 8 ++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/krea_normal_formatter.py b/krea_normal_formatter.py index feee2f6..023274d 100644 --- a/krea_normal_formatter.py +++ b/krea_normal_formatter.py @@ -80,6 +80,16 @@ def _framed_composition_phrase(composition: str, prefix: str = "framed as") -> s return f"{prefix} {composition}" +def _appearance_with_phrase(appearance: str, with_indefinite_article: Callable[[str], str]) -> str: + appearance = str(appearance or "").strip() + if not appearance: + return "" + first_clause = appearance.split(",", 1)[0].lower() + if re.search(r"\b(?:body|build|figure|frame|physique|silhouette)\b", first_clause): + appearance = with_indefinite_article(appearance) + return f"with {appearance}" + + def format_normal_row_result( request: KreaNormalRowRequest, deps: KreaNormalRowDependencies, @@ -100,9 +110,12 @@ def format_normal_row_result( if primary in ("woman", "man") or subject_type in ("woman", "man", "single_any"): subject = deps.age_subject(row, "adult woman") appearance = deps.appearance_phrase(row) + subject_phrase = deps.with_indefinite_article(subject) + appearance_phrase = _appearance_with_phrase(appearance, deps.with_indefinite_article) + if appearance_phrase: + subject_phrase = f"{subject_phrase} {appearance_phrase}" parts = [ - deps.with_indefinite_article(subject), - f"showing {appearance}" if appearance else "", + subject_phrase, f"wearing {item}" if item else "", f"{pose}" if pose else "", f"with {expression}" if expression else "", diff --git a/tools/prompt_smoke.py b/tools/prompt_smoke.py index cc6f317..cf60b55 100644 --- a/tools/prompt_smoke.py +++ b/tools/prompt_smoke.py @@ -1447,8 +1447,12 @@ def smoke_krea_normal_row_routes() -> None: "Krea single route kept old comma-with figure grammar", ) _expect( - "adult woman, showing slim busty figure with" in figure_note_prompt, - "Krea single route did not naturalize figure-note appearance", + "adult woman with a slim busty figure with" in figure_note_prompt, + "Krea single route did not attach figure-note appearance to the subject", + ) + _expect( + "adult woman, showing slim busty figure with" not in figure_note_prompt, + "Krea single route kept awkward showing figure-note grammar", ) style_metadata = dict( single,