From c8434037a0f120c3a092af83d6db3ee6fccdae1e Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Sat, 10 Feb 2024 11:42:43 -0500 Subject: [PATCH 1/5] Call rescale_output_resolution before early return --- nerfstudio/models/splatfacto.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nerfstudio/models/splatfacto.py b/nerfstudio/models/splatfacto.py index a826599f94..37c774253d 100644 --- a/nerfstudio/models/splatfacto.py +++ b/nerfstudio/models/splatfacto.py @@ -740,6 +740,10 @@ def get_outputs(self, camera: Cameras) -> Dict[str, Union[torch.Tensor, List]]: rgb = background.repeat(int(camera.height.item()), int(camera.width.item()), 1) depth = background.new_ones(*rgb.shape[:2], 1) * 10 accumulation = background.new_zeros(*rgb.shape[:2], 1) + + # rescale the camera back to original dimensions before returning + camera.rescale_output_resolution(camera_downscale) + return {"rgb": rgb, "depth": depth, "accumulation": accumulation} # Important to allow xys grads to populate properly From c5520fb4b1ff45907f3a6a67acc76cdbcbf08ccb Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Sat, 10 Feb 2024 16:51:35 +0000 Subject: [PATCH 2/5] Fix ruff --- nerfstudio/models/splatfacto.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nerfstudio/models/splatfacto.py b/nerfstudio/models/splatfacto.py index 37c774253d..a44d1213ef 100644 --- a/nerfstudio/models/splatfacto.py +++ b/nerfstudio/models/splatfacto.py @@ -743,7 +743,7 @@ def get_outputs(self, camera: Cameras) -> Dict[str, Union[torch.Tensor, List]]: # rescale the camera back to original dimensions before returning camera.rescale_output_resolution(camera_downscale) - + return {"rgb": rgb, "depth": depth, "accumulation": accumulation} # Important to allow xys grads to populate properly From 4f29522e26a7c4f0f799eafd95168f57be3efef1 Mon Sep 17 00:00:00 2001 From: Chung Min Kim Date: Tue, 13 Feb 2024 14:17:23 -0800 Subject: [PATCH 3/5] Move rescale_output_resolution to after project_gaussians --- nerfstudio/models/splatfacto.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nerfstudio/models/splatfacto.py b/nerfstudio/models/splatfacto.py index bc7e4a5759..323cefd1e0 100644 --- a/nerfstudio/models/splatfacto.py +++ b/nerfstudio/models/splatfacto.py @@ -747,14 +747,14 @@ def get_outputs(self, camera: Cameras) -> Dict[str, Union[torch.Tensor, List]]: tile_bounds, ) # type: ignore + # rescale the camera back to original dimensions before returning + camera.rescale_output_resolution(camera_downscale) + if (self.radii).sum() == 0: rgb = background.repeat(int(camera.height.item()), int(camera.width.item()), 1) depth = background.new_ones(*rgb.shape[:2], 1) * 10 accumulation = background.new_zeros(*rgb.shape[:2], 1) - # rescale the camera back to original dimensions before returning - camera.rescale_output_resolution(camera_downscale) - return {"rgb": rgb, "depth": depth, "accumulation": accumulation, "background": background} # Important to allow xys grads to populate properly From 6fba30f97043095b7246dd4f6a3bbad33f2f2e05 Mon Sep 17 00:00:00 2001 From: Chung Min Kim Date: Tue, 13 Feb 2024 14:37:34 -0800 Subject: [PATCH 4/5] Remove duplicate rescale_camera_resolution --- nerfstudio/models/splatfacto.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/nerfstudio/models/splatfacto.py b/nerfstudio/models/splatfacto.py index 323cefd1e0..b4120cfc50 100644 --- a/nerfstudio/models/splatfacto.py +++ b/nerfstudio/models/splatfacto.py @@ -770,8 +770,6 @@ def get_outputs(self, camera: Cameras) -> Dict[str, Union[torch.Tensor, List]]: else: rgbs = torch.sigmoid(colors_crop[:, 0, :]) - # rescale the camera back to original dimensions - camera.rescale_output_resolution(camera_downscale) assert (num_tiles_hit > 0).any() # type: ignore # apply the compensation of screen space blurring to gaussians From c53e158a81a94f9f6c76791a8c4b2453fdde03e1 Mon Sep 17 00:00:00 2001 From: Chung Min Kim Date: Tue, 13 Feb 2024 15:05:14 -0800 Subject: [PATCH 5/5] Use H, W instead of rescaled camera dimensions --- nerfstudio/models/splatfacto.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nerfstudio/models/splatfacto.py b/nerfstudio/models/splatfacto.py index b4120cfc50..071a063e3f 100644 --- a/nerfstudio/models/splatfacto.py +++ b/nerfstudio/models/splatfacto.py @@ -751,7 +751,7 @@ def get_outputs(self, camera: Cameras) -> Dict[str, Union[torch.Tensor, List]]: camera.rescale_output_resolution(camera_downscale) if (self.radii).sum() == 0: - rgb = background.repeat(int(camera.height.item()), int(camera.width.item()), 1) + rgb = background.repeat(H, W, 1) depth = background.new_ones(*rgb.shape[:2], 1) * 10 accumulation = background.new_zeros(*rgb.shape[:2], 1)