From 36c48c7177ef452b8200ef524073ff8ef96c6643 Mon Sep 17 00:00:00 2001 From: Justin Kerr Date: Tue, 20 Feb 2024 14:09:55 -0800 Subject: [PATCH] Update project, rasterize with block_width interface (#2937) * new interface for block width in gsplat --- nerfstudio/models/splatfacto.py | 12 ++++-------- pyproject.toml | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/nerfstudio/models/splatfacto.py b/nerfstudio/models/splatfacto.py index 071a063e3..e1f64ebcb 100644 --- a/nerfstudio/models/splatfacto.py +++ b/nerfstudio/models/splatfacto.py @@ -707,12 +707,6 @@ class SplatfactoModel(Model): W, H = int(camera.width.item()), int(camera.height.item()) self.last_size = (H, W) projmat = projection_matrix(0.001, 1000, fovx, fovy, device=self.device) - BLOCK_X, BLOCK_Y = 16, 16 - tile_bounds = ( - int((W + BLOCK_X - 1) // BLOCK_X), - int((H + BLOCK_Y - 1) // BLOCK_Y), - 1, - ) if crop_ids is not None: opacities_crop = self.opacities[crop_ids] @@ -730,7 +724,7 @@ class SplatfactoModel(Model): quats_crop = self.quats colors_crop = torch.cat((features_dc_crop[:, None, :], features_rest_crop), dim=1) - + BLOCK_WIDTH = 16 # this controls the tile size of rasterization, 16 is a good default self.xys, depths, self.radii, conics, comp, num_tiles_hit, cov3d = project_gaussians( # type: ignore means_crop, torch.exp(scales_crop), @@ -744,7 +738,7 @@ class SplatfactoModel(Model): cy, H, W, - tile_bounds, + BLOCK_WIDTH, ) # type: ignore # rescale the camera back to original dimensions before returning @@ -791,6 +785,7 @@ class SplatfactoModel(Model): opacities, H, W, + BLOCK_WIDTH, background=background, return_alpha=True, ) # type: ignore @@ -808,6 +803,7 @@ class SplatfactoModel(Model): torch.sigmoid(opacities_crop), H, W, + BLOCK_WIDTH, background=torch.zeros(3, device=self.device), )[..., 0:1] # type: ignore depth_im = torch.where(alpha > 0, depth_im / alpha, depth_im.detach().max()) diff --git a/pyproject.toml b/pyproject.toml index e2a731f64..42ce41b70 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -63,7 +63,7 @@ dependencies = [ "xatlas", "trimesh>=3.20.2", "timm==0.6.7", - "gsplat>=0.1.5", + "gsplat>=0.1.6", "pytorch-msssim", "pathos", "packaging"