root commited on
Commit
316d1bb
1 Parent(s): 086f64b

fix some bugs

Browse files
Files changed (2) hide show
  1. app.py +19 -10
  2. ui_functions.py +8 -4
app.py CHANGED
@@ -246,21 +246,29 @@ if __name__ == "__main__":
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("发送图片到图生图(Sent the image to img2img)").style(
250
  margin=False,
251
  rounded=(True, True, True, True),
252
  )
253
 
254
- go_to_img2img_btn = gr.Button("转至图生图(Go to img2img)").style(
255
- margin=False,
256
- rounded=(True, True, True, True),
257
- )
 
258
 
259
 
260
  gr.Examples(examples=examples, fn=request_images, inputs=text, outputs=gallery, examples_per_page=100)
261
  text.submit(request_images, inputs=[text, class_draw, style_draw, sample_size, sr_option], outputs=gallery)
262
  btn.click(request_images, inputs=[text, class_draw, style_draw, sample_size, sr_option], outputs=gallery)
263
 
 
 
 
 
 
 
264
  with gr.TabItem("图生图(Img-to-Img)", id="img2img_tab"):
265
  with gr.Row(elem_id="prompt_row"):
266
  img2img_prompt = gr.Textbox(label="Prompt",
@@ -428,13 +436,14 @@ if __name__ == "__main__":
428
  output_txt2img_copy_to_input_btn.click(
429
  uifn.copy_img_to_input,
430
  [gallery],
431
- [img2img_image_editor, img2img_image_mask],
432
- )
433
- go_to_img2img_btn.click(
434
- uifn.go_to_img2img,
435
- [],
436
- [tabs],
437
  )
 
 
 
 
 
 
438
 
439
  # 下面这几个函数现在都没什么用
440
  output_img2img_copy_to_input_btn.click(
 
246
  label="Generated images", show_label=False, elem_id="gallery"
247
  ).style(grid=[2], height="auto")
248
 
249
+ img_choices = gr.Dropdown(["图片1(img1)"],label='请选择一张图片发送到图生图',show_label=True,value="图片1(img1)")
250
  output_txt2img_copy_to_input_btn = gr.Button("发送图片到图生图(Sent the image to img2img)").style(
251
  margin=False,
252
  rounded=(True, True, True, True),
253
  )
254
 
255
+ # 并没有什么软用,转跳还是很卡,而且只能转跳一次
256
+ # go_to_img2img_btn = gr.Button("转至图生图(Go to img2img)").style(
257
+ # margin=False,
258
+ # rounded=(True, True, True, True),
259
+ # )
260
 
261
 
262
  gr.Examples(examples=examples, fn=request_images, inputs=text, outputs=gallery, examples_per_page=100)
263
  text.submit(request_images, inputs=[text, class_draw, style_draw, sample_size, sr_option], outputs=gallery)
264
  btn.click(request_images, inputs=[text, class_draw, style_draw, sample_size, sr_option], outputs=gallery)
265
 
266
+ sample_size.change(
267
+ fun=uifn.change_img_choices,
268
+ inputs=[sample_size],
269
+ outputs=[img_choices]
270
+ )
271
+
272
  with gr.TabItem("图生图(Img-to-Img)", id="img2img_tab"):
273
  with gr.Row(elem_id="prompt_row"):
274
  img2img_prompt = gr.Textbox(label="Prompt",
 
436
  output_txt2img_copy_to_input_btn.click(
437
  uifn.copy_img_to_input,
438
  [gallery],
439
+ [tabs, img2img_image_editor, img2img_image_mask],
 
 
 
 
 
440
  )
441
+
442
+ # go_to_img2img_btn.click(
443
+ # uifn.go_to_img2img,
444
+ # [],
445
+ # [tabs],
446
+ # )
447
 
448
  # 下面这几个函数现在都没什么用
449
  output_img2img_copy_to_input_btn.click(
ui_functions.py CHANGED
@@ -5,6 +5,13 @@ from io import BytesIO
5
  import base64
6
  import re
7
 
 
 
 
 
 
 
 
8
 
9
  def change_image_editor_mode(choice, cropped_image, masked_image, resize_mode, width, height):
10
  if choice == "Mask":
@@ -85,12 +92,9 @@ def copy_img_to_input(img):
85
  processed_image = Image.open(BytesIO(base64.b64decode(image_data)))
86
  tab_update = gr.update(selected='img2img_tab')
87
  img_update = gr.update(value=processed_image)
88
- return processed_image, processed_image
89
  except IndexError:
90
  return [None, None]
91
- def go_to_img2img():
92
- tab_update = gr.update(selected='img2img_tab')
93
- return tab_update
94
 
95
  def copy_img_to_edit(img):
96
  try:
 
5
  import base64
6
  import re
7
 
8
+ def change_img_choices(sample_size):
9
+ choices = ['图片1(img1)']
10
+ for i in range(sample_size):
11
+ choices.append(
12
+ '图片{}(img_{})'.format(i+1,i+1)
13
+ )
14
+ return choices
15
 
16
  def change_image_editor_mode(choice, cropped_image, masked_image, resize_mode, width, height):
17
  if choice == "Mask":
 
92
  processed_image = Image.open(BytesIO(base64.b64decode(image_data)))
93
  tab_update = gr.update(selected='img2img_tab')
94
  img_update = gr.update(value=processed_image)
95
+ return tab_update,processed_image, processed_image
96
  except IndexError:
97
  return [None, None]
 
 
 
98
 
99
  def copy_img_to_edit(img):
100
  try: