| 391 | |
| 392 | @torch.no_grad() |
| 393 | def visualization(self): |
| 394 | |
| 395 | import matplotlib as mpl |
| 396 | import matplotlib.cm as cm |
| 397 | from PIL import Image |
| 398 | |
| 399 | save_dir = self.args.depth_img_save_dir |
| 400 | depth_path = self.args.depth_path |
| 401 | |
| 402 | depth, scale = read_pfm(depth_path) |
| 403 | vmax = np.percentile(depth, 95) |
| 404 | normalizer = mpl.colors.Normalize(vmin=depth.min(), vmax=vmax) |
| 405 | mapper = cm.ScalarMappable(norm=normalizer, cmap='magma') |
| 406 | colormapped_im = (mapper.to_rgba(depth)[:, :, :3] * 255).astype(np.uint8) |
| 407 | im = Image.fromarray(colormapped_im) |
| 408 | im.save(os.path.join(save_dir, "depth.png")) |
| 409 | |
| 410 | print("Successfully visualize!") |
| 411 | |