acmyu commited on
Commit
cb386b4
·
1 Parent(s): c54f540

api to get frames from video

Browse files
Files changed (2) hide show
  1. app.py +6 -1
  2. main.py +5 -1
app.py CHANGED
@@ -1,4 +1,4 @@
1
- from main import run_app, run_train, run_inference, run_generate_frame, run_interpolate_frames, resize_images
2
  from evaluate import run_evaluate, get_score
3
 
4
  import spaces
@@ -34,6 +34,7 @@ with gr.Blocks() as demo:
34
  eval_btn = gr.Button(value="Evaluate All")
35
  eval_btn2 = gr.Button(value="Evaluate")
36
  resize_btn = gr.Button(value="Resize")
 
37
  with gr.Column():
38
  animation = gr.Video(label="Result")
39
  frames = gr.Gallery(type="pil", label="Frames", format="png")
@@ -73,6 +74,10 @@ with gr.Blocks() as demo:
73
  resize_btn.click(
74
  resize_images, inputs=[frame_imgs, img_width, img_height], outputs=[frames]
75
  )
 
 
 
 
76
 
77
 
78
  demo.launch(share=True, show_error=True)
 
1
+ from main import run_app, run_train, run_inference, run_generate_frame, run_interpolate_frames, resize_images, get_frames
2
  from evaluate import run_evaluate, get_score
3
 
4
  import spaces
 
34
  eval_btn = gr.Button(value="Evaluate All")
35
  eval_btn2 = gr.Button(value="Evaluate")
36
  resize_btn = gr.Button(value="Resize")
37
+ frames_btn = gr.Button(value="Get Frames")
38
  with gr.Column():
39
  animation = gr.Video(label="Result")
40
  frames = gr.Gallery(type="pil", label="Frames", format="png")
 
74
  resize_btn.click(
75
  resize_images, inputs=[frame_imgs, img_width, img_height], outputs=[frames]
76
  )
77
+
78
+ frames_btn.click(
79
+ resize_images, inputs=[mocap, fps], outputs=[frames]
80
+ )
81
 
82
 
83
  demo.launch(share=True, show_error=True)
main.py CHANGED
@@ -1342,7 +1342,11 @@ def resize_images(images, width, height):
1342
  images = [img[0] for img in images]
1343
  return [resize_pad(img, width, height, True) for img in images]
1344
 
1345
-
 
 
 
 
1346
 
1347
 
1348
 
 
1342
  images = [img[0] for img in images]
1343
  return [resize_pad(img, width, height, True) for img in images]
1344
 
1345
+ def get_frames(video_path, fps):
1346
+ frames = extract_frames(video_path, fps)
1347
+ for f in frames:
1348
+ f.thumbnail((512,512))
1349
+ return frames
1350
 
1351
 
1352