From ffbd16a375cc7579f9291353e58bd81f64f852ad Mon Sep 17 00:00:00 2001 From: Feez2403 Date: Sun, 12 May 2024 03:38:13 +0200 Subject: [PATCH] Fix edge case of depth colormap (#3139) If the user sets near_plane as 0.0, the "or" will take the second term (float(torch.min(depth))) instead of using the 0.0 value. We fix this by checking explicitely for a "None" variable --- nerfstudio/utils/colormaps.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nerfstudio/utils/colormaps.py b/nerfstudio/utils/colormaps.py index 0f1fc40b7..4d5284e77 100644 --- a/nerfstudio/utils/colormaps.py +++ b/nerfstudio/utils/colormaps.py @@ -134,8 +134,8 @@ def apply_depth_colormap( Colored depth image with colors in [0, 1] """ - near_plane = near_plane or float(torch.min(depth)) - far_plane = far_plane or float(torch.max(depth)) + near_plane = near_plane if near_plane is not None else float(torch.min(depth)) + far_plane = far_plane if far_plane is not None else float(torch.max(depth)) depth = (depth - near_plane) / (far_plane - near_plane + 1e-10) depth = torch.clip(depth, 0, 1)