Use item axis values in SDXL tags
This commit is contained in:
@@ -102,6 +102,43 @@ def formatter_hint_tags(*rows: dict[str, Any]) -> list[str]:
|
||||
return tags
|
||||
|
||||
|
||||
def _axis_value_texts(value: Any) -> list[str]:
|
||||
if isinstance(value, str):
|
||||
text = clean(value)
|
||||
return [text] if text and text.lower() not in ("any", "auto", "random", "none") else []
|
||||
if isinstance(value, (int, float, bool)) or value is None:
|
||||
return []
|
||||
if isinstance(value, list):
|
||||
texts: list[str] = []
|
||||
for item in value:
|
||||
texts.extend(_axis_value_texts(item))
|
||||
return texts
|
||||
if isinstance(value, dict):
|
||||
for preferred in ("text", "prompt", "template", "value", "name"):
|
||||
preferred_texts = _axis_value_texts(value.get(preferred))
|
||||
if preferred_texts:
|
||||
return preferred_texts
|
||||
texts: list[str] = []
|
||||
for item in value.values():
|
||||
texts.extend(_axis_value_texts(item))
|
||||
return texts
|
||||
return []
|
||||
|
||||
|
||||
def axis_value_tags(row: dict[str, Any]) -> list[str]:
|
||||
if not isinstance(row, dict):
|
||||
return []
|
||||
axis_values = row.get("item_axis_values")
|
||||
if not isinstance(axis_values, dict):
|
||||
return []
|
||||
tags: list[str] = []
|
||||
seen: set[str] = set()
|
||||
for value in axis_values.values():
|
||||
for text in _axis_value_texts(value):
|
||||
add(tags, seen, text)
|
||||
return tags
|
||||
|
||||
|
||||
def combine_tags(*parts: Any) -> str:
|
||||
tags: list[str] = []
|
||||
seen: set[str] = set()
|
||||
@@ -261,6 +298,7 @@ def tag_route_dependencies() -> sdxl_tag_routes.SDXLTagRouteDependencies:
|
||||
character_tags_from_descriptor=character_tags_from_descriptor,
|
||||
metadata_family_tags=metadata_family_tags,
|
||||
formatter_hint_tags=formatter_hint_tags,
|
||||
axis_value_tags=axis_value_tags,
|
||||
camera_tags=camera_tags,
|
||||
explicit_tags=explicit_tags,
|
||||
softcore_pair_tags=softcore_pair_tags,
|
||||
|
||||
Reference in New Issue
Block a user