xyz grid allow bool

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2025-04-13 08:39:31 -04:00
parent 90415a7469
commit a8abed125e
5 changed files with 22 additions and 8 deletions
+5 -3
View File
@@ -2,11 +2,13 @@
## Update for 2025-04-13
- [CFG-Zero](https://github.com/WeichenFan/CFG-Zero-star) yet-another guidance method optimized for flow-matching models
implemented for `FLUX.1`, `SD3.x`, `CogView4`, `HunyuanVideo`, `WanAI`
enable in *settings -> pipeline modifiers -> cfg zero*
- [CFG-Zero](https://github.com/WeichenFan/CFG-Zero-star) new guidance method optimized for flow-matching models
implemented for `FLUX.1`, `SD3.x`, `CogView4`, `HunyuanVideo`, `WanAI`
enable and configure in *settings -> pipeline modifiers -> cfg zero*
experiment with CFGZero support in XYZ-grid
- cleanup `CogView3` and `CogView4` model loader
- ui display reference models with subdued color
- xyz grid support bool
## Update for 2025-04-12
+1
View File
@@ -40,6 +40,7 @@ def apply(p: processing.StableDiffusionProcessing):
from modules.cfgzero.hunyuan_t2v_pipeline import HunyuanVideoCFGZeroPipeline
shared.sd_model = sd_models.switch_pipe(HunyuanVideoCFGZeroPipeline, shared.sd_model)
shared.log.debug(f'Apply CFGZero: cls={cls} init={shared.opts.cfgzero_enabled} star={shared.opts.cfgzero_star} steps={shared.opts.cfgzero_steps}')
p.task_args['use_zero_init'] = shared.opts.cfgzero_enabled
p.task_args['use_cfg_zero_star'] = shared.opts.cfgzero_star
p.task_args['zero_steps'] = int(shared.opts.cfgzero_steps)
+1 -1
View File
@@ -118,7 +118,7 @@ def combine_grid(grid):
class GridAnnotation:
def __init__(self, text='', is_active=True):
self.text = text
self.text = str(text)
self.is_active = is_active
self.size = None
+2 -1
View File
@@ -1,4 +1,4 @@
from scripts.xyz_grid_shared import apply_field, apply_task_arg, apply_task_args, apply_setting, apply_prompt_primary, apply_prompt_refine, apply_prompt_detailer, apply_prompt_all, apply_order, apply_sampler, apply_hr_sampler_name, confirm_samplers, apply_checkpoint, apply_refiner, apply_unet, apply_dict, apply_clip_skip, apply_vae, list_lora, apply_lora, apply_lora_strength, apply_te, apply_styles, apply_upscaler, apply_context, apply_detailer, apply_override, apply_processing, apply_options, apply_seed, format_value_add_label, format_value, format_value_join_list, do_nothing, format_nothing, str_permutations # pylint: disable=no-name-in-module, unused-import
from scripts.xyz_grid_shared import apply_field, apply_task_arg, apply_task_args, apply_setting, apply_prompt_primary, apply_prompt_refine, apply_prompt_detailer, apply_prompt_all, apply_order, apply_sampler, apply_hr_sampler_name, confirm_samplers, apply_checkpoint, apply_refiner, apply_unet, apply_dict, apply_clip_skip, apply_vae, list_lora, apply_lora, apply_lora_strength, apply_te, apply_styles, apply_upscaler, apply_context, apply_detailer, apply_override, apply_processing, apply_options, apply_seed, format_value_add_label, format_bool, format_value, format_value_join_list, do_nothing, format_nothing, str_permutations # pylint: disable=no-name-in-module, unused-import
from modules import shared, shared_items, sd_samplers, ipadapter, sd_models, sd_vae, sd_unet
@@ -213,4 +213,5 @@ axis_options = [
AxisOption("[IY] Start", float, apply_task_arg('infusenet_guidance_start')),
AxisOption("[IY] End", float, apply_task_arg('infusenet_guidance_end')),
AxisOption("[TeaCache] Threshold", float, apply_setting('teacache_thresh')),
AxisOption("[CFGZero] Enabled", bool, apply_setting('cfgzero_enabled'), fmt=format_bool, choices=lambda: [False, True]),
]
+13 -3
View File
@@ -58,7 +58,13 @@ def apply_options(p, x, xs):
def apply_setting(field):
def fun(p, x, xs):
shared.log.debug(f'XYZ grid apply setting: {field}={x}')
t = type(shared.opts.get(field))
if t == bool:
if isinstance(x, str):
x = x.lower() in ['true', 't', 'yes', 'y']
if isinstance(x, int) or isinstance(x, float):
x = x > 0
shared.log.debug(f'XYZ grid apply setting: {field}={t}:{x}')
shared.opts.data[field] = x
return fun
@@ -288,15 +294,19 @@ def apply_override(field):
return fun
def format_bool(p, opt, x):
return f"{opt.label}: {x}"
def format_value_add_label(p, opt, x):
if type(x) == float:
x = round(x, 8)
x = round(x, 4)
return f"{opt.label}: {x}"
def format_value(p, opt, x):
if type(x) == float:
x = round(x, 8)
x = round(x, 4)
return x