Skip to content

Commit 08761ab

Browse files
example with vanilla nerf
1 parent f66bacf commit 08761ab

File tree

4 files changed

+40
-11
lines changed

4 files changed

+40
-11
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,19 @@ python examples/trainval.py vanilla --train_split train
3131

3232
Performance on test set:
3333

34-
| | Lego |
35-
| - | - |
36-
| Paper PSNR (train set) | 32.54 |
37-
| Our PSNR (train set) | 33.21 |
38-
| Our PSNR (trainval set) | 33.66 |
39-
| Our train time & test FPS | 45min; 0.43FPS |
34+
| | Lego | Mic | Materials | Chair | Hotdog |
35+
| - | - | - | - | - | - |
36+
| Paper PSNR (train set) | 32.54 | 32.91 | 29.62 | 33.00 | 36.18 |
37+
| Our PSNR (train set) | 33.21 | 33.36 | 29.48 | 32.79 | 35.54 |
38+
| Our PSNR (trainval set) | 33.66 | - | - | - | - | - |
39+
| Our train time & test FPS | 45min; 0.43FPS | 44min; 1FPS | 37min; 0.33FPS* | 44min; 0.57FPS* | 50min; 0.15 FPS* |
4040

4141
For reference, vanilla NeRF paper trains on V100 GPU for 1-2 days per scene. Test time rendering takes about 30 secs to render a 800x800 image. Our model is trained on a TITAN X.
4242

4343
Note: We only use a single MLP with more samples (1024), instead of two MLPs with coarse-to-fine sampling as in the paper. Both ways share the same spirit to do dense sampling around the surface. Our fast rendering inheritly skip samples away from the surface so we can simplly increase the number of samples with a single MLP, to achieve the same goal with coarse-to-fine sampling, without runtime or memory issue.
4444

45+
*FPS for some scenes are tested under `--test_chunk_size=8192` (default is `81920`) to avoid OOM.
46+
4547
<!--
4648
4749
Tested with the default settings on the Lego test set.

examples/datasets/nerf_synthetic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class SubjectLoader(torch.utils.data.Dataset):
6161
"lego",
6262
"materials",
6363
"mic",
64+
"ship",
6465
]
6566

6667
WIDTH, HEIGHT = 800, 800

examples/trainval.py

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
TARGET_SAMPLE_BATCH_SIZE = 1 << 16
1616

1717

18-
def render_image(radiance_field, rays, render_bkgd, render_step_size):
18+
def render_image(
19+
radiance_field, rays, render_bkgd, render_step_size, test_chunk_size=81920
20+
):
1921
"""Render the pixels of an image.
2022
2123
Args:
@@ -48,7 +50,7 @@ def sigma_rgb_fn(frustum_origins, frustum_dirs, frustum_starts, frustum_ends):
4850
return radiance_field(positions, frustum_dirs)
4951

5052
results = []
51-
chunk = torch.iinfo(torch.int32).max if radiance_field.training else 81920
53+
chunk = torch.iinfo(torch.int32).max if radiance_field.training else test_chunk_size
5254
for i in range(0, num_rays, chunk):
5355
chunk_rays = namedtuple_map(lambda r: r[i : i + chunk], rays)
5456
chunk_results = volumetric_rendering(
@@ -95,10 +97,31 @@ def sigma_rgb_fn(frustum_origins, frustum_dirs, frustum_starts, frustum_ends):
9597
choices=["train", "trainval"],
9698
help="which train split to use",
9799
)
100+
parser.add_argument(
101+
"--scene",
102+
type=str,
103+
default="lego",
104+
choices=[
105+
"chair",
106+
"drums",
107+
"ficus",
108+
"hotdog",
109+
"lego",
110+
"materials",
111+
"mic",
112+
"ship",
113+
],
114+
help="which scene to use",
115+
)
116+
parser.add_argument(
117+
"--test_chunk_size",
118+
type=int,
119+
default=81920,
120+
)
98121
args = parser.parse_args()
99122

100123
device = "cuda:0"
101-
scene = "lego"
124+
scene = args.scene
102125

103126
# setup the scene bounding box.
104127
scene_aabb = torch.tensor([-1.5, -1.5, -1.5, 1.5, 1.5, 1.5])
@@ -251,7 +274,11 @@ def occ_eval_fn(x: torch.Tensor) -> torch.Tensor:
251274
render_bkgd = data["color_bkgd"].to(device)
252275
# rendering
253276
rgb, acc, _, _ = render_image(
254-
radiance_field, rays, render_bkgd, render_step_size
277+
radiance_field,
278+
rays,
279+
render_bkgd,
280+
render_step_size,
281+
test_chunk_size=args.test_chunk_size,
255282
)
256283
mse = F.mse_loss(rgb, pixels)
257284
psnr = -10.0 * torch.log(mse) / np.log(10.0)

nerfacc/volumetric_rendering.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from typing import Callable, List, Optional, Tuple
22

3-
43
import torch
54

65
from .utils import (

0 commit comments

Comments
 (0)