MCPcopy Create free account
hub / github.com/AdaptiveMotorControlLab/FMPose3D / h36m_coco_format

Function h36m_coco_format

fmpose3d/lib/preprocess.py:48–77  ·  view source on GitHub ↗
(keypoints, scores)

Source from the content-addressed store, hash-verified

46
47
48def h36m_coco_format(keypoints, scores):
49 assert len(keypoints.shape) == 4 and len(scores.shape) == 3
50
51 h36m_kpts = []
52 h36m_scores = []
53 valid_frames = []
54
55 for i in range(keypoints.shape[0]):
56 kpts = keypoints[i]
57 score = scores[i]
58
59 new_score = np.zeros_like(score, dtype=np.float32)
60
61 if np.sum(kpts) != 0.:
62 kpts, valid_frame = coco_h36m(kpts)
63 h36m_kpts.append(kpts)
64 valid_frames.append(valid_frame)
65
66 new_score[:, h36m_coco_order] = score[:, coco_order]
67 new_score[:, 0] = np.mean(score[:, [11, 12]], axis=1, dtype=np.float32)
68 new_score[:, 8] = np.mean(score[:, [5, 6]], axis=1, dtype=np.float32)
69 new_score[:, 7] = np.mean(new_score[:, [0, 8]], axis=1, dtype=np.float32)
70 new_score[:, 10] = np.mean(score[:, [1, 2, 3, 4]], axis=1, dtype=np.float32)
71
72 h36m_scores.append(new_score)
73
74 h36m_kpts = np.asarray(h36m_kpts, dtype=np.float32)
75 h36m_scores = np.asarray(h36m_scores, dtype=np.float32)
76
77 return h36m_kpts, h36m_scores, valid_frames
78
79
80def revise_kpts(h36m_kpts, h36m_scores, valid_frames):

Callers 3

test_2d_pose_estimationFunction · 0.90
predictMethod · 0.90
get_pose2DFunction · 0.90

Calls 1

coco_h36mFunction · 0.70

Tested by 1

test_2d_pose_estimationFunction · 0.72