Giter Club home page Giter Club logo

freenerf's Introduction

[CVPR23] FreeNeRF: Improving Few-shot Neural Rendering with Free Frequency Regularization

This repository contains the code release for the CVPR 2023 project

FreeNeRF: Improving Few-shot Neural Rendering with Free Frequency Regularization,
Jiawei Yang, Marco Pavone, and Yue Wang
Computer Vision and Pattern Recognition (CVPR), 2023

The code is based on RegNeRF implementation.

Teaser Image

About FreeNeRF

Novel view synthesis with sparse inputs is a challenging problem for neural radiance fields (NeRF). Recent efforts alleviate this challenge by introducing external supervision, such as pre-trained models and extra depth signals, and by non-trivial patch-based rendering. In this paper, we present Frequency regularized NeRF (FreeNeRF), a surprisingly simple baseline that outperforms previous methods with minimal modifications to the plain NeRF. We analyze the key challenges in few-shot neural rendering and find that frequency plays an important role in NeRF's training. Based on the analysis, we propose two regularization terms. One is to regularize the frequency range of NeRF's inputs, while the other is to penalize the near-camera density fields. Both techniques are ``free lunches'' at no additional computational cost. We demonstrate that even with one line of code change, the original NeRF can achieve similar performance as other complicated methods in the few-shot setting. FreeNeRF achieves state-of-the-art performance across diverse datasets, including Blender, DTU, and LLFF. We hope this simple baseline will motivate a rethinking of the fundamental role of frequency in NeRF's training under the low-data regime and beyond.

TL;DR: We use frequency regularization and occlusion regularization to improve few-shot neural rendering. Both techniques can be implemented with a few lines of code.

Installation

We recommend to use Anaconda to set up the environment. First, create a new freenerf environment:

conda create -n freenerf python=3.6.15

Next, activate the environment:

conda activate freenerf

You can then install the dependencies:

pip install -r requirements.txt

Finally, install jaxlib with the correct CUDA version. For example, if you have CUDA 11.0 installed, you can run

pip install --upgrade pip
pip install --upgrade jaxlib==0.1.68+cuda110 -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html

Data

Please follow RegNeRF's data preparation instructions to prepare the DTU and LLFF datasets.

Running the code

Training an new model

For training a new model from scratch, you need to first need to define your CUDA devices. For example, when having access to 4 GPUs, you can run

export CUDA_VISIBLE_DEVICES=0,1,2,3

and then you can start the training process by calling

python train.py --gin_configs configs/{CONFIG}

where you replace {CONFIG} with the config you want to use.

We provide the config files for FreeNeRF, RegNeRF, and our direct baseline mipNeRF in the configs folder. In the config files, you might need to adjust the Config.data_dir argument pointing to your dataset location. For the DTU dataset, you might further need to adjust the Config.dtu_mask_path argument.

We provide the wandb interface for logging. You might need to install wandb and change the the wandb settings in inter/configs.py to fit your own wandb account.


Alternatively, we provide some sample scripts for training our models in the sample_scripts folder. For example, you can run

bash sample_scripts/train_eval_dtu.sh freenerf 3 30 where freenerf is the method name, 3 is the number of shots, and 30 is the scan ID. Please refer to the sample_scripts folder for more details.

Rendering test images

You can render and evaluate test images by running

python eval.py --gin_configs configs/{CONFIG}

where you replace {CONFIG} with the config you want to use. Similarly, you can render a camera trajectory (which we used for our videos) by running

python render.py --gin_configs configs/{CONFIG}

Reproducing the results

Our results are obtained on 4 NVIDIA A40 GPUs. The results can be slightly different across different runs due to the randomness in the training process. For example, in the DTU dataset, we can obtain a PSNR as high as 20.21 dB under the 3-shot setting, compared to 19.92 dB in the paper.

Please find the results and models in this google drive. Note that these results are reproduced versions and might not strictly be the same as those on our project page. In addition, we use the reg_end_ratio in the provided config files instead of the explicit reg_end iterations in this code.

  • We will release the pre-trained models soon.

Citation

If you find our work useful, please cite it as

@InProceedings{Yang2023FreeNeRF,
    author    = {Jiawei Yang and Marco Pavone and Yue Wang},},  
    title     = {FreeNeRF: Improving Few-shot Neural Rendering with Free Frequency Regularization},
    booktitle = {Proc. IEEE Conf. on Computer Vision and Pattern Recognition (CVPR)},
    year      = {2023},
}

freenerf's People

Contributors

jiawei-yang 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  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  avatar  avatar  avatar  avatar  avatar  avatar

freenerf's Issues

Can this work be combined with multi-resolution hash coding?

It's a great job!
But I noticed that your results were obtained on 4 NVIDIA A40 GPUs.
This is very counterintuitive, less mirrors of the training view will increase the burden of training.
Can it be combined with hash multi-resolution coding to speed up training time and reduce GPU burden?

Best wish
Chenglong

About frequency regularization mask in code

Very good job, but I have a doubt about the code. In the function get_freq_reg_mask in the math.py, why don't you multiply the ptr by 3 when calculating the frequency mask fractional part?
For example:
freq_mask[int_ptr * 3 : int_ptr * 3 + 3] =3* (ptr - int_ptr)
Please forgive me if there is a misunderstanding.

