From 06bc11673deda7c50660b273d69e357732296613 Mon Sep 17 00:00:00 2001 From: Mai Huy TRUONG <49065195+Nacriema@users.noreply.github.com> Date: Mon, 19 Feb 2024 13:50:27 +0700 Subject: [PATCH] Fix bug when no person detected in the video (#230) * fix bug when no detected person in video * fix lint --------- Co-authored-by: kennymckormick --- README.md | 2 +- demo/demo_skeleton.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2fa19848..b9d2ca7b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# PYSKL +# PYSKL [![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/revisiting-skeleton-based-action-recognition/skeleton-based-action-recognition-on-ntu-rgbd)](https://paperswithcode.com/sota/skeleton-based-action-recognition-on-ntu-rgbd?p=revisiting-skeleton-based-action-recognition) [![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/dg-stgcn-dynamic-spatial-temporal-modeling/skeleton-based-action-recognition-on-ntu-rgbd-1)](https://paperswithcode.com/sota/skeleton-based-action-recognition-on-ntu-rgbd-1?p=dg-stgcn-dynamic-spatial-temporal-modeling) diff --git a/demo/demo_skeleton.py b/demo/demo_skeleton.py index 52022ac6..93867f54 100644 --- a/demo/demo_skeleton.py +++ b/demo/demo_skeleton.py @@ -213,6 +213,8 @@ def pose_tracking(pose_results, max_tracks=2, thre=30): new_track['track_id'] = num_tracks new_track['data'] = [(idx, poses[j])] tracks.append(new_track) + if num_joints is None: + return None, None tracks.sort(key=lambda x: -len(x['data'])) result = np.zeros((max_tracks, len(pose_results), num_joints, 3), dtype=np.float16) for i, track in enumerate(tracks[:max_tracks]): @@ -284,9 +286,11 @@ def main(): fake_anno['keypoint'] = keypoint fake_anno['keypoint_score'] = keypoint_score - results = inference_recognizer(model, fake_anno) - - action_label = label_map[results[0][0]] + if fake_anno['keypoint'] is None: + action_label = '' + else: + results = inference_recognizer(model, fake_anno) + action_label = label_map[results[0][0]] pose_model = init_pose_model(args.pose_config, args.pose_checkpoint, args.device)