-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1787b9a
commit 5ee0751
Showing
31 changed files
with
4,459 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Anpei Chen | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# TensoRF | ||
## [Project page](https://apchenstu.github.io/TensoRF/) | [Paper](https://arxiv.org/abs/2203.09517) | ||
This repository contains a pytorch implementation for the paper: [TensoRF: Tensorial Radiance Fields](https://arxiv.org/abs/2203.09517). Our work present a novel approach to model and reconstruct radiance fields, which achieves super | ||
**fast** training process, **compact** memory footprint and **state-of-the-art** rendering quality.<br><br> | ||
|
||
|
||
https://user-images.githubusercontent.com/16453770/158920837-3fafaa17-6ed9-4414-a0b1-a80dc9e10301.mp4 | ||
## Installation | ||
|
||
#### Tested on Ubuntu 20.04 + Pytorch 1.10.1 | ||
|
||
Install environment: | ||
``` | ||
conda create -n TensoRF python=3.8 | ||
conda activate TensoRF | ||
pip install torch torchvision | ||
pip install tqdm scikit-image opencv-python configargparse lpips imageio-ffmpeg kornia lpips tensorboard | ||
``` | ||
|
||
|
||
## Dataset | ||
* [Synthetic-NeRF](https://drive.google.com/drive/folders/128yBriW1IG_3NJ5Rp7APSTZsJqdJdfc1) | ||
* [Synthetic-NSVF](https://dl.fbaipublicfiles.com/nsvf/dataset/Synthetic_NSVF.zip) | ||
* [Tanks&Temples](https://dl.fbaipublicfiles.com/nsvf/dataset/TanksAndTemple.zip) | ||
* [Forward-facing](https://drive.google.com/drive/folders/128yBriW1IG_3NJ5Rp7APSTZsJqdJdfc1) | ||
|
||
|
||
|
||
## Quick Start | ||
The training script is in `train.py`, to train a TensoRF: | ||
|
||
``` | ||
python train.py --config configs/lego.txt | ||
``` | ||
|
||
|
||
we provide a few examples in the configuration folder, please note: | ||
|
||
`dataset_name`, choices = ['blender', 'llff', 'nsvf', 'tankstemple']; | ||
|
||
`shadingMode`, choices = ['MLP_Fea', 'SH']; | ||
|
||
`model_name`, choices = ['TensorVMSplit', 'TensorCP'], corresponding to the VM and CP decomposition. | ||
You need to uncomment the last a few rows of the configuration file if you want to training with the TensorCP model; | ||
|
||
`n_lamb_sigma` and `n_lamb_sh` are string type refer to the basis number of density and appearance along XYZ | ||
dimension; | ||
|
||
`N_voxel_init` and `N_voxel_final` control the resolution of matrix and vector; | ||
|
||
`N_vis` and `vis_every` control the visualization during training; | ||
|
||
You need to set `--render_test 1`/`--render_path 1` if you want to render testing views or path after training. | ||
|
||
More options refer to the `opt.py`. | ||
|
||
### For pretrained checkpoints and results please see: | ||
[https://1drv.ms/u/s!Ard0t_p4QWIMgQ2qSEAs7MUk8hVw?e=dc6hBm](https://1drv.ms/u/s!Ard0t_p4QWIMgQ2qSEAs7MUk8hVw?e=dc6hBm) | ||
|
||
|
||
|
||
## Rendering | ||
|
||
``` | ||
python train.py --config configs/lego.txt --ckpt path/to/your/checkpoint --render_only 1 --render_test 1 | ||
``` | ||
|
||
You can just simply pass `--render_only 1` and `--ckpt path/to/your/checkpoint` to render images from a pre-trained | ||
checkpoint. You may also need to specify what you want to render, like `--render_test 1`, `--render_train 1` or `--render_path 1`. | ||
The rendering results are located in your checkpoint folder. | ||
|
||
## Extracting mesh | ||
You can also export the mesh by passing `--export_mesh 1`: | ||
``` | ||
python train.py --config configs/lego.txt --ckpt path/to/your/checkpoint --export_mesh 1 | ||
``` | ||
Note: Please re-train the model and don't use the pretrained checkpoints provided by us for mesh extraction, | ||
because some render parameters has changed. | ||
|
||
## Training with your own data | ||
We provide two options for training on your own image set: | ||
|
||
1. Following the instructions in the [NSVF repo](https://github.com/facebookresearch/NSVF#prepare-your-own-dataset), then set the dataset_name to 'tankstemple'. | ||
2. Calibrating images with the script from [NGP](https://github.com/NVlabs/instant-ngp/blob/master/docs/nerf_dataset_tips.md): | ||
`python dataLoader/colmap2nerf.py --colmap_matcher exhaustive --run_colmap`, then adjust the datadir in `configs/your_own_data.txt`. Please check the `scene_bbox` and `near_far` if you get abnormal results. | ||
|
||
|
||
## Citation | ||
If you find our code or paper helps, please consider citing: | ||
``` | ||
@article{tensorf, | ||
title={TensoRF: Tensorial Radiance Fields}, | ||
author={Chen, Anpei and Xu, Zexiang and Geiger, Andreas and Yu, Jingyi and Su, Hao}, | ||
journal={arXiv preprint arXiv:2203.09517}, | ||
year={2022} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
dataset_name = blender | ||
datadir = ../nerf_synthetic/chair | ||
expname = tensorf_lego_VM | ||
basedir = ./log | ||
|
||
n_iters = 30000 | ||
batch_size = 4096 | ||
|
||
N_voxel_init = 2097156 # 128**3 | ||
N_voxel_final = 27000000 # 300**3 | ||
upsamp_list = [2000, 3000, 4000, 5500, 7000] | ||
update_AlphaMask_list = [2000, 4000] | ||
|
||
N_vis = 5 | ||
vis_every = 10000 | ||
|
||
# lr_init = 0.005 # 0.001 # 0.5 # 0.02 # test | ||
# lr_basis = 0.005 # 0.001 # 0.02 # 0.001 # test | ||
|
||
render_test = 1 | ||
|
||
n_lamb_sigma = [16, 16, 16] | ||
n_lamb_sh = [48, 48, 48] | ||
model_name = TensorVMSplit | ||
|
||
shadingMode = MLP_Fea | ||
fea2denseAct = softplus | ||
|
||
view_pe = 2 | ||
fea_pe = 2 | ||
|
||
L1_weight_inital = 0 # 8e-5 | ||
L1_weight_rest = 0 # 4e-5 | ||
rm_weight_mask_thre = 1e-4 | ||
|
||
## please uncomment following configuration if hope to training on cp model | ||
#model_name = TensorCP | ||
#n_lamb_sigma = [96] | ||
#n_lamb_sh = [288] | ||
#N_voxel_final = 125000000 # 500**3 | ||
#L1_weight_inital = 1e-5 | ||
#L1_weight_rest = 1e-5 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
dataset_name = llff | ||
datadir = ./data/nerf_llff_data/flower | ||
expname = tensorf_flower_VM | ||
basedir = ./log | ||
|
||
downsample_train = 4.0 | ||
ndc_ray = 1 | ||
|
||
n_iters = 25000 | ||
batch_size = 4096 | ||
|
||
N_voxel_init = 2097156 # 128**3 | ||
N_voxel_final = 262144000 # 640**3 | ||
upsamp_list = [2000,3000,4000,5500] | ||
update_AlphaMask_list = [2500] | ||
|
||
N_vis = -1 # vis all testing images | ||
vis_every = 10000 | ||
|
||
render_test = 1 | ||
render_path = 1 | ||
|
||
n_lamb_sigma = [16,4,4] | ||
n_lamb_sh = [48,12,12] | ||
|
||
shadingMode = MLP_Fea | ||
fea2denseAct = relu | ||
|
||
view_pe = 0 | ||
fea_pe = 0 | ||
|
||
TV_weight_density = 1.0 | ||
TV_weight_app = 1.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
dataset_name = blender | ||
datadir = ./data/nerf_synthetic/lego | ||
expname = tensorf_lego_VM | ||
basedir = ./log | ||
|
||
n_iters = 30000 | ||
batch_size = 4096 | ||
|
||
N_voxel_init = 2097156 # 128**3 | ||
N_voxel_final = 27000000 # 300**3 | ||
upsamp_list = [2000,3000,4000,5500,7000] | ||
update_AlphaMask_list = [2000,4000] | ||
|
||
N_vis = 5 | ||
vis_every = 10000 | ||
|
||
render_test = 1 | ||
|
||
n_lamb_sigma = [16,16,16] | ||
n_lamb_sh = [48,48,48] | ||
model_name = TensorVMSplit | ||
|
||
|
||
shadingMode = MLP_Fea | ||
fea2denseAct = softplus | ||
|
||
view_pe = 2 | ||
fea_pe = 2 | ||
|
||
L1_weight_inital = 8e-5 | ||
L1_weight_rest = 4e-5 | ||
rm_weight_mask_thre = 1e-4 | ||
|
||
## please uncomment following configuration if hope to training on cp model | ||
#model_name = TensorCP | ||
#n_lamb_sigma = [96] | ||
#n_lamb_sh = [288] | ||
#N_voxel_final = 125000000 # 500**3 | ||
#L1_weight_inital = 1e-5 | ||
#L1_weight_rest = 1e-5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
dataset_name = blender | ||
datadir = ../nerf_synthetic/lego | ||
expname = tensorf_lego_VM | ||
basedir = ./log | ||
|
||
n_iters = 30000 | ||
batch_size = 4096 | ||
|
||
N_voxel_init = 2097156 # 128**3 | ||
N_voxel_final = 27000000 # 300**3 | ||
upsamp_list = [2000,3000,4000,5500,7000] | ||
update_AlphaMask_list = [2000,4000] | ||
|
||
n_vis = 5 | ||
vis_every = 10000 | ||
|
||
render_test = 1 | ||
|
||
n_lamb_sigma = [16,16,16] | ||
n_lamb_sh = [48,48,48] | ||
model_name = PREF | ||
|
||
shadingMode = MLP_Fea | ||
fea2denseAct = softplus | ||
|
||
view_pe = 2 | ||
fea_pe = 2 | ||
|
||
L1_weight_inital = 8e-5 | ||
L1_weight_rest = 4e-5 | ||
rm_weight_mask_thre = 1e-4 | ||
|
||
## please uncomment following configuration if hope to training on cp model | ||
#model_name = TensorCP | ||
#n_lamb_sigma = [96] | ||
#n_lamb_sh = [288] | ||
#N_voxel_final = 125000000 # 500**3 | ||
#L1_weight_inital = 1e-5 | ||
#L1_weight_rest = 1e-5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
|
||
dataset_name = tankstemple | ||
datadir = ./data/TanksAndTemple/Truck | ||
expname = tensorf_truck_VM | ||
basedir = ./log | ||
|
||
n_iters = 30000 | ||
batch_size = 4096 | ||
|
||
N_voxel_init = 2097156 # 128**3 | ||
N_voxel_final = 27000000 # 300**3 | ||
upsamp_list = [2000,3000,4000,5500,7000] | ||
update_AlphaMask_list = [2000,4000] | ||
|
||
N_vis = 5 | ||
vis_every = 10000 | ||
|
||
render_test = 1 | ||
|
||
n_lamb_sigma = [16,16,16] | ||
n_lamb_sh = [48,48,48] | ||
|
||
shadingMode = MLP_Fea | ||
fea2denseAct = softplus | ||
|
||
view_pe = 2 | ||
fea_pe = 2 | ||
|
||
TV_weight_density = 0.1 | ||
TV_weight_app = 0.01 | ||
|
||
## please uncomment following configuration if hope to training on cp model | ||
#model_name = TensorCP | ||
#n_lamb_sigma = [96] | ||
#n_lamb_sh = [288] | ||
#N_voxel_final = 125000000 # 500**3 | ||
#L1_weight_inital = 1e-5 | ||
#L1_weight_rest = 1e-5 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
dataset_name = nsvf | ||
datadir = ./data/Synthetic_NSVF/Wineholder | ||
expname = tensorf_Wineholder_VM | ||
basedir = ./log | ||
|
||
n_iters = 30000 | ||
batch_size = 4096 | ||
|
||
N_voxel_init = 2097156 # 128**3 | ||
N_voxel_final = 27000000 # 300**3 | ||
upsamp_list = [2000,3000,4000,5500,7000] | ||
update_AlphaMask_list = [2000,4000] | ||
|
||
N_vis = 5 | ||
vis_every = 10000 | ||
|
||
render_test = 1 | ||
|
||
n_lamb_sigma = [16,16,16] | ||
n_lamb_sh = [48,48,48] | ||
|
||
shadingMode = MLP_Fea | ||
fea2denseAct = softplus | ||
|
||
view_pe = 2 | ||
fea_pe = 2 | ||
|
||
L1_weight_inital = 8e-5 | ||
L1_weight_rest = 4e-5 | ||
rm_weight_mask_thre = 1e-4 | ||
|
||
## please uncomment following configuration if hope to training on cp model | ||
#model_name = TensorCP | ||
#n_lamb_sigma = [96] | ||
#n_lamb_sh = [288] | ||
#N_voxel_final = 125000000 # 500**3 | ||
#L1_weight_inital = 1e-5 | ||
#L1_weight_rest = 1e-5 |
Oops, something went wrong.