-
Notifications
You must be signed in to change notification settings - Fork 68
/
demo_vizmodel.py
33 lines (22 loc) · 909 Bytes
/
demo_vizmodel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import sys
import urllib.request
import tensorflow_io as tfio
import cameralib
from demos import metrabsviz
def main():
vizmodel = metrabsviz.VizModel('https://bit.ly/metrabs_l', skeleton='smpl_24')
frame_batches = tfio.IODataset.from_ffmpeg(get_video(sys.argv[1]), 'v:0').batch(8).prefetch(1)
camera = cameralib.Camera.from_fov(55, imshape=frame_batches.element_spec.shape[1:3])
for frame_batch in frame_batches:
pred = vizmodel.detect_and_visualize_poses_batched(frame_batch, camera)
# use pred['poses3d']
def get_video(source, temppath='/tmp/video.mp4'):
if not source.startswith('http'):
return source
opener = urllib.request.build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
urllib.request.install_opener(opener)
urllib.request.urlretrieve(source, temppath)
return temppath
if __name__ == '__main__':
main()