Spaces:
Paused
Paused
get frame poses
Browse files
app.py
CHANGED
|
@@ -76,7 +76,7 @@ with gr.Blocks() as demo:
|
|
| 76 |
)
|
| 77 |
|
| 78 |
frames_btn.click(
|
| 79 |
-
get_frames, inputs=[mocap, fps], outputs=[frames]
|
| 80 |
)
|
| 81 |
|
| 82 |
|
|
|
|
| 76 |
)
|
| 77 |
|
| 78 |
frames_btn.click(
|
| 79 |
+
get_frames, inputs=[mocap, fps], outputs=[frames, frames_thumb, pose_coords]
|
| 80 |
)
|
| 81 |
|
| 82 |
|
main.py
CHANGED
|
@@ -1344,9 +1344,25 @@ def resize_images(images, width, height):
|
|
| 1344 |
|
| 1345 |
def get_frames(video_path, fps):
|
| 1346 |
frames = extract_frames(video_path, fps)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1347 |
for f in frames:
|
| 1348 |
-
f
|
| 1349 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1350 |
|
| 1351 |
|
| 1352 |
|
|
|
|
| 1344 |
|
| 1345 |
def get_frames(video_path, fps):
|
| 1346 |
frames = extract_frames(video_path, fps)
|
| 1347 |
+
|
| 1348 |
+
dwpose = DWposeDetector(device="cuda")
|
| 1349 |
+
poses = []
|
| 1350 |
+
progress_bar = tqdm(range(len(frames)), initial=0, desc="Frames")
|
| 1351 |
for f in frames:
|
| 1352 |
+
_, pose_coords = get_pose(f, dwpose, "tar_pose"+str(len(poses))+".png")
|
| 1353 |
+
coords = {}
|
| 1354 |
+
for k in pose_coords:
|
| 1355 |
+
if k == 'bodies_multi':
|
| 1356 |
+
coords['bodies'] = pose_coords[k].tolist()
|
| 1357 |
+
elif k in ['hands']:
|
| 1358 |
+
coords[k] = pose_coords[k].tolist()
|
| 1359 |
+
elif k in ['num_candidates']:
|
| 1360 |
+
coords[k] = pose_coords[k]
|
| 1361 |
+
poses.append(json.dumps(coords))
|
| 1362 |
+
progress_bar.update(1)
|
| 1363 |
+
|
| 1364 |
+
print("done")
|
| 1365 |
+
return frames, getThumbnails(frames), poses
|
| 1366 |
|
| 1367 |
|
| 1368 |
|