Add SDXL prompt formatter

This commit is contained in:
2026-06-25 11:23:36 +02:00
parent c95588b12f
commit b4abd24b35
2 changed files with 639 additions and 0 deletions
+96
View File
@@ -254,6 +254,14 @@ NODE_INPUT_TOOLTIPS = {
"SxCPKrea2Formatter": {
"metadata_json": "Best input for Krea2 formatting because it preserves cast, camera, and hardcore action metadata.",
},
"SxCPSDXLFormatter": {
"metadata_json": "Best input for SDXL tag formatting because it preserves cast, camera, outfit, and explicit action metadata.",
"style_preset": "Positive style anchor preset. flat_vector_pony matches the old SDXL tag style.",
"quality_preset": "Quality/score tag tail for SDXL or Pony-style checkpoints.",
"custom_style": "Optional replacement for the style preset. Leave empty to use style_preset.",
"custom_quality": "Optional replacement for the quality preset. Leave empty to use quality_preset.",
"nude_weight": "Weight used when explicit nude/body exposure tags are inferred.",
},
"SxCPCaptionNaturalizer": {
"style_policy": "drop_style_tail removes training/style boilerplate; keep_style_terms preserves more of it.",
"include_trigger": "Add the naturalizer trigger to the rewritten caption.",
@@ -413,6 +421,7 @@ try:
)
from .caption_naturalizer import naturalize_caption
from .krea_formatter import format_krea2_prompt
from .sdxl_formatter import format_sdxl_prompt, sdxl_quality_preset_choices, sdxl_style_preset_choices
except ImportError:
from loop_nodes import (
ANY_TYPE,
@@ -489,6 +498,7 @@ except ImportError:
)
from caption_naturalizer import naturalize_caption
from krea_formatter import format_krea2_prompt
from sdxl_formatter import format_sdxl_prompt, sdxl_quality_preset_choices, sdxl_style_preset_choices
if PromptServer is not None and web is not None:
@@ -2192,6 +2202,90 @@ class SxCPKrea2Formatter:
)
class SxCPSDXLFormatter:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"source_text": ("STRING", {"default": "", "multiline": True}),
"input_hint": (["auto", "metadata_json", "prompt"], {"default": "auto"}),
"target": (["auto", "single", "softcore", "hardcore"], {"default": "auto"}),
"style_preset": (sdxl_style_preset_choices(), {"default": "flat_vector_pony"}),
"quality_preset": (sdxl_quality_preset_choices(), {"default": "pony_high"}),
"trigger": ("STRING", {"default": "mythp0rt", "multiline": False}),
"prepend_trigger_to_prompt": ("BOOLEAN", {"default": True}),
"preserve_trigger": ("BOOLEAN", {"default": False}),
"nude_weight": ("FLOAT", {"default": 1.29, "min": 0.1, "max": 3.0, "step": 0.01}),
},
"optional": {
"metadata_json": ("STRING", {"default": "", "multiline": True}),
"negative_prompt": ("STRING", {"default": "", "multiline": True}),
"custom_style": ("STRING", {"default": "", "multiline": True}),
"custom_quality": ("STRING", {"default": "", "multiline": True}),
"extra_positive": ("STRING", {"default": "", "multiline": True}),
"extra_negative": ("STRING", {"default": "", "multiline": True}),
},
}
RETURN_TYPES = ("STRING", "STRING", "STRING", "STRING", "STRING", "STRING", "STRING")
RETURN_NAMES = (
"sdxl_prompt",
"negative_prompt",
"sdxl_softcore_prompt",
"sdxl_hardcore_prompt",
"softcore_negative_prompt",
"hardcore_negative_prompt",
"method",
)
FUNCTION = "build"
CATEGORY = "prompt_builder"
def build(
self,
source_text,
input_hint,
target,
style_preset,
quality_preset,
trigger,
prepend_trigger_to_prompt,
preserve_trigger,
nude_weight,
metadata_json="",
negative_prompt="",
custom_style="",
custom_quality="",
extra_positive="",
extra_negative="",
):
row = format_sdxl_prompt(
source_text=source_text or "",
metadata_json=metadata_json or "",
negative_prompt=negative_prompt or "",
input_hint=input_hint,
target=target,
style_preset=style_preset,
quality_preset=quality_preset,
trigger=trigger,
prepend_trigger=prepend_trigger_to_prompt,
preserve_trigger=preserve_trigger,
nude_weight=nude_weight,
custom_style=custom_style or "",
custom_quality=custom_quality or "",
extra_positive=extra_positive or "",
extra_negative=extra_negative or "",
)
return (
row["sdxl_prompt"],
row["negative_prompt"],
row["sdxl_softcore_prompt"],
row["sdxl_hardcore_prompt"],
row["softcore_negative_prompt"],
row["hardcore_negative_prompt"],
row["method"],
)
class SxCPInstaOFOptions:
@classmethod
def INPUT_TYPES(cls):
@@ -2399,6 +2493,7 @@ NODE_CLASS_MAPPINGS = {
"SxCPCharacterProfileLoad": SxCPCharacterProfileLoad,
"SxCPCaptionNaturalizer": SxCPCaptionNaturalizer,
"SxCPKrea2Formatter": SxCPKrea2Formatter,
"SxCPSDXLFormatter": SxCPSDXLFormatter,
"SxCPInstaOFOptions": SxCPInstaOFOptions,
"SxCPInstaOFPromptPair": SxCPInstaOFPromptPair,
}
@@ -2438,6 +2533,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
"SxCPCharacterProfileLoad": "SxCP Character Profile Load",
"SxCPCaptionNaturalizer": "SxCP Caption Naturalizer",
"SxCPKrea2Formatter": "SxCP Krea2 Formatter",
"SxCPSDXLFormatter": "SxCP SDXL Formatter",
"SxCPInstaOFOptions": "SxCP Insta/OF Options",
"SxCPInstaOFPromptPair": "SxCP Insta/OF Prompt Pair",
}