diff --git a/javascript/active.js b/javascript/active.js index 8851599..0e8fcc3 100644 --- a/javascript/active.js +++ b/javascript/active.js @@ -1,3 +1,7 @@ +let dynthres_update_enabled = function() { + return Array.from(arguments); +}; + (function(){ let accordions = {}; let enabled = {}; @@ -5,6 +9,16 @@ let accordion_id_prefix = "#dynthres_"; let extension_checkbox_class = ".dynthres-enabled"; + dynthres_update_enabled = function() { + let res = Array.from(arguments); + let tabname = res[1] ? "img2img" : "txt2img"; + + let checkbox = accordions[tabname]?.querySelector(extension_checkbox_class + ' input'); + checkbox?.dispatchEvent(new Event('change')); + + return res; + }; + function attachEnabledButtonListener(checkbox, accordion) { let span = accordion.querySelector('.label-wrap span'); let badge = document.createElement('input'); diff --git a/scripts/dynamic_thresholding.py b/scripts/dynamic_thresholding.py index b88246b..1068976 100644 --- a/scripts/dynamic_thresholding.py +++ b/scripts/dynamic_thresholding.py @@ -42,6 +42,8 @@ class Script(scripts.Script): def vis_change(isVis): return {"visible": isVis, "__type__": "update"} # "Dynamic Thresholding (CFG Scale Fix)" + dtrue = gr.Checkbox(value=True, visible=False) + dfalse = gr.Checkbox(value=False, visible=False) with gr.Accordion("Dynamic Thresholding (CFG Scale Fix)", open=False, elem_id="dynthres_" + ("img2img" if is_img2img else "txt2img")): with gr.Row(): enabled = gr.Checkbox(value=False, label="Enable Dynamic Thresholding (CFG Scale Fix)", elem_classes=["dynthres-enabled"]) @@ -68,8 +70,9 @@ class Script(scripts.Script): cfg_mode.change(shouldShowSchedulerValue, inputs=[cfg_mode, mimic_mode], outputs=[sched_val, mimic_scale_min, cfg_scale_min]) mimic_mode.change(shouldShowSchedulerValue, inputs=[cfg_mode, mimic_mode], outputs=[sched_val, mimic_scale_min, cfg_scale_min]) enabled.change( - fn=lambda x: {"visible": x, "__type__": "update"}, - inputs=[enabled], + _js="dynthres_update_enabled", + fn=lambda x, y: {"visible": x, "__type__": "update"}, + inputs=[enabled, dtrue if is_img2img else dfalse], outputs=[accordion], show_progress = False) self.infotext_fields = (