Skip to content

Commit

Permalink
Using scene_id instead of scan_id
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardramon committed Jan 4, 2021
1 parent 5ad56f2 commit 7b0a8eb
Show file tree
Hide file tree
Showing 19 changed files with 40 additions and 40 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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]
```


Expand All @@ -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]
```


Expand Down
2 changes: 1 addition & 1 deletion code/confs/ablation/dtu_fixed_noisy_cameras.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion code/confs/ablation/dtu_no_feature_vector.conf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ loss{
dataset{
data_dir = DTU
img_res = [1200, 1600]
scan_id = scan114
scene_id = scan114
}
model{
feature_vector_size = 0
Expand Down
2 changes: 1 addition & 1 deletion code/confs/ablation/dtu_no_normal.conf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ loss{
dataset{
data_dir = DTU
img_res = [1200, 1600]
scan_id = scan114
scene_id = scan114
}
model{
feature_vector_size = 256
Expand Down
2 changes: 1 addition & 1 deletion code/confs/ablation/dtu_no_view_dir.conf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ loss{
dataset{
data_dir = DTU
img_res = [1200, 1600]
scan_id = scan114
scene_id = scan114
}
model{
feature_vector_size = 256
Expand Down
2 changes: 1 addition & 1 deletion code/confs/crx_fixed_cameras.conf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ loss{
dataset{
data_dir = DTU
img_res = [600, 800]
scan_id = scan65
scene_id = scan65
}
model{
feature_vector_size = 256
Expand Down
2 changes: 1 addition & 1 deletion code/confs/crx_fixed_cameras_disentangled.conf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ loss{
dataset{
data_dir = CRX
img_res = [600, 804]
scan_id = scan65
scene_id = scan65
}
model{
geometry_network
Expand Down
2 changes: 1 addition & 1 deletion code/confs/crx_trained_cameras.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ loss{
dataset{
data_dir = CRX
img_res = [600, 804]
scan_id = scan65
scene_id = scan65
}
model{
feature_vector_size = 256
Expand Down
2 changes: 1 addition & 1 deletion code/confs/crx_trained_cameras_disentangled.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ loss{
dataset{
data_dir = CRX
img_res = [600, 804]
scan_id = scan65
scene_id = scan65
}
model{
geometry_network
Expand Down
2 changes: 1 addition & 1 deletion code/confs/crx_trained_cameras_prior.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ loss{
dataset{
data_dir = CRX
img_res = [600, 804]
scan_id = scan65
scene_id = scan65
}
model{
geometry_network
Expand Down
2 changes: 1 addition & 1 deletion code/confs/crx_trained_cameras_prior_latent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ loss{
dataset{
data_dir = CRX
img_res = [600, 804]
scan_id = scan65
scene_id = scan65
}
model{
geometry_network
Expand Down
2 changes: 1 addition & 1 deletion code/confs/dtu_fixed_cameras.conf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ loss{
dataset{
data_dir = DTU
img_res = [1200, 1600]
scan_id = scan65
scene_id = scan65
}
model{
feature_vector_size = 256
Expand Down
2 changes: 1 addition & 1 deletion code/confs/dtu_trained_cameras.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ loss{
dataset{
data_dir = DTU
img_res = [1200, 1600]
scan_id = scan65
scene_id = scan65
}
model{
feature_vector_size = 256
Expand Down
2 changes: 1 addition & 1 deletion code/confs/dummy_fixed_cameras.conf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ loss{
dataset{
data_dir = dummy
img_res = [64, 64]
scan_id = scan0
scene_id = scan0
}
model{
geometry_network
Expand Down
4 changes: 2 additions & 2 deletions code/datasets/scene_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions code/evaluation/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand All @@ -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
Expand Down Expand Up @@ -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,):
Expand Down Expand Up @@ -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.')
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions code/evaluation/eval_disentanglement.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions code/training/exp_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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
)

Expand Down
10 changes: 5 additions & 5 deletions code/training/idr_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 7b0a8eb

Please sign in to comment.