fffiloni commited on
Commit
4d67d4b
·
verified ·
1 Parent(s): f06ef56

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -4
app.py CHANGED
@@ -325,7 +325,7 @@ def propagate_to_all(video_in, checkpoint, stored_inference_state, stored_frame_
325
 
326
 
327
  if vis_frame_type == "check":
328
- return gr.update(value=jpeg_images, visible=True), gr.update(visible=False, value=None)
329
  elif vis_frame_type == "render":
330
  # Create a video clip from the image sequence
331
  original_fps = get_video_fps(video_in)
@@ -333,9 +333,14 @@ def propagate_to_all(video_in, checkpoint, stored_inference_state, stored_frame_
333
  clip = ImageSequenceClip(jpeg_images, fps=fps)
334
  # Write the result to a file
335
  final_vid_output_path = "output_video.mp4"
336
- clip.write_videofile(output_path, codec='libx264')
337
- return gr.update(visible=False, value=None), gr.update(value=final_vid_output_path, visible=True)
338
-
 
 
 
 
 
339
 
340
  with gr.Blocks() as demo:
341
  first_frame_path = gr.State()
@@ -405,6 +410,11 @@ with gr.Blocks() as demo:
405
  )
406
 
407
  propagate_btn.click(
 
 
 
 
 
408
  fn = propagate_to_all,
409
  inputs = [video_in, checkpoint, stored_inference_state, stored_frame_names, video_frames_dir, vis_frame_type],
410
  outputs = [output_propagated, output_video]
 
325
 
326
 
327
  if vis_frame_type == "check":
328
+ return gr.update(value=jpeg_images), gr.update(value=None)
329
  elif vis_frame_type == "render":
330
  # Create a video clip from the image sequence
331
  original_fps = get_video_fps(video_in)
 
333
  clip = ImageSequenceClip(jpeg_images, fps=fps)
334
  # Write the result to a file
335
  final_vid_output_path = "output_video.mp4"
336
+ clip.write_videofile(final_vid_output_path, codec='libx264')
337
+ return gr.update(value=None), gr.update(value=final_vid_output_path)
338
+
339
+ def update_ui(vis_frame_type):
340
+ if vis_frame_type == "check":
341
+ return gr.update(visible=True), gr.update(visible=False)
342
+ elif vis_frame_type == "render":
343
+ return gr.update(visible=False), gr.update(visible=True)
344
 
345
  with gr.Blocks() as demo:
346
  first_frame_path = gr.State()
 
410
  )
411
 
412
  propagate_btn.click(
413
+ fn = update_ui,
414
+ inputs = [vis_frame_type],
415
+ outputs = [output_propagated, output_video],
416
+ queue=False
417
+ ).then(
418
  fn = propagate_to_all,
419
  inputs = [video_in, checkpoint, stored_inference_state, stored_frame_names, video_frames_dir, vis_frame_type],
420
  outputs = [output_propagated, output_video]