def compare_classification(pred, gt): inside_class = sdf_nn.post_process_sign(pred) eval_dict = evaluation.compare_predictions_binary_tensors( ground_truth=gt.squeeze(), predicted=inside_class, prediction_name='training_metrics') return eval_dict
def post_process(batch_pred, train_opt, output_ids, output_pred_ind, patch_radius, fixed_radius): # post-processing of the prediction if 'imp_surf' in train_opt.outputs: oi_imp = output_ids['imp'][0] imp_surf_pred = batch_pred[:, output_pred_ind[oi_imp]: output_pred_ind[oi_imp] + 1] imp_surf_pred = sdf_nn.post_process_distance(pred=imp_surf_pred) if not fixed_radius: imp_surf_pred *= patch_radius.unsqueeze(dim=1) batch_pred[:, output_pred_ind[oi_imp]:output_pred_ind[oi_imp] + 1] = \ imp_surf_pred if 'imp_surf_magnitude' in train_opt.outputs: oi_ism = output_ids['ism'][0] imp_surf_mag_pred = batch_pred[:, output_pred_ind[oi_ism]: output_pred_ind[oi_ism] + 1] imp_surf_mag_pred = sdf_nn.post_process_magnitude( pred=imp_surf_mag_pred) if not fixed_radius: imp_surf_mag_pred *= patch_radius.unsqueeze(dim=1) batch_pred[:, output_pred_ind[oi_ism]:output_pred_ind[oi_ism] + 1] = \ imp_surf_mag_pred if 'imp_surf_sign' in train_opt.outputs: oi_iss = output_ids['iss'][0] imp_surf_sig_pred = batch_pred[:, output_pred_ind[oi_iss]: output_pred_ind[oi_iss] + 1] imp_surf_sig_pred = sdf_nn.post_process_sign(pred=imp_surf_sig_pred) batch_pred[:, output_pred_ind[oi_iss]:output_pred_ind[oi_iss] + 1] = imp_surf_sig_pred
def post_process(batch_pred, train_opt, output_ids, output_pred_ind, patch_radius, fixed_radius, trans): # post-processing of the prediction if 'imp_surf' in train_opt.outputs: oi_imp = output_ids['imp'][0] imp_surf_pred = batch_pred[:, output_pred_ind[oi_imp]: output_pred_ind[oi_imp] + 1] imp_surf_pred = sdf_nn.post_process_distance(pred=imp_surf_pred) if not fixed_radius: imp_surf_pred *= patch_radius.unsqueeze(dim=1) batch_pred[:, output_pred_ind[oi_imp]:output_pred_ind[oi_imp] + 1] = \ imp_surf_pred if 'imp_surf_magnitude' in train_opt.outputs: oi_ism = output_ids['ism'][0] imp_surf_mag_pred = batch_pred[:, output_pred_ind[oi_ism]: output_pred_ind[oi_ism] + 1] imp_surf_mag_pred = sdf_nn.post_process_magnitude( pred=imp_surf_mag_pred) if not fixed_radius: imp_surf_mag_pred *= patch_radius.unsqueeze(dim=1) batch_pred[:, output_pred_ind[oi_ism]:output_pred_ind[oi_ism] + 1] = \ imp_surf_mag_pred if 'imp_surf_sign' in train_opt.outputs: oi_iss = output_ids['iss'][0] imp_surf_sig_pred = batch_pred[:, output_pred_ind[oi_iss]: output_pred_ind[oi_iss] + 1] imp_surf_sig_pred = sdf_nn.post_process_sign(pred=imp_surf_sig_pred) batch_pred[:, output_pred_ind[oi_iss]:output_pred_ind[oi_iss] + 1] = imp_surf_sig_pred if 'normals' in train_opt.outputs: oi_n = output_ids['normal'][0] n_pred = batch_pred[:, output_pred_ind[oi_n]:output_pred_ind[oi_n] + 3] if trans is not None: n_pred[:, :] = torch.bmm(n_pred.unsqueeze(1), trans.transpose(2, 1)).squeeze(dim=1) n_pred_len = torch.max( n_pred.new_tensor([sys.float_info.epsilon * 100]), n_pred.norm(p=2, dim=1, keepdim=True)) n_pred = n_pred / n_pred_len batch_pred[:, output_pred_ind[oi_n]:output_pred_ind[oi_n] + 3] = n_pred