Use shared formatter target choices
This commit is contained in:
@@ -89,9 +89,10 @@ Formatter target handling now has one home:
|
|||||||
- `formatter_target.py`
|
- `formatter_target.py`
|
||||||
|
|
||||||
It owns route-neutral target normalization for `auto`, `single`, `softcore`,
|
It owns route-neutral target normalization for `auto`, `single`, `softcore`,
|
||||||
and `hardcore`, including pair-side semantics. Single-output formatters select
|
and `hardcore`, including node choice lists and pair-side semantics.
|
||||||
the softcore side for pair `auto`/`single` targets, while caption pair routing
|
Single-output formatters select the softcore side for pair `auto`/`single`
|
||||||
can still include both sides for combined training captions.
|
targets, while caption pair routing can still include both sides for combined
|
||||||
|
training captions.
|
||||||
|
|
||||||
Shared hardcore phrase cleanup now has one home:
|
Shared hardcore phrase cleanup now has one home:
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ class PairTargetPolicy:
|
|||||||
include_hardcore: bool
|
include_hardcore: bool
|
||||||
|
|
||||||
|
|
||||||
|
def target_choices() -> list[str]:
|
||||||
|
return list(FORMATTER_TARGETS)
|
||||||
|
|
||||||
|
|
||||||
def normalize_target(value: Any) -> str:
|
def normalize_target(value: Any) -> str:
|
||||||
target = str(value or "").strip().lower().replace("-", "_").replace(" ", "_")
|
target = str(value or "").strip().lower().replace("-", "_").replace(" ", "_")
|
||||||
target = _TARGET_ALIASES.get(target, target)
|
target = _TARGET_ALIASES.get(target, target)
|
||||||
|
|||||||
+5
-3
@@ -4,6 +4,7 @@ try:
|
|||||||
from .caption_naturalizer import naturalize_caption
|
from .caption_naturalizer import naturalize_caption
|
||||||
from .caption_policy import caption_profile_choices
|
from .caption_policy import caption_profile_choices
|
||||||
from .formatter_input import INPUT_HINT_CAPTION_OR_PROMPT, INPUT_HINT_PROMPT, input_hint_choices
|
from .formatter_input import INPUT_HINT_CAPTION_OR_PROMPT, INPUT_HINT_PROMPT, input_hint_choices
|
||||||
|
from .formatter_target import target_choices
|
||||||
from .krea_formatter import format_krea2_prompt
|
from .krea_formatter import format_krea2_prompt
|
||||||
from .sdxl_formatter import (
|
from .sdxl_formatter import (
|
||||||
format_sdxl_prompt,
|
format_sdxl_prompt,
|
||||||
@@ -15,6 +16,7 @@ except ImportError: # Allows local smoke tests from the repository root.
|
|||||||
from caption_naturalizer import naturalize_caption
|
from caption_naturalizer import naturalize_caption
|
||||||
from caption_policy import caption_profile_choices
|
from caption_policy import caption_profile_choices
|
||||||
from formatter_input import INPUT_HINT_CAPTION_OR_PROMPT, INPUT_HINT_PROMPT, input_hint_choices
|
from formatter_input import INPUT_HINT_CAPTION_OR_PROMPT, INPUT_HINT_PROMPT, input_hint_choices
|
||||||
|
from formatter_target import target_choices
|
||||||
from krea_formatter import format_krea2_prompt
|
from krea_formatter import format_krea2_prompt
|
||||||
from sdxl_formatter import (
|
from sdxl_formatter import (
|
||||||
format_sdxl_prompt,
|
format_sdxl_prompt,
|
||||||
@@ -36,7 +38,7 @@ class SxCPCaptionNaturalizer:
|
|||||||
"style_policy": (["drop_style_tail", "keep_style_terms"], {"default": "drop_style_tail"}),
|
"style_policy": (["drop_style_tail", "keep_style_terms"], {"default": "drop_style_tail"}),
|
||||||
"trigger": ("STRING", {"default": "sxcppnl7"}),
|
"trigger": ("STRING", {"default": "sxcppnl7"}),
|
||||||
"include_trigger": ("BOOLEAN", {"default": True}),
|
"include_trigger": ("BOOLEAN", {"default": True}),
|
||||||
"target": (["auto", "single", "softcore", "hardcore"], {"default": "auto"}),
|
"target": (target_choices(), {"default": "auto"}),
|
||||||
},
|
},
|
||||||
"optional": {
|
"optional": {
|
||||||
"source_text_input": ("STRING", {"forceInput": True}),
|
"source_text_input": ("STRING", {"forceInput": True}),
|
||||||
@@ -83,7 +85,7 @@ class SxCPKrea2Formatter:
|
|||||||
"required": {
|
"required": {
|
||||||
"source_text": ("STRING", {"default": "", "multiline": True}),
|
"source_text": ("STRING", {"default": "", "multiline": True}),
|
||||||
"input_hint": (input_hint_choices(text_hint=INPUT_HINT_PROMPT), {"default": "auto"}),
|
"input_hint": (input_hint_choices(text_hint=INPUT_HINT_PROMPT), {"default": "auto"}),
|
||||||
"target": (["auto", "single", "softcore", "hardcore"], {"default": "auto"}),
|
"target": (target_choices(), {"default": "auto"}),
|
||||||
"detail_level": (["balanced", "concise", "dense"], {"default": "balanced"}),
|
"detail_level": (["balanced", "concise", "dense"], {"default": "balanced"}),
|
||||||
"style_mode": (["preserve", "photographic", "minimal"], {"default": "preserve"}),
|
"style_mode": (["preserve", "photographic", "minimal"], {"default": "preserve"}),
|
||||||
"preserve_trigger": ("BOOLEAN", {"default": False}),
|
"preserve_trigger": ("BOOLEAN", {"default": False}),
|
||||||
@@ -155,7 +157,7 @@ class SxCPSDXLFormatter:
|
|||||||
"required": {
|
"required": {
|
||||||
"source_text": ("STRING", {"default": "", "multiline": True}),
|
"source_text": ("STRING", {"default": "", "multiline": True}),
|
||||||
"input_hint": (input_hint_choices(text_hint=INPUT_HINT_PROMPT), {"default": "auto"}),
|
"input_hint": (input_hint_choices(text_hint=INPUT_HINT_PROMPT), {"default": "auto"}),
|
||||||
"target": (["auto", "single", "softcore", "hardcore"], {"default": "auto"}),
|
"target": (target_choices(), {"default": "auto"}),
|
||||||
"formatter_profile": (sdxl_formatter_profile_choices(), {"default": "manual_controls"}),
|
"formatter_profile": (sdxl_formatter_profile_choices(), {"default": "manual_controls"}),
|
||||||
"style_preset": (sdxl_style_preset_choices(), {"default": "flat_vector_pony"}),
|
"style_preset": (sdxl_style_preset_choices(), {"default": "flat_vector_pony"}),
|
||||||
"quality_preset": (sdxl_quality_preset_choices(), {"default": "pony_high"}),
|
"quality_preset": (sdxl_quality_preset_choices(), {"default": "pony_high"}),
|
||||||
|
|||||||
@@ -2814,6 +2814,10 @@ def smoke_formatter_input_policy() -> None:
|
|||||||
|
|
||||||
|
|
||||||
def smoke_formatter_target_policy() -> None:
|
def smoke_formatter_target_policy() -> None:
|
||||||
|
_expect(
|
||||||
|
formatter_target.target_choices() == ["auto", "single", "softcore", "hardcore"],
|
||||||
|
"Formatter target choices changed",
|
||||||
|
)
|
||||||
_expect(formatter_target.normalize_target("single") == "single", "Formatter target lost single")
|
_expect(formatter_target.normalize_target("single") == "single", "Formatter target lost single")
|
||||||
_expect(formatter_target.normalize_target("Hard-Core") == "hardcore", "Formatter target alias lost hardcore")
|
_expect(formatter_target.normalize_target("Hard-Core") == "hardcore", "Formatter target alias lost hardcore")
|
||||||
_expect(formatter_target.normalize_target("soft") == "softcore", "Formatter target alias lost softcore")
|
_expect(formatter_target.normalize_target("soft") == "softcore", "Formatter target alias lost softcore")
|
||||||
@@ -6259,7 +6263,9 @@ def smoke_node_formatter_registration() -> None:
|
|||||||
caption_inputs = sxcp_nodes.NODE_CLASS_MAPPINGS["SxCPCaptionNaturalizer"].INPUT_TYPES().get("required") or {}
|
caption_inputs = sxcp_nodes.NODE_CLASS_MAPPINGS["SxCPCaptionNaturalizer"].INPUT_TYPES().get("required") or {}
|
||||||
_expect("caption_profile" in caption_inputs, "Caption Naturalizer lost caption_profile input")
|
_expect("caption_profile" in caption_inputs, "Caption Naturalizer lost caption_profile input")
|
||||||
_expect("target" in caption_inputs, "Caption Naturalizer lost target input")
|
_expect("target" in caption_inputs, "Caption Naturalizer lost target input")
|
||||||
|
_expect(caption_inputs["target"][0] == formatter_target.target_choices(), "Caption Naturalizer target choices drifted")
|
||||||
_expect("tooltip" in caption_inputs["caption_profile"][1], "Caption profile tooltip injection missing")
|
_expect("tooltip" in caption_inputs["caption_profile"][1], "Caption profile tooltip injection missing")
|
||||||
|
_expect(krea_inputs["target"][0] == formatter_target.target_choices(), "Krea2 Formatter target choices drifted")
|
||||||
|
|
||||||
krea_output = krea_node().build(
|
krea_output = krea_node().build(
|
||||||
"sxcppnl7 A woman standing by a window",
|
"sxcppnl7 A woman standing by a window",
|
||||||
@@ -6291,6 +6297,7 @@ def smoke_node_formatter_registration() -> None:
|
|||||||
_expect(sdxl_output[6].startswith("text("), "SDXL Formatter method changed unexpectedly")
|
_expect(sdxl_output[6].startswith("text("), "SDXL Formatter method changed unexpectedly")
|
||||||
sdxl_inputs = sxcp_nodes.NODE_CLASS_MAPPINGS["SxCPSDXLFormatter"].INPUT_TYPES().get("required") or {}
|
sdxl_inputs = sxcp_nodes.NODE_CLASS_MAPPINGS["SxCPSDXLFormatter"].INPUT_TYPES().get("required") or {}
|
||||||
_expect("formatter_profile" in sdxl_inputs, "SDXL Formatter lost formatter_profile input")
|
_expect("formatter_profile" in sdxl_inputs, "SDXL Formatter lost formatter_profile input")
|
||||||
|
_expect(sdxl_inputs["target"][0] == formatter_target.target_choices(), "SDXL Formatter target choices drifted")
|
||||||
_expect("tooltip" in sdxl_inputs["formatter_profile"][1], "SDXL formatter_profile tooltip injection missing")
|
_expect("tooltip" in sdxl_inputs["formatter_profile"][1], "SDXL formatter_profile tooltip injection missing")
|
||||||
|
|
||||||
pair = pb.build_insta_of_pair(
|
pair = pb.build_insta_of_pair(
|
||||||
|
|||||||
Reference in New Issue
Block a user