(self, outs, cur_sample_idx)
| 806 | return result |
| 807 | |
| 808 | def evaluate(self, outs, cur_sample_idx): |
| 809 | annots = self.datalist |
| 810 | sample_num = len(outs) |
| 811 | eval_result = { |
| 812 | 'pa_mpvpe_all': [], |
| 813 | 'pa_mpvpe_l_hand': [], |
| 814 | 'pa_mpvpe_r_hand': [], |
| 815 | 'pa_mpvpe_hand': [], |
| 816 | 'pa_mpvpe_face': [], |
| 817 | 'mpvpe_all': [], |
| 818 | 'mpvpe_l_hand': [], |
| 819 | 'mpvpe_r_hand': [], |
| 820 | 'mpvpe_hand': [], |
| 821 | 'mpvpe_face': [] |
| 822 | } |
| 823 | |
| 824 | vis = getattr(cfg, 'vis', False) |
| 825 | vis_save_dir = cfg.vis_dir |
| 826 | |
| 827 | csv_file = f'{cfg.result_dir}/agora_smplx_error.csv' |
| 828 | file = open(csv_file, 'a', newline='') |
| 829 | for n in range(sample_num): |
| 830 | annot = annots[cur_sample_idx + n] |
| 831 | out = outs[n] |
| 832 | mesh_gt = out['smplx_mesh_cam_target'] |
| 833 | mesh_out = out['smplx_mesh_cam'] |
| 834 | |
| 835 | # print('zzz',mesh_gt.shape,mesh_out.shape) |
| 836 | # from pytorch3d.io import save_obj |
| 837 | # for m_i,(mesh_gt_i,mesh_out_i) in enumerate(zip(mesh_gt,mesh_out)): |
| 838 | # save_obj('temp_gt_%d.obj'%m_i,verts=torch.Tensor(mesh_gt_i),faces=torch.tensor([])) |
| 839 | # save_obj('temp_pred_%d.obj'%m_i,verts=torch.Tensor(mesh_out_i),faces=torch.tensor([])) |
| 840 | |
| 841 | ann_idx = out['gt_ann_idx'] |
| 842 | img_path = [] |
| 843 | for ann_id in ann_idx: |
| 844 | img_path.append(annots[ann_id]['img_path']) |
| 845 | eval_result['img_path'] = img_path |
| 846 | eval_result['ann_idx'] = ann_idx |
| 847 | # MPVPE from all vertices |
| 848 | mesh_out_align = \ |
| 849 | mesh_out - np.dot( |
| 850 | smpl_x.J_regressor, mesh_out).transpose(1,0,2)[:, smpl_x.J_regressor_idx['pelvis'], None, :] + \ |
| 851 | np.dot(smpl_x.J_regressor, mesh_gt).transpose(1,0,2)[:, smpl_x.J_regressor_idx['pelvis'], None, :] |
| 852 | |
| 853 | eval_result['mpvpe_all'].extend( |
| 854 | np.sqrt(np.sum( |
| 855 | (mesh_out_align - mesh_gt)**2, -1)).mean(-1) * 1000) |
| 856 | mesh_out_align = rigid_align_batch(mesh_out, mesh_gt) |
| 857 | eval_result['pa_mpvpe_all'].extend( |
| 858 | np.sqrt(np.sum( |
| 859 | (mesh_out_align - mesh_gt)**2, -1)).mean(-1) * 1000) |
| 860 | |
| 861 | # MPVPE from hand vertices |
| 862 | mesh_gt_lhand = mesh_gt[:, smpl_x.hand_vertex_idx['left_hand'], :] |
| 863 | mesh_out_lhand = mesh_out[:, smpl_x.hand_vertex_idx['left_hand'], :] |
| 864 | mesh_gt_rhand = mesh_gt[:, smpl_x.hand_vertex_idx['right_hand'], :] |
| 865 | mesh_out_rhand = mesh_out[:, smpl_x.hand_vertex_idx['right_hand'], :] |
nothing calls this directly
no test coverage detected