Skip to content

Commit ca7ffab

Browse files
tangkangqitangantennawilsonCernWq
committed
add viser viewer for training, with background image and point cloud viz (nv-tlabs#135)
* add viser viewer for training conifg * add viser gui utils (for training viz), with point cloud and background image option * add resolution adjust with browser size or sidebar config * clear background when render checkbox unchecked * add render of density distance hits normals * Fix camera-to-world conversion logic Updated camera-to-world conversion logic by using the view matrix directly, questioning the previous inversion method. --------- Co-authored-by: tangkangqi <tangkangqi@yeah.net> Co-authored-by: Qi Wu <wilson.over.cloud@gmail.com>
1 parent e3c4629 commit ca7ffab

3 files changed

Lines changed: 373 additions & 2 deletions

File tree

configs/base_gs.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ resume: ""
1010
out_dir: "./runs"
1111
n_iterations: 30000
1212
with_gui: false
13+
with_viser_gui: false
1314
gui_update_from_device: true
1415
val_frequency: 5000
1516
num_workers: 24

threedgrut/trainer.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from collections import defaultdict
1818
from pathlib import Path
1919
from typing import Any, Optional, Union
20-
20+
import time
2121
import numpy as np
2222
import torch
2323
import torch.utils.data
@@ -39,6 +39,7 @@
3939
from threedgrut.render import Renderer
4040
from threedgrut.strategy.base import BaseStrategy
4141
from threedgrut.utils.gui import GUI
42+
from threedgrut.utils.viser_gui_util import ViserGUI
4243
from threedgrut.utils.logger import logger
4344
from threedgrut.utils.misc import check_step_condition, create_summary_writer, jet_map
4445
from threedgrut.utils.timer import CudaTimer
@@ -298,6 +299,8 @@ def init_gui(
298299
gui = None
299300
if conf.with_gui:
300301
gui = GUI(conf, model, train_dataset, val_dataset, scene_bbox)
302+
elif conf.with_viser_gui:
303+
gui = ViserGUI(conf, model, train_dataset, val_dataset, scene_bbox)
301304
self.gui = gui
302305

303306
def init_metrics(self):
@@ -715,6 +718,18 @@ def render_gui(self, scene_updated):
715718
"Terminating training from GUI window is not supported. Please terminate it from the terminal."
716719
)
717720

721+
def render_gui_viser(self, scene_updated):
722+
gui = self.gui
723+
if gui is not None:
724+
if gui.live_update:
725+
# update render view
726+
if scene_updated or self.model.positions.requires_grad:
727+
gui.update_point_cloud()
728+
for client in gui.server.get_clients().values():
729+
gui.update_render_view(client, force=True)
730+
while not gui.viz_do_train:
731+
time.sleep(0.0001)
732+
718733
@torch.cuda.nvtx.range(f"run_train_pass")
719734
def run_train_pass(self, conf: DictConfig):
720735
"""Runs a single train epoch over the dataset."""
@@ -842,7 +857,11 @@ def run_train_pass(self, conf: DictConfig):
842857
self.save_checkpoint()
843858

844859
with torch.cuda.nvtx.range(f"train_{global_step-1}_update_gui"):
845-
self.render_gui(scene_updated) # Updating the GUI
860+
# self.render_gui(scene_updated) # Updating the GUI
861+
if self.conf.with_viser_gui:
862+
self.render_gui_viser(scene_updated)
863+
elif self.conf.with_gui:
864+
self.render_gui(scene_updated)
846865

847866
self.log_training_pass(metrics)
848867

0 commit comments

Comments
 (0)