skytnt commited on
Commit
a2917b0
1 Parent(s): 72ea4ce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -39
app.py CHANGED
@@ -249,7 +249,8 @@ def encode_img_fn(img):
249
  def gen_video_fn(w1, w2, frame):
250
  if w1 is None or w2 is None:
251
  return None
252
- model.gen_video(np.array(json.loads(w1), dtype=np.float32), np.array(json.loads(w2), dtype=np.float32), "video.mp4", int(frame))
 
253
  return "video.mp4"
254
 
255
 
@@ -262,50 +263,62 @@ if __name__ == '__main__':
262
  "the model is not good, just for fun.")
263
  with gr.Tabs():
264
  with gr.TabItem("generate image"):
265
- with gr.Column():
266
- with gr.Row():
 
267
  gen_input1 = gr.Checkbox(value=False, label="use seed")
268
  gen_input2 = gr.Number(value=1, label="seed")
269
- gen_input3 = gr.Slider(minimum=0, maximum=1, step=0.01, value=0.6, label="psi")
270
- gen_submit = gr.Button("Run")
271
- gen_output1 = gr.Image()
272
- select_img_input_w1 = gr.Textbox(visible=False)
273
- select_img_input_img1 = gr.Image(visible=False)
 
 
274
 
275
  with gr.TabItem("encode image"):
276
- with gr.Column():
277
- encode_img_input = gr.Image()
278
- encode_img_submit = gr.Button("Run")
279
- encode_img_output1 = gr.Textbox(label="message")
280
- with gr.Row():
281
- encode_img_output2 = gr.Image(label="detected")
282
- encode_img_output3 = gr.Image(label="encoded")
283
- select_img_input_w2 = gr.Textbox(visible=False)
284
- select_img_input_img2 = gr.Image(visible=False)
 
 
 
 
285
 
286
  with gr.TabItem("generate video"):
287
- with gr.Column():
288
- gr.Markdown("## generate video between 2 images")
289
- with gr.Row():
290
- with gr.Column():
291
- gr.Markdown("please select image 1")
292
- select_img1_dropdown = gr.Dropdown(label="source",
293
- choices=["current generated image",
294
- "current encoded image"], type="index")
295
- select_img1_button = gr.Button("select")
296
- select_img1_output_img = gr.Image(label="image 1")
297
- select_img1_output_w = gr.Textbox(visible=False)
298
- with gr.Column():
299
- gr.Markdown("please select image 2")
300
- select_img2_dropdown = gr.Dropdown(label="source",
301
- choices=["current generated image",
302
- "current encoded image"], type="index")
303
- select_img2_button = gr.Button("select")
304
- select_img2_output_img = gr.Image(label="image 2")
305
- select_img2_output_w = gr.Textbox(visible=False)
306
- generate_video_frame = gr.Slider(minimum=10, maximum=30, step=1, label="frame", value=10)
307
- generate_video_button = gr.Button("generate")
308
- generate_video_output = gr.Video()
 
 
 
 
 
309
 
310
  gen_submit.click(gen_fn, [gen_input1, gen_input2, gen_input3],
311
  [gen_output1, select_img_input_w1, select_img_input_img1])
 
249
  def gen_video_fn(w1, w2, frame):
250
  if w1 is None or w2 is None:
251
  return None
252
+ model.gen_video(np.array(json.loads(w1), dtype=np.float32), np.array(json.loads(w2), dtype=np.float32), "video.mp4",
253
+ int(frame))
254
  return "video.mp4"
255
 
256
 
 
263
  "the model is not good, just for fun.")
264
  with gr.Tabs():
265
  with gr.TabItem("generate image"):
266
+ with gr.Row():
267
+ with gr.Column():
268
+ gr.Markdown("generate image randomly or by seed")
269
  gen_input1 = gr.Checkbox(value=False, label="use seed")
270
  gen_input2 = gr.Number(value=1, label="seed")
271
+ gen_input3 = gr.Slider(minimum=0, maximum=1, step=0.01, value=0.6, label="truncation psi")
272
+ with gr.Group():
273
+ gen_submit = gr.Button("Run")
274
+ with gr.Column():
275
+ gen_output1 = gr.Image()
276
+ select_img_input_w1 = gr.Textbox(visible=False)
277
+ select_img_input_img1 = gr.Image(visible=False)
278
 
279
  with gr.TabItem("encode image"):
280
+ with gr.Row():
281
+ with gr.Column():
282
+ gr.Markdown("you'd better upload a standing full-body image")
283
+ encode_img_input = gr.Image()
284
+ with gr.Group():
285
+ encode_img_submit = gr.Button("Run")
286
+ with gr.Column():
287
+ encode_img_output1 = gr.Textbox(label="message")
288
+ with gr.Row():
289
+ encode_img_output2 = gr.Image(label="detected")
290
+ encode_img_output3 = gr.Image(label="encoded")
291
+ select_img_input_w2 = gr.Textbox(visible=False)
292
+ select_img_input_img2 = gr.Image(visible=False)
293
 
294
  with gr.TabItem("generate video"):
295
+ with gr.Row():
296
+ with gr.Column():
297
+ gr.Markdown("## generate video between 2 images")
298
+ with gr.Row():
299
+ with gr.Column():
300
+ gr.Markdown("please select image 1")
301
+ select_img1_dropdown = gr.Radio(label="source",
302
+ choices=["current generated image",
303
+ "current encoded image"], type="index")
304
+ with gr.Group():
305
+ select_img1_button = gr.Button("select")
306
+ select_img1_output_img = gr.Image(label="image 1")
307
+ select_img1_output_w = gr.Textbox(visible=False)
308
+ with gr.Column():
309
+ gr.Markdown("please select image 2")
310
+ select_img2_dropdown = gr.Radio(label="source",
311
+ choices=["current generated image",
312
+ "current encoded image"], type="index")
313
+ with gr.Group():
314
+ select_img2_button = gr.Button("select")
315
+ select_img2_output_img = gr.Image(label="image 2")
316
+ select_img2_output_w = gr.Textbox(visible=False)
317
+ generate_video_frame = gr.Slider(minimum=10, maximum=30, step=1, label="frame", value=10)
318
+ with gr.Group():
319
+ generate_video_button = gr.Button("generate")
320
+ with gr.Column():
321
+ generate_video_output = gr.Video()
322
 
323
  gen_submit.click(gen_fn, [gen_input1, gen_input2, gen_input3],
324
  [gen_output1, select_img_input_w1, select_img_input_img1])