Add expression enable controls
This commit is contained in:
+41
-4
@@ -40,6 +40,18 @@ def _clean(value: Any) -> str:
|
||||
return text
|
||||
|
||||
|
||||
def _is_false(value: Any) -> bool:
|
||||
if isinstance(value, bool):
|
||||
return value is False
|
||||
if isinstance(value, str):
|
||||
return value.strip().lower() in ("false", "0", "no", "off")
|
||||
return False
|
||||
|
||||
|
||||
def _expression_disabled(row: dict[str, Any]) -> bool:
|
||||
return bool(row.get("expression_disabled")) or _is_false(row.get("expression_enabled", True))
|
||||
|
||||
|
||||
def _sentence(text: str) -> str:
|
||||
text = _clean(text).strip(" ,;")
|
||||
if not text:
|
||||
@@ -1009,6 +1021,15 @@ def _appearance_phrase(row: dict[str, Any]) -> str:
|
||||
return ", ".join(_clean(part) for part in parts if _clean(part))
|
||||
|
||||
|
||||
def _expression_phrase(expression: Any) -> str:
|
||||
expression = _clean(expression)
|
||||
if not expression:
|
||||
return ""
|
||||
if ";" in expression or re.search(r"\b(?:Woman|Man) [A-Z] has\b|\bthe (?:woman|man) has\b", expression):
|
||||
return f"Expressions: {expression}"
|
||||
return f"with {expression}"
|
||||
|
||||
|
||||
def _camera_phrase(row: dict[str, Any]) -> str:
|
||||
directive = _clean(row.get("camera_directive"))
|
||||
if directive:
|
||||
@@ -1090,7 +1111,9 @@ def _normal_row_to_krea(row: dict[str, Any], detail_level: str, style_mode: str)
|
||||
item = re.sub(r",?\s*(fashion editorial|resort) styling$", "", item, flags=re.IGNORECASE)
|
||||
scene = _row_value(row, "scene_text", ("Setting", "Scene")) or _clean(row.get("scene"))
|
||||
pose = _row_value(row, "pose", ("Sexual pose", "Pose"))
|
||||
expression = _row_value(row, "expression", ("Facial expressions", "Facial expression"))
|
||||
expression = ""
|
||||
if not _expression_disabled(row):
|
||||
expression = _row_value(row, "character_expression_text") or _row_value(row, "expression", ("Facial expressions", "Facial expression"))
|
||||
composition = re.sub(r"^vertical\s+", "", _row_value(row, "composition", ("Composition",)), flags=re.IGNORECASE)
|
||||
camera = _camera_phrase(row)
|
||||
style = _style_phrase(row, style_mode)
|
||||
@@ -1111,6 +1134,7 @@ def _normal_row_to_krea(row: dict[str, Any], detail_level: str, style_mode: str)
|
||||
cast_prose, cast_labels = _cast_prose(cast_descriptor_text)
|
||||
if not cast_labels and women_count == 1 and men_count == 1:
|
||||
cast_labels = ["Woman A", "Man A"]
|
||||
expression = _natural_label_text(expression, cast_labels)
|
||||
role_graph = _sanitize_scene_text_for_cast(row.get("role_graph"), cast_labels)
|
||||
item = _sanitize_scene_text_for_cast(item, cast_labels)
|
||||
role_graph = _natural_label_text(role_graph, cast_labels)
|
||||
@@ -1123,7 +1147,7 @@ def _normal_row_to_krea(row: dict[str, Any], detail_level: str, style_mode: str)
|
||||
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 {scene}" if scene else "",
|
||||
f"Facial expressions are {expression}" if expression else "",
|
||||
_expression_phrase(expression),
|
||||
_composition_phrase(composition, action, "The image is framed as"),
|
||||
camera,
|
||||
style if detail_level != "concise" else "",
|
||||
@@ -1228,6 +1252,19 @@ def _insta_pair_to_krea(row: dict[str, Any], detail_level: str, style_mode: str)
|
||||
partner_pose = ""
|
||||
partner_outfit_text = _natural_label_text(partner_outfit_text, soft_labels)
|
||||
|
||||
soft_expression = ""
|
||||
if not _expression_disabled(soft):
|
||||
soft_expression = _natural_label_text(
|
||||
_clean(soft.get("character_expression_text")) or _clean(soft.get("expression")),
|
||||
soft_labels,
|
||||
)
|
||||
hard_expression = ""
|
||||
if not _expression_disabled(hard):
|
||||
hard_expression = _natural_label_text(
|
||||
_clean(hard.get("character_expression_text")) or _clean(hard.get("expression")),
|
||||
hard_labels,
|
||||
)
|
||||
|
||||
soft_parts = [
|
||||
soft_cast_prose,
|
||||
soft_cast_presence,
|
||||
@@ -1235,7 +1272,7 @@ def _insta_pair_to_krea(row: dict[str, Any], detail_level: str, style_mode: str)
|
||||
partner_pose,
|
||||
f"wearing {soft.get('item')}" if soft.get("item") else "",
|
||||
f"{soft.get('pose')}" if soft.get("pose") else "",
|
||||
f"with {soft.get('expression')}" if soft.get("expression") else "",
|
||||
_expression_phrase(soft_expression),
|
||||
f"in {soft.get('scene_text')}" if soft.get("scene_text") else "",
|
||||
f"framed as {soft.get('composition')}" if soft.get("composition") else "",
|
||||
soft_camera,
|
||||
@@ -1246,7 +1283,7 @@ def _insta_pair_to_krea(row: dict[str, Any], detail_level: str, style_mode: str)
|
||||
_natural_clothing_state(row.get("hardcore_clothing_state")),
|
||||
hard_cast_prose,
|
||||
f"set in {hard_scene}" if hard_scene else "",
|
||||
f"with {hard.get('expression')}" if hard.get("expression") else "",
|
||||
_expression_phrase(hard_expression),
|
||||
_composition_phrase(hard_composition, hard_action),
|
||||
hard_camera,
|
||||
hard_style if detail_level != "concise" else "",
|
||||
|
||||
Reference in New Issue
Block a user