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
e6647a00
Commit
e6647a00
authored
Dec 15, 2023
by
Ruilong Li
Browse files
a big cleanup: data fix seed; ngp cubic box
parent
6ab97aeb
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
6 deletions
+19
-6
examples/datasets/nerf_360_v2.py
examples/datasets/nerf_360_v2.py
+6
-3
examples/datasets/nerf_synthetic.py
examples/datasets/nerf_synthetic.py
+6
-3
examples/radiance_fields/ngp.py
examples/radiance_fields/ngp.py
+7
-0
No files found.
examples/datasets/nerf_360_v2.py
View file @
e6647a00
...
...
@@ -258,6 +258,8 @@ class SubjectLoader(torch.utils.data.Dataset):
)
self
.
K
=
torch
.
tensor
(
self
.
K
).
to
(
torch
.
float32
).
to
(
device
)
self
.
height
,
self
.
width
=
self
.
images
.
shape
[
1
:
3
]
self
.
g
=
torch
.
Generator
(
device
=
device
)
self
.
g
.
manual_seed
(
42
)
def
__len__
(
self
):
return
len
(
self
.
images
)
...
...
@@ -274,7 +276,7 @@ class SubjectLoader(torch.utils.data.Dataset):
if
self
.
training
:
if
self
.
color_bkgd_aug
==
"random"
:
color_bkgd
=
torch
.
rand
(
3
,
device
=
self
.
images
.
device
)
color_bkgd
=
torch
.
rand
(
3
,
device
=
self
.
images
.
device
,
generator
=
self
.
g
)
elif
self
.
color_bkgd_aug
==
"white"
:
color_bkgd
=
torch
.
ones
(
3
,
device
=
self
.
images
.
device
)
elif
self
.
color_bkgd_aug
==
"black"
:
...
...
@@ -304,14 +306,15 @@ class SubjectLoader(torch.utils.data.Dataset):
len
(
self
.
images
),
size
=
(
num_rays
,),
device
=
self
.
images
.
device
,
generator
=
self
.
g
,
)
else
:
image_id
=
[
index
]
*
num_rays
x
=
torch
.
randint
(
0
,
self
.
width
,
size
=
(
num_rays
,),
device
=
self
.
images
.
device
0
,
self
.
width
,
size
=
(
num_rays
,),
device
=
self
.
images
.
device
,
generator
=
self
.
g
)
y
=
torch
.
randint
(
0
,
self
.
height
,
size
=
(
num_rays
,),
device
=
self
.
images
.
device
0
,
self
.
height
,
size
=
(
num_rays
,),
device
=
self
.
images
.
device
,
generator
=
self
.
g
)
else
:
image_id
=
[
index
]
...
...
examples/datasets/nerf_synthetic.py
View file @
e6647a00
...
...
@@ -124,6 +124,8 @@ class SubjectLoader(torch.utils.data.Dataset):
self
.
camtoworlds
=
self
.
camtoworlds
.
to
(
device
)
self
.
K
=
self
.
K
.
to
(
device
)
assert
self
.
images
.
shape
[
1
:
3
]
==
(
self
.
HEIGHT
,
self
.
WIDTH
)
self
.
g
=
torch
.
Generator
(
device
=
device
)
self
.
g
.
manual_seed
(
42
)
def
__len__
(
self
):
return
len
(
self
.
images
)
...
...
@@ -141,7 +143,7 @@ class SubjectLoader(torch.utils.data.Dataset):
if
self
.
training
:
if
self
.
color_bkgd_aug
==
"random"
:
color_bkgd
=
torch
.
rand
(
3
,
device
=
self
.
images
.
device
)
color_bkgd
=
torch
.
rand
(
3
,
device
=
self
.
images
.
device
,
generator
=
self
.
g
)
elif
self
.
color_bkgd_aug
==
"white"
:
color_bkgd
=
torch
.
ones
(
3
,
device
=
self
.
images
.
device
)
elif
self
.
color_bkgd_aug
==
"black"
:
...
...
@@ -172,14 +174,15 @@ class SubjectLoader(torch.utils.data.Dataset):
len
(
self
.
images
),
size
=
(
num_rays
,),
device
=
self
.
images
.
device
,
generator
=
self
.
g
,
)
else
:
image_id
=
[
index
]
*
num_rays
x
=
torch
.
randint
(
0
,
self
.
WIDTH
,
size
=
(
num_rays
,),
device
=
self
.
images
.
device
0
,
self
.
WIDTH
,
size
=
(
num_rays
,),
device
=
self
.
images
.
device
,
generator
=
self
.
g
)
y
=
torch
.
randint
(
0
,
self
.
HEIGHT
,
size
=
(
num_rays
,),
device
=
self
.
images
.
device
0
,
self
.
HEIGHT
,
size
=
(
num_rays
,),
device
=
self
.
images
.
device
,
generator
=
self
.
g
)
else
:
image_id
=
[
index
]
...
...
examples/radiance_fields/ngp.py
View file @
e6647a00
...
...
@@ -85,6 +85,13 @@ class NGPRadianceField(torch.nn.Module):
super
().
__init__
()
if
not
isinstance
(
aabb
,
torch
.
Tensor
):
aabb
=
torch
.
tensor
(
aabb
,
dtype
=
torch
.
float32
)
# Turns out rectangle aabb will leads to uneven collision so bad performance.
# We enforce a cube aabb here.
center
=
(
aabb
[...,
:
num_dim
]
+
aabb
[...,
num_dim
:])
/
2.0
size
=
(
aabb
[...,
num_dim
:]
-
aabb
[...,
:
num_dim
]).
max
()
aabb
=
torch
.
cat
([
center
-
size
/
2.0
,
center
+
size
/
2.0
],
dim
=-
1
)
self
.
register_buffer
(
"aabb"
,
aabb
)
self
.
num_dim
=
num_dim
self
.
use_viewdirs
=
use_viewdirs
...
...
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