skytnt commited on
Commit
1c479ac
1 Parent(s): 7616c67
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -248,8 +248,8 @@ def get_thumbnail(img):
248
  return img_new
249
 
250
 
251
- def gen_fn(method, seed, psi1, psi2, noise):
252
- if method == 0:
253
  seed = random.randint(0, 2 ** 32 - 1)
254
  z = RandomState(int(seed)).randn(1, 1024)
255
  w = model.get_w(z.astype(dtype=np.float32), psi1, psi2)
@@ -289,9 +289,8 @@ if __name__ == '__main__':
289
  with gr.Column():
290
  gr.Markdown("generate image randomly or by seed")
291
  with gr.Row():
292
- gen_input1 = gr.Radio(label="method", value="random",
293
- choices=["random", "seed"], type="index")
294
- gen_input2 = gr.Slider(minimum=0, maximum=2 ** 32 - 1, step=1, value=0, label="seed")
295
  gen_input3 = gr.Slider(minimum=0, maximum=1, step=0.01, value=1, label="truncation psi 1")
296
  gen_input4 = gr.Slider(minimum=0, maximum=1, step=0.01, value=1, label="truncation psi 2")
297
  gen_input5 = gr.Slider(minimum=0, maximum=1, step=0.01, value=1, label="noise strength")
@@ -346,7 +345,7 @@ if __name__ == '__main__':
346
  with gr.Column():
347
  generate_video_output = gr.Video(label="output video")
348
  gen_submit.click(gen_fn, [gen_input1, gen_input2, gen_input3, gen_input4, gen_input5],
349
- [gen_output1, gen_input2, select_img_input_w1, select_img_input_img1])
350
  encode_img_submit.click(encode_img_fn, [encode_img_input, gen_input5],
351
  [encode_img_output1, encode_img_output2, encode_img_output3, select_img_input_w2,
352
  select_img_input_img2])
 
248
  return img_new
249
 
250
 
251
+ def gen_fn(seed, random_seed, psi1, psi2, noise):
252
+ if random_seed:
253
  seed = random.randint(0, 2 ** 32 - 1)
254
  z = RandomState(int(seed)).randn(1, 1024)
255
  w = model.get_w(z.astype(dtype=np.float32), psi1, psi2)
 
289
  with gr.Column():
290
  gr.Markdown("generate image randomly or by seed")
291
  with gr.Row():
292
+ gen_input1 = gr.Slider(minimum=0, maximum=2 ** 32 - 1, step=1, value=0, label="seed")
293
+ gen_input2 = gr.Checkbox(label="Random", value=True)
 
294
  gen_input3 = gr.Slider(minimum=0, maximum=1, step=0.01, value=1, label="truncation psi 1")
295
  gen_input4 = gr.Slider(minimum=0, maximum=1, step=0.01, value=1, label="truncation psi 2")
296
  gen_input5 = gr.Slider(minimum=0, maximum=1, step=0.01, value=1, label="noise strength")
 
345
  with gr.Column():
346
  generate_video_output = gr.Video(label="output video")
347
  gen_submit.click(gen_fn, [gen_input1, gen_input2, gen_input3, gen_input4, gen_input5],
348
+ [gen_output1, gen_input1, select_img_input_w1, select_img_input_img1])
349
  encode_img_submit.click(encode_img_fn, [encode_img_input, gen_input5],
350
  [encode_img_output1, encode_img_output2, encode_img_output3, select_img_input_w2,
351
  select_img_input_img2])