Add per-axis seed modes
This commit is contained in:
+35
-9
@@ -60,6 +60,7 @@ SEED_LOCK_AXES = (
|
||||
"expression",
|
||||
"composition",
|
||||
)
|
||||
SEED_MODE_CHOICES = ["auto", "follow_main", "fixed", "random"]
|
||||
|
||||
ETHNICITY_FILTER_CHOICES = [
|
||||
"any",
|
||||
@@ -860,6 +861,10 @@ def subcategory_choices() -> list[str]:
|
||||
return choices
|
||||
|
||||
|
||||
def seed_mode_choices() -> list[str]:
|
||||
return list(SEED_MODE_CHOICES)
|
||||
|
||||
|
||||
CATEGORY_PRESETS = {
|
||||
"auto_weighted": ("auto_weighted", RANDOM_SUBCATEGORY),
|
||||
"women_casual": ("Casual clothes", RANDOM_SUBCATEGORY),
|
||||
@@ -1192,18 +1197,39 @@ def build_seed_config_json(
|
||||
role_seed: int = -1,
|
||||
expression_seed: int = -1,
|
||||
composition_seed: int = -1,
|
||||
category_seed_mode: str = "auto",
|
||||
subcategory_seed_mode: str = "auto",
|
||||
content_seed_mode: str = "auto",
|
||||
person_seed_mode: str = "auto",
|
||||
scene_seed_mode: str = "auto",
|
||||
pose_seed_mode: str = "auto",
|
||||
role_seed_mode: str = "auto",
|
||||
expression_seed_mode: str = "auto",
|
||||
composition_seed_mode: str = "auto",
|
||||
) -> str:
|
||||
rng = random.SystemRandom()
|
||||
|
||||
def axis_seed(value: int, mode: str) -> int:
|
||||
mode = mode if mode in SEED_MODE_CHOICES else "auto"
|
||||
if mode == "auto":
|
||||
return int(value)
|
||||
if mode == "random":
|
||||
return rng.randint(0, 0xFFFFFFFF)
|
||||
if mode == "fixed":
|
||||
return max(0, int(value))
|
||||
return -1
|
||||
|
||||
return json.dumps(
|
||||
{
|
||||
"category_seed": int(category_seed),
|
||||
"subcategory_seed": int(subcategory_seed),
|
||||
"content_seed": int(content_seed),
|
||||
"person_seed": int(person_seed),
|
||||
"scene_seed": int(scene_seed),
|
||||
"pose_seed": int(pose_seed),
|
||||
"role_seed": int(role_seed),
|
||||
"expression_seed": int(expression_seed),
|
||||
"composition_seed": int(composition_seed),
|
||||
"category_seed": axis_seed(category_seed, category_seed_mode),
|
||||
"subcategory_seed": axis_seed(subcategory_seed, subcategory_seed_mode),
|
||||
"content_seed": axis_seed(content_seed, content_seed_mode),
|
||||
"person_seed": axis_seed(person_seed, person_seed_mode),
|
||||
"scene_seed": axis_seed(scene_seed, scene_seed_mode),
|
||||
"pose_seed": axis_seed(pose_seed, pose_seed_mode),
|
||||
"role_seed": axis_seed(role_seed, role_seed_mode),
|
||||
"expression_seed": axis_seed(expression_seed, expression_seed_mode),
|
||||
"composition_seed": axis_seed(composition_seed, composition_seed_mode),
|
||||
},
|
||||
ensure_ascii=True,
|
||||
sort_keys=True,
|
||||
|
||||
Reference in New Issue
Block a user