NeuS Implementation (#1444)

* add initial method configs and data manager

* add neus scheduler

* add initial surface model and neus

* add Neus ray sampler

* add sdf field

* move scale/shift calc to math utils

* add debug and fix sdf_dataset typo

* update vscode neus debug

* fix dataset and get initial working version

* add magic number from original repo

* black fixes

* clean up get weights/transmittance from alphas

* clean up typos in sdf datamanager

* type annotations on neus scheduler and remove unused params

* clean up and annotate sdf field along w/ other fixes

* more clean up

* remove unnessary directions norm

* resolve comments

* update neus scheduler to follow refactor

* fix linter errors

* fix some typos

* remove get_weights_from_alpha

* more comment fixes

* more linter error fixes

* clean up and add comments

* more little fixes for types/comments

* more comments

* rename NeuS Scheduler to DelayedScheduler

* rename DelayedScheduler to CosineDecayScheduler
This commit is contained in:
Pablo Vela authored and GitHub committed 2023-03-12 16:01:18 -04:00
1 parent 1b18b44d81
commit ddfa463f4d
16 files changed
+1376 -53

No files matched your search

+33
View File
@@ -107,3 +107,36 @@ class ExponentialDecayScheduler(Scheduler):
scheduler = lr_scheduler.LambdaLR(optimizer, lr_lambda=func)
return scheduler
@dataclass
class CosineDecaySchedulerConfig(SchedulerConfig):
"""Basic scheduler config with self-defined exponential decay schedule"""
_target: Type = field(default_factory=lambda: CosineDecayScheduler)
"""target class to instantiate"""
warm_up_end: int = 5000
"""Iteration number where warmp ends"""
learning_rate_alpha: float = 0.05
"""Learning rate alpha value"""
max_steps: int = 300000
"""The maximum number of steps."""
class CosineDecayScheduler(Scheduler):
"""Starts with a flat lr schedule until it reaches N epochs then applies a given scheduler"""
config: CosineDecaySchedulerConfig
def get_scheduler(self, optimizer: Optimizer, lr_init: float) -> lr_scheduler._LRScheduler:
def func(step):
if step < self.config.warm_up_end:
learning_factor = step / self.config.warm_up_end
else:
alpha = self.config.learning_rate_alpha
progress = (step - self.config.warm_up_end) / (self.config.max_steps - self.config.warm_up_end)
learning_factor = (np.cos(np.pi * progress) + 1.0) * 0.5 * (1 - alpha) + alpha
return learning_factor
scheduler = lr_scheduler.LambdaLR(optimizer, lr_lambda=func)
return scheduler