Updated Requirements

Very cool paper! I tried installing and running the repository but encountered several issues today while setting up an environment. Do you have an updated / more recent requirements.txt file? Or a Docker file? Python 3.6.15 and the stated repositories cause some issues. I couldn't resolve all the dependencies with Conda and Pip.

Blender configuration files

Hello @eadien,

Thank you for the great work on this paper!

I was wondering if it would be possible for you to share the config files you have used to create the results on the blender datasets? It would be nice to use the same configuration values to reproduce the results.

Thank you in advance for your answer!

Extremely slow when launching the experiments

Hi jiawei,
When I ran RegNeRF on Nvidia GPU, the Jax compilation stage is extremely time consuming (more than 20 minutes). I noticed that your code is based on Jax, have you ever encountered this problem?

BTW, I also noticed that for RegNeRF, GPU consumes more than 23 GB with only batchsize 1024. Do you have any idea why is that so high?

question about freq mask code

Looking at the frequency mask computation function, I'm a bit confused on this line. Wouldn't this always constraint ptr to be <2 ? How would we be able to mask more frequencies this way?

ptr = pos_enc_length / 3 * current_iter / total_reg_iter + 1

Training with custom dataset

Hi, thanks for your great work.
I want to train on my own dataset that I have, so what data would I need apart from the image files?
Could you provide some details on how to train on custom datasets?

Generalizable NeRF

Great job!I wanna ask that do you think regularizing the frequency of positional encoding could help improve the Generalizable NeRF?

question about updates in the Dietnerf folder

May I ask where the code is added specifically in the Dietnerf folder? The content in run_ nerf.py & run_ nerf_helpers.py is consistent with the original version. And the 'get_freq_mask' function in utils.py is not applied. Thanks

Performance Issue

Thanks for your great work.
However, I find that the performance improvement does not come from your novel "frequency mask". You set positional encoding to be "mask+ concatenation of xyz", while I set the mask to be all 1 all other NeRF still get a huge improvement (like RegNeRF).

In other paper, they do not use concatenation of xyz to positional encoding, while you do. And you claim mainly for mask. In that case, I think your claim somewhat is wrong in the paper.

Im having a tough time with the copy and paste instructions.

When I open up Anaconda and paste
conda create -n freenerf python=3.6.15
it returns
(base) C:\Users\alexm>conda create -n freenerf python=3.6.15
Collecting package metadata (current_repodata.json): done
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed

PackagesNotFoundError: The following packages are not available from current channels:

  • python=3.6.15

Current channels:

To search for alternate channels that may provide the conda package you're
looking for, navigate to

https://anaconda.org

and use the search bar at the top of the page.

Novelty of frequency regularization

Hi,
Thanks for sharing the work. May I know how the frequency regularization is different from that proposed in barf and other papers?

Paper mentions "We note that our frequency regularization shares some similarities with the coarse-to-fine frequency schedules used in other works [23, 16]. Different from theirs, our work focuses on the few-shot neural rendering problem and reveals the catastrophic failure patterns caused by high frequency inputs and their implication to this problem". But does it have a relevant technical difference?

Outdated python version and package conflicts

As Python3.6 is no longer supported by conda anymore (stated in the official conda website), I used the channel conda-forge to build the virtual environment, which is similar to this issue.

However, after building the virtual environment, I found some errors while running the requirements.txt. The following shows the details:

image

Is there any solution to this issue? Or do you provide any updated version of the code please? Thanks.

render.py error

After training, python render.py --gin_configs configs/{CONFIG} ran into an error while python eval.py --gin_configs configs/{CONFIG} didn't. This seems to be related with the definition of render_eval_fn.

However, when I replace render_eval_fn of render.py with that of eval.py, there is no error but the rendering looks unreasonable. Can the author please look into it and make render.py work normally? I am using LLFF dataset and 3 input views.

Nerf representations

-> Is it possible to extract a mesh from the output weights similar to the .ipynb file provided in the original nerf repo using marching cubes.

Why does few-shot require such a large video memory?

thanks for your work!
I tried to implement occlusion regularization on tensorRF, but 22G video memory is not enough for rendering test.
I want to know why the video memory within 10G in multi-view can be used for most of the nerf generation, but few shots need such video memory.

I can't solve these dependency problems

Oryx 0.2.1 is looking for Jaxlib 0.1.68 which doesn't exist. Its not on pypi.org.
ERROR: Could not find a version that satisfies the requirement jaxlib==0.1.68 (from oryx) (from versions: none)
ERROR: No matching distribution found for jaxlib==0.1.68
I have tryed installing different versions of oryx but then they require different versions of Jaxlib and I have been repeatedly defeated trying to install the correct iteration of jax or jaxlib. I'll try some more when I have more time and patience.

Training on Nerf_LLFF dataset

Hi, your codebase is really good and well maintained!
I am trying to replicate the renderings and training on nerf_llff dataset but keep running into the issue of

raise RuntimeError(f'images.shape[0]={images.shape[0]}, ' +f'but poses.shape[0]={poses.shape[0]}')

The dataset is in the same format as mentioned in the RegNerf repo and the path have also been configured accordingly based on the configs file.

What may the reason for the issue. Please would you help me out! @Jiawei-Yang

Regards
SriSiddarthC

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.