MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / keypoint_3d_auc

Function keypoint_3d_auc

detrsmpl/core/evaluation/eval_utils.py:169–221  ·  view source on GitHub ↗

Calculate the Area Under the Curve (3DAUC) computed for a range of 3DPCK thresholds. Paper ref: `Monocular 3D Human Pose Estimation In The Wild Using Improved CNN Supervision' 3DV'2017. `__ . This implementation is derived from mpii_compute_3d_pck.m,

(pred, gt, mask, alignment='none')

Source from the content-addressed store, hash-verified

167
168
169def keypoint_3d_auc(pred, gt, mask, alignment='none'):
170 """Calculate the Area Under the Curve (3DAUC) computed for a range of 3DPCK
171 thresholds.
172 Paper ref: `Monocular 3D Human Pose Estimation In The Wild Using Improved
173 CNN Supervision' 3DV'2017. <https://arxiv.org/pdf/1611.09813>`__ .
174 This implementation is derived from mpii_compute_3d_pck.m, which is
175 provided as part of the MPI-INF-3DHP test data release.
176 Note:
177 batch_size: N
178 num_keypoints: K
179 keypoint_dims: C
180 Args:
181 pred (np.ndarray[N, K, C]): Predicted keypoint location.
182 gt (np.ndarray[N, K, C]): Groundtruth keypoint location.
183 mask (np.ndarray[N, K]): Visibility of the target. False for invisible
184 joints, and True for visible. Invisible joints will be ignored for
185 accuracy calculation.
186 alignment (str, optional): method to align the prediction with the
187 groundtruth. Supported options are:
188 - ``'none'``: no alignment will be applied
189 - ``'scale'``: align in the least-square sense in scale
190 - ``'procrustes'``: align in the least-square sense in scale,
191 rotation and translation.
192 Returns:
193 auc: AUC computed for a range of 3DPCK thresholds.
194 """
195 assert mask.any()
196
197 if alignment == 'none':
198 pass
199 elif alignment == 'procrustes':
200 pred = np.stack([
201 compute_similarity_transform(pred_i, gt_i)
202 for pred_i, gt_i in zip(pred, gt)
203 ])
204 elif alignment == 'scale':
205 pred_dot_pred = np.einsum('nkc,nkc->n', pred, pred)
206 pred_dot_gt = np.einsum('nkc,nkc->n', pred, gt)
207 scale_factor = pred_dot_gt / pred_dot_pred
208 pred = pred * scale_factor[:, None, None]
209 else:
210 raise ValueError(f'Invalid value for alignment: {alignment}')
211
212 error = np.linalg.norm(pred - gt, ord=2, axis=-1)
213
214 thresholds = np.linspace(0., 150, 31)
215 pck_values = np.zeros(len(thresholds))
216 for i in range(len(thresholds)):
217 pck_values[i] = (error < thresholds[i]).astype(np.float32)[mask].mean()
218
219 auc = pck_values.mean() * 100
220
221 return auc
222
223
224def fg_vertices_to_mesh_distance(groundtruth_vertices,

Callers 3

_report_3d_aucMethod · 0.90
_report_3d_aucMethod · 0.90
_report_3d_aucMethod · 0.90

Calls 1

Tested by

no test coverage detected