Fix tensorf chkpt loading (#1266)

* setting tensorf default from wandb to viewer

* adding functionality to adjust model depending on the step of the checkpoint that is loaded

* cleaning code

* bug fix

* fixing style
This commit is contained in:
Terrance Wang authored and GitHub committed 2023-01-20 12:00:51 -08:00
1 parent 9eb880aa91
commit 73bffe058f
4 files changed
+29 -4

No files matched your search

+8
View File
@@ -210,3 +210,11 @@ class Model(nn.Module):
"""
state = {key.replace("module.", ""): value for key, value in loaded_state["model"].items()}
self.load_state_dict(state) # type: ignore
def update_to_step(self, step: int) -> None:
"""Called when loading a model from a checkpoint. Sets any model parameters that change over
training to the correct value, based on the training step of the checkpoint.
Args:
step: training step of the loaded checkpoint
"""
+15 -1
View File
@@ -114,7 +114,8 @@ class TensoRFModel(Model):
def reinitialize_optimizer(
self, training_callback_attributes: TrainingCallbackAttributes, step: int # pylint: disable=unused-argument
):
resolution = self.upsampling_steps.pop(0)
index = self.upsampling_iters.index(step)
resolution = self.upsampling_steps[index]
# upsample the position and direction grids
self.field.density_encoding.upsample_grid(resolution)
@@ -143,6 +144,19 @@ class TensoRFModel(Model):
]
return callbacks
def update_to_step(self, step: int) -> None:
if step < self.upsampling_iters[0]:
return
new_iters = list(self.upsampling_iters) + [step + 1]
new_iters.sort()
index = new_iters.index(step + 1)
new_grid_resolution = self.upsampling_steps[index - 1]
self.field.density_encoding.upsample_grid(new_grid_resolution) # type: ignore
self.field.color_encoding.upsample_grid(new_grid_resolution) # type: ignore
def populate_modules(self):
"""Set the fields and modules"""
super().populate_modules()