This commit is contained in:
Justin Kerr committed 2023-10-13 00:22:27 -07:00
1 parent d8b76fea4d
commit f4cc901e08
11 files changed
+231 -160

No files matched your search

+1 -1
View File
@@ -270,7 +270,7 @@ class ControlPanel:
step: the train step to set the model to
"""
with self.viser_server.atomic(), self.stat_folder:
self.markdown.content=f"Step: {step}"
self.markdown.content = f"Step: {step}"
def update_output_options(self, new_options: List[str]):
"""
+21 -8
View File
@@ -27,6 +27,7 @@ from nerfstudio.utils.writer import GLOBAL_BUFFER, EventName, TimeWriter
from nerfstudio.viewer.server import viewer_utils
from nerfstudio.viewer_beta.utils import CameraState, get_camera
from nerfstudio.models.gaussian_splatting import GaussianSplattingModel
if TYPE_CHECKING:
from nerfstudio.viewer_beta.viewer import Viewer
@@ -126,9 +127,15 @@ class RenderStateMachine(threading.Thread):
with TimeWriter(None, None, write=False) as vis_t:
with self.viewer.train_lock if self.viewer.train_lock is not None else contextlib.nullcontext():
if isinstance(self.viewer.get_model(),GaussianSplattingModel):
camera_ray_bundle=None
if isinstance(self.viewer.get_model(), GaussianSplattingModel):
camera_ray_bundle = None
self.viewer.get_model().set_crop(obb)
color = self.viewer.control_panel.background_color
background_color = torch.tensor(
[color[0] / 255.0, color[1] / 255.0, color[2] / 255.0],
device=self.viewer.get_model().device,
)
self.viewer.get_model().set_background(background_color)
else:
camera_ray_bundle = camera.generate_rays(camera_indices=0, obb_box=obb)
self.viewer.get_model().eval()
@@ -146,21 +153,27 @@ class RenderStateMachine(threading.Thread):
with background_color_override_context(
background_color
), torch.no_grad(), viewer_utils.SetTrace(self.check_interrupt):
outputs = self.viewer.get_model().get_outputs_for_camera_ray_bundle(camera_ray_bundle,camera=camera)
outputs = self.viewer.get_model().get_outputs_for_camera_ray_bundle(
camera_ray_bundle, camera=camera
)
else:
with torch.no_grad(), viewer_utils.SetTrace(self.check_interrupt):
outputs = self.viewer.get_model().get_outputs_for_camera_ray_bundle(camera_ray_bundle,camera=camera)
outputs = self.viewer.get_model().get_outputs_for_camera_ray_bundle(
camera_ray_bundle, camera=camera
)
except viewer_utils.IOChangeException:
self.viewer.get_model().train()
raise
self.viewer.get_model().train()
if isinstance(self.viewer.get_model(),GaussianSplattingModel):
num_rays = image_height*image_width
if isinstance(self.viewer.get_model(), GaussianSplattingModel):
num_rays = image_height * image_width
else:
num_rays = len(camera_ray_bundle)
if self.viewer.control_panel.layer_depth:
if isinstance(self.viewer.get_model(),GaussianSplattingModel):
outputs["gl_z_buf_depth"] = outputs['depth']
if isinstance(self.viewer.get_model(), GaussianSplattingModel):
# TODO: sending depth at high resolution lags the network a lot, figure out how to do this more efficiently
# outputs["gl_z_buf_depth"] = outputs["depth"]
pass
else:
# convert to z_depth if depth compositing is enabled
R = camera.camera_to_worlds[0:3, 0:3].T
+1 -1
View File
@@ -65,7 +65,7 @@ def get_camera(
cx=pp_w,
cy=pp_h,
camera_type=camera_type,
camera_to_worlds=camera_state.c2w.to(torch.float32)[None,...],
camera_to_worlds=camera_state.c2w.to(torch.float32)[None, ...],
times=torch.tensor([0.0], dtype=torch.float32),
)
return camera