This repository contains the code release for NeRFocus: Neural Radiance Field for 3D Synthetic Defocus. This implementation is written in JAX, and is a fork of Jon Barron's Mip-NeRF implementation.
git clone https://github.com/wyhuai/nerfocus.git; cd nerfocus
conda install pip; pip install --upgrade pip
pip install -r requirements.txt
We provide a pretrained model in experiments/horns, so you can run the following command to generate a video with defocus effects. You may change the lens parameters "l" and "a" in eval_vid.py to adjust the focus distance and aperture size.
python -m eval_vid --data_dir=horns --train_dir=experiments/horns --chunk=3196 --gin_file=configs/llff.gin --logtostderr
You can download the datasets from the NeRF official Google Drive.
You can generate the multi-blur datasets by running datatool.py, remember to change your desired data path and the blur kernel size.
Run the following command, make sure the path is correct. You also need to change the path inside train.py to your data path.
python -m train --data_dir=horns --train_dir=experiments/horns --gin_file=configs/llff.gin --logtostderr
You can also train your own dataset, as long as it confroms to NeRF data format.