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
ff7cf01a
Unverified
Commit
ff7cf01a
authored
Oct 10, 2022
by
Ruilong Li(李瑞龙)
Committed by
GitHub
Oct 10, 2022
Browse files
update docs for ray gradients (#62)
parent
f9a6ae6a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
12 deletions
+14
-12
README.md
README.md
+7
-6
docs/source/index.rst
docs/source/index.rst
+7
-6
No files found.
README.md
View file @
ff7cf01a
...
...
@@ -39,9 +39,9 @@ from torch import Tensor
import
nerfacc
radiance_field
=
...
# network: a NeRF model
optimizer
=
...
# network optimizer
rays_o
:
Tensor
=
...
# ray origins. (n_rays, 3)
rays_d
:
Tensor
=
...
# ray normalized directions. (n_rays, 3)
optimizer
=
...
# optimizer
def
sigma_fn
(
t_starts
:
Tensor
,
t_ends
:
Tensor
,
ray_indices
:
Tensor
...
...
@@ -76,16 +76,17 @@ def rgb_sigma_fn(
# Efficient Raymarching: Skip empty and occluded space, pack samples from all rays.
# packed_info: (n_rays, 2). t_starts: (n_samples, 1). t_ends: (n_samples, 1).
packed_info
,
t_starts
,
t_ends
=
nerfacc
.
ray_marching
(
with
torch
.
no_grad
():
packed_info
,
t_starts
,
t_ends
=
nerfacc
.
ray_marching
(
rays_o
,
rays_d
,
sigma_fn
=
sigma_fn
,
near_plane
=
0.2
,
far_plane
=
1.0
,
early_stop_eps
=
1e-4
,
alpha_thre
=
1e-2
,
)
)
# Differentiable Volumetric Rendering.
# colors: (n_rays, 3). opaicity: (n_rays, 1). depth: (n_rays, 1).
color
,
opacity
,
depth
=
nerfacc
.
rendering
(
rgb_sigma_fn
,
packed_info
,
t_starts
,
t_ends
)
# Optimize
the radience field.
# Optimize
: Both the network and rays will receive gradients
optimizer
.
zero_grad
()
loss
=
F
.
mse_loss
(
color
,
color_gt
)
loss
.
backward
()
...
...
docs/source/index.rst
View file @
ff7cf01a
...
...
@@ -53,9 +53,9 @@ An simple example is like this:
import nerfacc
radiance_field = ... # network: a NeRF model
optimizer = ... # network optimizer
rays_o: Tensor = ... # ray origins. (n_rays, 3)
rays_d: Tensor = ... # ray normalized directions. (n_rays, 3)
optimizer = ... # optimizer
def sigma_fn(
t_starts: Tensor, t_ends:Tensor, ray_indices: Tensor
...
...
@@ -90,6 +90,7 @@ An simple example is like this:
# Efficient Raymarching: Skip empty and occluded space, pack samples from all rays.
# packed_info: (n_rays, 2). t_starts: (n_samples, 1). t_ends: (n_samples, 1).
with torch.no_grad():
packed_info, t_starts, t_ends = nerfacc.ray_marching(
rays_o, rays_d, sigma_fn=sigma_fn, near_plane=0.2, far_plane=1.0,
early_stop_eps=1e-4, alpha_thre=1e-2,
...
...
@@ -99,7 +100,7 @@ An simple example is like this:
# colors: (n_rays, 3). opaicity: (n_rays, 1). depth: (n_rays, 1).
color, opacity, depth = nerfacc.rendering(rgb_sigma_fn, packed_info, t_starts, t_ends)
# Optimize
the radience field.
# Optimize
: Both the network and rays will receive gradients
optimizer.zero_grad()
loss = F.mse_loss(color, color_gt)
loss.backward()
...
...
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