Naturalize Krea camera and expression labels
This commit is contained in:
+23
-7
@@ -324,14 +324,30 @@ def _expression_phrase(expression: Any) -> str:
|
|||||||
expression,
|
expression,
|
||||||
flags=re.IGNORECASE,
|
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}"
|
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:
|
def _camera_phrase(row: dict[str, Any]) -> str:
|
||||||
directive = _clean(row.get("camera_directive"))
|
directive = _clean(row.get("camera_directive"))
|
||||||
if directive:
|
if directive:
|
||||||
return directive
|
return _natural_camera_phrase(directive)
|
||||||
config = row.get("camera_config")
|
config = row.get("camera_config")
|
||||||
if isinstance(config, dict):
|
if isinstance(config, dict):
|
||||||
detail = _clean(config.get("camera_detail"))
|
detail = _clean(config.get("camera_detail"))
|
||||||
@@ -341,13 +357,13 @@ def _camera_phrase(row: dict[str, Any]) -> str:
|
|||||||
if custom:
|
if custom:
|
||||||
base = _clean(config.get("camera_mode")).replace("_", " ")
|
base = _clean(config.get("camera_mode")).replace("_", " ")
|
||||||
pieces = [piece for piece in (base, custom) if piece and piece != "standard"]
|
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("_", " ")
|
mode = _clean(config.get("camera_mode")).replace("_", " ")
|
||||||
shot = _clean(config.get("shot_size")).replace("_", " ")
|
shot = _clean(config.get("shot_size")).replace("_", " ")
|
||||||
angle = _clean(config.get("angle")).replace("_", " ")
|
angle = _clean(config.get("angle")).replace("_", " ")
|
||||||
pieces = [piece for piece in (mode, shot, angle) if piece and piece != "auto" and piece != "standard"]
|
pieces = [piece for piece in (mode, shot, angle) if piece and piece != "auto" and piece != "standard"]
|
||||||
if pieces:
|
if pieces:
|
||||||
return "Camera: " + ", ".join(pieces)
|
return _natural_camera_phrase(", ".join(pieces))
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
@@ -365,7 +381,7 @@ def _camera_phrase_from_config(config: Any) -> str:
|
|||||||
if custom:
|
if custom:
|
||||||
base = _clean(config.get("camera_mode")).replace("_", " ")
|
base = _clean(config.get("camera_mode")).replace("_", " ")
|
||||||
pieces = [piece for piece in (base, custom) if piece and piece != "standard"]
|
pieces = [piece for piece in (base, custom) if piece and piece != "standard"]
|
||||||
return "Camera: " + ", ".join(pieces)
|
return _natural_camera_phrase(", ".join(pieces))
|
||||||
values = [
|
values = [
|
||||||
_clean(config.get("camera_mode")).replace("_", " "),
|
_clean(config.get("camera_mode")).replace("_", " "),
|
||||||
_clean(config.get("shot_size")).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")]
|
pieces = [value for value in values if value and value not in ("auto", "standard")]
|
||||||
if not pieces:
|
if not pieces:
|
||||||
return ""
|
return ""
|
||||||
return "Camera: " + ", ".join(pieces)
|
return _natural_camera_phrase(", ".join(pieces))
|
||||||
|
|
||||||
|
|
||||||
def _pair_camera_phrase(directive: Any, config: Any, row: dict[str, Any]) -> str:
|
def _pair_camera_phrase(directive: Any, config: Any, row: dict[str, Any]) -> str:
|
||||||
directive_text = _clean(directive)
|
directive_text = _clean(directive)
|
||||||
if directive_text:
|
if directive_text:
|
||||||
return directive_text
|
return _natural_camera_phrase(directive_text)
|
||||||
if isinstance(config, dict) and (
|
if isinstance(config, dict) and (
|
||||||
_clean(config.get("camera_detail")) == "off" or _clean(config.get("camera_mode")) == "disabled"
|
_clean(config.get("camera_detail")) == "off" or _clean(config.get("camera_mode")) == "disabled"
|
||||||
):
|
):
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ SOFTCORE_NOISE_TERMS = (
|
|||||||
|
|
||||||
FORMATTER_LABEL_LEAKS = (
|
FORMATTER_LABEL_LEAKS = (
|
||||||
"body exposure:",
|
"body exposure:",
|
||||||
|
"camera:",
|
||||||
"camera control:",
|
"camera control:",
|
||||||
"characters:",
|
"characters:",
|
||||||
"clothing:",
|
"clothing:",
|
||||||
@@ -52,6 +53,7 @@ FORMATTER_LABEL_LEAKS = (
|
|||||||
"composition:",
|
"composition:",
|
||||||
"facial expression:",
|
"facial expression:",
|
||||||
"facial expressions:",
|
"facial expressions:",
|
||||||
|
"expressions:",
|
||||||
"hardcore setup:",
|
"hardcore setup:",
|
||||||
"outfit:",
|
"outfit:",
|
||||||
"pose:",
|
"pose:",
|
||||||
|
|||||||
Reference in New Issue
Block a user