Skip to content
Snippets Groups Projects
Commit 3cf5fbae authored by Thomas Müller's avatar Thomas Müller
Browse files

Customize the GUI resolution via `--width` and `--height`

parent ada83421
No related branches found
No related tags found
No related merge requests found
...@@ -36,20 +36,21 @@ def parse_args(): ...@@ -36,20 +36,21 @@ def parse_args():
parser.add_argument("--save_snapshot", default="", help="Save this snapshot after training. recommended extension: .msgpack") parser.add_argument("--save_snapshot", default="", help="Save this snapshot after training. recommended extension: .msgpack")
parser.add_argument("--nerf_compatibility", action="store_true", help="Matches parameters with original NeRF. Can cause slowness and worse results on some scenes.") parser.add_argument("--nerf_compatibility", action="store_true", help="Matches parameters with original NeRF. Can cause slowness and worse results on some scenes.")
parser.add_argument("--test_transforms", default="", help="Path to a nerf style transforms json from which we will compute PSNR") parser.add_argument("--test_transforms", default="", help="Path to a nerf style transforms json from which we will compute PSNR.")
parser.add_argument("--screenshot_transforms", default="", help="Path to a nerf style transforms json from which to save a screenshot.") parser.add_argument("--screenshot_transforms", default="", help="Path to a nerf style transforms.json from which to save screenshots.")
parser.add_argument("--screenshot_frames", nargs="*", help="Which frame(s) to take a screenshot of") parser.add_argument("--screenshot_frames", nargs="*", help="Which frame(s) to take screenshots of.")
parser.add_argument("--screenshot_dir", default="", help="which directory to output screenshots to") parser.add_argument("--screenshot_dir", default="", help="Which directory to output screenshots to.")
parser.add_argument("--screenshot_w", type=int, default=0, help="screenshot res width") parser.add_argument("--screenshot_spp", type=int, default=16, help="Number of samples per pixel in screenshots.")
parser.add_argument("--screenshot_h", type=int, default=0, help="screenshot res height")
parser.add_argument("--screenshot_spp", type=int, default=16, help="screenshot spp") parser.add_argument("--width", "--screenshot_w", type=int, default=0, help="Resolution width of GUI and screenshots.")
parser.add_argument("--height", "--screenshot_h", type=int, default=0, help="Resolution height of GUI and screenshots.")
parser.add_argument("--gui", action="store_true", help="Run the testbed GUI interactively.") parser.add_argument("--gui", action="store_true", help="Run the testbed GUI interactively.")
parser.add_argument("--train", action="store_true", help="If the GUI is enabled, controls whether training starts immediately.") parser.add_argument("--train", action="store_true", help="If the GUI is enabled, controls whether training starts immediately.")
parser.add_argument("--n_steps", type=int, default=-1, help="Number of steps to train for before quitting.") parser.add_argument("--n_steps", type=int, default=-1, help="Number of steps to train for before quitting.")
parser.add_argument("--sharpen", default=0, help="Set amount of sharpening applied to NeRF training images") parser.add_argument("--sharpen", default=0, help="Set amount of sharpening applied to NeRF training images.")
args = parser.parse_args() args = parser.parse_args()
return args return args
...@@ -122,8 +123,8 @@ if __name__ == "__main__": ...@@ -122,8 +123,8 @@ if __name__ == "__main__":
if args.gui: if args.gui:
# Pick a sensible GUI resolution depending on arguments. # Pick a sensible GUI resolution depending on arguments.
sw = args.screenshot_w or 1920 sw = args.width or 1920
sh = args.screenshot_h or 1080 sh = args.height or 1080
while sw*sh > 1920*1080*4: while sw*sh > 1920*1080*4:
sw = int(sw / 2) sw = int(sw / 2)
sh = int(sh / 2) sh = int(sh / 2)
...@@ -277,7 +278,7 @@ if __name__ == "__main__": ...@@ -277,7 +278,7 @@ if __name__ == "__main__":
ssim = totssim/(totcount or 1) ssim = totssim/(totcount or 1)
print(f"PSNR={psnr} [min={minpsnr} max={maxpsnr}] SSIM={ssim}") print(f"PSNR={psnr} [min={minpsnr} max={maxpsnr}] SSIM={ssim}")
if args.screenshot_w: if args.width:
if ref_transforms: if ref_transforms:
testbed.fov_axis = 0 testbed.fov_axis = 0
testbed.fov = ref_transforms["camera_angle_x"] * 180 / np.pi testbed.fov = ref_transforms["camera_angle_x"] * 180 / np.pi
...@@ -295,13 +296,13 @@ if __name__ == "__main__": ...@@ -295,13 +296,13 @@ if __name__ == "__main__":
outname = outname + ".png" outname = outname + ".png"
print(f"rendering {outname}") print(f"rendering {outname}")
image = testbed.render(args.screenshot_w or int(ref_transforms["w"]), args.screenshot_h or int(ref_transforms["h"]), args.screenshot_spp, True) image = testbed.render(args.width or int(ref_transforms["w"]), args.height or int(ref_transforms["h"]), args.screenshot_spp, True)
os.makedirs(os.path.dirname(outname), exist_ok=True) os.makedirs(os.path.dirname(outname), exist_ok=True)
write_image(outname, image) write_image(outname, image)
else: elif args.screenshot_dir:
outname = os.path.join(args.screenshot_dir, args.scene + "_" + network_stem) outname = os.path.join(args.screenshot_dir, args.scene + "_" + network_stem)
print(f"Rendering {outname}.png") print(f"Rendering {outname}.png")
image = testbed.render(args.screenshot_w, args.screenshot_h, args.screenshot_spp, True) image = testbed.render(args.width, args.height, args.screenshot_spp, True)
if os.path.dirname(outname) != "": if os.path.dirname(outname) != "":
os.makedirs(os.path.dirname(outname), exist_ok=True) os.makedirs(os.path.dirname(outname), exist_ok=True)
write_image(outname + ".png", image) write_image(outname + ".png", image)
......
...@@ -85,6 +85,20 @@ int main(int argc, char** argv) { ...@@ -85,6 +85,20 @@ int main(int argc, char** argv) {
{"snapshot"}, {"snapshot"},
}; };
ValueFlag<uint32_t> width_flag{
parser,
"WIDTH",
"Resolution width of the GUI.",
{"width"},
};
ValueFlag<uint32_t> height_flag{
parser,
"HEIGHT",
"Resolution height of the GUI.",
{"height"},
};
Flag version_flag{ Flag version_flag{
parser, parser,
"VERSION", "VERSION",
...@@ -211,7 +225,7 @@ int main(int argc, char** argv) { ...@@ -211,7 +225,7 @@ int main(int argc, char** argv) {
#endif #endif
if (gui) { if (gui) {
testbed.init_window(1920, 1080); testbed.init_window(width_flag ? get(width_flag) : 1920, height_flag ? get(height_flag) : 1080);
} }
// Render/training loop // Render/training loop
......
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