Preserve hyphenated SDXL tags

This commit is contained in:
2026-06-27 22:14:20 +02:00
parent c74798d80f
commit 15b28b422f
3 changed files with 12 additions and 1 deletions
+1 -1
View File
@@ -63,7 +63,7 @@ def split_tag_text(text: Any) -> list[str]:
text, text,
flags=re.IGNORECASE, flags=re.IGNORECASE,
) )
text = re.sub(r"\b(?:and|with)\b", ",", text, flags=re.IGNORECASE) text = re.sub(r"(?<!-)\b(?:and|with)\b(?!-)", ",", text, flags=re.IGNORECASE)
parts = re.split(r"\s*[,;]\s*", text) parts = re.split(r"\s*[,;]\s*", text)
return [clean(part).strip(" .") for part in parts if clean(part).strip(" .")] return [clean(part).strip(" .") for part in parts if clean(part).strip(" .")]
+7
View File
@@ -582,6 +582,12 @@ def _sdxl_expression_label_issues(name: str, sdxl_prompt: str) -> list[str]:
return [] return []
def _sdxl_hyphen_fragment_issues(name: str, sdxl_prompt: str) -> list[str]:
if re.search(r"\b[a-z]+-,\s*-[a-z]+", sdxl_prompt, flags=re.IGNORECASE):
return [f"{name}.sdxl_prompt: broken_hyphenated_tag"]
return []
def _trace_dict(formatter_name: str, payload: dict[str, Any]) -> tuple[dict[str, Any], str]: def _trace_dict(formatter_name: str, payload: dict[str, Any]) -> tuple[dict[str, Any], str]:
trace_text = str(payload.get("route_trace_json") or "") trace_text = str(payload.get("route_trace_json") or "")
if not trace_text: if not trace_text:
@@ -720,6 +726,7 @@ def _formatter_issues(
issues.extend(_composition_label_issues(name, prompts)) issues.extend(_composition_label_issues(name, prompts))
issues.extend(_sdxl_composition_tag_issues(name, sdxl_prompt)) issues.extend(_sdxl_composition_tag_issues(name, sdxl_prompt))
issues.extend(_sdxl_expression_label_issues(name, sdxl_prompt)) issues.extend(_sdxl_expression_label_issues(name, sdxl_prompt))
issues.extend(_sdxl_hyphen_fragment_issues(name, sdxl_prompt))
for label, value in ( for label, value in (
(f"{name}.krea_negative", krea.get("negative_prompt")), (f"{name}.krea_negative", krea.get("negative_prompt")),
+4
View File
@@ -4676,6 +4676,10 @@ def smoke_sdxl_tag_policy() -> None:
_expect("hands braced on thighs" in axis_tags, "SDXL axis tags lost selected detail axis") _expect("hands braced on thighs" in axis_tags, "SDXL axis tags lost selected detail axis")
_expect("close body alignment" in axis_tags, "SDXL axis tags lost split detail axis") _expect("close body alignment" in axis_tags, "SDXL axis tags lost split detail axis")
_expect("random" not in axis_tags, "SDXL axis tags should ignore random placeholders") _expect("random" not in axis_tags, "SDXL axis tags should ignore random placeholders")
hyphenated_tags = sdxl_tag_policy.split_tag_text("front-and-back penetration with hands on hips")
_expect("front-and-back penetration" in hyphenated_tags, "SDXL tag splitter broke hyphenated and compound")
_expect("front-" not in hyphenated_tags and "-back penetration" not in hyphenated_tags, "SDXL tag splitter emitted broken hyphen fragments")
_expect("hands on hips" in hyphenated_tags, "SDXL tag splitter stopped splitting non-hyphenated with connector")
_expect( _expect(
sdxl_formatter._camera_tags(row) == sdxl_tag_policy.camera_tags(row), sdxl_formatter._camera_tags(row) == sdxl_tag_policy.camera_tags(row),
"SDXL formatter camera helper should delegate to sdxl_tag_policy", "SDXL formatter camera helper should delegate to sdxl_tag_policy",