From 50f9895f1af7ef662826dee521b55d3668d0349d Mon Sep 17 00:00:00 2001 From: Matthew Tancik Date: Fri, 11 Nov 2022 11:38:36 -0800 Subject: [PATCH] Add flag to kill training when complete (#948) --- nerfstudio/configs/base_config.py | 2 ++ nerfstudio/engine/trainer.py | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/nerfstudio/configs/base_config.py b/nerfstudio/configs/base_config.py index 7b02e1a24..f5d2a31cf 100644 --- a/nerfstudio/configs/base_config.py +++ b/nerfstudio/configs/base_config.py @@ -178,6 +178,8 @@ class ViewerConfig(PrintableConfig): max_num_display_images: int = 512 """Maximum number of training images to display in the viewer, to avoid lag. This does not change which images are actually used in training/evaluation. If -1, display all.""" + quit_on_train_completion: bool = False + """Whether to kill the training job when it has completed. Note this will stop rendering in the viewer.""" from nerfstudio.engine.optimizers import OptimizerConfig diff --git a/nerfstudio/engine/trainer.py b/nerfstudio/engine/trainer.py index 5b5bca84c..90e93a7e0 100644 --- a/nerfstudio/engine/trainer.py +++ b/nerfstudio/engine/trainer.py @@ -131,6 +131,7 @@ class Trainer: self._init_viewer_state() with TimeWriter(writer, EventName.TOTAL_TRAIN_TIME): num_iterations = self.config.trainer.max_num_iterations + step = 0 for step in range(self._start_step, self._start_step + num_iterations): with TimeWriter(writer, EventName.ITER_TRAIN_TIME, step=step) as train_t: @@ -174,10 +175,12 @@ class Trainer: writer.write_out_storage() # save checkpoint at the end of training self.save_checkpoint(step) + CONSOLE.rule() CONSOLE.print("[bold green]:tada: :tada: :tada: Training Finished :tada: :tada: :tada:", justify="center") - CONSOLE.print("Use ctrl+c to quit", justify="center") - self._always_render(step) + if not self.config.viewer.quit_on_train_completion: + CONSOLE.print("Use ctrl+c to quit", justify="center") + self._always_render(step) @check_main_thread def _always_render(self, step):