Skip to content
Snippets Groups Projects
Commit 87335693 authored by Thomas Pickles's avatar Thomas Pickles
Browse files

Added options to runfile.

parent 58444d5e
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment