Extract SDXL preset policy

This commit is contained in:
2026-06-27 01:25:39 +02:00
parent 4c45d96472
commit a128b2dc9a
5 changed files with 130 additions and 52 deletions
+19 -50
View File
@@ -5,10 +5,12 @@ from typing import Any
try:
from . import formatter_input as input_policy
from . import sdxl_presets as sdxl_policy
from .hardcore_action_metadata import normalize_hardcore_action_family
from .prompt_hygiene import sanitize_negative_text, sanitize_tag_prompt
except ImportError: # Allows local smoke tests with `python -c`.
import formatter_input as input_policy
import sdxl_presets as sdxl_policy
from hardcore_action_metadata import normalize_hardcore_action_family
from prompt_hygiene import sanitize_negative_text, sanitize_tag_prompt
@@ -19,50 +21,11 @@ TRIGGER_CANDIDATES = (
"mythp0rt",
)
SDXL_STYLE_PRESETS = {
"flat_vector_pony": "(skindentation:1.25), (flat color:2.0), no lineart, no outline, Flat vector",
"flat_vector": "(flat color:2.0), no lineart, no outline, Flat vector",
"photographic": "realistic photo, detailed skin texture, depth of field",
"none": "",
}
SDXL_QUALITY_PRESETS = {
"pony_high": (
"amazing quality, ultra detailed, 8k, very detailed, high detailed texture, "
"highly detailed anatomy, best quality, newest, very aesthetic, (score_9:1.1), "
"(score_8_up:1.1), (score_7_up:1.1), masterpiece, absurdres, highres"
),
"sdxl_high": "masterpiece, best quality, amazing quality, ultra detailed, 8k, absurdres, highres",
"none": "",
}
SDXL_DEFAULT_NEGATIVE = (
"worst quality, low quality, normal quality, lowres, bad anatomy, bad hands, "
"extra fingers, missing fingers, fused fingers, deformed, disfigured, malformed body, "
"watermark, signature, text, logo, blurry, jpeg artifacts, censored, mosaic censor"
)
SDXL_ACTION_FAMILY_TAGS = {
"foreplay": ("foreplay", "body contact"),
"outercourse": ("outercourse", "non-penetrative sex"),
"oral": ("oral sex",),
"penetration": ("penetrative sex", "penetration"),
"toy_double": ("double penetration", "toy-assisted sex"),
"climax": ("climax", "semen"),
}
SDXL_POSITION_FAMILY_TAGS = {
"penetrative": ("penetrative sex",),
"foreplay": ("foreplay",),
"interaction": ("interaction",),
"manual": ("manual stimulation",),
"oral": ("oral sex",),
"outercourse": ("outercourse",),
"anal": ("anal sex",),
"climax": ("climax",),
"threesome": ("threesome",),
"group": ("group sex",),
}
SDXL_STYLE_PRESETS = sdxl_policy.SDXL_STYLE_PRESETS
SDXL_QUALITY_PRESETS = sdxl_policy.SDXL_QUALITY_PRESETS
SDXL_DEFAULT_NEGATIVE = sdxl_policy.SDXL_DEFAULT_NEGATIVE
SDXL_ACTION_FAMILY_TAGS = sdxl_policy.SDXL_ACTION_FAMILY_TAGS
SDXL_POSITION_FAMILY_TAGS = sdxl_policy.SDXL_POSITION_FAMILY_TAGS
PROMPT_FIELD_LABELS = (
"Ages",
@@ -88,11 +51,11 @@ PROMPT_FIELD_LABELS = (
def sdxl_style_preset_choices() -> list[str]:
return list(SDXL_STYLE_PRESETS)
return sdxl_policy.sdxl_style_preset_choices()
def sdxl_quality_preset_choices() -> list[str]:
return list(SDXL_QUALITY_PRESETS)
return sdxl_policy.sdxl_quality_preset_choices()
def _clean(value: Any) -> str:
@@ -362,7 +325,10 @@ def _row_core_tags(row: dict[str, Any], nude_weight: float) -> list[str]:
def _style_prefix(style_preset: str, trigger: str, prepend_trigger: bool, custom_style: str) -> str:
style = custom_style if _clean(custom_style) else SDXL_STYLE_PRESETS.get(style_preset, SDXL_STYLE_PRESETS["flat_vector_pony"])
style = custom_style if _clean(custom_style) else SDXL_STYLE_PRESETS.get(
style_preset,
SDXL_STYLE_PRESETS[sdxl_policy.DEFAULT_STYLE_PRESET],
)
trigger = _clean(trigger)
if prepend_trigger and trigger:
return _combine_tags(style, trigger)
@@ -370,7 +336,10 @@ def _style_prefix(style_preset: str, trigger: str, prepend_trigger: bool, custom
def _quality_tail(quality_preset: str, custom_quality: str) -> str:
return _clean(custom_quality) or SDXL_QUALITY_PRESETS.get(quality_preset, SDXL_QUALITY_PRESETS["pony_high"])
return _clean(custom_quality) or SDXL_QUALITY_PRESETS.get(
quality_preset,
SDXL_QUALITY_PRESETS[sdxl_policy.DEFAULT_QUALITY_PRESET],
)
def _soft_tags(row: dict[str, Any], root: dict[str, Any], nude_weight: float) -> str:
@@ -488,8 +457,8 @@ def format_sdxl_prompt(
extra_positive: str = "",
extra_negative: str = "",
) -> dict[str, str]:
style_preset = style_preset if style_preset in SDXL_STYLE_PRESETS else "flat_vector_pony"
quality_preset = quality_preset if quality_preset in SDXL_QUALITY_PRESETS else "pony_high"
style_preset = sdxl_policy.normalize_style_preset(style_preset)
quality_preset = sdxl_policy.normalize_quality_preset(quality_preset)
target = target if target in ("auto", "single", "softcore", "hardcore") else "auto"
nude_weight = max(0.1, min(3.0, float(nude_weight)))
row, method = _row_from_inputs(source_text, metadata_json, input_hint)