diff options
author | AUTOMATIC <16777216c@gmail.com> | 2023-04-29 16:39:22 +0000 |
---|---|---|
committer | AUTOMATIC <16777216c@gmail.com> | 2023-04-29 16:39:22 +0000 |
commit | e40b2d947d874ed5504701bfd8e32243e0c456eb (patch) | |
tree | 30f0a848182970416d9df111b5632b78b955eb58 | |
parent | a95dc02535ce647efbb3bc66964ab61b6f1446f4 (diff) | |
download | stable-diffusion-webui-gfx803-e40b2d947d874ed5504701bfd8e32243e0c456eb.tar.gz stable-diffusion-webui-gfx803-e40b2d947d874ed5504701bfd8e32243e0c456eb.tar.bz2 stable-diffusion-webui-gfx803-e40b2d947d874ed5504701bfd8e32243e0c456eb.zip |
change gradio callback from change to release in a bunch of places now that it's fixed in gradio
-rw-r--r-- | javascript/ui.js | 11 | ||||
-rw-r--r-- | modules/ui.py | 12 |
2 files changed, 21 insertions, 2 deletions
diff --git a/javascript/ui.js b/javascript/ui.js index dc538231..0ba92ef8 100644 --- a/javascript/ui.js +++ b/javascript/ui.js @@ -366,3 +366,14 @@ function currentImg2imgSourceResolution(_, _, scaleBy){ var img = gradioApp().querySelector('#mode_img2img > div[style="display: block;"] img') return img ? [img.naturalWidth, img.naturalHeight, scaleBy] : [0, 0, scaleBy] } + +function updateImg2imgResizeToTextAfterChangingImage(){ + // At the time this is called from gradio, the image has no yet been replaced. + // There may be a better solution, but this is simple and straightforward so I'm going with it. + + setTimeout(function() { + gradioApp().getElementById('img2img_update_resize_to').click() + }, 500); + + return [] +} diff --git a/modules/ui.py b/modules/ui.py index 1130345c..a32500d1 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -782,8 +782,9 @@ def create_ui(): with FormRow():
scale_by_html = FormHTML(resize_from_to_html(0, 0, 0.0), elem_id="img2img_scale_resolution_preview")
gr.Slider(label="Unused", elem_id="img2img_unused_scale_by_slider")
+ button_update_resize_to = gr.Button(visible=False, elem_id="img2img_update_resize_to")
- scale_by.change(
+ on_change_args = dict(
fn=resize_from_to_html,
_js="currentImg2imgSourceResolution",
inputs=[dummy_component, dummy_component, scale_by],
@@ -791,6 +792,12 @@ def create_ui(): show_progress=False,
)
+ scale_by.release(**on_change_args)
+ button_update_resize_to.click(**on_change_args)
+
+ for component in img2img_image_inputs:
+ component.change(fn=lambda: None, _js="updateImg2imgResizeToTextAfterChangingImage", inputs=[], outputs=[], show_progress=False)
+
tab_scale_to.select(fn=lambda: 0, inputs=[], outputs=[selected_scale_tab])
tab_scale_by.select(fn=lambda: 1, inputs=[], outputs=[selected_scale_tab])
@@ -1647,7 +1654,8 @@ def create_ui(): component = component_dict[k]
info = opts.data_labels[k]
- component.change(
+ change_handler = component.release if hasattr(component, 'release') else component.change
+ change_handler(
fn=lambda value, k=k: run_settings_single(value, key=k),
inputs=[component],
outputs=[component, text_settings],
|