From 3fc3ec47e77e313a884772e454a5212597375ad0 Mon Sep 17 00:00:00 2001 From: mcallisterdavid Date: Fri, 23 Sep 2022 16:44:02 -0700 Subject: [PATCH 1/8] key fixes --- nerfactory/models/vanilla_nerf.py | 2 -- scripts/run_eval.py | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/nerfactory/models/vanilla_nerf.py b/nerfactory/models/vanilla_nerf.py index 85ffbdfd67..52ace5800e 100644 --- a/nerfactory/models/vanilla_nerf.py +++ b/nerfactory/models/vanilla_nerf.py @@ -218,8 +218,6 @@ def get_image_metrics_and_images( "fine_psnr": float(fine_psnr), "fine_ssim": float(fine_ssim), "fine_lpips": float(fine_lpips), - "ray_loss_coarse": float(torch.mean(outputs["ray_loss_coarse"])), - "ray_loss_fine": float(torch.mean(outputs["ray_loss_fine"])), } images_dict = {"img": combined_rgb, "accumulation": combined_acc, "depth": combined_depth} return metrics_dict, images_dict diff --git a/scripts/run_eval.py b/scripts/run_eval.py index e25eafc7a7..1d7b86dcf5 100755 --- a/scripts/run_eval.py +++ b/scripts/run_eval.py @@ -77,6 +77,7 @@ def _render_trajectory_video( camera_ray_bundle = cameras.generate_rays(camera_indices=camera_idx).to(pipeline.device) with torch.no_grad(): outputs = pipeline.model.get_outputs_for_camera_ray_bundle(camera_ray_bundle) + print("OUTPUTS:", outputs.keys()) image = outputs[rendered_output_name].cpu().numpy() images.append(image) @@ -151,7 +152,7 @@ class RenderTrajectory: # Path to config YAML file. load_config: Path # Name of the renderer output to use. rgb, depth, etc. - rendered_output_name: str = "rgb" + rendered_output_name: str = "rgb_fine" # Trajectory to render. traj: Literal["spiral", "interp", "filename"] = "spiral" # Scaling factor to apply to the camera image resolution. From ded72de1cb9081026f1574f2074125aefcb8bc5d Mon Sep 17 00:00:00 2001 From: David McAllister Date: Fri, 23 Sep 2022 16:46:17 -0700 Subject: [PATCH 2/8] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e65b62336e..08b5cf6fc7 100644 --- a/README.md +++ b/README.md @@ -137,10 +137,10 @@ To run with all the defaults, e.g. vanilla nerf method with the blender lego ima python scripts/run_train.py --help # Run a vanilla nerf model. -python scripts/run_train.py vanilla_nerf +python scripts/run_train.py vanilla-nerf # Run a faster version with instant ngp using tcnn (without the viewer). -python scripts/run_train.py instant_ngp +python scripts/run_train.py instant-ngp ``` #### 3.x Training a model with the viewer From 3a20251474b75921da492b91f330cd2a3dd092a9 Mon Sep 17 00:00:00 2001 From: David McAllister Date: Fri, 23 Sep 2022 17:29:26 -0700 Subject: [PATCH 3/8] Update run_eval.py --- scripts/run_eval.py | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/run_eval.py b/scripts/run_eval.py index 1d7b86dcf5..de35102880 100755 --- a/scripts/run_eval.py +++ b/scripts/run_eval.py @@ -77,7 +77,6 @@ def _render_trajectory_video( camera_ray_bundle = cameras.generate_rays(camera_indices=camera_idx).to(pipeline.device) with torch.no_grad(): outputs = pipeline.model.get_outputs_for_camera_ray_bundle(camera_ray_bundle) - print("OUTPUTS:", outputs.keys()) image = outputs[rendered_output_name].cpu().numpy() images.append(image) From f8865affc5ae4d76af7e7b630810f4322c51dba8 Mon Sep 17 00:00:00 2001 From: mcallisterdavid Date: Sun, 2 Oct 2022 18:31:29 -0700 Subject: [PATCH 4/8] Better error reporting --- scripts/eval.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/eval.py b/scripts/eval.py index a826624878..a5ee168b20 100755 --- a/scripts/eval.py +++ b/scripts/eval.py @@ -8,6 +8,7 @@ import json import logging import os +import sys from dataclasses import dataclass from pathlib import Path from typing import Literal, Tuple, Union @@ -48,6 +49,11 @@ def _load_checkpoint(config: cfg.TrainerConfig, pipeline: Pipeline) -> Path: if config.load_step is None: console.print("Loading latest checkpoint from load_dir") # NOTE: this is specific to the checkpoint name format + if not os.path.exists(config.load_dir): + console.rule("Error", style="red") + console.print(f"No checkpoint directory found at {config.load_dir}, ", justify="center") + console.print("Please make sure the checkpoint exists, they should be generated periodically during training", justify="center") + sys.exit(1) load_step = sorted(int(x[x.find("-") + 1 : x.find(".")]) for x in os.listdir(config.load_dir))[-1] else: load_step = config.load_step @@ -93,6 +99,11 @@ def _render_trajectory_video( camera_ray_bundle = cameras.generate_rays(camera_indices=camera_idx).to(pipeline.device) with torch.no_grad(): outputs = pipeline.model.get_outputs_for_camera_ray_bundle(camera_ray_bundle) + if rendered_output_name not in outputs: + console.rule("Error", style="red") + console.print(f"Could not find {rendered_output_name} in the model outputs", justify="center") + console.print(f"Please set --rendered_output_name to one of: {outputs.keys()}") + sys.exit(1) image = outputs[rendered_output_name].cpu().numpy() images.append(image) From 7c497337c683f73df4b32c2e2f692d0195e90cf1 Mon Sep 17 00:00:00 2001 From: mcallisterdavid Date: Sun, 2 Oct 2022 18:36:04 -0700 Subject: [PATCH 5/8] lint --- scripts/eval.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/eval.py b/scripts/eval.py index a5ee168b20..ed217334f0 100755 --- a/scripts/eval.py +++ b/scripts/eval.py @@ -52,7 +52,10 @@ def _load_checkpoint(config: cfg.TrainerConfig, pipeline: Pipeline) -> Path: if not os.path.exists(config.load_dir): console.rule("Error", style="red") console.print(f"No checkpoint directory found at {config.load_dir}, ", justify="center") - console.print("Please make sure the checkpoint exists, they should be generated periodically during training", justify="center") + console.print( + "Please make sure the checkpoint exists, they should be generated periodically during training", + justify="center", + ) sys.exit(1) load_step = sorted(int(x[x.find("-") + 1 : x.find(".")]) for x in os.listdir(config.load_dir))[-1] else: From 8bccb7a82323364d4d4b3c9a8931d949e7ab0cd5 Mon Sep 17 00:00:00 2001 From: mcallisterdavid Date: Sun, 2 Oct 2022 21:36:36 -0700 Subject: [PATCH 6/8] Removed rgb fine change --- scripts/eval.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/eval.py b/scripts/eval.py index ed217334f0..320556cbef 100755 --- a/scripts/eval.py +++ b/scripts/eval.py @@ -181,7 +181,7 @@ class RenderTrajectory: # Path to config YAML file. load_config: Path # Name of the renderer output to use. rgb, depth, etc. - rendered_output_name: str = "rgb_fine" + rendered_output_name: str = "rgb" # Trajectory to render. traj: Literal["spiral", "interp", "filename"] = "spiral" # Scaling factor to apply to the camera image resolution. From dd30aa5ca0e1acdb91b14ea21a9e811ce5c8a032 Mon Sep 17 00:00:00 2001 From: mcallisterdavid Date: Sun, 2 Oct 2022 22:25:25 -0700 Subject: [PATCH 7/8] Readme updates --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 98cf176e7b..02b171b9b8 100644 --- a/README.md +++ b/README.md @@ -160,7 +160,7 @@ ns-train nerfacto --vis viewer --viewer.zmq-port 8001 --viewer.websocket-port 80 ### 3.x Training a model with the viewer -Make sure to forward a port for the websocket to localhost. The default port is 7007, which you should be expose to localhost:7007. +Make sure to forward a port for the websocket to localhost. The default port is 7007, which you should expose to localhost:7007. ```bash # with the default port @@ -168,6 +168,9 @@ ns-train nerfacto --vis viewer # with a specified websocket port ns-train nerfacto --vis viewer --viewer.websocket-port=7008 + +# port forward if running on remote +ssh -L localhost:7008:localhost:7008 {REMOTE HOST} ``` ### 4. Visualizing training runs @@ -201,10 +204,10 @@ We support logging to weights and biases. To enable wandb logging, add the flag -## 5. Rendering a trajectories during inference +## 5. Rendering a trajectory during inference ``` -ns-eval render-trajectory --load-config=outputs/blender_lego/instant_ngp/2022-07-07_230905/config.yml--traj=spiral --output-path=output.mp4 +ns-eval render-trajectory --load-config=outputs/blender_lego/instant_ngp/{MOST_RECENT_RUN}/config.yml--traj=spiral --output-path=output.mp4 ``` ## 6. In-depth guide From 032ed95347a41266c5bfb022bfaf7d44b9c97464 Mon Sep 17 00:00:00 2001 From: mcallisterdavid Date: Sun, 2 Oct 2022 23:00:12 -0700 Subject: [PATCH 8/8] Justify centeR --- scripts/eval.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/eval.py b/scripts/eval.py index 320556cbef..148fa408bb 100755 --- a/scripts/eval.py +++ b/scripts/eval.py @@ -105,7 +105,7 @@ def _render_trajectory_video( if rendered_output_name not in outputs: console.rule("Error", style="red") console.print(f"Could not find {rendered_output_name} in the model outputs", justify="center") - console.print(f"Please set --rendered_output_name to one of: {outputs.keys()}") + console.print(f"Please set --rendered_output_name to one of: {outputs.keys()}", justify="center") sys.exit(1) image = outputs[rendered_output_name].cpu().numpy() images.append(image)