Synchronize pair embedded row outputs
This commit is contained in:
@@ -194,8 +194,8 @@ Already isolated:
|
|||||||
by default, while SDXL can opt into legacy unknown key tags for compatibility.
|
by default, while SDXL can opt into legacy unknown key tags for compatibility.
|
||||||
- final row and pair text normalization lives in `row_normalization.py`,
|
- final row and pair text normalization lives in `row_normalization.py`,
|
||||||
covering trigger prepending, extra-positive append, negative merge/dedupe,
|
covering trigger prepending, extra-positive append, negative merge/dedupe,
|
||||||
caption-part joining, and embedded soft/hard row sanitation before metadata
|
caption-part joining, embedded soft/hard row output synchronization, and row
|
||||||
leaves generation.
|
sanitation before metadata leaves generation.
|
||||||
|
|
||||||
### Pair / Adapter Layer
|
### Pair / Adapter Layer
|
||||||
|
|
||||||
@@ -230,6 +230,9 @@ Already isolated:
|
|||||||
- final pair output assembly lives in `pair_output.py`, including soft/hard
|
- final pair output assembly lives in `pair_output.py`, including soft/hard
|
||||||
prompt strings, trigger preservation, negatives, captions, and root metadata
|
prompt strings, trigger preservation, negatives, captions, and root metadata
|
||||||
shape; the final cleanup step is delegated to `row_normalization.py`.
|
shape; the final cleanup step is delegated to `row_normalization.py`.
|
||||||
|
Embedded soft/hard rows are synchronized to the final pair prompt, caption,
|
||||||
|
and negative outputs during normalization so serialized pair metadata does
|
||||||
|
not carry stale standalone row text.
|
||||||
|
|
||||||
### Krea2 Formatter Path
|
### Krea2 Formatter Path
|
||||||
|
|
||||||
@@ -437,7 +440,8 @@ Medium-term:
|
|||||||
|
|
||||||
Near-term:
|
Near-term:
|
||||||
|
|
||||||
- Normalize pair metadata with one helper.
|
- Normalize pair metadata with one helper, including embedded row prompt,
|
||||||
|
caption, and negative synchronization.
|
||||||
- Confirm pair prompts, captions, and soft/hard rows carry the same sanitized
|
- Confirm pair prompts, captions, and soft/hard rows carry the same sanitized
|
||||||
scene/camera/clothing fields.
|
scene/camera/clothing fields.
|
||||||
- Keep same-room pair continuity synchronized in both assembled prompt text and
|
- Keep same-room pair continuity synchronized in both assembled prompt text and
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ Core helper ownership:
|
|||||||
| `scene_camera_adapters.py` | Location-aware camera/scene prose such as coworking lounge camera layout. |
|
| `scene_camera_adapters.py` | Location-aware camera/scene prose such as coworking lounge camera layout. |
|
||||||
| `krea_cast.py` | Shared formatter cast descriptor parsing, cast labels, cast prose, natural cast descriptor text, and label replacement used by Krea2 and caption routes. |
|
| `krea_cast.py` | Shared formatter cast descriptor parsing, cast labels, cast prose, natural cast descriptor text, and label replacement used by Krea2 and caption routes. |
|
||||||
| `prompt_hygiene.py` | Generic prompt, caption, and negative-prompt cleanup. |
|
| `prompt_hygiene.py` | Generic prompt, caption, and negative-prompt cleanup. |
|
||||||
| `row_normalization.py` | Final prompt-row and pair metadata normalization: trigger prepending, extra-positive append, negative merge/dedupe, caption-part joining, and embedded soft/hard row sanitation. |
|
| `row_normalization.py` | Final prompt-row and pair metadata normalization: trigger prepending, extra-positive append, negative merge/dedupe, caption-part joining, embedded soft/hard row output synchronization, and embedded row sanitation. |
|
||||||
| `formatter_input.py` | Shared formatter input parsing: text cleanup, metadata/source JSON detection, trigger-prefix stripping, shared prompt field-label inventory, fallback field-label stripping, `Avoid:` splitting, prompt-field extraction, and metadata row-value fallback. |
|
| `formatter_input.py` | Shared formatter input parsing: text cleanup, metadata/source JSON detection, trigger-prefix stripping, shared prompt field-label inventory, fallback field-label stripping, `Avoid:` splitting, prompt-field extraction, and metadata row-value fallback. |
|
||||||
| `sdxl_presets.py` | SDXL formatter profiles, style presets, quality presets, default negative prompt, and metadata-family tag hints used by the SDXL formatter and node choice lists. |
|
| `sdxl_presets.py` | SDXL formatter profiles, style presets, quality presets, default negative prompt, and metadata-family tag hints used by the SDXL formatter and node choice lists. |
|
||||||
| `caption_policy.py` | Caption naturalizer policy data and helpers: caption profiles, style tails, item labels, metadata-family caption labels, detail/style-policy normalization, clothing cleanup, and composition cleanup. |
|
| `caption_policy.py` | Caption naturalizer policy data and helpers: caption profiles, style tails, item labels, metadata-family caption labels, detail/style-policy normalization, clothing cleanup, and composition cleanup. |
|
||||||
@@ -494,7 +494,7 @@ plain prompt text. When debugging, inspect these fields before editing pools.
|
|||||||
| `options` | `SxCP Insta/OF Options` | Formatters/debug | Soft/hard level, cast mode, continuity, camera modes, expression settings. |
|
| `options` | `SxCP Insta/OF Options` | Formatters/debug | Soft/hard level, cast mode, continuity, camera modes, expression settings. |
|
||||||
| `shared_descriptor` | `pair_cast.py` | Pair formatters | Primary creator descriptor. |
|
| `shared_descriptor` | `pair_cast.py` | Pair formatters | Primary creator descriptor. |
|
||||||
| `shared_cast_descriptors` | `pair_cast.py` | Pair formatters | Full cast descriptor list. |
|
| `shared_cast_descriptors` | `pair_cast.py` | Pair formatters | Full cast descriptor list. |
|
||||||
| `softcore_row`, `hardcore_row` | Pair route | Pair formatters | Full normal metadata rows for each side. |
|
| `softcore_row`, `hardcore_row` | Pair route | Pair formatters | Full normal metadata rows for each side; their prompt, caption, and negative fields are synchronized to the final pair outputs during pair normalization. |
|
||||||
| `softcore_prompt`, `hardcore_prompt` | `pair_output.py` | Direct output/fallback | Raw pair prompts before formatter rewrite. |
|
| `softcore_prompt`, `hardcore_prompt` | `pair_output.py` | Direct output/fallback | Raw pair prompts before formatter rewrite. |
|
||||||
| `softcore_negative_prompt`, `hardcore_negative_prompt` | `pair_output.py` | Formatter negatives | Separate negatives for each side. |
|
| `softcore_negative_prompt`, `hardcore_negative_prompt` | `pair_output.py` | Formatter negatives | Separate negatives for each side. |
|
||||||
| `softcore_partner_styling` | `pair_cast.py` | Krea/SDXL pair branch | Partner softcore clothing and pose when same-cast softcore is enabled. |
|
| `softcore_partner_styling` | `pair_cast.py` | Krea/SDXL pair branch | Partner softcore clothing and pose when same-cast softcore is enabled. |
|
||||||
|
|||||||
@@ -101,9 +101,28 @@ def sanitize_metadata_row_text(row: dict[str, Any], *, active_trigger: str = "")
|
|||||||
return row
|
return row
|
||||||
|
|
||||||
|
|
||||||
|
def synchronize_pair_row_outputs(pair: dict[str, Any]) -> dict[str, Any]:
|
||||||
|
mapping = (
|
||||||
|
("softcore_row", "softcore_prompt", "softcore_caption", "softcore_negative_prompt"),
|
||||||
|
("hardcore_row", "hardcore_prompt", "hardcore_caption", "hardcore_negative_prompt"),
|
||||||
|
)
|
||||||
|
for row_key, prompt_key, caption_key, negative_key in mapping:
|
||||||
|
row = pair.get(row_key)
|
||||||
|
if not isinstance(row, dict):
|
||||||
|
continue
|
||||||
|
if prompt_key in pair:
|
||||||
|
row["prompt"] = pair.get(prompt_key, "")
|
||||||
|
if caption_key in pair:
|
||||||
|
row["caption"] = pair.get(caption_key, "")
|
||||||
|
if negative_key in pair:
|
||||||
|
row["negative_prompt"] = pair.get(negative_key, "")
|
||||||
|
return pair
|
||||||
|
|
||||||
|
|
||||||
def normalize_pair_metadata(pair: dict[str, Any], *, active_trigger: str = "") -> dict[str, Any]:
|
def normalize_pair_metadata(pair: dict[str, Any], *, active_trigger: str = "") -> dict[str, Any]:
|
||||||
trigger = str(active_trigger or "").strip()
|
trigger = str(active_trigger or "").strip()
|
||||||
triggers = _trigger_tuple(trigger)
|
triggers = _trigger_tuple(trigger)
|
||||||
|
synchronize_pair_row_outputs(pair)
|
||||||
for key in ("softcore_prompt", "hardcore_prompt"):
|
for key in ("softcore_prompt", "hardcore_prompt"):
|
||||||
if key in pair:
|
if key in pair:
|
||||||
pair[key] = sanitize_prompt_text(pair.get(key, ""), triggers=triggers)
|
pair[key] = sanitize_prompt_text(pair.get(key, ""), triggers=triggers)
|
||||||
|
|||||||
@@ -852,6 +852,14 @@ def smoke_row_normalization_policy() -> None:
|
|||||||
_expect_trigger_once("row_normalization.pair.hardcore_prompt", pair.get("hardcore_prompt"), Trigger)
|
_expect_trigger_once("row_normalization.pair.hardcore_prompt", pair.get("hardcore_prompt"), Trigger)
|
||||||
_expect_trigger_once("row_normalization.pair.softcore_row.prompt", pair["softcore_row"].get("prompt"), Trigger)
|
_expect_trigger_once("row_normalization.pair.softcore_row.prompt", pair["softcore_row"].get("prompt"), Trigger)
|
||||||
_expect_trigger_once("row_normalization.pair.hardcore_row.caption", pair["hardcore_row"].get("caption"), Trigger)
|
_expect_trigger_once("row_normalization.pair.hardcore_row.caption", pair["hardcore_row"].get("caption"), Trigger)
|
||||||
|
_expect(
|
||||||
|
pair["softcore_row"].get("prompt") == pair.get("softcore_prompt"),
|
||||||
|
"Pair normalization left stale soft row prompt text",
|
||||||
|
)
|
||||||
|
_expect(
|
||||||
|
pair["hardcore_row"].get("caption") == pair.get("hardcore_caption"),
|
||||||
|
"Pair normalization left stale hard row caption text",
|
||||||
|
)
|
||||||
_expect_no_duplicate_comma_items("row_normalization.pair.soft_negative", pair.get("softcore_negative_prompt"))
|
_expect_no_duplicate_comma_items("row_normalization.pair.soft_negative", pair.get("softcore_negative_prompt"))
|
||||||
_expect_no_duplicate_comma_items("row_normalization.pair.hard_row_negative", pair["hardcore_row"].get("negative_prompt"))
|
_expect_no_duplicate_comma_items("row_normalization.pair.hard_row_negative", pair["hardcore_row"].get("negative_prompt"))
|
||||||
|
|
||||||
@@ -1491,6 +1499,18 @@ def _expect_pair(pair: dict[str, Any], name: str) -> None:
|
|||||||
_expect_trigger_once(f"{name}.hardcore_prompt", pair.get("hardcore_prompt"), Trigger)
|
_expect_trigger_once(f"{name}.hardcore_prompt", pair.get("hardcore_prompt"), Trigger)
|
||||||
_expect_trigger_once(f"{name}.softcore_caption", pair.get("softcore_caption"), Trigger)
|
_expect_trigger_once(f"{name}.softcore_caption", pair.get("softcore_caption"), Trigger)
|
||||||
_expect_trigger_once(f"{name}.hardcore_caption", pair.get("hardcore_caption"), Trigger)
|
_expect_trigger_once(f"{name}.hardcore_caption", pair.get("hardcore_caption"), Trigger)
|
||||||
|
_expect(pair["softcore_row"].get("prompt") == pair.get("softcore_prompt"), f"{name}.softcore_row prompt drifted from pair prompt")
|
||||||
|
_expect(pair["hardcore_row"].get("prompt") == pair.get("hardcore_prompt"), f"{name}.hardcore_row prompt drifted from pair prompt")
|
||||||
|
_expect(pair["softcore_row"].get("caption") == pair.get("softcore_caption"), f"{name}.softcore_row caption drifted from pair caption")
|
||||||
|
_expect(pair["hardcore_row"].get("caption") == pair.get("hardcore_caption"), f"{name}.hardcore_row caption drifted from pair caption")
|
||||||
|
_expect(
|
||||||
|
pair["softcore_row"].get("negative_prompt") == pair.get("softcore_negative_prompt"),
|
||||||
|
f"{name}.softcore_row negative drifted from pair negative",
|
||||||
|
)
|
||||||
|
_expect(
|
||||||
|
pair["hardcore_row"].get("negative_prompt") == pair.get("hardcore_negative_prompt"),
|
||||||
|
f"{name}.hardcore_row negative drifted from pair negative",
|
||||||
|
)
|
||||||
_expect_no_duplicate_comma_items(f"{name}.softcore_negative", pair.get("softcore_negative_prompt"))
|
_expect_no_duplicate_comma_items(f"{name}.softcore_negative", pair.get("softcore_negative_prompt"))
|
||||||
_expect_no_duplicate_comma_items(f"{name}.hardcore_negative", pair.get("hardcore_negative_prompt"))
|
_expect_no_duplicate_comma_items(f"{name}.hardcore_negative", pair.get("hardcore_negative_prompt"))
|
||||||
_expect_formatter_outputs(pair, name, target="softcore")
|
_expect_formatter_outputs(pair, name, target="softcore")
|
||||||
|
|||||||
Reference in New Issue
Block a user