root commited on
Commit
cd03287
1 Parent(s): 37ef96c

add img choice

Browse files
Files changed (2) hide show
  1. app.py +4 -3
  2. ui_functions.py +2 -2
app.py CHANGED
@@ -246,8 +246,9 @@ if __name__ == "__main__":
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
  )
@@ -435,7 +436,7 @@ if __name__ == "__main__":
435
  # )
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
 
 
246
  label="Generated images", show_label=False, elem_id="gallery"
247
  ).style(grid=[2], height="auto")
248
 
249
+ with gr.Row().style(mobile_collapse=False, equal_height=True):
250
+ img_choices = gr.Dropdown(["图片1(img1)"],label='请选择一张图片发送到图生图',show_label=True,value="图片1(img1)", type="index")
251
+ output_txt2img_copy_to_input_btn = gr.Button("发送图片到图生图(Sent the image to img2img)").style(
252
  margin=False,
253
  rounded=(True, True, True, True),
254
  )
 
436
  # )
437
  output_txt2img_copy_to_input_btn.click(
438
  uifn.copy_img_to_input,
439
+ [gallery, img_choices],
440
  [tabs, img2img_image_editor, img2img_image_mask],
441
  )
442
 
ui_functions.py CHANGED
@@ -83,12 +83,12 @@ def copy_img_params_to_lab(params):
83
  return prompt,seed,steps,cfg_scale,sampler
84
  except IndexError:
85
  return [None, None]
86
- def copy_img_to_input(img):
87
  try:
88
  # print(img)
89
  # print("=============")
90
  # print("The img type is:{}".format(type(img[0])))
91
- image_data = re.sub('^data:image/.+;base64,', '', img[0])
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)
 
83
  return prompt,seed,steps,cfg_scale,sampler
84
  except IndexError:
85
  return [None, None]
86
+ def copy_img_to_input(img, idx):
87
  try:
88
  # print(img)
89
  # print("=============")
90
  # print("The img type is:{}".format(type(img[0])))
91
+ image_data = re.sub('^data:image/.+;base64,', '', img[idx])
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)