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

Method evaluate

datasets/EgoBody_Egocentric.py:62–160  ·  view source on GitHub ↗
(self, outs, cur_sample_idx)

Source from the content-addressed store, hash-verified

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

rigid_align_batchFunction · 0.90
extendMethod · 0.45

Tested by

no test coverage detected