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
a0ab0265
Commit
a0ab0265
authored
Sep 12, 2022
by
Ruilong Li
Browse files
update steps_counter to int
parent
9bddde48
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
7 deletions
+14
-7
examples/trainval.py
examples/trainval.py
+6
-5
nerfacc/volumetric_rendering.py
nerfacc/volumetric_rendering.py
+8
-2
No files found.
examples/trainval.py
View file @
a0ab0265
...
@@ -69,14 +69,15 @@ def render_image(radiance_field, rays, render_bkgd, render_step_size):
...
@@ -69,14 +69,15 @@ def render_image(radiance_field, rays, render_bkgd, render_step_size):
)
)
results
.
append
(
chunk_results
)
results
.
append
(
chunk_results
)
rgb
,
depth
,
acc
,
counter
,
compact_counter
=
[
rgb
,
depth
,
acc
,
counter
,
compact_counter
=
[
torch
.
cat
(
r
,
dim
=
0
)
for
r
in
zip
(
*
results
)
torch
.
cat
(
r
,
dim
=
0
)
if
isinstance
(
r
[
0
],
torch
.
Tensor
)
else
r
for
r
in
zip
(
*
results
)
]
]
return
(
return
(
rgb
.
view
((
*
rays_shape
[:
-
1
],
-
1
)),
rgb
.
view
((
*
rays_shape
[:
-
1
],
-
1
)),
depth
.
view
((
*
rays_shape
[:
-
1
],
-
1
)),
depth
.
view
((
*
rays_shape
[:
-
1
],
-
1
)),
acc
.
view
((
*
rays_shape
[:
-
1
],
-
1
)),
acc
.
view
((
*
rays_shape
[:
-
1
],
-
1
)),
counter
.
sum
(
),
sum
(
counter
),
compact_counter
.
sum
(
),
sum
(
compact_counter
),
)
)
...
@@ -191,7 +192,7 @@ if __name__ == "__main__":
...
@@ -191,7 +192,7 @@ if __name__ == "__main__":
)
)
num_rays
=
len
(
pixels
)
num_rays
=
len
(
pixels
)
num_rays
=
int
(
num_rays
=
int
(
num_rays
*
(
TARGET_SAMPLE_BATCH_SIZE
/
float
(
compact_counter
.
item
()
))
num_rays
*
(
TARGET_SAMPLE_BATCH_SIZE
/
float
(
compact_counter
))
)
)
train_dataset
.
update_num_rays
(
num_rays
)
train_dataset
.
update_num_rays
(
num_rays
)
alive_ray_mask
=
acc
.
squeeze
(
-
1
)
>
0
alive_ray_mask
=
acc
.
squeeze
(
-
1
)
>
0
...
@@ -210,7 +211,7 @@ if __name__ == "__main__":
...
@@ -210,7 +211,7 @@ if __name__ == "__main__":
f
"elapsed_time=
{
elapsed_time
:.
2
f
}
s (data=
{
data_time
:.
2
f
}
s) |
{
step
=
}
| "
f
"elapsed_time=
{
elapsed_time
:.
2
f
}
s (data=
{
data_time
:.
2
f
}
s) |
{
step
=
}
| "
f
"loss=
{
loss
:.
5
f
}
| "
f
"loss=
{
loss
:.
5
f
}
| "
f
"alive_ray_mask=
{
alive_ray_mask
.
long
().
sum
():
d
}
| "
f
"alive_ray_mask=
{
alive_ray_mask
.
long
().
sum
():
d
}
| "
f
"counter=
{
counter
.
item
()
:
d
}
| compact_counter=
{
compact_counter
.
item
()
:
d
}
| num_rays=
{
len
(
pixels
):
d
}
"
f
"counter=
{
counter
:
d
}
| compact_counter=
{
compact_counter
:
d
}
| num_rays=
{
len
(
pixels
):
d
}
"
)
)
# if time.time() - tic > 300:
# if time.time() - tic > 300:
...
...
nerfacc/volumetric_rendering.py
View file @
a0ab0265
...
@@ -23,6 +23,12 @@ def volumetric_rendering(
...
@@ -23,6 +23,12 @@ def volumetric_rendering(
"""A *fast* version of differentiable volumetric rendering."""
"""A *fast* version of differentiable volumetric rendering."""
n_rays
=
rays_o
.
shape
[
0
]
n_rays
=
rays_o
.
shape
[
0
]
rays_o
=
rays_o
.
contiguous
()
rays_d
=
rays_d
.
contiguous
()
scene_aabb
=
scene_aabb
.
contiguous
()
scene_occ_binary
=
scene_occ_binary
.
contiguous
()
render_bkgd
=
render_bkgd
.
contiguous
()
# get packed samples from ray marching & occupancy check.
# get packed samples from ray marching & occupancy check.
with
torch
.
no_grad
():
with
torch
.
no_grad
():
(
(
...
@@ -45,7 +51,7 @@ def volumetric_rendering(
...
@@ -45,7 +51,7 @@ def volumetric_rendering(
frustum_positions
=
(
frustum_positions
=
(
frustum_origins
+
frustum_dirs
*
(
frustum_starts
+
frustum_ends
)
/
2.0
frustum_origins
+
frustum_dirs
*
(
frustum_starts
+
frustum_ends
)
/
2.0
)
)
steps_counter
=
packed_info
[:,
-
1
].
sum
(
0
,
keepdim
=
True
)
steps_counter
=
frustum_origins
.
shape
[
0
]
# compat the samples thru volumetric rendering
# compat the samples thru volumetric rendering
with
torch
.
no_grad
():
with
torch
.
no_grad
():
...
@@ -64,7 +70,7 @@ def volumetric_rendering(
...
@@ -64,7 +70,7 @@ def volumetric_rendering(
frustum_positions
,
frustum_positions
,
frustum_dirs
,
frustum_dirs
,
)
)
compact_steps_counter
=
compact_
packed_info
[:,
-
1
].
sum
(
0
,
keepdim
=
True
)
compact_steps_counter
=
compact_
frustum_positions
.
shape
[
0
]
# network
# network
compact_query_results
=
query_fn
(
compact_frustum_positions
,
compact_frustum_dirs
)
compact_query_results
=
query_fn
(
compact_frustum_positions
,
compact_frustum_dirs
)
...
...
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