Git Product home page Git Product logo

dp-nerf's Introduction

Official implementation of DP-NeRF.

DP-NeRF: Deblurred Neural Radiance Field with Physical Scene Priors (CVPR 2023)

We propose DP-NeRF, a novel neural radiance field (NeRF) framework, that reconstructs the clean 3D scene from blurry images applying rigid blurring kernel (RBK) based on physical scene priors. We impose the physical constraints on the blurring kernel of neural radiance field inspired by the in-camera blurring process during image acquisition on the 3D scene.

Overview

DP-NeRF models the rigid blurring kernel (RBK) which preserve the 3D geomentric and appearance consistency to reconstruct the clean neural radiance field (NeRF) from blurry inputs. RBK is formulated as rigid motions of the cameras which are shared with all pixels in a single image. It effectively model the blind blurring kernel on each images by imposing physical constraints of the acquired blurred image imitating blurring process.

Training & Evaluation

1. Environment

git clone https://github.com/dogyoonlee/DP-NeRF.git
cd DP-NeRF
pip install -r requirements.txt
Dependencies (click to expand)
  • numpy
  • scikit-image
  • torch>=1.8
  • torchvision>=0.9.1
  • imageio
  • imageio-ffmpeg
  • matplotlib
  • configargparse
  • tensorboardX>=2.0
  • opencv-python
  • einops
  • tensorboard
  • 2. Download dataset

    We use the dataset from Deblur-NeRF to train the DP-NERF. Download the dataset from here.

    There are total of 31 scenes used in the paper, 5 synthetic scene and 10 real-world scene for each blur type: camera-motion blur, defocus blur. In addition, there are 1 scene for object motion blur which are refered as temporal inconsistency in our paper.

    Note that, quantitative evaluation of the bush scene in real-defocus dataset is excluded in the paper since there are no clean ground truth image to evaluate.

    3. Set parameters

    Change the training parameters to train on your computer. You must change the basedir, datadir, and tbdir.

    Training Options (click to expand)
    • expname: name of the experiment.
    • rbk_use_origin: use origin ray to train the RBK. Default to use.
    • rbk_num_motion: the number of rigid motion. k in the paper.
    • use_dpnerf: use rigid blurring kernel.
    • use_awp: use adaptive weight proposal.
    • use_coarse_to_fine_opt: use coarse-to-fine optimization.

    4. Train

    For example, to train blurpool scene,

    python run_dpnerf.py --config ./configs/blurpool/tx_blurpool_dpnerf.txt --expname $experiment_name
    

    The training and tensorboard results will be save in <basedir>/<expname> and <tbdir>.

    5. Evaluation

    Evaluation is automatically executed every --i_testset iterations. Please refer the other logging options in run_dpnerf.py to adjust save and print the results.

    After the training, execute the evaluation results following command. For example, to evaluate blurpool scene after 200000 iteration,

    python run_dpnerf.py --config ./configs/blurpool/tx_blurpool_dpnerf.txt --expname $dir_to_log --ft_path ./<basedir>/<expname>/200000.tar --render_only --render_test
    

    Pretrained Weights

    We additionally provide the pretrained weight sample for blurpool scene in here.

    We cannot provide the pretrained weights for full scene since we did refactoring on the code after submit our work on the conference.

    Hence, we trained our model again for blurpool scene.

    The evaluation result of the provided sample weight is as follows:

    PNSR SSIM LPIPS
    Blurpool(paper) 31.96 0.8768 0.0908
    Blurpool(provided weight) 32.04 0.8754 0.0873

    Visualization

    You can render or save the results after 200000 iteration of training following process.

    1. Visualization of trained model

    Visualize the trained model as videos of spiral-path.

    Results will be saved in ./<basedir>/<dir_to_log>/renderonly_path_199999.

    python run_dpnerf.py --config ./configs/blurpool/tx_blurpool_dpnerf.txt --expname $dir_to_log --ft_path ./<basedir>/<expname>/200000.tar --render_only 
    

    Visualize the trained model as images of training views in datasets.

    Results will be saved in ./<basedir>/<dir_to_log>/renderonly_test_199999

    python run_dpnerf.py --config ./configs/blurpool/tx_blurpool_dpnerf.txt --expname $dir_to_log --ft_path ./<basedir>/<expname>/200000.tar --render_only  --render_test
    

    2. Save the warped poses and images

    Results will be saved in ./<basedir>/<dir_to_log>/warped_ray_img_path_199999

    python run_dpnerf.py --config ./configs/blurpool/tx_blurpool_dpnerf.txt --expname $dir_to_log --ft_path ./<basedir>/<expname>/200000.tar --save_warped_ray_img
    

    3. Visualize the warped rays

    You can visualize the warped rays in specific image index using following command.

    Note that, you should modify the code of plotting rays in here of warped_rays_vis.py correponding to your trained model (rbk_num_motion) in saved checkpoint.

    python warped_rays_vis.py --config ./configs/blurpool/tx_blurpool_dpnerf.txt --warped_rays_path $warped_ray_saved_dir/rays_warped.npy
    

    Notes

    GPU memory

    DP-NeRF require gradually large memory as the number of rigid motion increases. It is same drawback with Deblur-NeRF. If you have not enough memory to train on your single GPU, set N_rand to a smaller value, or use multiple GPUs.

    Multi-GPUs training

    To train the DP-NeRF with multiple gpus, please set num_gpu=<num_gpu>.

    Original NeRF training

    To train original NeRf, set blur_model_type = none.

    License

    MIT License

    Citation

    If you find our work useful in your research, please consider citing:

    @InProceedings{Lee_2023_CVPR,
        author    = {Lee, Dogyoon and Lee, Minhyeok and Shin, Chajin and Lee, Sangyoun},
        title     = {DP-NeRF: Deblurred Neural Radiance Field With Physical Scene Priors},
        booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
        month     = {June},
        year      = {2023},
        pages     = {12386-12396}
    }
    
    @article{lee2022deblurred,
      title={Deblurred Neural Radiance Field with Physical Scene Priors},
      author={Lee, Dogyoon and Lee, Minhyeok and Shin, Chajin and Lee, Sangyoun},
      journal={arXiv preprint arXiv:2211.12046},
      year={2022}
    }
    

    Acknowledgement

    The structure of this codebase is borrowed from Deblur-NeRF.

    dp-nerf's People

    Contributors

    dogyoonlee avatar

    Stargazers

     avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

    Watchers

     avatar  avatar  avatar

    dp-nerf's Issues

    Effectiveness of entropy loss

    Hi! Thanks to your great work!

    I noticed that there exists some modifed EntropyLoss in your codebase which is not being used. Does it work in your experiments? It would be great if you could share your thoughts on it.

    Problem about llff dataset.

    I train dp-nerf on the blurred LLFF data ( generated by applying blur kernel), and resize the input to 252x188. The results are like this.
    010
    000
    It seems like that the main obj in the image disappears, are there any parameters need to adjust with resolution?

    RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation

    [TRAIN] Iter: 600 Loss: 0.023193560540676117 PSNR: 19.362762451171875 TIME: 0h:0m:40.74s
    [TRAIN] Iter: 800 Loss: 0.01994657889008522 PSNR: 20.115781784057617 TIME: 0h:0m:53.53s
    [TRAIN] Iter: 1000 Loss: 0.018907170742750168 PSNR: 20.629796981811523 TIME: 0h:1m:6.02s
    Traceback (most recent call last):
    File "/DP-NeRF-main/run_dpnerf.py", line 753, in
    train()
    File "/DP-NeRF-main/run_dpnerf.py", line 639, in train
    loss.backward()
    File "/lcy_DP/lib/python3.9/site-packages/torch/_tensor.py", line 396, in backward
    torch.autograd.backward(self, gradient, retain_graph, create_graph, inputs=inputs)
    File "/miniconda3/envs/lcy_DP/lib/python3.9/site-packages/torch/autograd/init.py", line 173, in backward
    Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass
    RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [512]], which is output 0 of LinalgVectorNormBackward0, is at version 1; expected version 0 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).

    训练到1000iter时报错,这个怎么解决呀.是pytorch版本问题吗。我的版本为pyorch==1.12.1

    Would you like to share the pretrained weights please?

    Hi teams, thanks for sharing your awesome work!

    I want to train your model on real scenes data, but unfortunately, I cannot because of my GPU memory limit.

    Though I can reduce batch size but I want to see the result from the model that is used in your paper, so would you like to share the what you trained if it is fine?

    Thanks!

    loss.backward() error

    RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [1024]], which is output 0 of LinalgVectorNormBackward0, is at version 1; expected version 0 instead.

    Recommend Projects

    • React photo React

      A declarative, efficient, and flexible JavaScript library for building user interfaces.

    • Vue.js photo Vue.js

      🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

    • Typescript photo Typescript

      TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

    • TensorFlow photo TensorFlow

      An Open Source Machine Learning Framework for Everyone

    • Django photo Django

      The Web framework for perfectionists with deadlines.

    • D3 photo D3

      Bring data to life with SVG, Canvas and HTML. 📊📈🎉

    Recommend Topics

    • javascript

      JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

    • web

      Some thing interesting about web. New door for the world.

    • server

      A server is a program made to process requests and deliver data to clients.

    • Machine learning

      Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

    • Game

      Some thing interesting about game, make everyone happy.

    Recommend Org

    • Facebook photo Facebook

      We are working to build community through open source technology. NB: members must have two-factor auth.

    • Microsoft photo Microsoft

      Open source projects and samples from Microsoft.

    • Google photo Google

      Google ❤️ Open Source for everyone.

    • D3 photo D3

      Data-Driven Documents codes.