Skip to content

Commit

Permalink
Properly reset train state after render lock in viewer (#3486)
Browse files Browse the repository at this point in the history
* properly reset train state after render locK

* finally block
  • Loading branch information
kerrj authored Oct 18, 2024
1 parent d2f2ad9 commit fc4fc5c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions nerfstudio/viewer/render_state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def _render_img(self, camera_state: CameraState):
device=self.viewer.get_model().device,
)
self.viewer.get_model().set_background(background_color)
was_training = self.viewer.get_model().training
self.viewer.get_model().eval()
step = self.viewer.step
try:
Expand All @@ -168,9 +169,10 @@ def _render_img(self, camera_state: CameraState):
with torch.no_grad(), viewer_utils.SetTrace(self.check_interrupt):
outputs = self.viewer.get_model().get_outputs_for_camera(camera, obb_box=obb)
except viewer_utils.IOChangeException:
self.viewer.get_model().train()
raise
self.viewer.get_model().train()
finally:
if was_training:
self.viewer.get_model().train()
num_rays = (camera.height * camera.width).item()
if self.viewer.control_panel.layer_depth:
if isinstance(self.viewer.get_model(), SplatfactoModel):
Expand Down

0 comments on commit fc4fc5c

Please sign in to comment.