skytnt commited on
Commit
17e3440
1 Parent(s): fc2d897

README and Code

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -233,14 +233,14 @@ def gen_fn(method, seed, psi1, psi2, noise):
233
  return img_out, w, get_thumbnail(img_out)
234
 
235
 
236
- def encode_img_fn(img):
237
  if img is None:
238
  return "please upload a image", None, None, None, None
239
  imgs = model.detect(img, 0.2, 0.03)
240
  if len(imgs) == 0:
241
  return "failed to detect waifu", None, None, None, None
242
  w = model.encode_img(imgs[0])
243
- img_out = model.get_img(w)
244
  return "success", imgs[0], img_out, w, get_thumbnail(img_out)
245
 
246
 
@@ -324,7 +324,7 @@ if __name__ == '__main__':
324
  generate_video_output = gr.Video(label="output video")
325
  gen_submit.click(gen_fn, [gen_input1, gen_input2, gen_input3, gen_input4, gen_input5],
326
  [gen_output1, select_img_input_w1, select_img_input_img1])
327
- encode_img_submit.click(encode_img_fn, [encode_img_input],
328
  [encode_img_output1, encode_img_output2, encode_img_output3, select_img_input_w2,
329
  select_img_input_img2])
330
  encode_img_examples.click(lambda x: x[0], [encode_img_examples], [encode_img_input])
 
233
  return img_out, w, get_thumbnail(img_out)
234
 
235
 
236
+ def encode_img_fn(img, noise):
237
  if img is None:
238
  return "please upload a image", None, None, None, None
239
  imgs = model.detect(img, 0.2, 0.03)
240
  if len(imgs) == 0:
241
  return "failed to detect waifu", None, None, None, None
242
  w = model.encode_img(imgs[0])
243
+ img_out = model.get_img(w, noise)
244
  return "success", imgs[0], img_out, w, get_thumbnail(img_out)
245
 
246
 
 
324
  generate_video_output = gr.Video(label="output video")
325
  gen_submit.click(gen_fn, [gen_input1, gen_input2, gen_input3, gen_input4, gen_input5],
326
  [gen_output1, select_img_input_w1, select_img_input_img1])
327
+ encode_img_submit.click(encode_img_fn, [encode_img_input, gen_input5],
328
  [encode_img_output1, encode_img_output2, encode_img_output3, select_img_input_w2,
329
  select_img_input_img2])
330
  encode_img_examples.click(lambda x: x[0], [encode_img_examples], [encode_img_input])