From 7b0a8eb9fa17e50c35c959f5b60d48316d30f588 Mon Sep 17 00:00:00 2001 From: Eduard Ramon Maldonado Date: Mon, 4 Jan 2021 16:07:47 +0100 Subject: [PATCH] Using scene_id instead of scan_id --- README.md | 14 +++++++------- code/confs/ablation/dtu_fixed_noisy_cameras.conf | 2 +- code/confs/ablation/dtu_no_feature_vector.conf | 2 +- code/confs/ablation/dtu_no_normal.conf | 2 +- code/confs/ablation/dtu_no_view_dir.conf | 2 +- code/confs/crx_fixed_cameras.conf | 2 +- code/confs/crx_fixed_cameras_disentangled.conf | 2 +- code/confs/crx_trained_cameras.conf | 2 +- code/confs/crx_trained_cameras_disentangled.conf | 2 +- code/confs/crx_trained_cameras_prior.conf | 2 +- code/confs/crx_trained_cameras_prior_latent.conf | 2 +- code/confs/dtu_fixed_cameras.conf | 2 +- code/confs/dtu_trained_cameras.conf | 2 +- code/confs/dummy_fixed_cameras.conf | 2 +- code/datasets/scene_dataset.py | 4 ++-- code/evaluation/eval.py | 16 ++++++++-------- code/evaluation/eval_disentanglement.py | 6 +++--- code/training/exp_runner.py | 4 ++-- code/training/idr_train.py | 10 +++++----- 19 files changed, 40 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index fe02099..5eb7bfe 100644 --- a/README.md +++ b/README.md @@ -44,14 +44,14 @@ We used our method to generate 3D reconstructions in two different setups: For training IDR run: ``` cd ./code -python training/exp_runner.py --conf ./confs/dtu_fixed_cameras.conf --scan_id SCAN_ID +python training/exp_runner.py --conf ./confs/dtu_fixed_cameras.conf --scene_id scene_id ``` -where SCAN_ID is the folder of the DTU scene to reconstruct, ie 'scan64' +where scene_id is the folder of the DTU scene to reconstruct, ie 'scan64' Then, to produce the meshed surface, run: ``` cd ./code -python evaluation/eval.py --conf ./confs/dtu_fixed_cameras.conf --scan_id SCAN_ID --checkpoint CHECKPOINT [--eval_rendering] +python evaluation/eval.py --conf ./confs/dtu_fixed_cameras.conf --scene_id scene_id --checkpoint CHECKPOINT [--eval_rendering] ``` where CHECKPOINT is the epoch you wish to evaluate or 'latest' if you wish to take the most recent epoch. Turning on `--eval_rendering` will further produce and evaluate PSNR of train image reconstructions. @@ -61,13 +61,13 @@ Turning on `--eval_rendering` will further produce and evaluate PSNR of train im For training IDR with cameras optimization run: ``` cd ./code -python training/exp_runner.py --train_cameras --conf ./confs/dtu_trained_cameras.conf --scan_id SCAN_ID +python training/exp_runner.py --train_cameras --conf ./confs/dtu_trained_cameras.conf --scene_id scene_id ``` Then, to evaluate cameras accuracy and to produce the meshed surface, run: ``` cd ./code -python evaluation/eval.py --eval_cameras --conf ./confs/dtu_trained_cameras.conf --scan_id SCAN_ID --checkpoint CHECKPOINT [--eval_rendering] +python evaluation/eval.py --eval_cameras --conf ./confs/dtu_trained_cameras.conf --scene_id scene_id --checkpoint CHECKPOINT [--eval_rendering] ``` @@ -76,11 +76,11 @@ python evaluation/eval.py --eval_cameras --conf ./confs/dtu_trained_cameras.con We have uploaded IDR trained models, and you can run the evaluation using: ``` cd ./code -python evaluation/eval.py --exps_folder trained_models --conf ./confs/dtu_fixed_cameras.conf --scan_id SCAN_ID --checkpoint 2000 [--eval_rendering] +python evaluation/eval.py --exps_folder trained_models --conf ./confs/dtu_fixed_cameras.conf --scene_id scene_id --checkpoint 2000 [--eval_rendering] ``` Or, for trained cameras: ``` -python evaluation/eval.py --exps_folder trained_models --conf ./confs/dtu_trained_cameras.conf --scan_id SCAN_ID --checkpoint 2000 --eval_cameras [--eval_rendering] +python evaluation/eval.py --exps_folder trained_models --conf ./confs/dtu_trained_cameras.conf --scene_id scene_id --checkpoint 2000 --eval_cameras [--eval_rendering] ``` diff --git a/code/confs/ablation/dtu_fixed_noisy_cameras.conf b/code/confs/ablation/dtu_fixed_noisy_cameras.conf index 2820fe3..9c6cba8 100644 --- a/code/confs/ablation/dtu_fixed_noisy_cameras.conf +++ b/code/confs/ablation/dtu_fixed_noisy_cameras.conf @@ -24,7 +24,7 @@ loss{ dataset{ data_dir = DTU img_res = [1200, 1600] - scan_id = scan114 + scene_id = scan114 cam_file = cameras_linear_init.npz } model{ diff --git a/code/confs/ablation/dtu_no_feature_vector.conf b/code/confs/ablation/dtu_no_feature_vector.conf index 900f194..e6da5bf 100644 --- a/code/confs/ablation/dtu_no_feature_vector.conf +++ b/code/confs/ablation/dtu_no_feature_vector.conf @@ -24,7 +24,7 @@ loss{ dataset{ data_dir = DTU img_res = [1200, 1600] - scan_id = scan114 + scene_id = scan114 } model{ feature_vector_size = 0 diff --git a/code/confs/ablation/dtu_no_normal.conf b/code/confs/ablation/dtu_no_normal.conf index b9a8491..7b62ecc 100644 --- a/code/confs/ablation/dtu_no_normal.conf +++ b/code/confs/ablation/dtu_no_normal.conf @@ -24,7 +24,7 @@ loss{ dataset{ data_dir = DTU img_res = [1200, 1600] - scan_id = scan114 + scene_id = scan114 } model{ feature_vector_size = 256 diff --git a/code/confs/ablation/dtu_no_view_dir.conf b/code/confs/ablation/dtu_no_view_dir.conf index bd7249d..74c3126 100644 --- a/code/confs/ablation/dtu_no_view_dir.conf +++ b/code/confs/ablation/dtu_no_view_dir.conf @@ -24,7 +24,7 @@ loss{ dataset{ data_dir = DTU img_res = [1200, 1600] - scan_id = scan114 + scene_id = scan114 } model{ feature_vector_size = 256 diff --git a/code/confs/crx_fixed_cameras.conf b/code/confs/crx_fixed_cameras.conf index 345570a..b1444e2 100644 --- a/code/confs/crx_fixed_cameras.conf +++ b/code/confs/crx_fixed_cameras.conf @@ -24,7 +24,7 @@ loss{ dataset{ data_dir = DTU img_res = [600, 800] - scan_id = scan65 + scene_id = scan65 } model{ feature_vector_size = 256 diff --git a/code/confs/crx_fixed_cameras_disentangled.conf b/code/confs/crx_fixed_cameras_disentangled.conf index 6de2b7c..1073923 100644 --- a/code/confs/crx_fixed_cameras_disentangled.conf +++ b/code/confs/crx_fixed_cameras_disentangled.conf @@ -24,7 +24,7 @@ loss{ dataset{ data_dir = CRX img_res = [600, 804] - scan_id = scan65 + scene_id = scan65 } model{ geometry_network diff --git a/code/confs/crx_trained_cameras.conf b/code/confs/crx_trained_cameras.conf index d34ca4c..e4133cc 100644 --- a/code/confs/crx_trained_cameras.conf +++ b/code/confs/crx_trained_cameras.conf @@ -25,7 +25,7 @@ loss{ dataset{ data_dir = CRX img_res = [600, 804] - scan_id = scan65 + scene_id = scan65 } model{ feature_vector_size = 256 diff --git a/code/confs/crx_trained_cameras_disentangled.conf b/code/confs/crx_trained_cameras_disentangled.conf index 3f2f45b..1ef435d 100644 --- a/code/confs/crx_trained_cameras_disentangled.conf +++ b/code/confs/crx_trained_cameras_disentangled.conf @@ -25,7 +25,7 @@ loss{ dataset{ data_dir = CRX img_res = [600, 804] - scan_id = scan65 + scene_id = scan65 } model{ geometry_network diff --git a/code/confs/crx_trained_cameras_prior.conf b/code/confs/crx_trained_cameras_prior.conf index 57c9c98..ff19390 100644 --- a/code/confs/crx_trained_cameras_prior.conf +++ b/code/confs/crx_trained_cameras_prior.conf @@ -25,7 +25,7 @@ loss{ dataset{ data_dir = CRX img_res = [600, 804] - scan_id = scan65 + scene_id = scan65 } model{ geometry_network diff --git a/code/confs/crx_trained_cameras_prior_latent.conf b/code/confs/crx_trained_cameras_prior_latent.conf index f9d2b5c..c948d42 100644 --- a/code/confs/crx_trained_cameras_prior_latent.conf +++ b/code/confs/crx_trained_cameras_prior_latent.conf @@ -25,7 +25,7 @@ loss{ dataset{ data_dir = CRX img_res = [600, 804] - scan_id = scan65 + scene_id = scan65 } model{ geometry_network diff --git a/code/confs/dtu_fixed_cameras.conf b/code/confs/dtu_fixed_cameras.conf index df4399a..88fbe26 100644 --- a/code/confs/dtu_fixed_cameras.conf +++ b/code/confs/dtu_fixed_cameras.conf @@ -24,7 +24,7 @@ loss{ dataset{ data_dir = DTU img_res = [1200, 1600] - scan_id = scan65 + scene_id = scan65 } model{ feature_vector_size = 256 diff --git a/code/confs/dtu_trained_cameras.conf b/code/confs/dtu_trained_cameras.conf index 6408475..0d16b28 100644 --- a/code/confs/dtu_trained_cameras.conf +++ b/code/confs/dtu_trained_cameras.conf @@ -25,7 +25,7 @@ loss{ dataset{ data_dir = DTU img_res = [1200, 1600] - scan_id = scan65 + scene_id = scan65 } model{ feature_vector_size = 256 diff --git a/code/confs/dummy_fixed_cameras.conf b/code/confs/dummy_fixed_cameras.conf index 87389a7..36edb05 100644 --- a/code/confs/dummy_fixed_cameras.conf +++ b/code/confs/dummy_fixed_cameras.conf @@ -24,7 +24,7 @@ loss{ dataset{ data_dir = dummy img_res = [64, 64] - scan_id = scan0 + scene_id = scan0 } model{ geometry_network diff --git a/code/datasets/scene_dataset.py b/code/datasets/scene_dataset.py index ed1dd83..7e6ffca 100644 --- a/code/datasets/scene_dataset.py +++ b/code/datasets/scene_dataset.py @@ -12,11 +12,11 @@ def __init__(self, train_cameras, data_dir, img_res, - scan_id=0, + scene_id='scan0', cam_file=None ): - self.instance_dir = os.path.join('../data', data_dir, '{0}'.format(scan_id)) + self.instance_dir = os.path.join('../data', data_dir, '{0}'.format(scene_id)) self.total_pixels = img_res[0] * img_res[1] self.img_res = img_res diff --git a/code/evaluation/eval.py b/code/evaluation/eval.py index 5d71b22..e98fd42 100644 --- a/code/evaluation/eval.py +++ b/code/evaluation/eval.py @@ -24,9 +24,9 @@ def evaluate(**kwargs): eval_rendering = kwargs['eval_rendering'] expname = conf.get_string('train.expname') + kwargs['expname'] - scan_id = kwargs['scan_id'] if kwargs['scan_id'] else conf.get_string('dataset.scan_id', default=None) - if scan_id: - expname = expname + '_{0}'.format(scan_id) + scene_id = kwargs['scene_id'] if kwargs['scene_id'] else conf.get_string('dataset.scene_id', default=None) + if scene_id: + expname = expname + '_{0}'.format(scene_id) if kwargs['timestamp'] == 'latest': if os.path.exists(os.path.join('../', kwargs['exps_folder_name'], expname)): @@ -52,8 +52,8 @@ def evaluate(**kwargs): model.cuda() dataset_conf = conf.get_config('dataset') - if kwargs['scan_id']: - dataset_conf['scan_id'] = kwargs['scan_id'] + if kwargs['scene_id']: + dataset_conf['scene_id'] = kwargs['scene_id'] eval_dataset = utils.get_class(conf.get_string('train.dataset_class'))(eval_cameras, **dataset_conf) # settings for camera optimization @@ -173,7 +173,7 @@ def evaluate(**kwargs): psnrs.append(psnr) psnrs = np.array(psnrs).astype(np.float64) - print("RENDERING EVALUATION {2}: psnr mean = {0} ; psnr std = {1}".format("%.2f" % psnrs.mean(), "%.2f" % psnrs.std(), scan_id)) + print("RENDERING EVALUATION {2}: psnr mean = {0} ; psnr std = {1}".format("%.2f" % psnrs.mean(), "%.2f" % psnrs.std(), scene_id)) def get_cameras_accuracy(pred_Rs, gt_Rs, pred_ts, gt_ts,): @@ -245,7 +245,7 @@ def calculate_psnr(img1, img2, mask): parser.add_argument('--gpu', type=str, default='auto', help='GPU to use [default: GPU auto]') parser.add_argument('--timestamp', default='latest', type=str, help='The experiemnt timestamp to test.') parser.add_argument('--checkpoint', default='latest',type=str,help='The trained model checkpoint to test') - parser.add_argument('--scan_id', type=str, help='If set, taken to be the scan id.') + parser.add_argument('--scene_id', type=str, help='If set, taken to be the scene id.') parser.add_argument('--resolution', default=512, type=int, help='Grid resolution for marching cube') parser.add_argument('--is_uniform_grid', default=False, action="store_true", help='If set, evaluate marching cube with uniform grid.') parser.add_argument('--eval_cameras', default=False, action="store_true", help='If set, evaluate camera accuracy of trained cameras.') @@ -268,7 +268,7 @@ def calculate_psnr(img1, img2, mask): evals_folder_name='evals', timestamp=opt.timestamp, checkpoint=opt.checkpoint, - scan_id=opt.scan_id, + scene_id=opt.scene_id, resolution=opt.resolution, eval_cameras=opt.eval_cameras, eval_rendering=opt.eval_rendering diff --git a/code/evaluation/eval_disentanglement.py b/code/evaluation/eval_disentanglement.py index c9e7a71..c82c988 100644 --- a/code/evaluation/eval_disentanglement.py +++ b/code/evaluation/eval_disentanglement.py @@ -53,7 +53,7 @@ def evaluate(**kwargs): model.rendering_network = model_fake.rendering_network dataset_conf = conf.get_config('dataset') - dataset_conf['scan_id'] = geometry_id + dataset_conf['scene_id'] = geometry_id eval_dataset = utils.get_class(conf.get_string('train.dataset_class'))(False, **dataset_conf) eval_dataloader = torch.utils.data.DataLoader(eval_dataset, @@ -138,8 +138,8 @@ def evaluate(**kwargs): parser = argparse.ArgumentParser() parser.add_argument('--conf', type=str, default='./confs/dtu_fixed_cameras.conf') parser.add_argument('--gpu', type=str, default='auto', help='GPU to use [default: GPU auto]') - parser.add_argument('--geometry_id', type=int, default=65, help='The scan id of the learned geometry.') - parser.add_argument('--appearance_id', type=int, default=110, help='The scan id of the learned appearance.') + parser.add_argument('--geometry_id', type=int, default='scan65', help='The scene id of the learned geometry.') + parser.add_argument('--appearance_id', type=int, default='scan110', help='The scene id of the learned appearance.') opt = parser.parse_args() diff --git a/code/training/exp_runner.py b/code/training/exp_runner.py index f5a502b..e24cc8b 100644 --- a/code/training/exp_runner.py +++ b/code/training/exp_runner.py @@ -17,7 +17,7 @@ parser.add_argument('--timestamp', default='latest', type=str, help='The timestamp of the run to be used in case of continuing from a previous run.') parser.add_argument('--checkpoint', default='latest',type=str,help='The checkpoint epoch number of the run to be used in case of continuing from a previous run.') parser.add_argument('--train_cameras', default=False, action="store_true", help='If set, optimizing also camera location.') - parser.add_argument('--scan_id', type=str, help='If set, taken to be the scan id.') + parser.add_argument('--scene_id', type=str, help='If set, taken to be the scene id.') opt = parser.parse_args() @@ -36,7 +36,7 @@ is_continue=opt.is_continue, timestamp=opt.timestamp, checkpoint=opt.checkpoint, - scan_id=opt.scan_id, + scene_id=opt.scene_id, train_cameras=opt.train_cameras ) diff --git a/code/training/idr_train.py b/code/training/idr_train.py index dac1411..1056201 100644 --- a/code/training/idr_train.py +++ b/code/training/idr_train.py @@ -21,9 +21,9 @@ def __init__(self,**kwargs): self.train_cameras = kwargs['train_cameras'] self.expname = self.conf.get_string('train.expname') + kwargs['expname'] - scan_id = kwargs['scan_id'] if kwargs['scan_id'] else self.conf.get_string('dataset.scan_id', default=None) - if scan_id: - self.expname = self.expname + '_{0}'.format(scan_id) + scene_id = kwargs['scene_id'] if kwargs['scene_id'] else self.conf.get_string('dataset.scene_id', default=None) + if scene_id: + self.expname = self.expname + '_{0}'.format(scene_id) if kwargs['is_continue'] and kwargs['timestamp'] == 'latest': if os.path.exists(os.path.join('../',kwargs['exps_folder_name'],self.expname)): @@ -78,8 +78,8 @@ def __init__(self,**kwargs): print('Loading data ...') dataset_conf = self.conf.get_config('dataset') - if kwargs['scan_id']: - dataset_conf['scan_id'] = kwargs['scan_id'] + if kwargs['scene_id']: + dataset_conf['scene_id'] = kwargs['scene_id'] self.train_dataset = utils.get_class(self.conf.get_string('train.dataset_class'))(self.train_cameras, **dataset_conf)