From 5158cc36ff7a5a367ea7474b21c6662e96168dd1 Mon Sep 17 00:00:00 2001 From: Matthew Tancik Date: Sat, 25 Feb 2023 16:06:41 -0800 Subject: [PATCH] Fix logic when using filename datasets (#1510) --- nerfstudio/configs/experiment_config.py | 4 +++- nerfstudio/viewer/server/viewer_utils.py | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/nerfstudio/configs/experiment_config.py b/nerfstudio/configs/experiment_config.py index 8ebd77467..98703ee40 100644 --- a/nerfstudio/configs/experiment_config.py +++ b/nerfstudio/configs/experiment_config.py @@ -96,7 +96,9 @@ class ExperimentConfig(InstantiateConfig): def set_experiment_name(self) -> None: """Dynamically set the experiment name""" if self.experiment_name is None: - self.experiment_name = str(self.pipeline.datamanager.dataparser.data).replace("../", "").replace("/", "-") + datapath = self.pipeline.datamanager.dataparser.data + datapath = datapath.parent if datapath.is_file() else datapath + self.experiment_name = str(datapath).replace("../", "").replace("/", "-") def get_base_dir(self) -> Path: """Retrieve the base directory to set relative paths""" diff --git a/nerfstudio/viewer/server/viewer_utils.py b/nerfstudio/viewer/server/viewer_utils.py index 30d1fdb54..37580c7e1 100644 --- a/nerfstudio/viewer/server/viewer_utils.py +++ b/nerfstudio/viewer/server/viewer_utils.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# pylint: disable=too-many-lines + """Code to interface with the `vis/` (the JS viewer). """ from __future__ import annotations @@ -70,11 +72,13 @@ def get_viewer_version() -> str: @check_main_thread -def setup_viewer(config: cfg.ViewerConfig, log_filename: Path, datapath: str): +def setup_viewer(config: cfg.ViewerConfig, log_filename: Path, datapath: Path): """Sets up the viewer if enabled Args: config: the configuration to instantiate viewer + log_filename: the log filename to write to + datapath: the path to the dataset """ viewer_state = ViewerState(config, log_filename=log_filename, datapath=datapath) banner_messages = [f"Viewer at: {viewer_state.viewer_url}"] @@ -250,14 +254,16 @@ class ViewerState: Args: config: viewer setup configuration + log_filename: filename to log viewer output to + datapath: path to data """ - def __init__(self, config: cfg.ViewerConfig, log_filename: Path, datapath: str): + def __init__(self, config: cfg.ViewerConfig, log_filename: Path, datapath: Path): self.config = config self.vis = None self.viewer_url = None self.log_filename = log_filename - self.datapath = datapath + self.datapath = datapath.parent if datapath.is_file() else datapath if self.config.launch_bridge_server: # start the viewer bridge server assert self.config.websocket_port is not None