def vis_group_color(self, estDisp, gtDisp=None, leftImage=None, rightImage=None, save_path=None): """ Args: estDisp, (tensor or numpy.array): in (1, 1, Height, Width) or (1, Height, Width) or (Height, Width) layout gtDisp, (None or tensor or numpy.array): in (1, 1, Height, Width) or (1, Height, Width) or (Height, Width) layout leftImage, (None or numpy.array), in (Height, Width, 3) layout rightImage, (None or numpy.array), in (Height, Width, 3) layout save_path, (None or String) Output: details refer to dmb.visualization.group_color """ assert isinstance(estDisp, (np.ndarray, torch.Tensor)) if torch.is_tensor(estDisp): estDisp = estDisp.clone().detach().cpu().numpy() if estDisp.ndim == 3: estDisp = estDisp[0, :, :] elif estDisp.ndim == 4: estDisp = estDisp[0, 0, :, :] if gtDisp is not None: assert isinstance(gtDisp, (np.ndarray, torch.Tensor)) if torch.is_tensor(gtDisp): gtDisp = gtDisp.clone().detach().cpu().numpy() if gtDisp.ndim == 3: gtDisp = gtDisp[0, :, :] elif gtDisp.ndim == 4: gtDisp = gtDisp[0, 0, :, :] return group_color(estDisp, gtDisp, leftImage, rightImage, save_path)
def visualize_disp(result_pkl): ori_data = result_pkl['OriginalData'] net_result = result_pkl['Result'] if 'disps' in net_result: disps = net_result['disps'] best_disp = disps[0][0, 0, :, :].cpu().numpy() else: return plt.imshow(group_color(best_disp, ori_data['leftDisp'], ori_data['leftImage'], ori_data['rightImage']), cmap='hot') plt.show()