wait for all cams to be seen after opacity reset for culling

This commit is contained in:
Justin Kerr committed 2023-10-10 11:17:52 -07:00
1 parent 17e95e1ba2
commit 66ddab3aa9
2 files changed
+7 -6

No files matched your search

+1 -1
View File
@@ -603,7 +603,7 @@ method_configs["gaussian-splatting"] = TrainerConfig(
), ),
optimizers={ optimizers={
"xyz": { "xyz": {
"optimizer": AdamOptimizerConfig(lr=1e-4, eps=1e-15), "optimizer": AdamOptimizerConfig(lr=1.6e-4, eps=1e-15),
"scheduler": ExponentialDecaySchedulerConfig( "scheduler": ExponentialDecaySchedulerConfig(
lr_final=1.6e-6, lr_final=1.6e-6,
max_steps=15000, max_steps=15000,
@@ -88,7 +88,7 @@ class GaussianSplattingModelConfig(ModelConfig):
"""training starts at 1/d resolution, every n steps this is doubled""" """training starts at 1/d resolution, every n steps this is doubled"""
num_downscales: int = 2 num_downscales: int = 2
"""at the beginning, resolution is 1/2^d, where d is this number""" """at the beginning, resolution is 1/2^d, where d is this number"""
cull_alpha_thresh: float = 0.01 cull_alpha_thresh: float = 0.02
"""threshold of opacity for culling gaussians""" """threshold of opacity for culling gaussians"""
cull_scale_thresh: float = 0.5 cull_scale_thresh: float = 0.5
"""threshold of scale for culling gaussians""" """threshold of scale for culling gaussians"""
@@ -100,7 +100,7 @@ class GaussianSplattingModelConfig(ModelConfig):
"""below this size, gaussians are *duplicated*, otherwise split""" """below this size, gaussians are *duplicated*, otherwise split"""
sh_degree_interval: int = 1000 sh_degree_interval: int = 1000
"""every n intervals turn on another sh degree""" """every n intervals turn on another sh degree"""
max_screen_size: int = 100 max_screen_size: int = 300
"""maximum screen size of a gaussian, in pixels""" """maximum screen size of a gaussian, in pixels"""
random_init: bool = False random_init: bool = False
"""whether to initialize the positions uniformly randomly (not SFM points)""" """whether to initialize the positions uniformly randomly (not SFM points)"""
@@ -130,8 +130,6 @@ class GaussianSplattingModel(Model):
def populate_modules(self): def populate_modules(self):
if self.seed_pts is not None and not self.config.random_init: if self.seed_pts is not None and not self.config.random_init:
# randmeans = torch.rand((30000,3))*8-4
# self.means = torch.nn.Parameter(torch.cat([self.seed_pts[0],randmeans],dim=0)) # (Location, Color)
self.means = torch.nn.Parameter(self.seed_pts[0]) # (Location, Color) self.means = torch.nn.Parameter(self.seed_pts[0]) # (Location, Color)
else: else:
self.means = torch.nn.Parameter((torch.rand((100000, 3)) - 0.5) * 2) self.means = torch.nn.Parameter((torch.rand((100000, 3)) - 0.5) * 2)
@@ -289,6 +287,10 @@ class GaussianSplattingModel(Model):
param_groups = self.get_param_groups() param_groups = self.get_param_groups()
for group,param in param_groups.items(): for group,param in param_groups.items():
self.dup_in_optim(optimizers.optimizers[group],dup_idcs,param,1) self.dup_in_optim(optimizers.optimizers[group],dup_idcs,param,1)
#only cull if we've seen every image since opacity reset
reset_interval = (self.config.reset_alpha_every * self.config.refine_every)
if self.step % reset_interval > self.num_train_data:
#then cull #then cull
deleted_mask = self.cull_gaussians() deleted_mask = self.cull_gaussians()
param_groups = self.get_param_groups() param_groups = self.get_param_groups()
@@ -296,7 +298,6 @@ class GaussianSplattingModel(Model):
self.remove_from_optim(optimizers.optimizers[group], deleted_mask, param) self.remove_from_optim(optimizers.optimizers[group], deleted_mask, param)
if self.step // self.config.refine_every % self.config.reset_alpha_every == 0: if self.step // self.config.refine_every % self.config.reset_alpha_every == 0:
print("Resetting alpha")
reset_value = 0.01 reset_value = 0.01
self.opacities.data = torch.full_like( self.opacities.data = torch.full_like(
self.opacities.data, torch.logit(torch.tensor(reset_value)).item() self.opacities.data, torch.logit(torch.tensor(reset_value)).item()