You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
3.9 KiB
Markdown

4 years ago
# NeRF++
4 years ago
Codebase for arXiv preprint ["NeRF++: Analyzing and Improving Neural Radiance Fields"](http://arxiv.org/abs/2010.07492)
4 years ago
* Work with 360 capture of large-scale unbounded scenes.
4 years ago
* Support multi-gpu training and inference with PyTorch DistributedDataParallel (DDP).
4 years ago
* Optimize per-image autoexposure (**experimental feature**).
4 years ago
4 years ago
## Demo
![](demo/tat_Truck.gif) ![](demo/tat_Playground.gif)
4 years ago
## Data
4 years ago
* Download our preprocessed data from [tanks_and_temples](https://drive.google.com/file/d/11KRfN91W1AxAW6lOFs4EeYDbeoQZCi87/view?usp=sharing), [lf_data](https://drive.google.com/file/d/1gsjDjkbTh4GAR9fFqlIDZ__qR9NYTURQ/view?usp=sharing).
* Put the data in the sub-folder data/ of this code directory.
4 years ago
* Data format.
4 years ago
* Each scene consists of 3 splits: train/test/validation.
4 years ago
* Intrinsics and poses are stored as flattened 4x4 matrices (row-major).
4 years ago
* Pixel coordinate of an image's upper-left corner is (column, row)=(0, 0), lower-right corner is (width-1, height-1).
4 years ago
* Poses are camera-to-world, not world-to-camera transformations.
4 years ago
* Opencv camera coordinate system is adopted, i.e., x--->right, y--->down, z--->scene. Similarly, intrinsic matrix also follows Opencv convention.
4 years ago
* To convert camera poses between Opencv and Opengl conventions, the following code snippet can be used for both Opengl2Opencv and Opencv2Opengl.
4 years ago
```python
import numpy as np
def convert_pose(C2W):
flip_yz = np.eye(4)
flip_yz[1, 1] = -1
flip_yz[2, 2] = -1
C2W = np.matmul(C2W, flip_yz)
return C2W
```
4 years ago
* Scene normalization: move the average camera center to origin, and put all the camera centers inside the unit sphere.
## Create environment
```bash
conda env create --file environment.yml
4 years ago
conda activate nerfplusplus
4 years ago
```
4 years ago
4 years ago
## Training (Use all available GPUs by default)
4 years ago
```python
python ddp_train_nerf.py --config configs/tanks_and_temples/tat_training_truck.txt
```
4 years ago
## Testing (Use all available GPUs by default)
4 years ago
```python
4 years ago
python ddp_test_nerf.py --config configs/tanks_and_temples/tat_training_truck.txt \
--render_splits test,camera_path
4 years ago
```
4 years ago
4 years ago
**Note**: due to restriction imposed by torch.distributed.gather function, please make sure the number of pixels in each image is divisible by the number of GPUs if you render images parallelly.
4 years ago
4 years ago
## Citation
Plese cite our work if you use the code.
```python
@article{kaizhang2020,
author = {Kai Zhang and Gernot Riegler and Noah Snavely and Vladlen Koltun},
title = {NeRF++: Analyzing and Improving Neural Radiance Fields},
4 years ago
journal = {arXiv:2010.07492},
4 years ago
year = {2020},
}
```
4 years ago
## Generate camera parameters (intrinsics and poses) with [COLMAP SfM](https://colmap.github.io/)
You can use the scripts inside *'colmap_runner/'* to generate camera parameters from images with COLMAP SfM.
4 years ago
* Specify *'img_dir'* and *'out_dir'* in *'colmap_runner/run_colmap.py'*.
* Inside *'colmap_runner/'*, execute command *'python run_colmap.py'*.
4 years ago
* After program finishes, you would see the posed images in the folder *'out_dir/posed_images'*.
4 years ago
* Distortion-free images are inside *'out_dir/posed_images/images'*.
4 years ago
* Raw COLMAP intrinsics and poses are stored as a json file *'out_dir/posed_images/kai_cameras.json'*.
4 years ago
* Normalized cameras are stored in *'out_dir/posed_images/kai_cameras_normalized.json'*. See the *'Scene normalization method'* in the *'Data'* section.
4 years ago
* Split distortion-free images and their correspoinding normalized cameras according to your need.
## Visualize cameras in 3D
4 years ago
Check *camera_visualizer/visualize_cameras.py* for visualizing cameras in 3D. It creates an interactive viewer for you to inspect whether your cameras have been normalized to be compatible with this codebase. Below is a screenshot of the viewer: green cameras are used for training, blue ones are for testing, while yellow ones denote a novel camera path to be synthesized.
4 years ago
![](camera_visualizer/screenshot_lowres.png)