mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-16 04:43:52 +08:00
added flag to view dataset from get-go (#366)
* added logic to comp rays/s on train and vis * added test and fixed vis rays/sec * added flag to just visualize dataset * added new script for viewing only dataset
This commit is contained in:
1 parent
e344396153
commit
e7cca834c8
4 files changed
+56
-4
No files matched your search
@@ -338,6 +338,7 @@ class ViewerConfig(PrintableConfig):
|
||||
|
||||
log_filename: Optional[Path] = None
|
||||
enable: bool = False
|
||||
train: bool = True
|
||||
zmq_url: str = "tcp://127.0.0.1:6000"
|
||||
launch_bridge_server: bool = True
|
||||
websocket_port: int = 7007
|
||||
|
||||
@@ -116,7 +116,9 @@ class Trainer:
|
||||
"""Train the model."""
|
||||
assert self.pipeline.datamanager.train_input_dataset is not None, "Missing DatsetInputs"
|
||||
|
||||
self.visualizer_state.init_scene(dataset=self.pipeline.datamanager.train_input_dataset)
|
||||
self.visualizer_state.init_scene(
|
||||
dataset=self.pipeline.datamanager.train_input_dataset, start_train=self.config.viewer.train
|
||||
)
|
||||
with TimeWriter(writer, EventName.TOTAL_TRAIN_TIME):
|
||||
num_iterations = self.config.trainer.max_num_iterations
|
||||
for step in range(self.start_step, self.start_step + num_iterations):
|
||||
|
||||
@@ -234,13 +234,12 @@ class VisualizerState:
|
||||
|
||||
self.outputs_set = False
|
||||
|
||||
def init_scene(self, dataset: InputDataset) -> None:
|
||||
def init_scene(self, dataset: InputDataset, start_train=True) -> None:
|
||||
"""Draw some images and the scene aabb in the viewer.
|
||||
|
||||
Args:
|
||||
dataset: dataset to render in the scene
|
||||
"""
|
||||
|
||||
# clear the current scene
|
||||
self.vis["sceneState/sceneBounds"].delete()
|
||||
self.vis["sceneState/cameras"].delete()
|
||||
@@ -257,6 +256,9 @@ class VisualizerState:
|
||||
json_ = dataset.dataset_inputs.scene_bounds.to_json()
|
||||
self.vis["sceneState/sceneBounds"].write(json_)
|
||||
|
||||
# set the initial state whether to train or not
|
||||
self.vis["renderingState/isTraining"].write(start_train)
|
||||
|
||||
# set the properties of the camera
|
||||
# self.vis["renderingState/camera"].write(json_)
|
||||
|
||||
@@ -284,7 +286,7 @@ class VisualizerState:
|
||||
local_step = step
|
||||
run_loop = not is_training
|
||||
while run_loop:
|
||||
if self._is_render_step(local_step):
|
||||
if self._is_render_step(local_step) and step > 0:
|
||||
self._render_image_in_viewer(graph)
|
||||
is_training = self.vis["renderingState/isTraining"].read()
|
||||
run_loop = not is_training
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
"""
|
||||
view_dataset.py
|
||||
"""
|
||||
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
|
||||
import torch
|
||||
import yaml
|
||||
from rich.console import Console
|
||||
|
||||
from nerfactory.configs import base as cfg
|
||||
from nerfactory.configs.utils import cli_from_base_configs
|
||||
from nerfactory.viewer.server import viewer_utils
|
||||
|
||||
logging.basicConfig(format="[%(filename)s:%(lineno)d] %(message)s", level=logging.DEBUG)
|
||||
|
||||
DEFAULT_TIMEOUT = timedelta(minutes=30)
|
||||
|
||||
# speedup for when input size to model doesn't change (much)
|
||||
torch.backends.cudnn.benchmark = True # type: ignore
|
||||
|
||||
|
||||
def main(config: cfg.Config) -> None:
|
||||
"""Main function."""
|
||||
if not config.viewer.enable:
|
||||
config.viewer.enable = True
|
||||
logging.info("Enabling viewer to view dataset")
|
||||
visualizer_state = viewer_utils.VisualizerState(config.viewer)
|
||||
datamanager = config.pipeline.datamanager.setup()
|
||||
visualizer_state.init_scene(dataset=datamanager.train_input_dataset, start_train=False)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
console = Console(width=120)
|
||||
|
||||
from nerfactory.configs.base_configs import base_configs
|
||||
|
||||
instantiated_config = cli_from_base_configs(base_configs)
|
||||
if instantiated_config.trainer.load_config:
|
||||
logging.info(f"Loading pre-set config from: {instantiated_config.trainer.load_config}")
|
||||
instantiated_config = yaml.load(instantiated_config.trainer.load_config.read_text(), Loader=yaml.Loader)
|
||||
|
||||
console.rule("Config")
|
||||
console.print(instantiated_config)
|
||||
console.rule("")
|
||||
main(config=instantiated_config)
|
||||
Reference in new issue
Block a user