Add men and couple casual outfit categories
This commit is contained in:
+41
-1
@@ -52,6 +52,14 @@ def _paragraph(parts: list[str]) -> str:
|
||||
return " ".join(part for part in (_sentence(part) for part in parts) if part)
|
||||
|
||||
|
||||
def _with_indefinite_article(text: str) -> str:
|
||||
text = _clean(text)
|
||||
if not text or text.lower().startswith(("a ", "an ")):
|
||||
return text
|
||||
article = "an" if text[:1].lower() in "aeiou" else "a"
|
||||
return f"{article} {text}"
|
||||
|
||||
|
||||
def _maybe_json(text: str) -> dict[str, Any] | None:
|
||||
text = _clean(text)
|
||||
if not text.startswith("{"):
|
||||
@@ -212,6 +220,18 @@ def _style_phrase(row: dict[str, Any], style_mode: str) -> str:
|
||||
return style or suffix
|
||||
|
||||
|
||||
def _couple_clothing_phrase(item: str) -> str:
|
||||
item = _clean(item)
|
||||
lower = item.lower()
|
||||
partner_text = re.sub(r"\bPartner ([AB]) wears\b", r"Partner \1 wearing", item)
|
||||
partner_text = re.sub(r"\bPartner ([AB]) has\b", r"Partner \1 with", partner_text)
|
||||
if lower.startswith("partner a "):
|
||||
return f"The outfits show {partner_text}"
|
||||
if lower.startswith(("two ", "paired ", "coordinated ")):
|
||||
return f"The outfits are {partner_text}"
|
||||
return f"The couple wears {item}"
|
||||
|
||||
|
||||
def _normal_row_to_krea(row: dict[str, Any], detail_level: str, style_mode: str) -> tuple[str, str]:
|
||||
subject_type = _clean(row.get("subject_type"))
|
||||
primary = _clean(row.get("primary_subject"))
|
||||
@@ -245,7 +265,7 @@ def _normal_row_to_krea(row: dict[str, Any], detail_level: str, style_mode: str)
|
||||
subject = _age_subject(row, "adult woman")
|
||||
appearance = _appearance_phrase(row)
|
||||
parts = [
|
||||
f"A {subject}" if not subject.lower().startswith(("a ", "an ")) else subject,
|
||||
_with_indefinite_article(subject),
|
||||
f"with {appearance}" if appearance else "",
|
||||
f"wearing {item}" if item else "",
|
||||
f"{pose}" if pose else "",
|
||||
@@ -257,6 +277,26 @@ def _normal_row_to_krea(row: dict[str, Any], detail_level: str, style_mode: str)
|
||||
]
|
||||
return _paragraph([", ".join(part for part in parts[:6] if part), *parts[6:]]), "metadata(single)"
|
||||
|
||||
if subject_type == "couple" or primary in ("two women", "two men", "a woman and a man"):
|
||||
subject = _clean(row.get("subject_phrase") or primary or "adult couple")
|
||||
if subject == "woman and man":
|
||||
subject = "a woman and a man"
|
||||
ages = _row_value(row, "age", ("Ages",)) or _clean(row.get("age_band"))
|
||||
body = _row_value(row, "body", ("Body types",)) or _clean(row.get("body_type"))
|
||||
parts = [
|
||||
f"An adult couple: {subject}, all visibly adult",
|
||||
f"Age detail: {ages}" if ages else "",
|
||||
f"Body types: {body}" if body else "",
|
||||
_couple_clothing_phrase(item) if item else "",
|
||||
f"The pose is {pose}" if pose else "",
|
||||
f"The setting is {scene}" if scene else "",
|
||||
f"Facial expressions are {expression}" if expression else "",
|
||||
f"The image is framed as {composition}" if composition else "",
|
||||
camera,
|
||||
style if detail_level != "concise" else "",
|
||||
]
|
||||
return _paragraph(parts), "metadata(couple)"
|
||||
|
||||
subject = _age_subject(row, primary or "adult scene")
|
||||
parts = [
|
||||
f"{subject}",
|
||||
|
||||
Reference in New Issue
Block a user