Synchronize pair embedded row outputs
This commit is contained in:
@@ -101,9 +101,28 @@ def sanitize_metadata_row_text(row: dict[str, Any], *, active_trigger: str = "")
|
||||
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]:
|
||||
trigger = str(active_trigger or "").strip()
|
||||
triggers = _trigger_tuple(trigger)
|
||||
synchronize_pair_row_outputs(pair)
|
||||
for key in ("softcore_prompt", "hardcore_prompt"):
|
||||
if key in pair:
|
||||
pair[key] = sanitize_prompt_text(pair.get(key, ""), triggers=triggers)
|
||||
|
||||
Reference in New Issue
Block a user