NeRF: Representing Scenes as Neural Radiance Fields for View Synthesis
Ben Mildenhall*1,
Pratul P. Srinivasan*1,
Matthew Tancik*1,
Jonathan T. Barron2,
Ravi Ramamoorthi3,
Ren Ng1
1UC Berkeley, 2Google Research, 3UC San Diego
*denotes equal contribution
A PyTorch re-implementation of Neural Radiance Fields.
Since the original release, and the concurrent pytorch implementation wrote all the codes basically in just two files, run_nerf.py
and run_nerf_helper.py
, which makes it very hard to read, along with many unnecessary operations, I re-organize the whole code architecture as below, which is more concise and readable.
βββ core
βΒ Β βββ datasets
βΒ Β βΒ Β βββ create_dataloader.py
βΒ Β βΒ Β βββ create_dataset.py
βΒ Β βΒ Β βββ create_rays.py
βΒ Β βΒ Β βββ load_blender.py
βΒ Β βΒ Β βββ load_deepvoxels.py
βΒ Β βΒ Β βββ load_llff.py
βΒ Β βββ models
βΒ Β βΒ Β βββ create_model.py
βΒ Β βΒ Β βββ embedder.py
βΒ Β βΒ Β βββ nerf.py
βΒ Β βββ utils
βΒ Β βββ create_configs.py
βΒ Β βββ metrics.py
βΒ Β βββ test_nerf_utils.py
βΒ Β βββ train_nerf_utils.py
βββ run_nerf.py
Besides the re-organization, I re-implement some of the core functions in NeRF:
core/datasets/dataset.py
: a unified dataset for blender, llff data type, with allN*H*W
rays generated;core/datasets/dataloader.py
: a unified dataloader for bothno_batching=True/False
;core/datasets/create_rays.py
: a vectorized implementation of rays generation,N*H*W
rays once;core/models/embedder.py
: a vectorized implementation of positional encoding;
With all the modifications describes above, this NeRF version is a littleπ« faster than the concurrent pytorch implementation, which may illustrates the bottleneck may relies on the caching of data, according to the re-implementaion by krrish94.
Download data for two example datasets: lego
and fern
bash download_example_data.sh
To train a low-res lego
NeRF:
python run_nerf.py --config configs/lego.txt
To train a high-res lego
NeRF:
python run_nerf.py --config configs/lego-official.txt
To train a low-res fern
NeRF:
python run_nerf.py --config configs/fern.txt
@misc{mildenhall2020nerf,
title={NeRF: Representing Scenes as Neural Radiance Fields for View Synthesis},
author={Ben Mildenhall and Pratul P. Srinivasan and Matthew Tancik and Jonathan T. Barron and Ravi Ramamoorthi and Ren Ng},
year={2020},
eprint={2003.08934},
archivePrefix={arXiv},
primaryClass={cs.CV}
}