remove some code duplication from #9348
This commit is contained in:
parent
1d1b5da4bf
commit
e5dd4b4ebf
@ -441,51 +441,27 @@ function updateImg2imgResizeToTextAfterChangingImage(){
|
||||
|
||||
}
|
||||
|
||||
function setRandomSeed(target_interface) {
|
||||
let seed = gradioApp().querySelector(`#${target_interface}_seed input`);
|
||||
if (!seed) {
|
||||
return [];
|
||||
}
|
||||
seed.value = "-1";
|
||||
seed.dispatchEvent(new Event("input"));
|
||||
|
||||
|
||||
function setRandomSeed(elem_id) {
|
||||
var input = gradioApp().querySelector("#" + elem_id + " input");
|
||||
if (!input) return [];
|
||||
|
||||
input.value = "-1";
|
||||
updateInput(input);
|
||||
return [];
|
||||
}
|
||||
|
||||
function setRandomSubseed(target_interface) {
|
||||
let subseed = gradioApp().querySelector(`#${target_interface}_subseed input`);
|
||||
if (!subseed) {
|
||||
return [];
|
||||
}
|
||||
subseed.value = "-1";
|
||||
subseed.dispatchEvent(new Event("input"));
|
||||
return [];
|
||||
}
|
||||
function switchWidthHeight(tabname) {
|
||||
var width = gradioApp().querySelector("#" + tabname + "_width input[type=number]");
|
||||
var height = gradioApp().querySelector("#" + tabname + "_height input[type=number]");
|
||||
if (!width || !height) return [];
|
||||
|
||||
function switchWidthHeightTxt2Img() {
|
||||
let width = gradioApp().querySelector("#txt2img_width input[type=number]");
|
||||
let height = gradioApp().querySelector("#txt2img_height input[type=number]");
|
||||
if (!width || !height) {
|
||||
return [];
|
||||
}
|
||||
let tmp = width.value;
|
||||
var tmp = width.value;
|
||||
width.value = height.value;
|
||||
height.value = tmp;
|
||||
width.dispatchEvent(new Event("input"));
|
||||
height.dispatchEvent(new Event("input"));
|
||||
return [];
|
||||
}
|
||||
|
||||
function switchWidthHeightImg2Img() {
|
||||
let width = gradioApp().querySelector("#img2img_width input[type=number]");
|
||||
let height = gradioApp().querySelector("#img2img_height input[type=number]");
|
||||
if (!width || !height) {
|
||||
updateInput(width);
|
||||
updateInput(height);
|
||||
return [];
|
||||
}
|
||||
let tmp = width.value;
|
||||
width.value = height.value;
|
||||
height.value = tmp;
|
||||
width.dispatchEvent(new Event("input"));
|
||||
height.dispatchEvent(new Event("input"));
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -189,9 +189,8 @@ def create_seed_inputs(target_interface):
|
||||
seed_resize_from_w = gr.Slider(minimum=0, maximum=2048, step=8, label="Resize seed from width", value=0, elem_id=f"{target_interface}_seed_resize_from_w")
|
||||
seed_resize_from_h = gr.Slider(minimum=0, maximum=2048, step=8, label="Resize seed from height", value=0, elem_id=f"{target_interface}_seed_resize_from_h")
|
||||
|
||||
target_interface_state = gr.Textbox(target_interface, visible=False)
|
||||
random_seed.click(fn=None, _js="setRandomSeed", show_progress=False, inputs=[target_interface_state], outputs=[])
|
||||
random_subseed.click(fn=None, _js="setRandomSubseed", show_progress=False, inputs=[target_interface_state], outputs=[])
|
||||
random_seed.click(fn=None, _js="function(){setRandomSeed('" + target_interface + "_seed')}", show_progress=False, inputs=[], outputs=[])
|
||||
random_subseed.click(fn=None, _js="function(){setRandomSeed('" + target_interface + "_subseed')}", show_progress=False, inputs=[], outputs=[])
|
||||
|
||||
def change_visibility(show):
|
||||
return {comp: gr_show(show) for comp in seed_extras}
|
||||
@ -575,7 +574,7 @@ def create_ui():
|
||||
txt2img_prompt.submit(**txt2img_args)
|
||||
submit.click(**txt2img_args)
|
||||
|
||||
res_switch_btn.click(fn=None, _js="switchWidthHeightTxt2Img", inputs=None, outputs=None, show_progress=False)
|
||||
res_switch_btn.click(fn=None, _js="function(){switchWidthHeight('txt2img')}", inputs=None, outputs=None, show_progress=False)
|
||||
|
||||
restore_progress_button.click(
|
||||
fn=progress.restore_progress,
|
||||
@ -951,7 +950,7 @@ def create_ui():
|
||||
img2img_prompt.submit(**img2img_args)
|
||||
submit.click(**img2img_args)
|
||||
|
||||
res_switch_btn.click(fn=None, _js="switchWidthHeightImg2Img", inputs=None, outputs=None, show_progress=False)
|
||||
res_switch_btn.click(fn=None, _js="function(){switchWidthHeight('img2img')}", inputs=None, outputs=None, show_progress=False)
|
||||
|
||||
restore_progress_button.click(
|
||||
fn=progress.restore_progress,
|
||||
|
Loading…
Reference in New Issue
Block a user