Skip to content

Commit

Permalink
Quickstart Guide Fixes (nerfstudio-project#531)
Browse files Browse the repository at this point in the history
* key fixes

* Update README.md

* Update run_eval.py

* Better error reporting

* lint

* Removed rgb fine change

* Readme updates

* Justify center
  • Loading branch information
mcallisterdavid authored Oct 3, 2022
1 parent 4533c7d commit e1772d7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,17 @@ 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
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
Expand Down Expand Up @@ -201,10 +204,10 @@ We support logging to weights and biases. To enable wandb logging, add the flag

</details>

## 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
Expand Down
2 changes: 0 additions & 2 deletions nerfstudio/models/vanilla_nerf.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,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
14 changes: 14 additions & 0 deletions scripts/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -48,6 +49,14 @@ 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
Expand Down Expand Up @@ -93,6 +102,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()}", justify="center")
sys.exit(1)
image = outputs[rendered_output_name].cpu().numpy()
images.append(image)

Expand Down

0 comments on commit e1772d7

Please sign in to comment.