sarafridov / K-Planes

Other
479 stars 45 forks source link

How to train DyNeRF scenes ? #1

Open phongnhhn92 opened 1 year ago

phongnhhn92 commented 1 year ago

Hi, thanks for providing the code ! I am trying to train DyNeRF scenes but I keep on stucking at the dataloader part.

 'isg': False,
 'isg_step': -1,
 'linear_decoder': False,
 'logdir': './logs/realdynamic',
 'ndc': True,
 'num_samples': 48,
 'num_steps': 90001,
 'optim_type': 'adam',
 'plane_tv_weight': 0.0002,
 'plane_tv_weight_proposal_net': 0.0002,
 'proposal_net_args_list': [{'num_input_coords': 4,
                             'num_output_coords': 8,
                             'resolution': [128, 128, 128, 150]},
                            {'num_input_coords': 4,
                             'num_output_coords': 8,
                             'resolution': [256, 256, 256, 150]}],
 'save_every': 30000,
 'save_outputs': True,
 'scene_bbox': [[-3.0, -1.8, -1.2], [3.0, 1.8, 1.2]],
 'scheduler_type': 'warmup_cosine',
 'single_jitter': False,
 'time_smoothness_weight': 0.001,
 'time_smoothness_weight_proposal_net': 1e-05,
 'train_fp16': True,
 'use_proposal_weight_anneal': True,
 'use_same_proposal_network': False,
 'valid_every': 30000}
2023-01-25 15:42:09,846|    INFO| Loading Video360Dataset with downsample=2.0
Loading train data:  53%|███████████████████████████████████████████████████████████████████████████▎                                                                   | 10/19 [00:43<00:34,  3.84s/it

I saw the recommendation to train these scenes with data_downsample=4 for one step. How exactly can I do that ? Should I manually change 'num_steps': 1 ?

sarafridov commented 1 year ago

Thanks for trying the code out so quickly! To set up the importance sampling, you would set data_downsample to 4 and num_steps to 1 in the config you're using. Then once it finishes you can reset to the original parameters and run again to actually train. Be aware that the DyNeRF dataset is much larger than the other datasets, and it can take several minutes to load (the other datasets load in a few seconds).

NagabhushanSN95 commented 10 months ago

How does K-Planes remember the importance sampling across the two runs? Does it save any file containing the importance sampling weights during the first run (with downsample=4) and load these weights during the second run (with downsample=2)?

sarafridov commented 10 months ago

Yes, it saves files called isg_weights.pt and ist_weights.pt with the importance sampling weights. I included these files for some of the scenes in the raw outputs folder on Google Drive, in case that is useful.

NagabhushanSN95 commented 10 months ago

Great! Thank you, for the clarification. One follow-up question. I am running out of memory (CPU RAM) when creating the isg_weights.pt and ist_weights.pt files for cutbeef scene with downsample=4. Would the performance take a serious hit if I create the importance sampling weights with downsample=8? Would you suggest any alternative to overcome the memory issue?

sarafridov commented 10 months ago

You could try with downsample 8; I don't expect it would hurt performance that much but there's a risk I might have hardcoded the 4 somewhere, so it might error but hopefully not. It's also not that much worse if you train without any importance sampling at all, though you will lose some details in the dynamic regions.

NagabhushanSN95 commented 10 months ago

I generated weights with down=8 and trained the model with down=2. The code didn't throw any error. So, I guess you haven't hard coded 4!

azzarelli commented 6 months ago

I'm going through something similar and saw the last comment. Just wanted to add that this bit is hardcoded https://github.com/sarafridov/K-Planes/blob/7e3a82dbdda31eddbe2a160bc9ef89e734d9fc54/plenoxels/datasets/video_datasets.py#L153