Skip to content

Commit

Permalink
experiments
Browse files Browse the repository at this point in the history
  • Loading branch information
sarafridov committed Nov 11, 2021
1 parent 19fde22 commit 4b7c4d6
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 2 deletions.
9 changes: 7 additions & 2 deletions opt/opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
group.add_argument('--tv_lumisphere_dir_factor', type=float, default=0.0)

group.add_argument('--lambda_l2_sh', type=float, default=0.0)#1e-4)
group.add_argument('--tv_early_only', type=int, default=1) # Turn off TV regularization after the first split/prune
# End Foreground TV

group.add_argument('--lambda_sparsity', type=float, default=
Expand Down Expand Up @@ -211,6 +212,7 @@

group.add_argument('--lr_decay', action='store_true', default=True)

group.add_argument('--n_train', type=int, default=None, help='Number of training images. Defaults to use all avaiable.')
args = parser.parse_args()
config_util.maybe_merge_config_file(args)

Expand Down Expand Up @@ -239,6 +241,7 @@
split="train",
device=device,
factor=factor,
n_images=args.n_train,
**config_util.build_data_options(args))

if args.background_nlayers > 0 and not dset.should_use_background:
Expand Down Expand Up @@ -554,8 +557,10 @@ def train_step():
last_upsamp_step = gstep_id_base
if reso_id < len(reso_list) - 1:
print('* Upsampling from', reso_list[reso_id], 'to', reso_list[reso_id + 1])
# args.lambda_tv = 0
# args.lambda_tv_sh = 0
if args.tv_early_only > 0:
print('turning off TV regularization')
args.lambda_tv = 0.0
args.lambda_tv_sh = 0.0
reso_id += 1
use_sparsify = True
z_reso = reso_list[reso_id] if isinstance(reso_list[reso_id], int) else reso_list[reso_id][2]
Expand Down
18 changes: 18 additions & 0 deletions opt/tasks/interpablate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"eval": true,
"data_root": "/home/sxyu/data/nerf_synthetic",
"train_root": "/home/sfk/svox2/opt/ckpt_auto/nearestneighbor",
"variables": {
"scene": ["lego", "mic", "ship", "chair", "ficus", "materials", "drums", "hotdog"],
"reso": ["[[256,256,256]]", "[[128,128,128]]"]
},
"tasks": [{
"train_dir": "{reso}_3e0_{scene}",
"data_dir": "{scene}",
"flags": [
"-B", "svox1",
"--lr_sigma", "3e0",
"--reso", "{reso}"
]
}]
}
16 changes: 16 additions & 0 deletions opt/tasks/ntrainablate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"eval": true,
"data_root": "/home/sxyu/data/nerf_synthetic",
"train_root": "/home/sfk/svox2/opt/ckpt_auto/256_to_512_tvearlyonly_ntrain",
"variables": {
"scene": ["lego", "mic", "ship", "chair", "ficus", "materials", "drums", "hotdog"],
"n_train": [25]
},
"tasks": [{
"train_dir": "train_{n_train}_{scene}",
"data_dir": "{scene}",
"flags": [
"--n_train", "{n_train}"
]
}]
}
16 changes: 16 additions & 0 deletions opt/tasks/tvearlyonly.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"eval": true,
"data_root": "/home/sxyu/data/nerf_synthetic",
"train_root": "/home/sfk/svox2/opt/ckpt_auto/256_to_512",
"variables": {
"scene": ["lego", "mic", "ship", "chair", "ficus", "materials", "drums", "hotdog"],
"tv_early_only": [0, 1]
},
"tasks": [{
"train_dir": "tv_early_only_{tv_early_only}_{scene}",
"data_dir": "{scene}",
"flags": [
"--tv_early_only", "{tv_early_only}"
]
}]
}
10 changes: 10 additions & 0 deletions opt/util/obj_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(
scale : Optional[float] = None,
permutation: bool = True,
white_bkgd: bool = True,
n_images = None,
**kwargs
):
assert path.isdir(root), f"'{root}' is not a directory"
Expand Down Expand Up @@ -88,6 +89,15 @@ def __init__(
self.gt = self.gt[..., :3]

self.n_images, self.h_full, self.w_full, _ = self.gt.shape
# Choose a subset of training images
if n_images is not None:
if n_images > self.n_images:
print(f'using {self.n_images} available training views instead of the requested {n_images}.')
n_images = self.n_images
self.n_images = n_images
self.gt = self.gt[0:n_images,...]
self.c2w = self.c2w[0:n_images,...]

self.intrins_full : Intrin = Intrin(focal, focal,
self.w_full * 0.5,
self.h_full * 0.5)
Expand Down

0 comments on commit 4b7c4d6

Please sign in to comment.