Extract Insta pair output assembly

This commit is contained in:
2026-06-26 21:51:32 +02:00
parent 8bff345cf7
commit e1ec8bd823
5 changed files with 253 additions and 126 deletions
+50 -118
View File
@@ -27,6 +27,7 @@ try:
from . import generate_prompt_batches as g
from . import pair_clothing
from . import pair_camera
from . import pair_output
from . import scene_camera_adapters
from .hardcore_text_cleanup import (
sanitize_hardcore_axis_values as _sanitize_hardcore_axis_values,
@@ -58,6 +59,7 @@ except ImportError: # Allows local smoke tests with `python -c`.
import generate_prompt_batches as g
import pair_clothing
import pair_camera
import pair_output
import scene_camera_adapters
from hardcore_text_cleanup import (
sanitize_hardcore_axis_values as _sanitize_hardcore_axis_values,
@@ -2797,13 +2799,6 @@ def _disable_row_expression(row: dict[str, Any], source: str = "disabled") -> di
return row
def _labeled_expression_sentence(label: str, expression: Any) -> str:
expression = str(expression or "").strip()
if not expression:
return ""
return f"{label}: {expression}. "
def _prepend_trigger(prompt: str, trigger: str, enabled: bool) -> str:
trigger = trigger.strip()
if not enabled or not trigger:
@@ -6959,10 +6954,6 @@ def _insta_of_partner_styling(
}
def _insta_of_active_trigger(prompt: str, trigger: str, enabled: bool) -> str:
return _prepend_trigger(prompt, trigger, enabled)
def build_insta_of_pair(
row_number: int,
start_index: int,
@@ -7256,111 +7247,52 @@ def build_insta_of_pair(
else f"Woman A: {descriptor}. "
)
soft_prompt = (
f"Insta/OF softcore mode: {platform_style}. "
f"{soft_descriptor_sentence}"
f"Softcore setup: {soft_level}. Cast: {soft_cast}. "
f"{soft_cast_presence}"
f"{soft_cast_styling_sentence}"
f"{soft_row['softcore_item_prompt_label']}: {soft_row['item']}. Pose: {soft_row['pose']}. Setting: {soft_row['scene_text']}. "
f"{soft_camera_scene_sentence}"
f"{_labeled_expression_sentence('Facial expression', soft_row.get('expression'))}"
f"Composition: {soft_row['composition']}. "
f"{soft_camera_sentence}"
"Keep the softcore version seductive, creator-shot, and styled as a soft teaser. "
f"{soft_row['positive_suffix']}."
return pair_output.assemble_insta_pair_metadata(
active_trigger=active_trigger,
prepend_trigger_to_prompt=bool(prepend_trigger_to_prompt),
extra_positive=extra_positive,
extra_negative=extra_negative,
soft_negative_base=INSTA_OF_SOFT_NEGATIVE,
hard_negative_base=INSTA_OF_NEGATIVE,
options=options,
platform_style=platform_style,
soft_descriptor_sentence=soft_descriptor_sentence,
soft_level=soft_level,
soft_cast=soft_cast,
soft_cast_presence=soft_cast_presence,
soft_cast_styling_sentence=soft_cast_styling_sentence,
soft_row=soft_row,
soft_camera_scene_sentence=soft_camera_scene_sentence,
soft_camera_sentence=soft_camera_sentence,
hard_level=hard_level,
hard_cast=hard_cast,
cast_descriptor_text=cast_descriptor_text,
pov_directive=pov_directive,
pov_character_labels=pov_character_labels,
hard_clothing_sentence=hard_clothing_sentence,
hard_row=hard_row,
hard_scene=hard_scene,
hard_camera_scene_sentence=hard_camera_scene_sentence,
hard_composition=hard_composition,
hard_detail_directive=hard_detail_directive,
hard_camera_sentence=hard_camera_sentence,
descriptor=descriptor,
soft_partner_outfit_text=soft_partner_outfit_text,
soft_partner_styling=soft_partner_styling,
soft_camera_scene_directive=soft_camera_scene_directive,
soft_camera_config=soft_camera_config,
soft_camera_directive=soft_camera_directive,
hard_camera_scene_directive=hard_camera_scene_directive,
hard_camera_config=hard_camera_config,
hard_camera_directive=hard_camera_directive,
camera_caption_text=_camera_caption_text,
cast_descriptors=cast_descriptors,
character_hardcore_clothing_entries=character_hardcore_clothing_entries,
default_man_hardcore_clothing_entries=default_man_hardcore_clothing_entries,
hard_clothing_state=hard_clothing_state,
hard_detail_density=hard_detail_density,
hard_women_count=hard_women_count,
hard_men_count=hard_men_count,
character_slots=character_slots,
character_slot_map=character_slot_map,
)
hard_prompt = (
f"Insta/OF hardcore mode: {platform_style}. "
f"Hardcore setup: {hard_level}. Cast: {hard_cast}. "
f"Cast descriptors: {cast_descriptor_text}. "
f"{pov_directive + ' ' if pov_directive else ''}"
f"{'Keep Woman A visually central from the POV camera. ' if pov_character_labels else 'Keep Woman A visually central. '}"
f"{hard_clothing_sentence}"
f"Role graph: {hard_row['role_graph']} Sexual scene: {hard_row['item']}. "
f"Setting: {hard_scene}. "
f"{hard_camera_scene_sentence}"
f"{_labeled_expression_sentence('Facial expressions', hard_row.get('expression'))}"
f"Composition: {hard_composition}. "
f"{hard_detail_directive}"
f"{hard_camera_sentence}"
f"{hard_row['positive_suffix']}."
)
if extra_positive.strip():
soft_prompt = f"{soft_prompt.rstrip()} {extra_positive.strip()}"
hard_prompt = f"{hard_prompt.rstrip()} {extra_positive.strip()}"
soft_prompt = _insta_of_active_trigger(soft_prompt, active_trigger, bool(prepend_trigger_to_prompt))
hard_prompt = _insta_of_active_trigger(hard_prompt, active_trigger, bool(prepend_trigger_to_prompt))
soft_prompt = sanitize_prompt_text(soft_prompt, triggers=(active_trigger,))
hard_prompt = sanitize_prompt_text(hard_prompt, triggers=(active_trigger,))
soft_negative = sanitize_negative_text(_combined_negative(INSTA_OF_SOFT_NEGATIVE, extra_negative))
hard_negative = sanitize_negative_text(_combined_negative(INSTA_OF_NEGATIVE, extra_negative))
soft_caption_parts = [
active_trigger,
"Insta/OF softcore mode",
descriptor,
soft_level,
soft_row["item"],
soft_row["pose"],
soft_partner_outfit_text,
soft_partner_styling["pose"],
soft_row["scene_text"],
soft_camera_scene_directive,
soft_row["composition"],
_camera_caption_text(soft_camera_config) if soft_camera_directive else "",
]
soft_caption = sanitize_caption_text(
", ".join(str(part).strip() for part in soft_caption_parts if str(part).strip()),
triggers=(active_trigger,),
)
hard_caption_parts = [
active_trigger,
"Insta/OF hardcore mode",
"Woman A",
descriptor,
hard_cast,
hard_row["role_graph"],
hard_row["item"],
hard_scene,
hard_camera_scene_directive,
hard_composition,
_camera_caption_text(hard_camera_config) if hard_camera_directive else "",
]
hard_caption = sanitize_caption_text(
", ".join(str(part).strip() for part in hard_caption_parts if str(part).strip()),
triggers=(active_trigger,),
)
metadata = {
"mode": "Insta/OF",
"options": options,
"shared_descriptor": descriptor,
"shared_cast_descriptors": cast_descriptors,
"pov_character_labels": pov_character_labels,
"pov_prompt_directive": pov_directive,
"softcore_partner_styling": soft_partner_styling,
"character_hardcore_clothing": character_hardcore_clothing_entries,
"default_man_hardcore_clothing": default_man_hardcore_clothing_entries,
"hardcore_clothing_state": hard_clothing_state,
"hardcore_detail_density": hard_detail_density,
"hardcore_position_config": hard_row.get("hardcore_position_config", {}),
"softcore_prompt": soft_prompt,
"hardcore_prompt": hard_prompt,
"softcore_negative_prompt": soft_negative,
"hardcore_negative_prompt": hard_negative,
"softcore_caption": soft_caption,
"hardcore_caption": hard_caption,
"softcore_row": soft_row,
"hardcore_row": hard_row,
"hardcore_women_count": hard_women_count,
"hardcore_men_count": hard_men_count,
"character_cast_slots": character_slots,
"character_slot_labels": sorted(character_slot_map),
"softcore_camera_config": soft_camera_config,
"hardcore_camera_config": hard_camera_config,
"softcore_camera_directive": soft_camera_directive,
"hardcore_camera_directive": hard_camera_directive,
"softcore_camera_scene_directive": soft_camera_scene_directive,
"hardcore_camera_scene_directive": hard_camera_scene_directive,
}
return metadata