Share formatter field label policy

This commit is contained in:
2026-06-27 01:33:48 +02:00
parent 64887a2750
commit 5efa073bfb
7 changed files with 34 additions and 65 deletions
+1 -20
View File
@@ -23,26 +23,7 @@ STYLE_TAILS = [
", coloured pencil comic illustration, crisp linework, hatching, soft pastel palette, warm sensual lighting, textured paper", ", coloured pencil comic illustration, crisp linework, hatching, soft pastel palette, warm sensual lighting, textured paper",
] ]
PROMPT_FIELD_LABELS = ( PROMPT_FIELD_LABELS = input_policy.prompt_field_labels()
"Ages",
"Body types",
"Cast",
"Cast descriptors",
"Characters",
"Scene",
"Setting",
"Pose",
"Sexual pose",
"Facial expression",
"Facial expressions",
"Clothing",
"Erotic outfit",
"Prop/detail",
"Composition",
"Role graph",
"Use",
"Avoid",
)
ITEM_LABELS = ( ITEM_LABELS = (
"Sexual pose", "Sexual pose",
+5 -3
View File
@@ -73,7 +73,8 @@ routes:
- JSON row detection from `metadata_json` or source text; - JSON row detection from `metadata_json` or source text;
- trigger-prefix stripping with route-specific trigger candidate lists; - trigger-prefix stripping with route-specific trigger candidate lists;
- `Avoid:` positive/negative splitting for fallback text; - `Avoid:` positive/negative splitting for fallback text;
- prompt field extraction such as `Setting:` or `Composition:`; - the shared prompt field-label inventory and extraction such as `Setting:`,
`Sexual scene:`, `Camera control:`, or `Composition:`;
- row-value fallback from metadata fields to labeled prompt text. - row-value fallback from metadata fields to labeled prompt text.
It must not make formatter-style decisions. Krea prose, SDXL tags, and training It must not make formatter-style decisions. Krea prose, SDXL tags, and training
@@ -261,8 +262,9 @@ Already isolated:
first-person body geometry, and selected-position-axis priority before loose first-person body geometry, and selected-position-axis priority before loose
context fallback. context fallback.
- `formatter_input.py` owns shared metadata/source JSON detection, trigger - `formatter_input.py` owns shared metadata/source JSON detection, trigger
stripping, prompt-field extraction, `Avoid:` splitting, and row-value stripping, the shared prompt field-label inventory, prompt-field extraction,
fallback for Krea, SDXL, and caption routes. `Avoid:` splitting, and row-value fallback for Krea, SDXL, and caption
routes.
Improve later: Improve later:
+1 -1
View File
@@ -95,7 +95,7 @@ Core helper ownership:
| `krea_cast.py` | Shared formatter cast descriptor parsing, cast labels, cast prose, natural cast descriptor text, and label replacement used by Krea2 and caption routes. | | `krea_cast.py` | Shared formatter cast descriptor parsing, cast labels, cast prose, natural cast descriptor text, and label replacement used by Krea2 and caption routes. |
| `prompt_hygiene.py` | Generic prompt, caption, and negative-prompt cleanup. | | `prompt_hygiene.py` | Generic prompt, caption, and negative-prompt cleanup. |
| `row_normalization.py` | Final prompt-row and pair metadata normalization: trigger prepending, extra-positive append, negative merge/dedupe, caption-part joining, and embedded soft/hard row sanitation. | | `row_normalization.py` | Final prompt-row and pair metadata normalization: trigger prepending, extra-positive append, negative merge/dedupe, caption-part joining, and embedded soft/hard row sanitation. |
| `formatter_input.py` | Shared formatter input parsing: text cleanup, metadata/source JSON detection, trigger-prefix stripping, `Avoid:` splitting, prompt-field extraction, and metadata row-value fallback. | | `formatter_input.py` | Shared formatter input parsing: text cleanup, metadata/source JSON detection, trigger-prefix stripping, shared prompt field-label inventory, `Avoid:` splitting, prompt-field extraction, and metadata row-value fallback. |
| `sdxl_presets.py` | SDXL style presets, quality presets, default negative prompt, and metadata-family tag hints used by the SDXL formatter and node choice lists. | | `sdxl_presets.py` | SDXL style presets, quality presets, default negative prompt, and metadata-family tag hints used by the SDXL formatter and node choice lists. |
## Node IO Map ## Node IO Map
+4
View File
@@ -30,6 +30,10 @@ DEFAULT_PROMPT_FIELD_LABELS = (
) )
def prompt_field_labels() -> tuple[str, ...]:
return DEFAULT_PROMPT_FIELD_LABELS
def clean_text(value: Any) -> str: def clean_text(value: Any) -> str:
text = "" if value is None else str(value) text = "" if value is None else str(value)
text = text.replace("\n", " ") text = text.replace("\n", " ")
+1 -20
View File
@@ -69,26 +69,7 @@ TRIGGER_CANDIDATES = (
"sxcpinup_coloredpencil", "sxcpinup_coloredpencil",
"sxcppnl7", "sxcppnl7",
) )
PROMPT_FIELD_LABELS = ( PROMPT_FIELD_LABELS = input_policy.prompt_field_labels()
"Ages",
"Body types",
"Cast",
"Cast descriptors",
"Characters",
"Scene",
"Setting",
"Pose",
"Sexual pose",
"Facial expression",
"Facial expressions",
"Clothing",
"Erotic outfit",
"Prop/detail",
"Composition",
"Role graph",
"Use",
"Avoid",
)
def _clean(value: Any) -> str: def _clean(value: Any) -> str:
+1 -21
View File
@@ -27,27 +27,7 @@ SDXL_DEFAULT_NEGATIVE = sdxl_policy.SDXL_DEFAULT_NEGATIVE
SDXL_ACTION_FAMILY_TAGS = sdxl_policy.SDXL_ACTION_FAMILY_TAGS SDXL_ACTION_FAMILY_TAGS = sdxl_policy.SDXL_ACTION_FAMILY_TAGS
SDXL_POSITION_FAMILY_TAGS = sdxl_policy.SDXL_POSITION_FAMILY_TAGS SDXL_POSITION_FAMILY_TAGS = sdxl_policy.SDXL_POSITION_FAMILY_TAGS
PROMPT_FIELD_LABELS = ( PROMPT_FIELD_LABELS = input_policy.prompt_field_labels()
"Ages",
"Body types",
"Cast",
"Cast descriptors",
"Characters",
"Scene",
"Setting",
"Pose",
"Sexual pose",
"Sexual scene",
"Facial expression",
"Facial expressions",
"Clothing",
"Erotic outfit",
"Composition",
"Role graph",
"Camera control",
"Use",
"Avoid",
)
def sdxl_style_preset_choices() -> list[str]: def sdxl_style_preset_choices() -> list[str]:
+21
View File
@@ -882,6 +882,27 @@ def smoke_formatter_input_policy() -> None:
formatter_input.row_value({"prompt": source_row["prompt"]}, "scene_text", ("Setting",)) == "quiet studio", formatter_input.row_value({"prompt": source_row["prompt"]}, "scene_text", ("Setting",)) == "quiet studio",
"Row value prompt fallback changed", "Row value prompt fallback changed",
) )
_expect(
krea_formatter.PROMPT_FIELD_LABELS is formatter_input.DEFAULT_PROMPT_FIELD_LABELS,
"Krea formatter field-label inventory should delegate to formatter_input",
)
_expect(
sdxl_formatter.PROMPT_FIELD_LABELS is formatter_input.DEFAULT_PROMPT_FIELD_LABELS,
"SDXL formatter field-label inventory should delegate to formatter_input",
)
_expect(
caption_naturalizer.PROMPT_FIELD_LABELS is formatter_input.DEFAULT_PROMPT_FIELD_LABELS,
"Caption formatter field-label inventory should delegate to formatter_input",
)
labeled_prompt = "Sexual scene: close-contact action. Camera control: side view. Composition: centered frame."
_expect(
formatter_input.prompt_field(labeled_prompt, "Sexual scene") == "close-contact action",
"Shared formatter field-label inventory lost Sexual scene parsing",
)
_expect(
formatter_input.prompt_field(labeled_prompt, "Camera control") == "side view",
"Shared formatter field-label inventory lost Camera control parsing",
)
_expect(krea_formatter._clean("a b , c") == formatter_input.clean_text("a b , c"), "Krea clean helper is not delegated") _expect(krea_formatter._clean("a b , c") == formatter_input.clean_text("a b , c"), "Krea clean helper is not delegated")
_expect(sdxl_formatter._clean("a b , c") == formatter_input.clean_text("a b , c"), "SDXL clean helper is not delegated") _expect(sdxl_formatter._clean("a b , c") == formatter_input.clean_text("a b , c"), "SDXL clean helper is not delegated")