4
0
mirror of https://github.com/nerfstudio-project/nerfstudio.git synced 2026-11-11 02:24:38 +08:00

Add alpha rendering to splatfacto, fix depth bug (#2824)

* Add alpha rendering to splatfacto, output as accumulation
This commit is contained in:
Justin Kerr 2024-01-25 12:51:16 -08:00 committed by GitHub
parent 3bade3a9dc
commit f2f4bf55b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View File

@ -748,7 +748,7 @@ class SplatfactoModel(Model):
# rescale the camera back to original dimensions
camera.rescale_output_resolution(camera_downscale)
assert (num_tiles_hit > 0).any() # type: ignore
rgb = rasterize_gaussians( # type: ignore
rgb, alpha = rasterize_gaussians( # type: ignore
self.xys,
depths,
self.radii,
@ -759,7 +759,9 @@ class SplatfactoModel(Model):
H,
W,
background=background,
return_alpha=True,
) # type: ignore
alpha = alpha[..., None]
rgb = torch.clamp(rgb, max=1.0) # type: ignore
depth_im = None
if not self.training:
@ -773,10 +775,12 @@ class SplatfactoModel(Model):
torch.sigmoid(opacities_crop),
H,
W,
background=torch.ones(3, device=self.device) * 10,
background=torch.zeros(3, device=self.device),
)[..., 0:1] # type: ignore
depth_im[alpha > 0] = depth_im[alpha > 0] / alpha[alpha > 0]
depth_im[alpha == 0] = 1000
return {"rgb": rgb, "depth": depth_im} # type: ignore
return {"rgb": rgb, "depth": depth_im, "accumulation": alpha} # type: ignore
def get_gt_img(self, image: torch.Tensor):
"""Compute groundtruth image with iteration dependent downscale factor for evaluation purpose

View File

@ -63,7 +63,7 @@ dependencies = [
"xatlas",
"trimesh>=3.20.2",
"timm==0.6.7",
"gsplat==0.1.2.1",
"gsplat==0.1.3",
"pytorch-msssim",
"pathos",
"packaging"