Naturalize Krea camera and expression labels

This commit is contained in:
2026-06-27 21:26:15 +02:00
parent b6314a246a
commit 4de00bcc9d
2 changed files with 25 additions and 7 deletions
+23 -7
View File
@@ -324,14 +324,30 @@ def _expression_phrase(expression: Any) -> str:
expression,
flags=re.IGNORECASE,
):
return f"Expressions: {expression}"
expression = re.sub(
r"\b((?:Woman|Man) [A-Z]|the (?:woman|man)) has\b",
r"\1 showing",
expression,
flags=re.IGNORECASE,
)
return f"With {expression[:1].lower()}{expression[1:]}"
return f"with {expression}"
def _natural_camera_phrase(value: str) -> str:
value = _clean(value)
if not value:
return ""
value = re.sub(r"^camera:\s*", "", value, flags=re.IGNORECASE).strip()
if not value:
return ""
return f"Captured with {value}"
def _camera_phrase(row: dict[str, Any]) -> str:
directive = _clean(row.get("camera_directive"))
if directive:
return directive
return _natural_camera_phrase(directive)
config = row.get("camera_config")
if isinstance(config, dict):
detail = _clean(config.get("camera_detail"))
@@ -341,13 +357,13 @@ def _camera_phrase(row: dict[str, Any]) -> str:
if custom:
base = _clean(config.get("camera_mode")).replace("_", " ")
pieces = [piece for piece in (base, custom) if piece and piece != "standard"]
return "Camera: " + ", ".join(pieces)
return _natural_camera_phrase(", ".join(pieces))
mode = _clean(config.get("camera_mode")).replace("_", " ")
shot = _clean(config.get("shot_size")).replace("_", " ")
angle = _clean(config.get("angle")).replace("_", " ")
pieces = [piece for piece in (mode, shot, angle) if piece and piece != "auto" and piece != "standard"]
if pieces:
return "Camera: " + ", ".join(pieces)
return _natural_camera_phrase(", ".join(pieces))
return ""
@@ -365,7 +381,7 @@ def _camera_phrase_from_config(config: Any) -> str:
if custom:
base = _clean(config.get("camera_mode")).replace("_", " ")
pieces = [piece for piece in (base, custom) if piece and piece != "standard"]
return "Camera: " + ", ".join(pieces)
return _natural_camera_phrase(", ".join(pieces))
values = [
_clean(config.get("camera_mode")).replace("_", " "),
_clean(config.get("shot_size")).replace("_", " "),
@@ -378,13 +394,13 @@ def _camera_phrase_from_config(config: Any) -> str:
pieces = [value for value in values if value and value not in ("auto", "standard")]
if not pieces:
return ""
return "Camera: " + ", ".join(pieces)
return _natural_camera_phrase(", ".join(pieces))
def _pair_camera_phrase(directive: Any, config: Any, row: dict[str, Any]) -> str:
directive_text = _clean(directive)
if directive_text:
return directive_text
return _natural_camera_phrase(directive_text)
if isinstance(config, dict) and (
_clean(config.get("camera_detail")) == "off" or _clean(config.get("camera_mode")) == "disabled"
):