mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-06 15:59:16 +08:00
1 parent
97cec622d8
commit
c79de3af81
5 files changed
+26
-14
No files matched your search
@@ -170,7 +170,7 @@ class ViewerConfig(PrintableConfig):
|
|||||||
"""whether or not to launch the bridge server"""
|
"""whether or not to launch the bridge server"""
|
||||||
websocket_port: Optional[int] = 7007
|
websocket_port: Optional[int] = 7007
|
||||||
"""the default websocket port to connect to"""
|
"""the default websocket port to connect to"""
|
||||||
ip_address: str = "0.0.0.0"
|
ip_address: str = "127.0.0.1"
|
||||||
"""the ip address where the bridge server is running"""
|
"""the ip address where the bridge server is running"""
|
||||||
num_rays_per_chunk: int = 32768
|
num_rays_per_chunk: int = 32768
|
||||||
"""number of rays per chunk to render with viewer"""
|
"""number of rays per chunk to render with viewer"""
|
||||||
|
|||||||
@@ -100,14 +100,14 @@ class ZMQWebSocketBridge:
|
|||||||
|
|
||||||
context = zmq.Context()
|
context = zmq.Context()
|
||||||
|
|
||||||
def __init__(self, zmq_port: int, websocket_port: int):
|
def __init__(self, zmq_port: int, websocket_port: int, ip_address: str):
|
||||||
self.zmq_port = zmq_port
|
self.zmq_port = zmq_port
|
||||||
self.websocket_pool = set()
|
self.websocket_pool = set()
|
||||||
self.app = self.make_app()
|
self.app = self.make_app()
|
||||||
self.ioloop = tornado.ioloop.IOLoop.current()
|
self.ioloop = tornado.ioloop.IOLoop.current()
|
||||||
|
|
||||||
# zmq
|
# zmq
|
||||||
zmq_url = f"tcp://0.0.0.0:{self.zmq_port:d}"
|
zmq_url = f"tcp://{ip_address}:{self.zmq_port:d}"
|
||||||
self.zmq_socket, self.zmq_stream, self.zmq_url = self.setup_zmq(zmq_url)
|
self.zmq_socket, self.zmq_stream, self.zmq_url = self.setup_zmq(zmq_url)
|
||||||
|
|
||||||
# websocket
|
# websocket
|
||||||
@@ -198,13 +198,16 @@ class ZMQWebSocketBridge:
|
|||||||
self.ioloop.start()
|
self.ioloop.start()
|
||||||
|
|
||||||
|
|
||||||
def run_viewer_bridge_server(zmq_port: int = 6000, websocket_port: int = 7007, use_ngrok: bool = False):
|
def run_viewer_bridge_server(
|
||||||
|
zmq_port: int = 6000, websocket_port: int = 7007, ip_address: str = "127.0.0.1", use_ngrok: bool = False
|
||||||
|
):
|
||||||
"""Run the viewer bridge server.
|
"""Run the viewer bridge server.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
zmq_port: port to use for zmq
|
zmq_port: port to use for zmq
|
||||||
websocket_port: port to use for websocket
|
websocket_port: port to use for websocket
|
||||||
host: host to connect to
|
ip_address: host to connect to
|
||||||
|
use_ngrok: whether to use ngrok to expose the zmq port
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# whether to launch pyngrok or not
|
# whether to launch pyngrok or not
|
||||||
@@ -214,7 +217,7 @@ def run_viewer_bridge_server(zmq_port: int = 6000, websocket_port: int = 7007, u
|
|||||||
http_tunnel = ngrok.connect(addr=str(zmq_port), proto="tcp")
|
http_tunnel = ngrok.connect(addr=str(zmq_port), proto="tcp")
|
||||||
print(http_tunnel)
|
print(http_tunnel)
|
||||||
|
|
||||||
bridge = ZMQWebSocketBridge(zmq_port=zmq_port, websocket_port=websocket_port)
|
bridge = ZMQWebSocketBridge(zmq_port=zmq_port, websocket_port=websocket_port, ip_address=ip_address)
|
||||||
print(bridge)
|
print(bridge)
|
||||||
try:
|
try:
|
||||||
bridge.run()
|
bridge.run()
|
||||||
|
|||||||
@@ -34,13 +34,17 @@ CONSOLE = Console()
|
|||||||
|
|
||||||
|
|
||||||
def run_viewer_bridge_server_as_subprocess(
|
def run_viewer_bridge_server_as_subprocess(
|
||||||
websocket_port: int, zmq_port: Optional[int] = None, log_filename: Union[str, None] = None
|
websocket_port: int,
|
||||||
|
zmq_port: Optional[int] = None,
|
||||||
|
ip_address: str = "127.0.0.1",
|
||||||
|
log_filename: Union[str, None] = None,
|
||||||
):
|
):
|
||||||
"""Runs the viewer bridge server as a subprocess.
|
"""Runs the viewer bridge server as a subprocess.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
zmq_port: Port to use for the ZMQ server.
|
zmq_port: Port to use for the ZMQ server.
|
||||||
websocket_port: Port to use for the websocket server.
|
websocket_port: Port to use for the websocket server.
|
||||||
|
ip_address: host to connect to
|
||||||
log_filename: Filename to use for the log file. If None, no log file is created.
|
log_filename: Filename to use for the log file. If None, no log file is created.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@@ -60,6 +64,8 @@ def run_viewer_bridge_server_as_subprocess(
|
|||||||
args.append(str(zmq_port))
|
args.append(str(zmq_port))
|
||||||
args.append("--websocket-port")
|
args.append("--websocket-port")
|
||||||
args.append(str(websocket_port))
|
args.append(str(websocket_port))
|
||||||
|
args.append("--ip-address")
|
||||||
|
args.append(str(ip_address))
|
||||||
# supress output if no log filename is specified
|
# supress output if no log filename is specified
|
||||||
logfile = open( # pylint: disable=consider-using-with
|
logfile = open( # pylint: disable=consider-using-with
|
||||||
log_filename if log_filename else os.devnull, "w", encoding="utf8"
|
log_filename if log_filename else os.devnull, "w", encoding="utf8"
|
||||||
|
|||||||
@@ -223,7 +223,10 @@ class ViewerState:
|
|||||||
assert self.config.websocket_port is not None
|
assert self.config.websocket_port is not None
|
||||||
self.log_filename.parent.mkdir(exist_ok=True)
|
self.log_filename.parent.mkdir(exist_ok=True)
|
||||||
zmq_port = run_viewer_bridge_server_as_subprocess(
|
zmq_port = run_viewer_bridge_server_as_subprocess(
|
||||||
self.config.websocket_port, zmq_port=self.config.zmq_port, log_filename=str(self.log_filename)
|
self.config.websocket_port,
|
||||||
|
zmq_port=self.config.zmq_port,
|
||||||
|
ip_address=self.config.ip_address,
|
||||||
|
log_filename=str(self.log_filename),
|
||||||
)
|
)
|
||||||
# TODO(ethan): log the output of the viewer bridge server in a file where the training logs go
|
# TODO(ethan): log the output of the viewer bridge server in a file where the training logs go
|
||||||
CONSOLE.line()
|
CONSOLE.line()
|
||||||
@@ -235,8 +238,8 @@ class ViewerState:
|
|||||||
CONSOLE.print(f"[Public] Open the viewer at {self.viewer_url}")
|
CONSOLE.print(f"[Public] Open the viewer at {self.viewer_url}")
|
||||||
CONSOLE.rule(characters="=")
|
CONSOLE.rule(characters="=")
|
||||||
CONSOLE.line()
|
CONSOLE.line()
|
||||||
self.vis = Viewer(zmq_port=zmq_port)
|
self.vis = Viewer(zmq_port=zmq_port, ip_address=self.config.ip_address)
|
||||||
self.vis_webrtc_thread = Viewer(zmq_port=zmq_port)
|
self.vis_webrtc_thread = Viewer(zmq_port=zmq_port, ip_address=self.config.ip_address)
|
||||||
else:
|
else:
|
||||||
assert self.config.zmq_port is not None
|
assert self.config.zmq_port is not None
|
||||||
self.vis = Viewer(zmq_port=self.config.zmq_port, ip_address=self.config.ip_address)
|
self.vis = Viewer(zmq_port=self.config.zmq_port, ip_address=self.config.ip_address)
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class ViewerWindow:
|
|||||||
|
|
||||||
context = zmq.Context()
|
context = zmq.Context()
|
||||||
|
|
||||||
def __init__(self, zmq_port, ip_address="0.0.0.0"):
|
def __init__(self, zmq_port, ip_address="127.0.0.1"):
|
||||||
self.zmq_port = zmq_port
|
self.zmq_port = zmq_port
|
||||||
self.client = self.context.socket(zmq.REQ)
|
self.client = self.context.socket(zmq.REQ)
|
||||||
zmq_url = f"tcp://{ip_address}:{self.zmq_port}"
|
zmq_url = f"tcp://{ip_address}:{self.zmq_port}"
|
||||||
@@ -70,7 +70,7 @@ class ViewerWindow:
|
|||||||
)
|
)
|
||||||
return umsgpack.unpackb(self.client.recv())
|
return umsgpack.unpackb(self.client.recv())
|
||||||
|
|
||||||
def timeout_ping(self, timeout_in_sec: int = 5):
|
def timeout_ping(self, timeout_in_sec: int = 15):
|
||||||
"""Timeout if ping fails to complete in timeout_in_secs seconds"""
|
"""Timeout if ping fails to complete in timeout_in_secs seconds"""
|
||||||
|
|
||||||
res = [Exception(f"Couldn't connect to the viewer Bridge Server in {timeout_in_sec} seconds. Exiting.")]
|
res = [Exception(f"Couldn't connect to the viewer Bridge Server in {timeout_in_sec} seconds. Exiting.")]
|
||||||
@@ -91,7 +91,7 @@ class ViewerWindow:
|
|||||||
raise ret
|
raise ret
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def assert_connected(self, timeout_in_sec: int = 5):
|
def assert_connected(self, timeout_in_sec: int = 15):
|
||||||
"""Check if the connection was established properly within some time.
|
"""Check if the connection was established properly within some time.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -117,7 +117,7 @@ class Viewer:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, zmq_port: Optional[int] = None, window: Optional[ViewerWindow] = None, ip_address: str = "0.0.0.0"
|
self, zmq_port: Optional[int] = None, window: Optional[ViewerWindow] = None, ip_address: str = "127.0.0.1"
|
||||||
):
|
):
|
||||||
if zmq_port is None and window is None:
|
if zmq_port is None and window is None:
|
||||||
raise ValueError("Must specify either zmq_port or window.")
|
raise ValueError("Must specify either zmq_port or window.")
|
||||||
|
|||||||
Reference in new issue
Block a user