Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
instant-ngp-tomography
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package 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
Thomas Pickles
instant-ngp-tomography
Commits
87335693
Commit
87335693
authored
2 years ago
by
Thomas Pickles
Browse files
Options
Downloads
Patches
Plain Diff
Added options to runfile.
parent
58444d5e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/run.py
+54
-4
54 additions, 4 deletions
scripts/run.py
with
54 additions
and
4 deletions
scripts/run.py
+
54
−
4
View file @
87335693
...
...
@@ -68,6 +68,9 @@ def parse_args():
parser
.
add_argument
(
"
--sharpen
"
,
default
=
0
,
help
=
"
Set amount of sharpening applied to NeRF training images. Range 0.0 to 1.0.
"
)
# parser.add_argument("--tomonerf", action="store_true", help="Apply tomography specific parameters to optimise NeRF output.")
parser
.
add_argument
(
"
--tomonerf
"
,
type
=
int
,
default
=
0
,
help
=
"
Which transforms to apply [single_channel, exponentiate img data, crop].
"
)
parser
.
add_argument
(
"
--crop
"
,
nargs
=
3
,
type
=
float
,
help
=
"
Percentage to crop unit cube to.
"
)
return
parser
.
parse_args
()
...
...
@@ -123,6 +126,50 @@ if __name__ == "__main__":
elif
args
.
network
:
testbed
.
reload_network_from_file
(
args
.
network
)
if
args
.
tomonerf
:
print
(
"
***Entering NERF for Tomography mode***
"
)
if
(
format
(
args
.
tomonerf
,
'
b
'
)[
-
1
]
==
'
1
'
):
print
(
"
TODO: Single channel mode
"
)
# single channel
if
(
format
(
args
.
tomonerf
,
'
b
'
)[
-
2
]
==
'
1
'
):
print
(
"
TODO: Exponentiate data
"
)
if
(
format
(
args
.
tomonerf
,
'
b
'
)[
-
3
]
==
'
1
'
):
print
(
"
TODO: Optimal cropping
"
)
# args.gui = True
args
.
width
=
args
.
height
=
400
print
(
"
Scaling image to be within unit cube...
"
)
# "aabb_scale": 1, # nothing exists outside unit cube
# with open(args.rendering_params) as f:
# rendering_params = json.load(f)
# data_dir=os.path.dirname(args.test_transforms)
# TODO: set scale, bounding box
# becomes 0.048, multiplied by 0.012 *
# from transforms.json training data, we have:
# "scale": 0.012,
# TODO: experiment with n_params, n_encoding_params
# # Evaluate metrics on black background
# testbed.background_color = [0.0, 0.0, 0.0, 1.0]
# print(f"Cropbox is {testbed.crop_box()}")
crop_x
,
crop_y
,
crop_z
=
args
.
crop
# box = np.array([[0.0, 0.0, -2.0, 0.0],[2.0, 0.,0.,0.],[0.,-2.0, 0.0, 0.0]], dtype=np.float32)
# testbed.set_crop_box(box)
crop_min
=
[(
100
-
size
)
/
200
for
size
in
args
.
crop
]
crop_max
=
[
1
-
(
100
-
size
)
/
200
for
size
in
args
.
crop
]
testbed
.
render_aabb
=
ngp
.
BoundingBox
(
crop_min
,
crop_max
)
print
(
f
"
Cropped to min
{
crop_min
}
, max
{
crop_max
}
"
)
# print(f"Testbed options is {dir(testbed)}")
# print(f"Testbed.bounding_radius are {dir(testbed.bounding_radius)}")
else
:
print
(
"
Tomonerf: Single channel mode
"
)
ref_transforms
=
{}
if
args
.
screenshot_transforms
:
# try to load the given file straight away
print
(
"
Screenshot transforms from
"
,
args
.
screenshot_transforms
)
...
...
@@ -239,13 +286,16 @@ if __name__ == "__main__":
testbed
.
render_ground_truth
=
False
image
=
testbed
.
render
(
resolution
[
0
],
resolution
[
1
],
spp
,
True
)
if
i
==
0
:
write_image
(
f
"
ref.png
"
,
ref_image
)
write_image
(
f
"
out.png
"
,
image
)
if
True
:
# i == 0:
print
(
f
"
Testing against provided ref images
"
)
print
(
f
"
Rendering GT as ref.png, out.png
"
)
write_image
(
f
"
ref_
{
i
}
.png
"
,
ref_image
)
write_image
(
f
"
out_
{
i
}
.png
"
,
image
)
diffimg
=
np
.
absolute
(
image
-
ref_image
)
diffimg
[...,
3
:
4
]
=
1.0
write_image
(
"
diff.png
"
,
diffimg
)
write_image
(
"
diff
_{i}
.png
"
,
diffimg
)
A
=
np
.
clip
(
linear_to_srgb
(
image
[...,:
3
]),
0.0
,
1.0
)
R
=
np
.
clip
(
linear_to_srgb
(
ref_image
[...,:
3
]),
0.0
,
1.0
)
...
...
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