From e9bd9c45ca9e8478dbff538de7d56fbd7db13879 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Sat, 27 Jun 2026 21:34:15 +0200 Subject: [PATCH] Naturalize Krea single appearance grammar --- krea_normal_formatter.py | 2 +- tools/prompt_route_simulation.py | 11 +++++++++++ tools/prompt_smoke.py | 18 ++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/krea_normal_formatter.py b/krea_normal_formatter.py index 2dd7991..c8abfc3 100644 --- a/krea_normal_formatter.py +++ b/krea_normal_formatter.py @@ -89,7 +89,7 @@ def format_normal_row_result( appearance = deps.appearance_phrase(row) parts = [ deps.with_indefinite_article(subject), - f"with {appearance}" if appearance else "", + f"showing {appearance}" if appearance else "", f"wearing {item}" if item else "", f"{pose}" if pose else "", f"with {expression}" if expression else "", diff --git a/tools/prompt_route_simulation.py b/tools/prompt_route_simulation.py index 549cf8c..db721a3 100644 --- a/tools/prompt_route_simulation.py +++ b/tools/prompt_route_simulation.py @@ -536,6 +536,16 @@ def _caption_expression_grammar_issues(name: str, caption_text: str) -> list[str return [] +def _krea_grammar_issues(name: str, krea_prompt: str) -> list[str]: + if re.search( + r"\b(?:woman|man|person),\s+with\s+[^.;]{0,120}\bfigure\s+with\b", + krea_prompt, + flags=re.IGNORECASE, + ): + return [f"{name}.krea_prompt: subject_appearance_with_grammar"] + return [] + + def _trace_dict(formatter_name: str, payload: dict[str, Any]) -> tuple[dict[str, Any], str]: trace_text = str(payload.get("route_trace_json") or "") if not trace_text: @@ -670,6 +680,7 @@ def _formatter_issues( issues.extend(_formatter_trace_issues(name, formats, target=target, row=row)) issues.extend(_caption_cast_descriptor_issues(name, row, caption_text)) issues.extend(_caption_expression_grammar_issues(name, caption_text)) + issues.extend(_krea_grammar_issues(name, krea_prompt)) for label, value in ( (f"{name}.krea_negative", krea.get("negative_prompt")), diff --git a/tools/prompt_smoke.py b/tools/prompt_smoke.py index 529b94a..c8dcaba 100644 --- a/tools/prompt_smoke.py +++ b/tools/prompt_smoke.py @@ -1432,6 +1432,24 @@ def smoke_krea_normal_row_routes() -> None: "style": "realistic creator-shot photography", } _expect_krea_normal_route_parity(single, "krea_normal_single", "metadata(single)") + single_figure_note = dict( + single, + body_phrase="slim busty figure with soft, natural fullness up top and a small waist", + ) + figure_note_prompt, figure_note_method = krea_formatter._normal_row_to_krea( + single_figure_note, + "balanced", + "preserve", + ) + _expect(figure_note_method == "metadata(single)", "Krea single figure-note route changed method") + _expect( + "adult woman, with slim busty figure with" not in figure_note_prompt, + "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", + ) style_metadata = dict( single, style="metadata style phrase",