Tighten Krea2 POV selector formatting

This commit is contained in:
2026-06-30 20:12:09 +02:00
parent f5ba07e340
commit 5f4dd7d77f
5 changed files with 194 additions and 21 deletions
+47 -2
View File
@@ -4,6 +4,10 @@ from dataclasses import dataclass
from typing import Any, Callable
MOUTH_EXPRESSION_TERMS = ("mouth", "oral", "tongue", "lips", "gagging", "saliva", "drool")
TOP_VIEW_ORAL_VARIANT = "pov_blowjob_top_down_vertical_shaft"
@dataclass(frozen=True)
class KreaConfiguredCastRequest:
row: dict[str, Any]
@@ -76,6 +80,45 @@ def _coworking_action_anchor(action_family: str, scene_text: str, action: str) -
)
def _list_values(value: Any) -> list[str]:
if isinstance(value, list):
return [str(item) for item in value if str(item).strip()]
if isinstance(value, str) and value.strip():
return [part.strip() for part in value.split(",") if part.strip()]
return []
def _krea2_variant_keys(row: dict[str, Any]) -> list[str]:
config = row.get("hardcore_position_config") if isinstance(row.get("hardcore_position_config"), dict) else {}
axis_values = row.get("item_axis_values") if isinstance(row.get("item_axis_values"), dict) else {}
return list(dict.fromkeys([*_list_values(config.get("krea2_variant_keys")), *_list_values(axis_values.get("krea2_variant_keys"))]))
def _has_krea2_variant(row: dict[str, Any], key: str) -> bool:
return key in _krea2_variant_keys(row)
def _filter_expression_for_krea2_variant(row: dict[str, Any], expression: Any) -> Any:
if not _has_krea2_variant(row, TOP_VIEW_ORAL_VARIANT):
return expression
clauses = [clause.strip() for clause in str(expression or "").split(";") if clause.strip()]
if not clauses:
return expression
kept = [
clause
for clause in clauses
if not any(term in clause.lower() for term in MOUTH_EXPRESSION_TERMS)
]
return "; ".join(kept)
def _filter_camera_scene_for_krea2_variant(row: dict[str, Any], camera_scene: Any) -> str:
text = str(camera_scene or "")
if _has_krea2_variant(row, TOP_VIEW_ORAL_VARIANT) and "eye-level" in text.lower():
return ""
return text
def format_configured_cast_result(
request: KreaConfiguredCastRequest,
deps: KreaConfiguredCastDependencies,
@@ -97,7 +140,8 @@ def format_configured_cast_result(
if not cast_labels and women_count == 1 and men_count == 1:
cast_labels = ["Woman A", "Man A"]
cast_labels = deps.merge_labels(cast_labels, pov_labels)
expression = deps.filter_pov_labeled_clauses(request.expression, pov_labels)
expression = _filter_expression_for_krea2_variant(row, request.expression)
expression = deps.filter_pov_labeled_clauses(expression, pov_labels)
expression = deps.natural_label_text(expression, cast_labels)
composition = deps.sanitize_hardcore_environment_anchors(request.composition)
source_composition = deps.sanitize_hardcore_environment_anchors(request.source_composition)
@@ -136,6 +180,7 @@ def format_configured_cast_result(
" ".join(part for part in (request.scene, request.camera_scene, composition, source_composition) if part),
action,
)
camera_scene = _filter_camera_scene_for_krea2_variant(row, request.camera_scene)
output_composition = deps.pov_composition_text(composition, pov_labels)
parts = [
action,
@@ -145,7 +190,7 @@ def format_configured_cast_result(
f"A consensual explicit adult scene with {subject}" if not action else "",
f"The cast includes {cast}" if cast and not cast_prose and not (women_count == 1 and men_count == 1) else "",
f"The setting is {request.scene}" if request.scene else "",
request.camera_scene,
camera_scene,
deps.expression_phrase(expression),
deps.composition_phrase(output_composition, action, "The image is framed as", detail_density),
camera,