Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inference near plane option #2938

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions nerfstudio/models/splatfacto.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ class SplatfactoModelConfig(ModelConfig):
However, PLY exported with antialiased rasterize mode is not compatible with classic mode. Thus many web viewers that
were implemented for classic mode can not render antialiased mode PLY properly without modifications.
"""
inference_near_plane: float = 0.0
"""Ignore any gaussians at distances less than this near plane."""


class SplatfactoModel(Model):
Expand Down Expand Up @@ -764,6 +766,16 @@ def get_outputs(self, camera: Cameras) -> Dict[str, Union[torch.Tensor, List]]:
else:
rgbs = torch.sigmoid(colors_crop[:, 0, :])

if not self.training and self.config.inference_near_plane != 0.0:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any update on doing this with the gsplat project_gaussians flag instead of manual masks?

mask = depths > self.config.inference_near_plane
self.xys = self.xys[mask]
depths = depths[mask]
self.radii = self.radii[mask]
conics = conics[mask]
num_tiles_hit = num_tiles_hit[mask]
rgbs = rgbs[mask]
opacities_crop = opacities_crop[mask]

assert (num_tiles_hit > 0).any() # type: ignore

# apply the compensation of screen space blurring to gaussians
Expand Down