Clickable viewer deployment (#308)

* first commit for clickable web viewer

* pylint ignore

* functional clickable viewer with updated docs

* fixed logging
This commit is contained in:
Ethan Weber authored and GitHub committed 2022-08-29 22:50:57 -07:00
1 parent d6b3eccd9c
commit 2cca012ad8
9 files changed
+181 -68

No files matched your search

+23 -9
View File
@@ -34,6 +34,7 @@ from nerfactory.models.base import Model
from nerfactory.utils import profiler, visualization
from nerfactory.utils.decorators import check_visualizer_enabled, decorate_all
from nerfactory.utils.writer import GLOBAL_BUFFER, EventName
from nerfactory.viewer.server.subprocess import run_viewer_bridge_server_as_subprocess
from nerfactory.viewer.server.utils import get_intrinsics_matrix_and_camera_to_world_h
from nerfactory.viewer.server.visualizer import Viewer
@@ -188,9 +189,29 @@ class VisualizerState:
self.config = config
self.vis = None
self.viewer_url = None
if self.config.enable:
zmq_url = self.config.zmq_url
self.vis = Viewer(zmq_url=zmq_url)
if self.config.launch_bridge_server:
# start the viewer bridge server
zmq_port = int(self.config.zmq_url.split(":")[-1])
websocket_port = self.config.websocket_port
run_viewer_bridge_server_as_subprocess(zmq_port, websocket_port)
# TODO(ethan): move this into the writer such that it's at the bottom
# of the logging stack and easy to see and click
# TODO(ethan): log the output of the viewer bridge server in a file where the training logs go
print("\n")
self.viewer_url = (
f"https://viewer.nerfactory.com/branch/master/?websocket_url=localhost:{websocket_port}"
)
viewer_url_local = f"http://localhost:4000/?websocket_url=localhost:{websocket_port}"
pub_open_viewer_instructions_string = f'[Public] Open the viewer at "{self.viewer_url}"'
dev_open_viewer_instructions_string = f'[Local] Open the viewer at "{viewer_url_local}"'
print("-" * len(pub_open_viewer_instructions_string))
print(pub_open_viewer_instructions_string)
print(dev_open_viewer_instructions_string)
print("-" * len(pub_open_viewer_instructions_string))
print("\n")
self.vis = Viewer(zmq_url=self.config.zmq_url)
else:
logging.info("Continuing without viewer.")
@@ -485,10 +506,3 @@ class VisualizerState:
stuff_colors = graph.stuff_colors if hasattr(graph, "stuff_colors") else None
self._send_output_to_viewer(outputs, stuff_colors=stuff_colors)
self._update_viewer_stats(render_duration, image_height)
def get_default_vis() -> Viewer:
"""Returns the default Visualizer."""
zmq_url = "tcp://0.0.0.0:6000"
viewer = Viewer(zmq_url=zmq_url)
return viewer