From 4cafad66d202433bc358d9c4b8291d593b6e4df8 Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Fri, 2 Sep 2022 23:25:29 +0300 Subject: this should send the currently selected image to other tabs instead of the first --- webui.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'webui.py') diff --git a/webui.py b/webui.py index c51a7829..f7a52107 100644 --- a/webui.py +++ b/webui.py @@ -1288,7 +1288,14 @@ def txt2img(prompt: str, negative_prompt: str, steps: int, sampler_index: int, u return processed.images, processed.js(), plaintext_to_html(processed.info) + def image_from_url_text(filedata): + if type(filedata) == list: + if len(filedata) == 0: + return None + + filedata = filedata[0] + if filedata.startswith("data:image/png;base64,"): filedata = filedata[len("data:image/png;base64,"):] @@ -1368,7 +1375,7 @@ with gr.Blocks(analytics_enabled=False) as txt2img_interface: with gr.Column(variant='panel'): with gr.Group(): - txt2img_gallery = gr.Gallery(label='Output') + txt2img_gallery = gr.Gallery(label='Output', elem_id='txt2img_gallery') with gr.Group(): with gr.Row(): @@ -1760,7 +1767,7 @@ with gr.Blocks(analytics_enabled=False) as img2img_interface: with gr.Column(variant='panel'): with gr.Group(): - img2img_gallery = gr.Gallery(label='Output') + img2img_gallery = gr.Gallery(label='Output', elem_id='img2img_gallery') with gr.Group(): with gr.Row(): @@ -1863,13 +1870,15 @@ with gr.Blocks(analytics_enabled=False) as img2img_interface: ) send_to_img2img.click( - fn=send_gradio_gallery_to_image, + fn=lambda x: image_from_url_text(x), + _js="extract_image_from_gallery", inputs=[txt2img_gallery], outputs=[init_img], ) send_to_inpaint.click( - fn=send_gradio_gallery_to_image, + fn=lambda x: image_from_url_text(x), + _js="extract_image_from_gallery", inputs=[txt2img_gallery], outputs=[init_img_with_mask], ) @@ -1952,14 +1961,17 @@ with gr.Blocks(analytics_enabled=False) as extras_interface: submit.click(**extras_args) + send_to_extras.click( - fn=send_gradio_gallery_to_image, + fn=lambda x: image_from_url_text(x), + _js="extract_image_from_gallery", inputs=[txt2img_gallery], outputs=[image], ) img2img_send_to_extras.click( - fn=send_gradio_gallery_to_image, + fn=lambda x: image_from_url_text(x), + _js="extract_image_from_gallery", inputs=[img2img_gallery], outputs=[image], ) -- cgit v1.2.1