Extract Krea POV support helpers
This commit is contained in:
+14
-66
@@ -29,6 +29,13 @@ try:
|
||||
prompt_cast_descriptors as _prompt_cast_descriptors,
|
||||
)
|
||||
from .krea_clothing import natural_clothing_state as _natural_clothing_state
|
||||
from .krea_pov import (
|
||||
filter_pov_labeled_clauses as _filter_pov_labeled_clauses,
|
||||
merge_labels as _merge_labels,
|
||||
pov_camera_phrase as _pov_camera_phrase,
|
||||
pov_composition_text as _pov_composition_text,
|
||||
pov_labels_from_value as _pov_labels_from_value,
|
||||
)
|
||||
from .prompt_hygiene import sanitize_negative_text, sanitize_prose_text
|
||||
except ImportError: # Allows local smoke tests with `python -c`.
|
||||
from krea_action_context import (
|
||||
@@ -55,6 +62,13 @@ except ImportError: # Allows local smoke tests with `python -c`.
|
||||
prompt_cast_descriptors as _prompt_cast_descriptors,
|
||||
)
|
||||
from krea_clothing import natural_clothing_state as _natural_clothing_state
|
||||
from krea_pov import (
|
||||
filter_pov_labeled_clauses as _filter_pov_labeled_clauses,
|
||||
merge_labels as _merge_labels,
|
||||
pov_camera_phrase as _pov_camera_phrase,
|
||||
pov_composition_text as _pov_composition_text,
|
||||
pov_labels_from_value as _pov_labels_from_value,
|
||||
)
|
||||
from prompt_hygiene import sanitize_negative_text, sanitize_prose_text
|
||||
|
||||
|
||||
@@ -230,41 +244,6 @@ def _combine_negative(*parts: str) -> str:
|
||||
return ", ".join(cleaned)
|
||||
|
||||
|
||||
def _pov_labels_from_value(value: Any) -> list[str]:
|
||||
labels: list[str] = []
|
||||
if isinstance(value, list):
|
||||
candidates = value
|
||||
else:
|
||||
candidates = re.split(r"[,;]\s*", _clean(value)) if _clean(value) else []
|
||||
for candidate in candidates:
|
||||
label = _clean(candidate)
|
||||
if re.match(r"^Man [A-Z]$", label) and label not in labels:
|
||||
labels.append(label)
|
||||
return labels
|
||||
|
||||
|
||||
def _merge_labels(*groups: list[str]) -> list[str]:
|
||||
merged: list[str] = []
|
||||
for group in groups:
|
||||
for label in group:
|
||||
if label and label not in merged:
|
||||
merged.append(label)
|
||||
return merged
|
||||
|
||||
|
||||
def _filter_pov_labeled_clauses(text: Any, pov_labels: list[str]) -> str:
|
||||
rendered = _clean(text)
|
||||
if not rendered or not pov_labels:
|
||||
return rendered
|
||||
clauses = [clause.strip() for clause in rendered.split(";") if clause.strip()]
|
||||
filtered = [
|
||||
clause
|
||||
for clause in clauses
|
||||
if not any(re.match(rf"^{re.escape(label)}\b", clause) for label in pov_labels)
|
||||
]
|
||||
return "; ".join(filtered)
|
||||
|
||||
|
||||
def _pov_ejaculation_target(context: str) -> str:
|
||||
if any(token in context for token in ("face", "mouth", "lips", "tongue", "chin")):
|
||||
return "onto her face and chest"
|
||||
@@ -562,37 +541,6 @@ def _pov_action_phrase(
|
||||
return rendered
|
||||
|
||||
|
||||
def _pov_camera_phrase(pov_labels: list[str], softcore: bool = False) -> str:
|
||||
if not pov_labels:
|
||||
return ""
|
||||
if softcore:
|
||||
return (
|
||||
"Camera is the male participant's first-person creator view in one continuous frame, with him implied by perspective or foreground cues"
|
||||
)
|
||||
return (
|
||||
"Camera is the male participant's first-person view in one continuous frame; only his foreground hands or body cues appear"
|
||||
)
|
||||
|
||||
|
||||
def _pov_composition_text(composition: Any, pov_labels: list[str]) -> str:
|
||||
text = _clean(composition)
|
||||
if not text or not pov_labels:
|
||||
return text
|
||||
text = re.sub(r"\ball participants visible\b", "visible partners readable", text, flags=re.IGNORECASE)
|
||||
text = re.sub(r"\ball adult bodies visible\b", "visible partners readable", text, flags=re.IGNORECASE)
|
||||
text = re.sub(r"\ball bodies visible\b", "visible partners readable", text, flags=re.IGNORECASE)
|
||||
text = re.sub(r"\ball three bodies readable\b", "visible partner bodies readable", text, flags=re.IGNORECASE)
|
||||
text = re.sub(r"\bwide group-sex composition\b", "first-person group-sex POV composition", text, flags=re.IGNORECASE)
|
||||
text = re.sub(
|
||||
r",?\s*adapted for first-person POV with the POV participant kept off-camera\b",
|
||||
"",
|
||||
text,
|
||||
flags=re.IGNORECASE,
|
||||
)
|
||||
text = re.sub(r",?\s*with the POV participant kept off-camera\b", "", text, flags=re.IGNORECASE)
|
||||
return _clean(text)
|
||||
|
||||
|
||||
def _sanitize_scene_text_for_cast(text: Any, labels: list[str]) -> str:
|
||||
text = _clean(text)
|
||||
if not text:
|
||||
|
||||
Reference in New Issue
Block a user