Don't change accordion visibility (#97)

pull/100/head
rkfg 2024-05-10 02:04:40 +03:00 committed by GitHub
parent 701a2087cf
commit ec5d85c1b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 4 deletions

View File

@ -49,7 +49,7 @@ class Script(scripts.Script):
with gr.Accordion("Dynamic Thresholding (CFG Scale Fix)", open=False, elem_id="dynthres_" + ("img2img" if is_img2img else "txt2img")): with gr.Accordion("Dynamic Thresholding (CFG Scale Fix)", open=False, elem_id="dynthres_" + ("img2img" if is_img2img else "txt2img")):
with gr.Row(): with gr.Row():
enabled = gr.Checkbox(value=False, label="Enable Dynamic Thresholding (CFG Scale Fix)", elem_classes=["dynthres-enabled"], elem_id='dynthres_enabled') enabled = gr.Checkbox(value=False, label="Enable Dynamic Thresholding (CFG Scale Fix)", elem_classes=["dynthres-enabled"], elem_id='dynthres_enabled')
with gr.Group(visible=False) as accordion: with gr.Group():
gr.HTML(value=f"View <a style=\"border-bottom: 1px #00ffff dotted;\" href=\"https://github.com/mcmonkeyprojects/sd-dynamic-thresholding/wiki/Usage-Tips\">the wiki for usage tips.</a><br><br>", elem_id='dynthres_wiki_link') gr.HTML(value=f"View <a style=\"border-bottom: 1px #00ffff dotted;\" href=\"https://github.com/mcmonkeyprojects/sd-dynamic-thresholding/wiki/Usage-Tips\">the wiki for usage tips.</a><br><br>", elem_id='dynthres_wiki_link')
mimic_scale = gr.Slider(minimum=1.0, maximum=30.0, step=0.5, label='Mimic CFG Scale', value=7.0, elem_id='dynthres_mimic_scale') mimic_scale = gr.Slider(minimum=1.0, maximum=30.0, step=0.5, label='Mimic CFG Scale', value=7.0, elem_id='dynthres_mimic_scale')
with gr.Accordion("Advanced Options", open=False, elem_id='dynthres_advanced_opts'): with gr.Accordion("Advanced Options", open=False, elem_id='dynthres_advanced_opts'):
@ -73,13 +73,11 @@ class Script(scripts.Script):
mimic_mode.change(should_show_scheduler_value, inputs=[cfg_mode, mimic_mode], outputs=[sched_val, mimic_scale_min, cfg_scale_min]) mimic_mode.change(should_show_scheduler_value, inputs=[cfg_mode, mimic_mode], outputs=[sched_val, mimic_scale_min, cfg_scale_min])
enabled.change( enabled.change(
_js="dynthres_update_enabled", _js="dynthres_update_enabled",
fn=lambda x, y: {"visible": x, "__type__": "update"}, fn=None,
inputs=[enabled, dtrue if is_img2img else dfalse], inputs=[enabled, dtrue if is_img2img else dfalse],
outputs=[accordion],
show_progress = False) show_progress = False)
self.infotext_fields = ( self.infotext_fields = (
(enabled, lambda d: gr.Checkbox.update(value="Dynamic thresholding enabled" in d)), (enabled, lambda d: gr.Checkbox.update(value="Dynamic thresholding enabled" in d)),
(accordion, lambda d: gr.Accordion.update(visible="Dynamic thresholding enabled" in d)),
(mimic_scale, "Mimic scale"), (mimic_scale, "Mimic scale"),
(separate_feature_channels, "Separate Feature Channels"), (separate_feature_channels, "Separate Feature Channels"),
(scaling_startpoint, lambda d: gr.Radio.update(value=d.get("Scaling Startpoint", "MEAN"))), (scaling_startpoint, lambda d: gr.Radio.update(value=d.get("Scaling Startpoint", "MEAN"))),