Keep Krea cast descriptors metadata driven

This commit is contained in:
2026-06-27 17:26:44 +02:00
parent f110ee6a89
commit 1950ce7bbf
4 changed files with 34 additions and 9 deletions
+2 -2
View File
@@ -774,10 +774,10 @@ Krea2 field consumption:
| Branch | Reads most from | Key functions |
| --- | --- | --- |
| Normal single/couple/generic row | `subject_type`, `item`, `pose`, `scene_text`, `expression`, `composition`, `camera_*`, style fields | `krea_normal_formatter.format_normal_row_result` |
| Normal configured cast/hardcore row | `cast_descriptor_text`, `women_count`, `men_count`, `source_role_graph`, `role_graph`, `item`, `item_axis_values`, `source_composition`, `pov_character_labels` | `krea_configured_cast_formatter.format_configured_cast_result`, `krea_actions.hardcore_action_sentence`, `krea_pov_actions.pov_action_phrase` |
| Normal configured cast/hardcore row | `cast_descriptor_text` only for cast descriptors, `women_count`, `men_count`, `source_role_graph`, `role_graph`, `item`, `item_axis_values`, `source_composition`, `pov_character_labels` | `krea_configured_cast_formatter.format_configured_cast_result`, `krea_actions.hardcore_action_sentence`, `krea_pov_actions.pov_action_phrase` |
| Insta/OF pair softcore | `shared_descriptor`, `softcore_row`, `softcore_partner_styling`, options, soft camera fields | `krea_pair_formatter.format_insta_pair_result` |
| Insta/OF pair hardcore | `hardcore_row`, `shared_cast_descriptors`, `hardcore_clothing_state`, `hardcore_detail_density`, hard camera fields, POV labels | `krea_pair_formatter.format_insta_pair_result`, `krea_actions.hardcore_action_sentence`, `krea_pov_actions.pov_action_phrase`, `krea_clothing.natural_clothing_state` |
| Plain text fallback | `source_text` only | `_fallback_text_to_krea` |
| Plain text fallback | `source_text` only, including raw prompt labels such as `Scene:` / `Pose:` | `_fallback_text_to_krea` |
If metadata is connected and `method` says `text(fallback)`, the formatter did
not parse metadata. That is a wiring/input-hint issue, not a prompt pool issue.
+1 -6
View File
@@ -32,7 +32,6 @@ class KreaConfiguredCastPrompt:
@dataclass(frozen=True)
class KreaConfiguredCastDependencies:
clean: Callable[[Any], str]
prompt_field: Callable[[str, str], str]
sanitize_hardcore_environment_anchors: Callable[[Any], str]
sanitize_hardcore_axis_values: Callable[[Any], Any]
sanitize_scene_text_for_cast: Callable[[Any, list[str]], str]
@@ -64,11 +63,7 @@ def format_configured_cast_result(
men_count = int(row.get("men_count") or 0)
except (TypeError, ValueError):
women_count = men_count = 0
cast_descriptor_text = (
deps.clean(row.get("cast_descriptor_text"))
or deps.prompt_field(deps.clean(row.get("prompt")), "Characters")
or deps.prompt_field(deps.clean(row.get("prompt")), "Cast descriptors")
)
cast_descriptor_text = deps.clean(row.get("cast_descriptor_text"))
pov_labels = deps.pov_labels_from_value(row.get("pov_character_labels"))
camera = request.camera
if pov_labels:
-1
View File
@@ -457,7 +457,6 @@ def _krea_normal_row_request_from_row(
def _krea_configured_cast_dependencies() -> krea_configured_cast_formatter.KreaConfiguredCastDependencies:
return krea_configured_cast_formatter.KreaConfiguredCastDependencies(
clean=_clean,
prompt_field=_prompt_field,
sanitize_hardcore_environment_anchors=_sanitize_hardcore_environment_anchors,
sanitize_hardcore_axis_values=_sanitize_hardcore_axis_values,
sanitize_scene_text_for_cast=_sanitize_scene_text_for_cast,
+31
View File
@@ -1414,6 +1414,37 @@ def smoke_krea_normal_row_routes() -> None:
}
_expect_krea_normal_route_parity(generic, "krea_normal_generic", "metadata(generic)")
configured_with_descriptor = _fixture_hardcore_row(
prompt="Characters: stale prompt subject, stale body, stale skin, stale hair, stale eyes.",
cast_descriptor_text=(
"Woman A: 30-year-old adult woman, toned figure, fair skin, red hair, gray eyes; "
"Man A: 45-year-old adult man, average figure, tan skin, dark hair"
),
)
descriptor_prompt, descriptor_method = krea_formatter._normal_row_to_krea(
configured_with_descriptor,
"balanced",
"preserve",
)
_expect(descriptor_method == "metadata(configured_cast)", "Krea configured-cast route changed method")
_expect("30-year-old adult woman" in descriptor_prompt, "Krea configured-cast route lost descriptor metadata")
_expect("toned figure" in descriptor_prompt, "Krea configured-cast route lost descriptor body metadata")
_expect("stale" not in descriptor_prompt, "Krea configured-cast route parsed stale prompt character labels")
configured_without_descriptor = _fixture_hardcore_row(
prompt="Characters: stale prompt subject, stale body, stale skin, stale hair, stale eyes.",
cast_descriptor_text="",
cast_descriptors=[],
)
no_descriptor_prompt, no_descriptor_method = krea_formatter._normal_row_to_krea(
configured_without_descriptor,
"balanced",
"preserve",
)
_expect(no_descriptor_method == "metadata(configured_cast)", "Krea configured-cast no-descriptor route changed method")
_expect("stale" not in no_descriptor_prompt, "Krea configured-cast route should not parse prompt labels without metadata")
_expect("private studio room with warm light" in no_descriptor_prompt, "Krea configured-cast route lost structured scene")
def smoke_krea_action_details_policy() -> None:
_expect(