(self, outs, cur_sample_idx)
| 43 | |
| 44 | |
| 45 | def evaluate(self, outs, cur_sample_idx): |
| 46 | annots = self.datalist |
| 47 | sample_num = len(outs) |
| 48 | eval_result = { |
| 49 | 'pa_mpvpe_all': [], |
| 50 | 'pa_mpvpe_l_hand': [], |
| 51 | 'pa_mpvpe_r_hand': [], |
| 52 | 'pa_mpvpe_hand': [], |
| 53 | 'pa_mpvpe_face': [], |
| 54 | 'mpvpe_all': [], |
| 55 | 'mpvpe_l_hand': [], |
| 56 | 'mpvpe_r_hand': [], |
| 57 | 'mpvpe_hand': [], |
| 58 | 'mpvpe_face': [], |
| 59 | 'pa_mpjpe_body': [], |
| 60 | 'pa_mpjpe_l_hand': [], |
| 61 | 'pa_mpjpe_r_hand': [], |
| 62 | 'pa_mpjpe_hand': [] |
| 63 | } |
| 64 | |
| 65 | csv_file = f'{cfg.result_dir}/ehf_smplx_error.csv' |
| 66 | file = open(csv_file, 'a', newline='') |
| 67 | for n in range(sample_num): |
| 68 | annot = annots[cur_sample_idx + n] |
| 69 | ann_id = annot['img_path'].split('/')[-1].split('_')[0] |
| 70 | out = outs[n] |
| 71 | ann_idx = out['gt_ann_idx'] |
| 72 | img_path = [] |
| 73 | for ann_id in ann_idx: |
| 74 | img_path.append(annots[ann_id]['img_path']) |
| 75 | eval_result['img_path'] = img_path |
| 76 | eval_result['ann_idx'] = ann_idx |
| 77 | # MPVPE from all vertices np.dot(self.cam_param['R'], out['smplx_mesh_cam_target'].transpose(0,2,1)).transpose(1,2,0) |
| 78 | # mesh_gt = np.dot( |
| 79 | # self.cam_param['R'], |
| 80 | # out['smplx_mesh_cam_target'].transpose(0,2,1) |
| 81 | # ).transpose(1,2,0) |
| 82 | mesh_gt = out['smplx_mesh_cam_target'] |
| 83 | mesh_out = out['smplx_mesh_cam'] |
| 84 | |
| 85 | # mesh_gt_align = rigid_align(mesh_gt, mesh_out) |
| 86 | |
| 87 | # print(mesh_out.shape) |
| 88 | mesh_out_align = rigid_align_batch(mesh_out, mesh_gt) |
| 89 | eval_result['pa_mpvpe_all'].append( |
| 90 | np.sqrt(np.sum( |
| 91 | (mesh_out_align - mesh_gt)**2, -1)).mean() * 1000) |
| 92 | mesh_out_align = mesh_out - np.dot( |
| 93 | smpl_x.J_regressor, |
| 94 | mesh_out).transpose(1,0,2)[:, smpl_x.J_regressor_idx['pelvis'], None, :] + np.dot( |
| 95 | smpl_x.J_regressor, |
| 96 | mesh_gt).transpose(1,0,2)[:, smpl_x.J_regressor_idx['pelvis'], None, :] |
| 97 | eval_result['mpvpe_all'].append( |
| 98 | np.sqrt(np.sum( |
| 99 | (mesh_out_align - mesh_gt)**2, -1)).mean() * 1000) |
| 100 | |
| 101 | # MPVPE from hand vertices |
| 102 | mesh_gt_lhand = mesh_gt[:, smpl_x.hand_vertex_idx['left_hand'], :] |
no test coverage detected