Spaces:
Runtime error
Runtime error
root
commited on
Commit
•
6e776e4
1
Parent(s):
9840338
add moveImageFromGallery
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
import io
|
3 |
from PIL import Image, PngImagePlugin
|
@@ -5,6 +6,7 @@ import base64
|
|
5 |
import requests
|
6 |
import json
|
7 |
import ui_functions as uifn
|
|
|
8 |
|
9 |
txt2img_defaults = {
|
10 |
'prompt': '',
|
@@ -120,10 +122,6 @@ def request_images(raw_text, class_draw, style_draw, batch_size):
|
|
120 |
|
121 |
return images
|
122 |
|
123 |
-
def call_JS(sd_method, **kwargs):
|
124 |
-
param_str = json.dumps(kwargs)
|
125 |
-
return f"async (...x) => {{ return await SD.{sd_method}({{ x, ...{param_str} }}) ?? []; }}"
|
126 |
-
|
127 |
def encode_pil_to_base64(pil_image):
|
128 |
with io.BytesIO() as output_bytes:
|
129 |
|
@@ -407,19 +405,19 @@ if __name__ == "__main__":
|
|
407 |
)
|
408 |
|
409 |
#
|
410 |
-
# output_txt2img_copy_to_input_btn.click(
|
411 |
-
# uifn.copy_img_to_input,
|
412 |
-
# [gallery],
|
413 |
-
# [img2img_image_editor, img2img_image_mask, tabs],
|
414 |
-
# _js=call_JS("moveImageFromGallery",
|
415 |
-
# fromId="txt2img_gallery_output",
|
416 |
-
# toId="img2img_mask")
|
417 |
-
# )
|
418 |
output_txt2img_copy_to_input_btn.click(
|
419 |
uifn.copy_img_to_input,
|
420 |
[gallery],
|
421 |
[img2img_image_editor, img2img_image_mask, tabs],
|
|
|
|
|
|
|
422 |
)
|
|
|
|
|
|
|
|
|
|
|
423 |
|
424 |
output_img2img_copy_to_input_btn.click(
|
425 |
uifn.copy_img_to_edit,
|
|
|
1 |
+
import imp
|
2 |
import gradio as gr
|
3 |
import io
|
4 |
from PIL import Image, PngImagePlugin
|
|
|
6 |
import requests
|
7 |
import json
|
8 |
import ui_functions as uifn
|
9 |
+
from css_and_js import js, call_JS
|
10 |
|
11 |
txt2img_defaults = {
|
12 |
'prompt': '',
|
|
|
122 |
|
123 |
return images
|
124 |
|
|
|
|
|
|
|
|
|
125 |
def encode_pil_to_base64(pil_image):
|
126 |
with io.BytesIO() as output_bytes:
|
127 |
|
|
|
405 |
)
|
406 |
|
407 |
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
408 |
output_txt2img_copy_to_input_btn.click(
|
409 |
uifn.copy_img_to_input,
|
410 |
[gallery],
|
411 |
[img2img_image_editor, img2img_image_mask, tabs],
|
412 |
+
_js=call_JS("moveImageFromGallery",
|
413 |
+
fromId="txt2img_gallery_output",
|
414 |
+
toId="img2img_mask")
|
415 |
)
|
416 |
+
# output_txt2img_copy_to_input_btn.click(
|
417 |
+
# uifn.copy_img_to_input,
|
418 |
+
# [gallery],
|
419 |
+
# [img2img_image_editor, img2img_image_mask, tabs],
|
420 |
+
# )
|
421 |
|
422 |
output_img2img_copy_to_input_btn.click(
|
423 |
uifn.copy_img_to_edit,
|