Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
nerfacc
Commits
19c7b89f
Unverified
Commit
19c7b89f
authored
Sep 15, 2022
by
Ruilong Li(李瑞龙)
Committed by
GitHub
Sep 15, 2022
Browse files
support stratified sampling (#10)
* support stratified sampling * bump version
parent
7f9ecf67
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
4 deletions
+11
-4
README.md
README.md
+1
-1
examples/trainval.py
examples/trainval.py
+2
-1
nerfacc/utils.py
nerfacc/utils.py
+5
-1
nerfacc/volumetric_rendering.py
nerfacc/volumetric_rendering.py
+2
-0
pyproject.toml
pyproject.toml
+1
-1
No files found.
README.md
View file @
19c7b89f
...
...
@@ -15,7 +15,7 @@ Ours on TITAN RTX :
| trainval | Lego | Mic | Materials |
| - | - | - | - |
| Time | 300s | 272s | 258s |
| PSNR | 36.
28
| 3
6.16 | 29.76
|
| PSNR | 36.
61
| 3
7.45 | 30.15
|
| FPS | 11.49 | 21.48 | 8.86 |
Instant-NGP paper (5 min) on 3090:
...
...
examples/trainval.py
View file @
19c7b89f
...
...
@@ -46,6 +46,7 @@ def render_image(radiance_field, rays, render_bkgd, render_step_size):
scene_resolution
=
occ_field
.
resolution
,
render_bkgd
=
render_bkgd
,
render_step_size
=
render_step_size
,
stratified
=
radiance_field
.
training
,
)
results
.
append
(
chunk_results
)
rgb
,
depth
,
acc
,
counter
,
compact_counter
=
[
...
...
@@ -65,7 +66,7 @@ if __name__ == "__main__":
torch
.
manual_seed
(
42
)
device
=
"cuda:0"
scene
=
"
lego
"
scene
=
"
materials
"
# setup dataset
train_dataset
=
SubjectLoader
(
...
...
nerfacc/utils.py
View file @
19c7b89f
...
...
@@ -45,7 +45,8 @@ def volumetric_marching(
t_min
:
Tensor
=
None
,
t_max
:
Tensor
=
None
,
render_step_size
:
float
=
1e-3
,
)
->
Tuple
[
Tensor
,
Tensor
,
Tensor
,
Tensor
,
Tensor
]:
stratified
:
bool
=
False
,
)
->
Tuple
[
torch
.
Tensor
,
torch
.
Tensor
,
torch
.
Tensor
,
torch
.
Tensor
,
torch
.
Tensor
]:
"""Volumetric marching with occupancy test.
Note: this function is not differentiable to inputs.
...
...
@@ -63,6 +64,7 @@ def volumetric_marching(
t_max: Optional. Ray far planes. Tensor with shape (n_ray,).
\
If not given it will be calculated using aabb test. Default is None.
render_step_size: Marching step size. Default is 1e-3.
stratified: Whether to use stratified sampling. Default is False.
Returns:
A tuple of tensors containing
...
...
@@ -86,6 +88,8 @@ def volumetric_marching(
==
scene_resolution
[
0
]
*
scene_resolution
[
1
]
*
scene_resolution
[
2
]
),
f
"Shape
{
scene_occ_binary
.
shape
}
is not right!"
if
stratified
:
t_min
=
t_min
+
torch
.
rand_like
(
t_min
)
*
render_step_size
(
packed_info
,
frustum_origins
,
...
...
nerfacc/volumetric_rendering.py
View file @
19c7b89f
...
...
@@ -19,6 +19,7 @@ def volumetric_rendering(
scene_resolution
:
Tuple
[
int
,
int
,
int
],
render_bkgd
:
torch
.
Tensor
,
render_step_size
:
int
,
stratified
:
bool
=
False
,
)
->
Tuple
[
torch
.
Tensor
,
torch
.
Tensor
,
torch
.
Tensor
]:
"""A *fast* version of differentiable volumetric rendering."""
n_rays
=
rays_o
.
shape
[
0
]
...
...
@@ -47,6 +48,7 @@ def volumetric_rendering(
scene_occ_binary
=
scene_occ_binary
,
# sampling
render_step_size
=
render_step_size
,
stratified
=
stratified
,
)
frustum_positions
=
(
frustum_origins
+
frustum_dirs
*
(
frustum_starts
+
frustum_ends
)
/
2.0
...
...
pyproject.toml
View file @
19c7b89f
...
...
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name
=
"nerfacc"
version
=
"0.0.
3
"
version
=
"0.0.
4
"
authors
=
[
{name
=
"Ruilong"
,
email
=
"ruilongli94@gmail.com"
}
]
license
=
{
text
=
"MIT"
}
requires-python
=
">=3.8"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment