def visualize_uncertainty(logvar, objects, grid): # Visualize uncertainty fig_uncert = plt.figure(num='uncertainty', figsize=(6, 6)) fig_uncert.clear() ax = fig_uncert.gca() ax = oft.vis_uncertainty(logvar[0, 0], objects[0], grid[0], ax=ax) # Setup colorbar def cbar_fmt(x, pos): return '{:.2f}'.format(math.exp(x)) cbar = plt.colorbar(ax.collections[0], format=FuncFormatter(cbar_fmt)) return oft.convert_figure(fig_uncert)
def visualize_score(preds, targets, grid): # Expand tuples score, pos_offsets, dim_offsets, ang_offsets = preds labels, sqr_dists, gt_pos_offsets, gt_dim_offsets, gt_ang_offsets = targets # TODO Compute # score = oft.model.loss.compute_uncertainty(score, sqr_dists, 0.25) # Visualize score fig_score = plt.figure(num='score', figsize=(8, 6)) fig_score.clear() # oft.vis_score(score[0, 0], grid[0], ax=plt.subplot(121)) oft.vis_score(score[0, 0].sigmoid(), grid[0], ax=plt.subplot(121)) oft.vis_score(labels[0, 0].float(), grid[0], ax=plt.subplot(122)) return oft.convert_figure(fig_score)
def visualize_image(image): fig = plt.figure('image', figsize=(8, 4)) plt.imshow(image[0].cpu().detach().permute(1, 2, 0).numpy()) plt.axis('off') return oft.convert_figure(fig)