Extract Krea cast and hardcore cleanup helpers
This commit is contained in:
+8
-64
@@ -11,6 +11,10 @@ from typing import Any, Callable
|
||||
try:
|
||||
from . import generate_prompt_batches as g
|
||||
from . import scene_camera_adapters
|
||||
from .hardcore_text_cleanup import (
|
||||
sanitize_hardcore_axis_values as _sanitize_hardcore_axis_values,
|
||||
sanitize_hardcore_environment_anchors as _sanitize_hardcore_environment_anchors,
|
||||
)
|
||||
from .prompt_hygiene import (
|
||||
sanitize_caption_text,
|
||||
sanitize_negative_text,
|
||||
@@ -19,6 +23,10 @@ try:
|
||||
except ImportError: # Allows local smoke tests with `python -c`.
|
||||
import generate_prompt_batches as g
|
||||
import scene_camera_adapters
|
||||
from hardcore_text_cleanup import (
|
||||
sanitize_hardcore_axis_values as _sanitize_hardcore_axis_values,
|
||||
sanitize_hardcore_environment_anchors as _sanitize_hardcore_environment_anchors,
|
||||
)
|
||||
from prompt_hygiene import (
|
||||
sanitize_caption_text,
|
||||
sanitize_negative_text,
|
||||
@@ -965,70 +973,6 @@ def _heuristic_cast_compatible(text: str, women_count: int, men_count: int) -> b
|
||||
return True
|
||||
|
||||
|
||||
HARDCORE_ENVIRONMENT_ANCHOR_REPLACEMENTS = (
|
||||
(r"\bon against a wall\b", "against a wall"),
|
||||
(r"\bstacked bodies on the bed\b", "close body alignment"),
|
||||
(r"\bstacked bodies with close body alignment\b", "close body alignment"),
|
||||
(r"\boverhead tangled-body anal frame\b", "overhead rear-entry anal frame"),
|
||||
(r"\btangled-body\b", "close-body"),
|
||||
(r"\bthree bodies tangled on the bed\b", "three bodies tangled in close contact"),
|
||||
(r"\ba triangle of bodies on the mattress\b", "a triangle of bodies in close contact"),
|
||||
(r"\bbodies tangled on the sheets\b", "bodies tangled in close contact"),
|
||||
(r"\bwet bodies tangled on sheets\b", "wet bodies tangled in close contact"),
|
||||
(r"\bbody arched on rumpled sheets\b", "body arched with clear skin contact"),
|
||||
(r"\bface-down ass-up on the mattress\b", "face-down ass-up position"),
|
||||
(r"\bsitting on the edge of the bed\b", "sitting on a raised edge"),
|
||||
(r"\blying at the bed edge with thighs open\b", "lying near a raised edge with thighs open"),
|
||||
(r"\bedge[- ]of[- ]bed\b", "edge-supported"),
|
||||
(r"\bbed[- ]edge\b", "raised edge"),
|
||||
(r"\bedge of (?:the )?bed\b", "raised edge"),
|
||||
(r"\bbed edge\b", "raised edge"),
|
||||
(r"\bhands? braced on the bed\b", "hands braced beside the body"),
|
||||
(r"\bone hand pressing into the mattress\b", "one hand braced beside the body"),
|
||||
(r"\bone foot planted on the bed\b", "one foot planted for leverage"),
|
||||
(r"\bfingers gripping sheets and skin\b", "fingers gripping skin"),
|
||||
(r"\bfingers gripping sheets\b", "fingers gripping skin"),
|
||||
(r"\bhands gripping sheets\b", "hands gripping skin"),
|
||||
(r"\bone hand gripping the sheets\b", "one hand gripping skin"),
|
||||
(r"\brumpled bed sheets\b", "wrinkled body-contact fabric"),
|
||||
(r"\bwet sheets beneath the bodies\b", "visible wetness beneath the bodies"),
|
||||
(r"\bsexual fluids on sheets\b", "sexual fluids visible on skin"),
|
||||
(r"\bcum dripping onto sheets\b", "cum visible on skin"),
|
||||
(r"\bfluid dripping onto sheets\b", "fluid visible on skin"),
|
||||
(r"\bsquirting fluid on the sheets\b", "squirting fluid visible on skin"),
|
||||
(r"\bsoft sheets\b", "soft fabric"),
|
||||
(r"\bsilk sheets\b", "silk fabric"),
|
||||
(r"\bsheets\b", "fabric"),
|
||||
(r"\bmattress\b", "low support surface"),
|
||||
(r"\ba low support surface\b", "a low body support"),
|
||||
(r"\ba low mattress\b", "a low body support"),
|
||||
(r"\ba wide couch\b", "a wide body support"),
|
||||
(r"\bwide couch\b", "wide body support"),
|
||||
(r"\bcouch\b", "body support"),
|
||||
(r"\bsofa\b", "body support"),
|
||||
(r"\bon the bed\b", "on a body support"),
|
||||
(r"\bon a bed\b", "on a body support"),
|
||||
(r"\bbedroom-floor\b", "floor-level"),
|
||||
(r"\bbedroom floor\b", "floor-level"),
|
||||
)
|
||||
|
||||
|
||||
def _sanitize_hardcore_environment_anchors(value: Any) -> str:
|
||||
text = str(value or "")
|
||||
if not text:
|
||||
return ""
|
||||
for pattern, replacement in HARDCORE_ENVIRONMENT_ANCHOR_REPLACEMENTS:
|
||||
text = re.sub(pattern, replacement, text, flags=re.IGNORECASE)
|
||||
text = re.sub(r"\s+,", ",", text)
|
||||
text = re.sub(r",\s*,", ",", text)
|
||||
text = re.sub(r"\s{2,}", " ", text)
|
||||
return text.strip()
|
||||
|
||||
|
||||
def _sanitize_hardcore_axis_values(values: dict[str, str]) -> dict[str, str]:
|
||||
return {key: _sanitize_hardcore_environment_anchors(value) for key, value in values.items()}
|
||||
|
||||
|
||||
def _compatible_entry(entry: Any, women_count: int, men_count: int) -> bool:
|
||||
if not isinstance(entry, dict):
|
||||
return _heuristic_cast_compatible(_entry_text(entry), women_count, men_count)
|
||||
|
||||
Reference in New Issue
Block a user