Skip to content

[A1111] Use the Webui's built-in InputAccordion component #106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 0 additions & 68 deletions javascript/active.js

This file was deleted.

14 changes: 3 additions & 11 deletions scripts/dynamic_thresholding.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import torch, traceback
import dynthres_core
from modules import scripts, script_callbacks, sd_samplers, sd_samplers_compvis, sd_samplers_common
from modules.ui_components import InputAccordion
try:
import dynthres_unipc
except Exception as e:
Expand Down Expand Up @@ -44,11 +45,7 @@ def ui(self, is_img2img):
def vis_change(is_vis):
return {"visible": is_vis, "__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"], elem_id='dynthres_enabled')
with InputAccordion(label="Dynamic Thresholding (CFG Scale Fix)", value=False, elem_id="dynthres_" + ("img2img" if is_img2img else "txt2img")) as enabled:
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')
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')
Expand All @@ -71,13 +68,8 @@ def should_show_scheduler_value(cfg_mode, mimic_mode):
return vis_change(sched_vis), vis_change(mimic_mode != "Constant" or DISABLE_VISIBILITY), vis_change(cfg_mode != "Constant" or DISABLE_VISIBILITY)
cfg_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(
_js="dynthres_update_enabled",
fn=None,
inputs=[enabled, dtrue if is_img2img else dfalse],
show_progress = False)
self.infotext_fields = (
(enabled, lambda d: gr.Checkbox.update(value="Dynamic thresholding enabled" in d)),
(enabled, lambda d: gr.update(value="Dynamic thresholding enabled" in d)),
(mimic_scale, "Mimic scale"),
(separate_feature_channels, "Separate Feature Channels"),
(scaling_startpoint, lambda d: gr.Radio.update(value=d.get("Scaling Startpoint", "MEAN"))),
Expand Down