Skip to content

neural radiance fields for novel view synthesis and 3d reconstruction

License

Notifications You must be signed in to change notification settings

stanleyedward/nerf_pytorch_lightning

Repository files navigation

Neural Radiance Fields

A neural radiance field ( NeRF ) is a simple fully connected network trained to reproduce input views of a single scene using a rendering loss. The network directly maps from spatial location and viewing direction (5D input) to colour and opacity (4D output), acting as the "volume" so we can use volume rendering to render new views differentiably.

nerf_output
Pipeline

Index

  1. My Renders
  2. Setup
  3. Training
  4. Evaluation
  5. References and Citations

My Renders

nerf_output
Novel Views
sphere
3D Reconstruction
  • Training graphs
loss
MSE
psnr
PSNR

Setup

  1. Clone and cd into the repository:

    git clone https://github.com/stanleyedward/nerf_pytorch_lightning.git
    cd nerf_pytorch_lightning
  2. Create and activate the conda environment:

    conda env create -f environment.yaml
    conda activate nerf
  3. Add the dataset to the dataset/ directory:

Training

note: Setup should be complete

  1. Change configurations

    In the config.py file

    """------------------------NeRF Config------------------------"""
    # data
    IMG_SIZE: int = 400
    BATCH_SIZE: int = 3072
    ...
    DEVICES: int = torch.cuda.device_count()
    MAX_EPOCHS: int = 17
  2. Run the train.py script

    python train.py

Evaluation

note: Setup should be complete

  1. Change configurations

    In the config.py file

    """------------------------NeRF Config------------------------"""
    ...
    #eval
    CKPT_DIR: str = "models/16_epoch_192_bins_400_nerf.ckpt" 
    CHUNK_SIZE: int = 20  # increase chunksize prevent CUDA out of memory errors
    OUTPUTS_DIR: str = "outputs" #folder you want to save the novel views in
  2. Run the eval.py script

    python eval.py

References and Citations

@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}
}
@misc{queianchen_nerf,
  author={Quei-An, Chen},
  title={Nerf_pl: a pytorch-lightning implementation of NeRF},
  url={https://github.com/kwea123/nerf_pl/},
  year={2020},
}
@misc{lin2020nerfpytorch,
  title={NeRF-pytorch},
  author={Yen-Chen, Lin},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished={\url{https://github.com/yenchenlin/nerf-pytorch/}},
  year={2020}
}