Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NeRF Dataset Loader
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julia Berger
NeRF Dataset Loader
Commits
87753e5f
Commit
87753e5f
authored
2 years ago
by
Julia Berger
Browse files
Options
Downloads
Patches
Plain Diff
added support for additional frame infos
parent
24e1f920
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
nerf_synthetic_dataset.py
+28
-7
28 additions, 7 deletions
nerf_synthetic_dataset.py
with
28 additions
and
7 deletions
nerf_synthetic_dataset.py
+
28
−
7
View file @
87753e5f
...
...
@@ -10,10 +10,12 @@ class NeRFSyntheticDataset(Dataset):
def
__init__
(
self
,
root_dir
,
split
=
'
train
'
,
additional_info
=
False
,
img_downscale
=
1
):
self
.
root_dir
=
root_dir
self
.
split
=
split
self
.
img_downscale
=
img_downscale
self
.
additional_info
=
additional_info
self
.
read_json
()
def
read_json
(
self
):
...
...
@@ -27,6 +29,7 @@ class NeRFSyntheticDataset(Dataset):
# Extract image and corresponding transformation matrix
imgs
=
[]
poses
=
[]
self
.
infos
=
[]
for
frame
in
meta
[
'
frames
'
]:
file_path
=
frame
[
'
file_path
'
]
if
file_path
[
-
4
:]
!=
'
.png
'
:
...
...
@@ -51,6 +54,13 @@ class NeRFSyntheticDataset(Dataset):
imgs
.
append
(
np
.
array
(
img
))
poses
.
append
(
np
.
array
(
frame
[
'
transform_matrix
'
]))
# Get additional information per frame, except file path and transformation matrix.
info
=
{}
for
key
in
frame
.
keys
():
if
key
!=
'
file_path
'
and
key
!=
'
transform_matrix
'
:
info
[
key
]
=
frame
[
key
]
self
.
infos
.
append
(
info
)
self
.
rgbs
=
(
np
.
array
(
imgs
)
/
255.
).
astype
(
np
.
float32
)
self
.
poses
=
np
.
array
(
poses
).
astype
(
np
.
float32
)
...
...
@@ -71,9 +81,20 @@ class NeRFSyntheticDataset(Dataset):
self
.
focal_y
=
.
5
*
self
.
h
/
np
.
tan
(.
5
*
camera_angle_y
)
self
.
focal_y
/=
self
.
img_downscale
def
__len__
(
self
):
return
self
.
rgbs
.
shape
[
0
]
def
__getitem__
(
self
,
idx
):
if
self
.
additional_info
:
return
{
'
rgb
'
:
self
.
rgbs
[
idx
],
'
pose
'
:
self
.
poses
[
idx
],
'
focal_x
'
:
self
.
focal_x
,
'
focal_y
'
:
self
.
focal_y
,
'
info
'
:
self
.
infos
[
idx
]
}
else
:
return
{
'
rgb
'
:
self
.
rgbs
[
idx
],
'
pose
'
:
self
.
poses
[
idx
],
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment