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

Function vertice_pve

detrsmpl/core/evaluation/eval_utils.py:85–116  ·  view source on GitHub ↗

Computes per vertex error (PVE). Args: verts_gt (N x verts_num x 3). verts_pred (N x verts_num x 3). alignment (str, optional): method to align the prediction with the groundtruth. Supported options are: - ``'none'``: no alignment will be applied

(pred_verts, target_verts, alignment='none')

Source from the content-addressed store, hash-verified

83
84
85def vertice_pve(pred_verts, target_verts, alignment='none'):
86 """Computes per vertex error (PVE).
87
88 Args:
89 verts_gt (N x verts_num x 3).
90 verts_pred (N x verts_num x 3).
91 alignment (str, optional): method to align the prediction with the
92 groundtruth. Supported options are:
93 - ``'none'``: no alignment will be applied
94 - ``'scale'``: align in the least-square sense in scale
95 - ``'procrustes'``: align in the least-square sense in scale,
96 rotation and translation.
97 Returns:
98 error_verts.
99 """
100 assert len(pred_verts) == len(target_verts)
101 if alignment == 'none':
102 pass
103 elif alignment == 'procrustes':
104 pred_verts = np.stack([
105 compute_similarity_transform(pred_i, gt_i)
106 for pred_i, gt_i in zip(pred_verts, target_verts)
107 ])
108 elif alignment == 'scale':
109 pred_dot_pred = np.einsum('nkc,nkc->n', pred_verts, pred_verts)
110 pred_dot_gt = np.einsum('nkc,nkc->n', pred_verts, target_verts)
111 scale_factor = pred_dot_gt / pred_dot_pred
112 pred_verts = pred_verts * scale_factor[:, None, None]
113 else:
114 raise ValueError(f'Invalid value for alignment: {alignment}')
115 error = np.linalg.norm(pred_verts - target_verts, ord=2, axis=-1).mean()
116 return error
117
118
119def keypoint_3d_pck(pred, gt, mask, alignment='none', threshold=150.):

Callers 5

_report_pveMethod · 0.90
_report_pveMethod · 0.90
report_ihmr_idxMethod · 0.90
_report_pveMethod · 0.90
report_ihmr_idxMethod · 0.90

Calls 1

Tested by

no test coverage detected