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

Method evaluate

datasets/ARCTIC.py:53–167  ·  view source on GitHub ↗
(self, outs, cur_sample_idx)

Source from the content-addressed store, hash-verified

51
52
53 def evaluate(self, outs, cur_sample_idx):
54 annots = self.datalist
55 sample_num = len(outs)
56 eval_result = {
57 'pa_mpvpe_all': [],
58 'pa_mpvpe_l_hand': [],
59 'pa_mpvpe_r_hand': [],
60 'pa_mpvpe_hand': [],
61 'pa_mpvpe_face': [],
62 'mpvpe_all': [],
63 'mpvpe_l_hand': [],
64 'mpvpe_r_hand': [],
65 'mpvpe_hand': [],
66 'mpvpe_face': []
67 }
68
69 vis = getattr(cfg, 'vis', False)
70 vis_save_dir = cfg.vis_dir
71 csv_file = f'{cfg.result_dir}/arctic_smplx_error.csv'
72 file = open(csv_file, 'a', newline='')
73
74 for n in range(sample_num):
75 annot = annots[cur_sample_idx + n]
76 out = outs[n]
77 mesh_gt = out['smplx_mesh_cam_target']
78 mesh_out = out['smplx_mesh_cam']
79 ann_idx = out['gt_ann_idx']
80 img_path = []
81 for ann_id in ann_idx:
82 img_path.append(annots[ann_id]['img_path'])
83 eval_result['img_path'] = img_path
84 # MPVPE from all vertices
85 mesh_out_align = \
86 mesh_out - np.dot(
87 smpl_x.J_regressor, mesh_out).transpose(1,0,2)[:, smpl_x.J_regressor_idx['pelvis'], None, :] + \
88 np.dot(smpl_x.J_regressor, mesh_gt).transpose(1,0,2)[:, smpl_x.J_regressor_idx['pelvis'], None, :]
89
90 eval_result['mpvpe_all'].append(
91 np.sqrt(np.sum(
92 (mesh_out_align - mesh_gt)**2, -1)).mean() * 1000)
93 mesh_out_align = rigid_align_batch(mesh_out, mesh_gt)
94 eval_result['pa_mpvpe_all'].append(
95 np.sqrt(np.sum(
96 (mesh_out_align - mesh_gt)**2, -1)).mean() * 1000)
97
98 # MPVPE from hand vertices
99 mesh_gt_lhand = mesh_gt[:, smpl_x.hand_vertex_idx['left_hand'], :]
100 mesh_out_lhand = mesh_out[:, smpl_x.hand_vertex_idx['left_hand'], :]
101 mesh_gt_rhand = mesh_gt[:, smpl_x.hand_vertex_idx['right_hand'], :]
102 mesh_out_rhand = mesh_out[:, smpl_x.hand_vertex_idx['right_hand'], :]
103 mesh_out_lhand_align = \
104 mesh_out_lhand - \
105 np.dot(smpl_x.J_regressor, mesh_out).transpose(1,0,2)[:, smpl_x.J_regressor_idx['lwrist'], None, :] + \
106 np.dot(smpl_x.J_regressor, mesh_gt).transpose(1,0,2)[:, smpl_x.J_regressor_idx['lwrist'], None, :]
107
108 mesh_out_rhand_align = \
109 mesh_out_rhand - \
110 np.dot(smpl_x.J_regressor, mesh_out).transpose(1,0,2)[:, smpl_x.J_regressor_idx['rwrist'], None, :] + \

Callers

nothing calls this directly

Calls 1

rigid_align_batchFunction · 0.90

Tested by

no test coverage detected