From c6e689509398474993ee54bafbb5515b1c680b87 Mon Sep 17 00:00:00 2001 From: Yuchen Song <554003530@qq.com> Date: Thu, 8 Sep 2022 16:40:32 +0800 Subject: [PATCH 1/2] fixed black disparity map problem --- run_nerf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_nerf.py b/run_nerf.py index bc270be86..1924f5b8d 100644 --- a/run_nerf.py +++ b/run_nerf.py @@ -806,7 +806,7 @@ def train(): print('Done, saving', rgbs.shape, disps.shape) moviebase = os.path.join(basedir, expname, '{}_spiral_{:06d}_'.format(expname, i)) imageio.mimwrite(moviebase + 'rgb.mp4', to8b(rgbs), fps=30, quality=8) - imageio.mimwrite(moviebase + 'disp.mp4', to8b(disps / np.max(disps)), fps=30, quality=8) + imageio.mimwrite(moviebase + 'disp.mp4', to8b(disps / np.nanmax(disps)), fps=30, quality=8) # if args.use_viewdirs: # render_kwargs_test['c2w_staticcam'] = render_poses[0][:3,:4] From 104bbad2ceaa447a9c5b9dda0600ce9de8414b47 Mon Sep 17 00:00:00 2001 From: Yuchen Song <554003530@qq.com> Date: Thu, 8 Sep 2022 16:48:58 +0800 Subject: [PATCH 2/2] render disp map from input pose --- load_llff.py | 3 ++- run_nerf.py | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/load_llff.py b/load_llff.py index 98b791637..b99a6f5fe 100644 --- a/load_llff.py +++ b/load_llff.py @@ -243,7 +243,8 @@ def min_line_dist(rays_o, rays_d): def load_llff_data(basedir, factor=8, recenter=True, bd_factor=.75, spherify=False, path_zflat=False): - poses, bds, imgs = _load_data(basedir, factor=factor) # factor=8 downsamples original imgs by 8x + # poses, bds, imgs = _load_data(basedir, factor=factor) # factor=8 downsamples original imgs by 8x + poses, bds, imgs = _load_data(basedir, width=1024, height=576) print('Loaded', basedir, bds.min(), bds.max()) # Correct rotation matrix ordering and move variable dim to axis 0 diff --git a/run_nerf.py b/run_nerf.py index 1924f5b8d..ec464921f 100644 --- a/run_nerf.py +++ b/run_nerf.py @@ -525,7 +525,7 @@ def config_parser(): help='frequency of weight ckpt saving') parser.add_argument("--i_testset", type=int, default=50000, help='frequency of testset saving') - parser.add_argument("--i_video", type=int, default=50000, + parser.add_argument("--i_video", type=int, default=50000, help='frequency of render_poses video saving') return parser @@ -803,11 +803,22 @@ def train(): # Turn on testing mode with torch.no_grad(): rgbs, disps = render_path(render_poses, hwf, K, args.chunk, render_kwargs_test) + rgbs_render, disps_render = render_path(poses, hwf, K, args.chunk, render_kwargs_test) print('Done, saving', rgbs.shape, disps.shape) moviebase = os.path.join(basedir, expname, '{}_spiral_{:06d}_'.format(expname, i)) imageio.mimwrite(moviebase + 'rgb.mp4', to8b(rgbs), fps=30, quality=8) imageio.mimwrite(moviebase + 'disp.mp4', to8b(disps / np.nanmax(disps)), fps=30, quality=8) + photodir = os.path.join(basedir, expname, 'rendered images') + os.makedirs(photodir, exist_ok=True) + photobase = os.path.join(photodir, '{}_{:06d}'.format(expname, i)) + os.makedirs('{}/rgbs'.format(photobase), exist_ok=True) + os.makedirs('{}/disp'.format(photobase), exist_ok=True) + for index in range(len(rgbs_render)): + imageio.imwrite(photobase + '/rgbs/{:04d}'.format(index+7) + '.jpg', to8b(rgbs_render[index])) + imageio.imwrite(photobase + '/disp/{:04d}'.format(index+7) + '.jpg', to8b(disps_render[index] / np.nanmax(disps_render))) + + # if args.use_viewdirs: # render_kwargs_test['c2w_staticcam'] = render_poses[0][:3,:4] # with torch.no_grad():