From 473560e399b266d83e9f6415423673b34be90334 Mon Sep 17 00:00:00 2001 From: JonathonLuiten Date: Wed, 12 Jul 2023 20:35:43 -0400 Subject: [PATCH 1/2] Update __init__.py --- gaussian_renderer/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gaussian_renderer/__init__.py b/gaussian_renderer/__init__.py index 7ca4cf3db..dc2333578 100644 --- a/gaussian_renderer/__init__.py +++ b/gaussian_renderer/__init__.py @@ -81,7 +81,7 @@ def render(viewpoint_camera, pc : GaussianModel, pipe, bg_color : torch.Tensor, colors_precomp = override_color # Rasterize visible Gaussians to image, obtain their radii (on screen). - rendered_image, radii = rasterizer( + rendered_image, radii, depth = rasterizer( means3D = means3D, means2D = means2D, shs = shs, @@ -95,5 +95,6 @@ def render(viewpoint_camera, pc : GaussianModel, pipe, bg_color : torch.Tensor, # They will be excluded from value updates used in the splitting criteria. return {"render": rendered_image, "viewspace_points": screenspace_points, - "visibility_filter" : radii > 0, - "radii": radii} + "visibility_filter": radii > 0, + "radii": radii, + "depth": depth} From 3dfbee7a064783ffd25a3c755e24bee5f93d0a8c Mon Sep 17 00:00:00 2001 From: Sai M Date: Mon, 11 Sep 2023 14:16:56 -0700 Subject: [PATCH 2/2] local CUDA changes --- gaussian_renderer/__init__.py | 5 +++-- render.py | 15 +++++++++++++-- submodules/diff-gaussian-rasterization | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/gaussian_renderer/__init__.py b/gaussian_renderer/__init__.py index b5c1b656f..b037b93a5 100644 --- a/gaussian_renderer/__init__.py +++ b/gaussian_renderer/__init__.py @@ -82,7 +82,7 @@ def render(viewpoint_camera, pc : GaussianModel, pipe, bg_color : torch.Tensor, colors_precomp = override_color # Rasterize visible Gaussians to image, obtain their radii (on screen). - rendered_image, radii, depth = rasterizer( + rendered_image, radii, depth, num_gauss = rasterizer( means3D = means3D, means2D = means2D, shs = shs, @@ -98,4 +98,5 @@ def render(viewpoint_camera, pc : GaussianModel, pipe, bg_color : torch.Tensor, "viewspace_points": screenspace_points, "visibility_filter": radii > 0, "radii": radii, - "depth": depth} + "depth": depth, + "num_gauss":num_gauss} diff --git a/render.py b/render.py index fc6b82de8..da6a571bc 100644 --- a/render.py +++ b/render.py @@ -20,20 +20,31 @@ from argparse import ArgumentParser from arguments import ModelParams, PipelineParams, get_combined_args from gaussian_renderer import GaussianModel +import matplotlib.pyplot as plt +import numpy as np def render_set(model_path, name, iteration, views, gaussians, pipeline, background): render_path = os.path.join(model_path, name, "ours_{}".format(iteration), "renders") gts_path = os.path.join(model_path, name, "ours_{}".format(iteration), "gt") + depth_path = os.path.join(model_path, name, "ours_{}".format(iteration), "depth") makedirs(render_path, exist_ok=True) makedirs(gts_path, exist_ok=True) + makedirs(depth_path, exist_ok=True) for idx, view in enumerate(tqdm(views, desc="Rendering progress")): - rendering = render(view, gaussians, pipeline, background)["render"] + results = render(view, gaussians, pipeline, background) + rendering = results["render"] gt = view.original_image[0:3, :, :] + depth = results["depth"] + print(results["num_gauss"]) + depth[(depth < 0)] = 0 + depth = (depth / (depth.max() + 1e-5)).detach().cpu().numpy().squeeze() + depth = (depth * 255).astype(np.uint8) torchvision.utils.save_image(rendering, os.path.join(render_path, '{0:05d}'.format(idx) + ".png")) torchvision.utils.save_image(gt, os.path.join(gts_path, '{0:05d}'.format(idx) + ".png")) - + #torchvision.utils.save_image(plt.cm.jet(depth.clone().detach().cpu()), os.path.join(depth_path, '{0:05d}'.format(idx) + ".png")) + plt.imsave(os.path.join(depth_path, '{0:05d}'.format(idx) + ".png"), depth, cmap='jet') def render_sets(dataset : ModelParams, iteration : int, pipeline : PipelineParams, skip_train : bool, skip_test : bool): with torch.no_grad(): gaussians = GaussianModel(dataset.sh_degree) diff --git a/submodules/diff-gaussian-rasterization b/submodules/diff-gaussian-rasterization index 8064f52ca..8cce57b7d 160000 --- a/submodules/diff-gaussian-rasterization +++ b/submodules/diff-gaussian-rasterization @@ -1 +1 @@ -Subproject commit 8064f52ca233942bdec2d1a1451c026deedd320b +Subproject commit 8cce57b7d9d7c39bca6d98583cec3fe4f6e3cb75