Skip to content

Commit

Permalink
update CP config
Browse files Browse the repository at this point in the history
  • Loading branch information
陈安沛 committed Mar 22, 2022
1 parent ccc2714 commit 7f50587
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 11 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 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/2103.15595). Our work present a novel approach to model and reconstruct radiance fields, which achieves super
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>


Expand Down Expand Up @@ -36,11 +36,12 @@ python train.py --config configs/lego.txt

we provide a few examples in the configuration folder, please note:

`dataset_name`, choices = ['blender', 'llff', 'nsvf', 'dtu','tankstemple'];
`dataset_name`, choices = ['blender', 'llff', 'nsvf', 'tankstemple'];

`shadingMode`, choices = ['MLP_Fea', 'SH'];

`model_name`, choices = ['TensorVMSplit', 'TensorCP'], corresponding to the VM and CP decomposition;
`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;
Expand Down
12 changes: 11 additions & 1 deletion configs/lego.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

dataset_name = blender
datadir = ./data/nerf_synthetic/lego
expname = tensorf_lego
expname = tensorf_lego_CP
basedir = ./log

n_iters = 30000
Expand All @@ -19,6 +19,8 @@ render_test = 1

n_lamb_sigma = [16,16,16]
n_lamb_sh = [48,48,48]
model_name = TensorVMSplit


shadingMode = MLP_Fea
fea2denseAct = softplus
Expand All @@ -29,3 +31,11 @@ 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
8 changes: 8 additions & 0 deletions configs/truck.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@ 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

8 changes: 8 additions & 0 deletions configs/wineholder.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@ 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
8 changes: 3 additions & 5 deletions models/tensoRF.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,16 +303,14 @@ def shrink(self, new_aabb):
self.update_stepSize((newSize[0], newSize[1], newSize[2]))




class TensorCP(TensorBase):
def __init__(self, aabb, gridSize, device, **kargs):
super(TensorCP, self).__init__(aabb, gridSize, device, **kargs)


def init_svd_volume(self, res, device):
self.density_line = self.init_one_svd(self.density_n_comp, self.gridSize, 0.2, device)
self.app_line = self.init_one_svd(self.app_n_comp, self.gridSize, 0.2, device)
self.density_line = self.init_one_svd(self.density_n_comp[0], self.gridSize, 0.2, device)
self.app_line = self.init_one_svd(self.app_n_comp[0], self.gridSize, 0.2, device)
self.basis_mat = torch.nn.Linear(self.app_n_comp[0], self.app_dim, bias=False).to(device)


Expand All @@ -321,7 +319,7 @@ def init_one_svd(self, n_component, gridSize, scale, device):
for i in range(len(self.vecMode)):
vec_id = self.vecMode[i]
line_coef.append(
torch.nn.Parameter(scale * torch.randn((1, n_component[i], gridSize[vec_id], 1))))
torch.nn.Parameter(scale * torch.randn((1, n_component, gridSize[vec_id], 1))))
return torch.nn.ParameterList(line_coef).to(device)


Expand Down
4 changes: 2 additions & 2 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ def reconstruction(args):
if __name__ == '__main__':

torch.set_default_dtype(torch.float32)
torch.manual_seed(20121202)
np.random.seed(20121202)
torch.manual_seed(20211202)
np.random.seed(20211202)

args = config_parser()
print(args)
Expand Down

0 comments on commit 7f50587

Please sign in to comment.