From 34c08440ddc830b25f8d9ec16ebd514370b40030 Mon Sep 17 00:00:00 2001 From: lupeng Date: Wed, 20 Sep 2023 12:36:36 +0800 Subject: [PATCH] fix 3d inferencer --- mmpose/apis/inferencers/pose3d_inferencer.py | 23 +++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/mmpose/apis/inferencers/pose3d_inferencer.py b/mmpose/apis/inferencers/pose3d_inferencer.py index 89d3edac5d..e34bdd88f1 100644 --- a/mmpose/apis/inferencers/pose3d_inferencer.py +++ b/mmpose/apis/inferencers/pose3d_inferencer.py @@ -235,8 +235,18 @@ def preprocess_single(self, bbox_center = stats_info.get('bbox_center', None) bbox_scale = stats_info.get('bbox_scale', None) - for i, pose_res in enumerate(pose_results_2d): - for j, data_sample in enumerate(pose_res): + pose_results_2d_copy = [] + for pose_res in pose_results_2d: + pose_res_copy = [] + for data_sample in pose_res: + + data_sample_copy = PoseDataSample() + data_sample_copy.gt_instances = \ + data_sample.gt_instances.clone() + data_sample_copy.pred_instances = \ + data_sample.pred_instances.clone() + data_sample_copy.track_id = data_sample.track_id + kpts = data_sample.pred_instances.keypoints bboxes = data_sample.pred_instances.bboxes keypoints = [] @@ -251,9 +261,12 @@ def preprocess_single(self, bbox_scale + bbox_center) else: keypoints.append(kpt[:, :2]) - pose_results_2d[i][j].pred_instances.keypoints = np.array( - keypoints) - pose_sequences_2d = collate_pose_sequence(pose_results_2d, True, + data_sample_copy.pred_instances.set_field( + np.array(keypoints), 'keypoints') + pose_res_copy.append(data_sample_copy) + + pose_results_2d_copy.append(pose_res_copy) + pose_sequences_2d = collate_pose_sequence(pose_results_2d_copy, True, target_idx) if not pose_sequences_2d: return []