DZRobo
commited on
Commit
·
0f11662
1
Parent(s):
7ca7bce
Add smart seed diversity and config options
Browse filesIntroduces 'smart_seed_k', 'smart_seed_steps', and 'smart_seed_diversity' parameters to the ComfyAdaptiveDetailEnhancer25 class and updates the smart seed selection logic to support diversity-based scoring. Updates mg_cade25.cfg to include these new smart seed options for each step. Also improves LoRA slot gating in mg_combinode.py to ignore empty, None, or disabled slots more strictly.
- mod/easy/mg_cade25_easy.py +17 -6
- mod/mg_combinode.py +6 -9
- pressets/mg_cade25.cfg +22 -4
mod/easy/mg_cade25_easy.py
CHANGED
|
@@ -2183,6 +2183,9 @@ class ComfyAdaptiveDetailEnhancer25:
|
|
| 2183 |
iterations = int(pv("iterations", iterations))
|
| 2184 |
# Smart-seed per-step toggle (defaults to True if not present in preset)
|
| 2185 |
smart_seed_enable = bool(pv("smart_seed_enable", True))
|
|
|
|
|
|
|
|
|
|
| 2186 |
steps_delta = float(pv("steps_delta", steps_delta))
|
| 2187 |
cfg_delta = float(pv("cfg_delta", cfg_delta))
|
| 2188 |
denoise_delta = float(pv("denoise_delta", denoise_delta))
|
|
@@ -2338,9 +2341,9 @@ class ComfyAdaptiveDetailEnhancer25:
|
|
| 2338 |
model, vae, positive, negative, current_latent,
|
| 2339 |
str(sampler_name), str(scheduler), float(current_cfg), float(current_denoise),
|
| 2340 |
base_seed=0, step_tag=step_tag,
|
| 2341 |
-
|
| 2342 |
-
|
| 2343 |
-
|
| 2344 |
except Exception as e:
|
| 2345 |
# propagate user cancel; swallow only non-interrupt errors
|
| 2346 |
if isinstance(e, model_management.InterruptProcessingException):
|
|
@@ -3436,7 +3439,8 @@ def _smart_seed_select(model,
|
|
| 3436 |
clip_vision=None,
|
| 3437 |
reference_image=None,
|
| 3438 |
clipseg_text: str = "",
|
| 3439 |
-
step_tag: str | None = None
|
|
|
|
| 3440 |
# Log start of SmartSeed selection
|
| 3441 |
try:
|
| 3442 |
# cooperative cancel before any smart-seed work
|
|
@@ -3446,9 +3450,9 @@ def _smart_seed_select(model,
|
|
| 3446 |
print("")
|
| 3447 |
print("")
|
| 3448 |
if step_tag:
|
| 3449 |
-
print(f"\x1b[34m==== {step_tag}, Smart_seed_random: Start ====\x1b[0m")
|
| 3450 |
else:
|
| 3451 |
-
print("\x1b[34m==== Smart_seed_random: Start ====\x1b[0m")
|
| 3452 |
except Exception:
|
| 3453 |
pass
|
| 3454 |
|
|
@@ -3498,6 +3502,13 @@ def _smart_seed_select(model,
|
|
| 3498 |
lum = float(img.mean().item())
|
| 3499 |
edge_target = 0.10
|
| 3500 |
score = -abs(ed - edge_target) - 2.0 * speck - 0.5 * abs(lum - 0.5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3501 |
|
| 3502 |
# Perceptual metrics: luminance std and Laplacian variance (downscaled)
|
| 3503 |
try:
|
|
|
|
| 2183 |
iterations = int(pv("iterations", iterations))
|
| 2184 |
# Smart-seed per-step toggle (defaults to True if not present in preset)
|
| 2185 |
smart_seed_enable = bool(pv("smart_seed_enable", True))
|
| 2186 |
+
smart_seed_k = int(pv("smart_seed_k", 3))
|
| 2187 |
+
smart_seed_steps = int(pv("smart_seed_steps", 3))
|
| 2188 |
+
smart_seed_diversity = float(pv("smart_seed_diversity", 0.0))
|
| 2189 |
steps_delta = float(pv("steps_delta", steps_delta))
|
| 2190 |
cfg_delta = float(pv("cfg_delta", cfg_delta))
|
| 2191 |
denoise_delta = float(pv("denoise_delta", denoise_delta))
|
|
|
|
| 2341 |
model, vae, positive, negative, current_latent,
|
| 2342 |
str(sampler_name), str(scheduler), float(current_cfg), float(current_denoise),
|
| 2343 |
base_seed=0, step_tag=step_tag,
|
| 2344 |
+
k=int(max(1, smart_seed_k)), probe_steps=int(max(1, smart_seed_steps)),
|
| 2345 |
+
clip_vision=clip_vision, reference_image=reference_image, clipseg_text=str(clipseg_text),
|
| 2346 |
+
diversity=float(max(0.0, smart_seed_diversity)))
|
| 2347 |
except Exception as e:
|
| 2348 |
# propagate user cancel; swallow only non-interrupt errors
|
| 2349 |
if isinstance(e, model_management.InterruptProcessingException):
|
|
|
|
| 3439 |
clip_vision=None,
|
| 3440 |
reference_image=None,
|
| 3441 |
clipseg_text: str = "",
|
| 3442 |
+
step_tag: str | None = None,
|
| 3443 |
+
diversity: float = 0.0) -> int:
|
| 3444 |
# Log start of SmartSeed selection
|
| 3445 |
try:
|
| 3446 |
# cooperative cancel before any smart-seed work
|
|
|
|
| 3450 |
print("")
|
| 3451 |
print("")
|
| 3452 |
if step_tag:
|
| 3453 |
+
print(f"\x1b[34m==== {step_tag}, Smart_seed_random: Start (k={int(k)}, steps={int(probe_steps)}, div={float(diversity):.2f}) ====\x1b[0m")
|
| 3454 |
else:
|
| 3455 |
+
print(f"\x1b[34m==== Smart_seed_random: Start (k={int(k)}, steps={int(probe_steps)}, div={float(diversity):.2f}) ====\x1b[0m")
|
| 3456 |
except Exception:
|
| 3457 |
pass
|
| 3458 |
|
|
|
|
| 3502 |
lum = float(img.mean().item())
|
| 3503 |
edge_target = 0.10
|
| 3504 |
score = -abs(ed - edge_target) - 2.0 * speck - 0.5 * abs(lum - 0.5)
|
| 3505 |
+
# Deterministic jitter to avoid tie clusters (scaled by diversity)
|
| 3506 |
+
if float(diversity) > 0.0:
|
| 3507 |
+
try:
|
| 3508 |
+
rnd = (_splitmix64(int(sd) ^ int(anchor)) & 0xFFFFFFFF) / 4294967296.0
|
| 3509 |
+
score += (rnd - 0.5) * float(diversity)
|
| 3510 |
+
except Exception:
|
| 3511 |
+
pass
|
| 3512 |
|
| 3513 |
# Perceptual metrics: luminance std and Laplacian variance (downscaled)
|
| 3514 |
try:
|
mod/mg_combinode.py
CHANGED
|
@@ -308,19 +308,16 @@ class MagicNodesCombiNode:
|
|
| 308 |
lora_stack = [] # list of (lora_file, sc, sm)
|
| 309 |
defer_clip = bool(standard_pipeline)
|
| 310 |
for use_lora, lora_name, sm, sc in loras:
|
| 311 |
-
#
|
| 312 |
-
if not
|
|
|
|
| 313 |
continue
|
| 314 |
-
# Resolve path safely (do not raise if missing)
|
| 315 |
try:
|
| 316 |
-
lora_path = folder_paths.get_full_path("loras",
|
| 317 |
except Exception:
|
| 318 |
lora_path = None
|
| 319 |
-
if not lora_path or not os.path.exists(lora_path):
|
| 320 |
-
try:
|
| 321 |
-
print(f"[CombiNode] LoRA '{lora_name}' not found; skipping.")
|
| 322 |
-
except Exception:
|
| 323 |
-
pass
|
| 324 |
continue
|
| 325 |
active_lora_paths.append(lora_path)
|
| 326 |
# keep lora object to avoid reloading
|
|
|
|
| 308 |
lora_stack = [] # list of (lora_file, sc, sm)
|
| 309 |
defer_clip = bool(standard_pipeline)
|
| 310 |
for use_lora, lora_name, sm, sc in loras:
|
| 311 |
+
# Strict gating: ignore slot when toggle is off OR name is None/empty/"None"
|
| 312 |
+
name = str(lora_name).strip() if lora_name is not None else ""
|
| 313 |
+
if (not bool(use_lora)) or (name == "") or (name.lower() in ("none", "null", "off")):
|
| 314 |
continue
|
| 315 |
+
# Resolve path safely (do not raise if missing). Missing behaves like disabled.
|
| 316 |
try:
|
| 317 |
+
lora_path = folder_paths.get_full_path("loras", name)
|
| 318 |
except Exception:
|
| 319 |
lora_path = None
|
| 320 |
+
if (not lora_path) or (not os.path.exists(lora_path)):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 321 |
continue
|
| 322 |
active_lora_paths.append(lora_path)
|
| 323 |
# keep lora object to avoid reloading
|
pressets/mg_cade25.cfg
CHANGED
|
@@ -15,6 +15,12 @@ steps_delta: -2.00
|
|
| 15 |
cfg_delta: 0.03
|
| 16 |
denoise_delta: 0.28
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
# toggles
|
| 19 |
apply_sharpen: false
|
| 20 |
apply_upscale: true
|
|
@@ -156,6 +162,12 @@ steps_delta: 2.00
|
|
| 156 |
cfg_delta: 0.03
|
| 157 |
denoise_delta: 0.0500
|
| 158 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
# toggles
|
| 160 |
apply_sharpen: false
|
| 161 |
apply_upscale: true
|
|
@@ -297,8 +309,11 @@ steps_delta: 4.00
|
|
| 297 |
cfg_delta: 0.03
|
| 298 |
denoise_delta: 0.0500
|
| 299 |
|
| 300 |
-
# Smart seed toggle
|
| 301 |
-
smart_seed_enable:
|
|
|
|
|
|
|
|
|
|
| 302 |
|
| 303 |
# toggles
|
| 304 |
apply_sharpen: false
|
|
@@ -442,8 +457,11 @@ steps_delta: 2.00
|
|
| 442 |
cfg_delta: 1.00
|
| 443 |
denoise_delta: 0.05
|
| 444 |
|
| 445 |
-
# Smart seed toggle
|
| 446 |
-
smart_seed_enable:
|
|
|
|
|
|
|
|
|
|
| 447 |
|
| 448 |
# toggles
|
| 449 |
apply_sharpen: true
|
|
|
|
| 15 |
cfg_delta: 0.03
|
| 16 |
denoise_delta: 0.28
|
| 17 |
|
| 18 |
+
# Smart seed toggle
|
| 19 |
+
smart_seed_enable: true
|
| 20 |
+
smart_seed_k: 6
|
| 21 |
+
smart_seed_steps: 7
|
| 22 |
+
smart_seed_diversity: 0.25
|
| 23 |
+
|
| 24 |
# toggles
|
| 25 |
apply_sharpen: false
|
| 26 |
apply_upscale: true
|
|
|
|
| 162 |
cfg_delta: 0.03
|
| 163 |
denoise_delta: 0.0500
|
| 164 |
|
| 165 |
+
# Smart seed toggle
|
| 166 |
+
smart_seed_enable: true
|
| 167 |
+
smart_seed_k: 5
|
| 168 |
+
smart_seed_steps: 5
|
| 169 |
+
smart_seed_diversity: 0.15
|
| 170 |
+
|
| 171 |
# toggles
|
| 172 |
apply_sharpen: false
|
| 173 |
apply_upscale: true
|
|
|
|
| 309 |
cfg_delta: 0.03
|
| 310 |
denoise_delta: 0.0500
|
| 311 |
|
| 312 |
+
# Smart seed toggle
|
| 313 |
+
smart_seed_enable: true
|
| 314 |
+
smart_seed_k: 2
|
| 315 |
+
smart_seed_steps: 4
|
| 316 |
+
smart_seed_diversity: 0.10
|
| 317 |
|
| 318 |
# toggles
|
| 319 |
apply_sharpen: false
|
|
|
|
| 457 |
cfg_delta: 1.00
|
| 458 |
denoise_delta: 0.05
|
| 459 |
|
| 460 |
+
# Smart seed toggle
|
| 461 |
+
smart_seed_enable: true
|
| 462 |
+
smart_seed_k: 2
|
| 463 |
+
smart_seed_steps: 4
|
| 464 |
+
smart_seed_diversity: 0.10
|
| 465 |
|
| 466 |
# toggles
|
| 467 |
apply_sharpen: true
|