Spaces:
Running
Running
root
commited on
Commit
·
fed751d
1
Parent(s):
6426022
fix some bugs
Browse files
app.py
CHANGED
|
@@ -148,16 +148,16 @@ def img2img(*args):
|
|
| 148 |
if type(item) == dict:
|
| 149 |
args[i]['image'] = encode_pil_to_base64(item['image'])
|
| 150 |
args[i]['mask'] = encode_pil_to_base64(item['mask'])
|
| 151 |
-
else:
|
| 152 |
-
|
| 153 |
-
|
| 154 |
|
| 155 |
batch_size = args[8]
|
| 156 |
|
| 157 |
url = "http://flagart.baai.ac.cn/api/img2img/"
|
| 158 |
d = {"data":args}
|
| 159 |
r = requests.post(url, json=d, headers={"Content-Type": "application/json", "Accept": "*/*", "Accept-Encoding": "gzip, deflate, br", "Connection": "keep-alive"})
|
| 160 |
-
print(r)
|
| 161 |
result_text = r.text
|
| 162 |
content = json.loads(result_text)["data"][0]
|
| 163 |
images = []
|
|
@@ -245,6 +245,7 @@ if __name__ == "__main__":
|
|
| 245 |
gallery = gr.Gallery(
|
| 246 |
label="Generated images", show_label=False, elem_id="gallery"
|
| 247 |
).style(grid=[2], height="auto")
|
|
|
|
| 248 |
output_txt2img_copy_to_input_btn = gr.Button("Go to img2img")
|
| 249 |
|
| 250 |
gr.Examples(examples=examples, fn=request_images, inputs=text, outputs=gallery, examples_per_page=100)
|
|
@@ -407,20 +408,21 @@ if __name__ == "__main__":
|
|
| 407 |
)
|
| 408 |
|
| 409 |
# 把上面这个注释掉下面就不管用了,很神奇无法理解...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 410 |
output_txt2img_copy_to_input_btn.click(
|
| 411 |
uifn.copy_img_to_input,
|
| 412 |
[gallery],
|
| 413 |
[tabs, img2img_image_editor, img2img_image_mask],
|
| 414 |
-
_js=call_JS("moveImageFromGallery",
|
| 415 |
-
fromId="txt2img_gallery_output",
|
| 416 |
-
toId="img2img_mask")
|
| 417 |
)
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
[gallery],
|
| 421 |
-
[tabs, img2img_image_editor, img2img_image_mask],
|
| 422 |
-
)
|
| 423 |
-
|
| 424 |
output_img2img_copy_to_input_btn.click(
|
| 425 |
uifn.copy_img_to_edit,
|
| 426 |
[output_img2img_gallery],
|
|
|
|
| 148 |
if type(item) == dict:
|
| 149 |
args[i]['image'] = encode_pil_to_base64(item['image'])
|
| 150 |
args[i]['mask'] = encode_pil_to_base64(item['mask'])
|
| 151 |
+
# else:
|
| 152 |
+
# print(i,type(item))
|
| 153 |
+
# print(item)
|
| 154 |
|
| 155 |
batch_size = args[8]
|
| 156 |
|
| 157 |
url = "http://flagart.baai.ac.cn/api/img2img/"
|
| 158 |
d = {"data":args}
|
| 159 |
r = requests.post(url, json=d, headers={"Content-Type": "application/json", "Accept": "*/*", "Accept-Encoding": "gzip, deflate, br", "Connection": "keep-alive"})
|
| 160 |
+
# print(r)
|
| 161 |
result_text = r.text
|
| 162 |
content = json.loads(result_text)["data"][0]
|
| 163 |
images = []
|
|
|
|
| 245 |
gallery = gr.Gallery(
|
| 246 |
label="Generated images", show_label=False, elem_id="gallery"
|
| 247 |
).style(grid=[2], height="auto")
|
| 248 |
+
|
| 249 |
output_txt2img_copy_to_input_btn = gr.Button("Go to img2img")
|
| 250 |
|
| 251 |
gr.Examples(examples=examples, fn=request_images, inputs=text, outputs=gallery, examples_per_page=100)
|
|
|
|
| 408 |
)
|
| 409 |
|
| 410 |
# 把上面这个注释掉下面就不管用了,很神奇无法理解...
|
| 411 |
+
# output_txt2img_copy_to_input_btn.click(
|
| 412 |
+
# uifn.copy_img_to_input,
|
| 413 |
+
# [gallery],
|
| 414 |
+
# [tabs, img2img_image_editor, img2img_image_mask],
|
| 415 |
+
# _js=call_JS("moveImageFromGallery",
|
| 416 |
+
# fromId="txt2img_gallery_output",
|
| 417 |
+
# toId="img2img_mask")
|
| 418 |
+
# )
|
| 419 |
output_txt2img_copy_to_input_btn.click(
|
| 420 |
uifn.copy_img_to_input,
|
| 421 |
[gallery],
|
| 422 |
[tabs, img2img_image_editor, img2img_image_mask],
|
|
|
|
|
|
|
|
|
|
| 423 |
)
|
| 424 |
+
|
| 425 |
+
# 下面这几个函数现在都没什么用
|
|
|
|
|
|
|
|
|
|
|
|
|
| 426 |
output_img2img_copy_to_input_btn.click(
|
| 427 |
uifn.copy_img_to_edit,
|
| 428 |
[output_img2img_gallery],
|