Skip to content

Commit cfff2bb

Browse files
Quickstart Guide Fixes (#531)
* key fixes * Update README.md * Update run_eval.py * Better error reporting * lint * Removed rgb fine change * Readme updates * Justify center
1 parent 297950f commit cfff2bb

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,17 @@ ns-train nerfacto --vis viewer --viewer.zmq-port 8001 --viewer.websocket-port 80
160160

161161
### 3.x Training a model with the viewer
162162

163-
Make sure to forward a port for the websocket to localhost. The default port is 7007, which you should be expose to localhost:7007.
163+
Make sure to forward a port for the websocket to localhost. The default port is 7007, which you should expose to localhost:7007.
164164

165165
```bash
166166
# with the default port
167167
ns-train nerfacto --vis viewer
168168

169169
# with a specified websocket port
170170
ns-train nerfacto --vis viewer --viewer.websocket-port=7008
171+
172+
# port forward if running on remote
173+
ssh -L localhost:7008:localhost:7008 {REMOTE HOST}
171174
```
172175

173176
### 4. Visualizing training runs
@@ -201,10 +204,10 @@ We support logging to weights and biases. To enable wandb logging, add the flag
201204

202205
</details>
203206

204-
## 5. Rendering a trajectories during inference
207+
## 5. Rendering a trajectory during inference
205208

206209
```
207-
ns-eval render-trajectory --load-config=outputs/blender_lego/instant_ngp/2022-07-07_230905/config.yml--traj=spiral --output-path=output.mp4
210+
ns-eval render-trajectory --load-config=outputs/blender_lego/instant_ngp/{MOST_RECENT_RUN}/config.yml--traj=spiral --output-path=output.mp4
208211
```
209212

210213
## 6. In-depth guide

nerfstudio/models/vanilla_nerf.py

-2
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,6 @@ def get_image_metrics_and_images(
194194
"fine_psnr": float(fine_psnr),
195195
"fine_ssim": float(fine_ssim),
196196
"fine_lpips": float(fine_lpips),
197-
"ray_loss_coarse": float(torch.mean(outputs["ray_loss_coarse"])),
198-
"ray_loss_fine": float(torch.mean(outputs["ray_loss_fine"])),
199197
}
200198
images_dict = {"img": combined_rgb, "accumulation": combined_acc, "depth": combined_depth}
201199
return metrics_dict, images_dict

scripts/eval.py

+14
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import json
99
import logging
1010
import os
11+
import sys
1112
from dataclasses import dataclass
1213
from pathlib import Path
1314
from typing import Literal, Tuple, Union
@@ -48,6 +49,14 @@ def _load_checkpoint(config: cfg.TrainerConfig, pipeline: Pipeline) -> Path:
4849
if config.load_step is None:
4950
console.print("Loading latest checkpoint from load_dir")
5051
# NOTE: this is specific to the checkpoint name format
52+
if not os.path.exists(config.load_dir):
53+
console.rule("Error", style="red")
54+
console.print(f"No checkpoint directory found at {config.load_dir}, ", justify="center")
55+
console.print(
56+
"Please make sure the checkpoint exists, they should be generated periodically during training",
57+
justify="center",
58+
)
59+
sys.exit(1)
5160
load_step = sorted(int(x[x.find("-") + 1 : x.find(".")]) for x in os.listdir(config.load_dir))[-1]
5261
else:
5362
load_step = config.load_step
@@ -93,6 +102,11 @@ def _render_trajectory_video(
93102
camera_ray_bundle = cameras.generate_rays(camera_indices=camera_idx).to(pipeline.device)
94103
with torch.no_grad():
95104
outputs = pipeline.model.get_outputs_for_camera_ray_bundle(camera_ray_bundle)
105+
if rendered_output_name not in outputs:
106+
console.rule("Error", style="red")
107+
console.print(f"Could not find {rendered_output_name} in the model outputs", justify="center")
108+
console.print(f"Please set --rendered_output_name to one of: {outputs.keys()}", justify="center")
109+
sys.exit(1)
96110
image = outputs[rendered_output_name].cpu().numpy()
97111
images.append(image)
98112

0 commit comments

Comments
 (0)