Clean SDXL imperative hand tags
This commit is contained in:
+6
-1
@@ -67,7 +67,12 @@ def split_tag_text(text: Any) -> list[str]:
|
||||
text = re.sub(r"(?<!-)\b(?:and|with)\b(?!-)", ",", text, flags=re.IGNORECASE)
|
||||
text = re.sub(r"\b(woman|man),\s+(woman|man)\s+are\b", r"\1 and \2 are", text, flags=re.IGNORECASE)
|
||||
parts = re.split(r"\s*[,;]\s*", text)
|
||||
return [clean(part).strip(" .") for part in parts if clean(part).strip(" .")]
|
||||
tags = []
|
||||
for part in parts:
|
||||
part = re.sub(r"^keep\s+", "", clean(part).strip(" ."), flags=re.IGNORECASE)
|
||||
if part:
|
||||
tags.append(part)
|
||||
return tags
|
||||
|
||||
|
||||
def tag_key(tag: str) -> str:
|
||||
|
||||
@@ -600,6 +600,12 @@ def _sdxl_sentence_boundary_tag_issues(name: str, sdxl_prompt: str) -> list[str]
|
||||
return []
|
||||
|
||||
|
||||
def _sdxl_imperative_tag_issues(name: str, sdxl_prompt: str) -> list[str]:
|
||||
if re.search(r"\bkeep\s+hands\b", sdxl_prompt, flags=re.IGNORECASE):
|
||||
return [f"{name}.sdxl_prompt: imperative_keep_hands_tag"]
|
||||
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:
|
||||
@@ -741,6 +747,7 @@ def _formatter_issues(
|
||||
issues.extend(_sdxl_hyphen_fragment_issues(name, sdxl_prompt))
|
||||
issues.extend(_sdxl_character_pair_fragment_issues(name, sdxl_prompt))
|
||||
issues.extend(_sdxl_sentence_boundary_tag_issues(name, sdxl_prompt))
|
||||
issues.extend(_sdxl_imperative_tag_issues(name, sdxl_prompt))
|
||||
|
||||
for label, value in (
|
||||
(f"{name}.krea_negative", krea.get("negative_prompt")),
|
||||
|
||||
@@ -4685,6 +4685,8 @@ def smoke_sdxl_tag_policy() -> None:
|
||||
_expect("woman" not in subject_pair_tags and "man are mid-transition" not in subject_pair_tags, "SDXL tag splitter emitted broken paired character fragments")
|
||||
sentence_boundary_tags = sdxl_tag_policy.split_tag_text("keep hands on hips, breasts, thighs. Man watches close")
|
||||
sentence_boundary_tags_lower = [tag.lower() for tag in sentence_boundary_tags]
|
||||
_expect("hands on hips" in sentence_boundary_tags_lower, "SDXL tag splitter did not clean leading keep imperative")
|
||||
_expect("keep hands on hips" not in sentence_boundary_tags_lower, "SDXL tag splitter kept leading keep imperative")
|
||||
_expect("thighs" in sentence_boundary_tags, "SDXL tag splitter lost pre-period tag")
|
||||
_expect("man watches close" in sentence_boundary_tags_lower, "SDXL tag splitter did not split sentence-boundary tag")
|
||||
_expect(
|
||||
|
||||
Reference in New Issue
Block a user