Add full random prompt builder mode
This commit is contained in:
@@ -20,6 +20,7 @@ PROFILE_DIR = ROOT_DIR / "profiles"
|
||||
|
||||
BUILTIN_CATEGORIES = [
|
||||
"auto_weighted",
|
||||
"auto_full",
|
||||
"woman",
|
||||
"man",
|
||||
"couple",
|
||||
@@ -1307,6 +1308,7 @@ def seed_mode_choices() -> list[str]:
|
||||
|
||||
CATEGORY_PRESETS = {
|
||||
"auto_weighted": ("auto_weighted", RANDOM_SUBCATEGORY),
|
||||
"auto_full": ("auto_full", RANDOM_SUBCATEGORY),
|
||||
"women_casual": ("Casual clothes", RANDOM_SUBCATEGORY),
|
||||
"men_casual": ("Men casual clothes", RANDOM_SUBCATEGORY),
|
||||
"couple_casual": ("Couple casual clothes", RANDOM_SUBCATEGORY),
|
||||
@@ -3016,6 +3018,23 @@ def _build_direct_builtin_row(
|
||||
return row
|
||||
|
||||
|
||||
def _auto_full_choice(seed_config: dict[str, int], seed: int, row_number: int) -> str:
|
||||
categories = load_category_library()
|
||||
if not categories:
|
||||
return "auto_weighted"
|
||||
category_rng = _axis_rng(seed_config, "category", seed, row_number)
|
||||
choices: list[dict[str, Any]] = [{"category": "auto_weighted", "weight": 1.0}]
|
||||
choices.extend(
|
||||
{
|
||||
"category": category["name"],
|
||||
"weight": category.get("weight", 1.0),
|
||||
}
|
||||
for category in categories
|
||||
)
|
||||
choice = _weighted_choice(category_rng, choices)
|
||||
return str(choice.get("category") or "auto_weighted")
|
||||
|
||||
|
||||
def _find_category(categories: list[dict[str, Any]], name_or_slug: str) -> dict[str, Any] | None:
|
||||
wanted = name_or_slug.strip().lower()
|
||||
for category in categories:
|
||||
@@ -6025,6 +6044,9 @@ def build_prompt(
|
||||
|
||||
exact_custom_subcategory = bool(subcategory and subcategory != RANDOM_SUBCATEGORY and " / " in subcategory)
|
||||
|
||||
if category == "auto_full" and not exact_custom_subcategory:
|
||||
category = _auto_full_choice(parsed_seed_config, seed, row_number)
|
||||
|
||||
if category == "auto_weighted" and not exact_custom_subcategory:
|
||||
row = _build_auto_weighted_row(
|
||||
row_number,
|
||||
|
||||
Reference in New Issue
Block a user