Extract Insta pair builder orchestration
This commit is contained in:
+60
-199
@@ -26,11 +26,8 @@ try:
|
||||
from . import generation_profile_config as generation_profile_policy
|
||||
from . import hardcore_position_config as hardcore_position_policy
|
||||
from . import location_config as location_policy
|
||||
from . import pair_clothing
|
||||
from . import pair_camera
|
||||
from . import pair_builder
|
||||
from . import pair_cast
|
||||
from . import pair_output
|
||||
from . import pair_rows
|
||||
from . import pair_options
|
||||
from . import pov_policy
|
||||
from . import row_normalization as row_policy
|
||||
@@ -75,11 +72,8 @@ except ImportError: # Allows local smoke tests with `python -c`.
|
||||
import generation_profile_config as generation_profile_policy
|
||||
import hardcore_position_config as hardcore_position_policy
|
||||
import location_config as location_policy
|
||||
import pair_clothing
|
||||
import pair_camera
|
||||
import pair_builder
|
||||
import pair_cast
|
||||
import pair_output
|
||||
import pair_rows
|
||||
import pair_options
|
||||
import pov_policy
|
||||
import row_normalization as row_policy
|
||||
@@ -2773,6 +2767,52 @@ def _insta_of_softcore_pose(rng: random.Random, level: str) -> str:
|
||||
return g.choose(rng, pair_options.softcore_pose_pool(level))
|
||||
|
||||
|
||||
def _insta_pair_build_dependencies() -> pair_builder.InstaPairBuildDependencies:
|
||||
return pair_builder.InstaPairBuildDependencies(
|
||||
default_trigger=g.TRIGGER,
|
||||
random_subcategory=RANDOM_SUBCATEGORY,
|
||||
soft_negative_base=INSTA_OF_SOFT_NEGATIVE,
|
||||
hard_negative_base=INSTA_OF_NEGATIVE,
|
||||
camera_detail_choices=CAMERA_DETAIL_CHOICES,
|
||||
hardcore_clothing_continuity=INSTA_OF_HARDCORE_CLOTHING_CONTINUITY,
|
||||
platform_styles=INSTA_OF_PLATFORM_STYLES,
|
||||
soft_levels=INSTA_OF_SOFT_LEVELS,
|
||||
hardcore_levels=INSTA_OF_HARDCORE_LEVELS,
|
||||
parse_options=_parse_insta_of_options,
|
||||
parse_filter_config=_parse_filter_config,
|
||||
parse_seed_config=_parse_seed_config,
|
||||
parse_character_cast=_parse_character_cast,
|
||||
character_slot_label_map=_character_slot_label_map,
|
||||
pov_character_labels=_pov_character_labels,
|
||||
softcore_category=_insta_of_softcore_category,
|
||||
build_prompt=build_prompt,
|
||||
axis_rng=_axis_rng,
|
||||
cast_expression_intensity_override=_cast_expression_intensity_override,
|
||||
context_from_character_slot=_context_from_character_slot,
|
||||
apply_character_context_to_row=_apply_character_context_to_row,
|
||||
disable_row_expression=_disable_row_expression,
|
||||
slot_softcore_outfit=_slot_softcore_outfit,
|
||||
softcore_outfit=_insta_of_softcore_outfit,
|
||||
softcore_pose=_insta_of_softcore_pose,
|
||||
softcore_item_prompt_label=_insta_of_softcore_item_prompt_label,
|
||||
pov_prompt_directive=_pov_prompt_directive,
|
||||
pov_composition_prompt=_pov_composition_prompt,
|
||||
hardcore_counts=_insta_of_hardcore_counts,
|
||||
character_context_for_label=_character_context_for_label,
|
||||
slot_is_pov=_slot_is_pov,
|
||||
choose=g.choose,
|
||||
camera_config_with_mode=_camera_config_with_mode,
|
||||
camera_directive=_camera_directive,
|
||||
apply_contextual_composition=_apply_coworking_composition,
|
||||
contextual_composition_prompt=_coworking_composition_prompt,
|
||||
composition_prompt=_composition_prompt,
|
||||
camera_scene_directive_for_context=_camera_scene_directive_for_context,
|
||||
slot_hardcore_clothing=_slot_hardcore_clothing,
|
||||
hardcore_detail_directive=pair_options.hardcore_detail_directive,
|
||||
camera_caption_text=_camera_caption_text,
|
||||
)
|
||||
|
||||
|
||||
def build_insta_of_pair(
|
||||
row_number: int,
|
||||
start_index: int,
|
||||
@@ -2797,207 +2837,28 @@ def build_insta_of_pair(
|
||||
extra_positive: str = "",
|
||||
extra_negative: str = "",
|
||||
) -> dict[str, Any]:
|
||||
options = _parse_insta_of_options(options_json)
|
||||
if filter_config:
|
||||
filters = _parse_filter_config(filter_config)
|
||||
ethnicity = filters["ethnicity"]
|
||||
figure = filters["figure"]
|
||||
no_plus_women = filters["no_plus_women"]
|
||||
no_black = filters["no_black"]
|
||||
hard_women_count, hard_men_count = _insta_of_hardcore_counts(options)
|
||||
active_trigger = trigger.strip() or g.TRIGGER
|
||||
parsed_seed_config = _parse_seed_config(seed_config)
|
||||
character_slots = _parse_character_cast(character_cast)
|
||||
character_slot_map = _character_slot_label_map(character_slots)
|
||||
pov_character_labels = _pov_character_labels(character_slot_map, hard_men_count)
|
||||
softcore_level_key = str(options["softcore_level"])
|
||||
soft_category, soft_subcategory = _insta_of_softcore_category(softcore_level_key)
|
||||
row_route = pair_rows.build_insta_pair_rows_result(
|
||||
request = pair_builder.InstaPairBuildRequest(
|
||||
row_number=row_number,
|
||||
start_index=start_index,
|
||||
seed=seed,
|
||||
active_trigger=active_trigger,
|
||||
parsed_seed_config=parsed_seed_config,
|
||||
options=options,
|
||||
ethnicity=ethnicity,
|
||||
figure=figure,
|
||||
no_plus_women=no_plus_women,
|
||||
no_black=no_black,
|
||||
character_profile=character_profile,
|
||||
character_cast=character_cast or "",
|
||||
character_slot_map=character_slot_map,
|
||||
pov_character_labels=pov_character_labels,
|
||||
hard_women_count=hard_women_count,
|
||||
hard_men_count=hard_men_count,
|
||||
soft_category=soft_category,
|
||||
soft_subcategory=soft_subcategory,
|
||||
softcore_level_key=softcore_level_key,
|
||||
hardcore_random_subcategory=RANDOM_SUBCATEGORY,
|
||||
hardcore_position_config=hardcore_position_config,
|
||||
location_config=location_config or "",
|
||||
composition_config=composition_config or "",
|
||||
build_prompt=build_prompt,
|
||||
axis_rng=_axis_rng,
|
||||
cast_expression_intensity_override=_cast_expression_intensity_override,
|
||||
context_from_character_slot=_context_from_character_slot,
|
||||
apply_character_context_to_row=_apply_character_context_to_row,
|
||||
disable_row_expression=_disable_row_expression,
|
||||
slot_softcore_outfit=_slot_softcore_outfit,
|
||||
softcore_outfit=_insta_of_softcore_outfit,
|
||||
softcore_pose=_insta_of_softcore_pose,
|
||||
softcore_item_prompt_label=_insta_of_softcore_item_prompt_label,
|
||||
pov_prompt_directive=_pov_prompt_directive,
|
||||
pov_composition_prompt=_pov_composition_prompt,
|
||||
)
|
||||
soft_row = row_route.soft_row
|
||||
hard_row = row_route.hard_row
|
||||
hard_content_rng = row_route.hard_content_rng
|
||||
|
||||
cast_context = pair_cast.resolve_insta_pair_cast_context(
|
||||
soft_row=soft_row,
|
||||
options=options,
|
||||
parsed_seed_config=parsed_seed_config,
|
||||
seed=seed,
|
||||
row_number=row_number,
|
||||
ethnicity=ethnicity,
|
||||
figure=figure,
|
||||
no_plus_women=no_plus_women,
|
||||
no_black=no_black,
|
||||
hard_women_count=hard_women_count,
|
||||
hard_men_count=hard_men_count,
|
||||
character_slots=character_slots,
|
||||
character_slot_map=character_slot_map,
|
||||
pov_character_labels=pov_character_labels,
|
||||
platform_styles=INSTA_OF_PLATFORM_STYLES,
|
||||
soft_levels=INSTA_OF_SOFT_LEVELS,
|
||||
hardcore_levels=INSTA_OF_HARDCORE_LEVELS,
|
||||
axis_rng=_axis_rng,
|
||||
character_context_for_label=_character_context_for_label,
|
||||
slot_is_pov=_slot_is_pov,
|
||||
choose=g.choose,
|
||||
slot_softcore_outfit=_slot_softcore_outfit,
|
||||
)
|
||||
descriptor = cast_context["descriptor"]
|
||||
cast_descriptors = cast_context["cast_descriptors"]
|
||||
cast_descriptor_text = cast_context["cast_descriptor_text"]
|
||||
soft_partner_styling = cast_context["soft_partner_styling"]
|
||||
soft_partner_outfit_text = cast_context["soft_partner_outfit_text"]
|
||||
platform_style = cast_context["platform_style"]
|
||||
soft_level = cast_context["soft_level"]
|
||||
hard_level = cast_context["hard_level"]
|
||||
camera_route = pair_camera.resolve_insta_pair_camera_result(
|
||||
soft_row=soft_row,
|
||||
hard_row=hard_row,
|
||||
options=options,
|
||||
trigger=trigger,
|
||||
prepend_trigger_to_prompt=prepend_trigger_to_prompt,
|
||||
seed_config=seed_config,
|
||||
options_json=options_json,
|
||||
filter_config=filter_config,
|
||||
camera_config=camera_config,
|
||||
softcore_camera_config=softcore_camera_config,
|
||||
hardcore_camera_config=hardcore_camera_config,
|
||||
hard_women_count=hard_women_count,
|
||||
hard_men_count=hard_men_count,
|
||||
pov_character_labels=pov_character_labels,
|
||||
camera_detail_choices=CAMERA_DETAIL_CHOICES,
|
||||
camera_config_with_mode=_camera_config_with_mode,
|
||||
camera_directive=_camera_directive,
|
||||
apply_contextual_composition=_apply_coworking_composition,
|
||||
contextual_composition_prompt=_coworking_composition_prompt,
|
||||
composition_prompt=_composition_prompt,
|
||||
camera_scene_directive_for_context=_camera_scene_directive_for_context,
|
||||
)
|
||||
soft_row = camera_route.soft_row
|
||||
hard_row = camera_route.hard_row
|
||||
hard_scene = camera_route.hard_scene
|
||||
hard_composition = camera_route.hard_composition
|
||||
soft_camera_config = camera_route.soft_camera_config
|
||||
hard_camera_config = camera_route.hard_camera_config
|
||||
soft_camera_directive = camera_route.soft_camera_directive
|
||||
hard_camera_directive = camera_route.hard_camera_directive
|
||||
soft_camera_scene_directive = camera_route.soft_camera_scene_directive
|
||||
hard_camera_scene_directive = camera_route.hard_camera_scene_directive
|
||||
soft_camera_scene_sentence = camera_route.soft_camera_scene_sentence
|
||||
hard_camera_scene_sentence = camera_route.hard_camera_scene_sentence
|
||||
soft_camera_sentence = camera_route.soft_camera_sentence
|
||||
hard_camera_sentence = camera_route.hard_camera_sentence
|
||||
soft_cast = cast_context["soft_cast"]
|
||||
soft_cast_presence = cast_context["soft_cast_presence"]
|
||||
soft_cast_styling_sentence = cast_context["soft_cast_styling_sentence"]
|
||||
hard_cast = cast_context["hard_cast"]
|
||||
character_hardcore_clothing_entries = pair_clothing.character_hardcore_clothing_entries(
|
||||
character_slot_map,
|
||||
hard_women_count,
|
||||
hard_men_count,
|
||||
pov_character_labels,
|
||||
hard_content_rng,
|
||||
_slot_hardcore_clothing,
|
||||
)
|
||||
clothing_route = pair_clothing.resolve_hardcore_pair_clothing_result(
|
||||
hard_row=hard_row,
|
||||
mode=options["hardcore_clothing_continuity"],
|
||||
softcore_outfit=soft_row["item"],
|
||||
character_hardcore_clothing_entries=character_hardcore_clothing_entries,
|
||||
men_count=hard_men_count,
|
||||
pov_labels=pov_character_labels,
|
||||
rng=hard_content_rng,
|
||||
continuity_map=INSTA_OF_HARDCORE_CLOTHING_CONTINUITY,
|
||||
choose=g.choose,
|
||||
)
|
||||
default_man_hardcore_clothing_entries = clothing_route.default_man_hardcore_clothing
|
||||
hard_clothing_state = clothing_route.hardcore_clothing_state
|
||||
hard_clothing_sentence = clothing_route.hardcore_clothing_sentence
|
||||
if clothing_route.requires_body_exposure_scene:
|
||||
hard_scene = pair_clothing.body_exposure_scene_text(hard_scene)
|
||||
hard_row["source_scene_text"] = hard_row.get("source_scene_text") or hard_row.get("scene_text", "")
|
||||
hard_row["scene_text"] = hard_scene
|
||||
hard_detail_density = options["hardcore_detail_density"]
|
||||
hard_detail_directive = pair_options.hardcore_detail_directive(hard_detail_density)
|
||||
pov_directive = _pov_prompt_directive(pov_character_labels)
|
||||
soft_descriptor_sentence = cast_context["soft_descriptor_sentence"]
|
||||
|
||||
return pair_output.assemble_insta_pair_metadata(
|
||||
active_trigger=active_trigger,
|
||||
prepend_trigger_to_prompt=bool(prepend_trigger_to_prompt),
|
||||
character_profile=character_profile,
|
||||
character_cast=character_cast,
|
||||
hardcore_position_config=hardcore_position_config,
|
||||
location_config=location_config,
|
||||
composition_config=composition_config,
|
||||
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,
|
||||
)
|
||||
return pair_builder.build_insta_of_pair(request, _insta_pair_build_dependencies())
|
||||
|
||||
Reference in New Issue
Block a user