Skip to content

Commit 11775f2

Browse files
authored
Implemented Plenoxel. (#1)
* add codes to run the blender dataset * change the default batch size * add white_bkgd option * corrct the ndc coordiinate * change the sampling strategy * add dataloader for tanks and temples * add tanks and temples * change the batch size for a fair comparison * hotfix: minor bug * hotfix: change the upsampe frequency * add torch.no_grad * add codes to load model * modify configs to run sweep * change the config to run sweep * hotfix: fix loading error * hotfix: fix typo * hotfix: minor fix * hotfix: change the expname * hotfix: change the expname
1 parent fd3986e commit 11775f2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+10459
-165
lines changed

.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ logs
66
*pycache*
77
*swap-pane*
88
*.idea*
9-
logs_collection
9+
logs_collection
10+
*build*
11+
*.egg-info*
12+
*.eggs*
13+
*_debug*

README.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,18 @@ This project is created and maintained by Yoonwoo Jeong, Jinoh Cho, and Seungjoo
1313
- Several options are different from the original NeRF (TensorFlow)
1414
- NeRF: Representing Scenes as Neural Radiance Fields for View Synthesis: [[Code](https://github.com/google-research/google-research/tree/master/jaxnerf) | [Paper](https://arxiv.org/pdf/2003.08934) | [Arxiv](https://arxiv.org/abs/2003.08934)]
1515
- Document: [Link](./docs/jaxnerf.md)
16-
- SNeRG (Torch Version)
16+
- SNeRG (Torch)
1717
- Coming Soon
18-
- MipNeRF (Torch Version)
18+
- MipNeRF (Torch)
1919
- Coming Soon
20-
- MipNeRF360 (Torch Version)
20+
- MipNeRF360 (Torch)
2121
- Coming Soon
22-
- NeRF++ (Torch Version)
22+
- NeRF++ (Torch)
2323
- Coming Soon
24+
- Plenoxel (Torch)
25+
- Reorganized the code structure for easier modification.
26+
- Plenoxels: Radiance Fields without Neural Networks [[Code](https://github.com/sxyu/svox2) | [Paper]()]
27+
- Document: [Link](./docs/plenoxel.md)
2428

2529
## Dataset
2630
```

config.py

+96-23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
import argparse
22

3+
def str2bool(v):
4+
if isinstance(v, bool):
5+
return v
6+
if v.lower() in ("yes", "true", "t", "y", "1"):
7+
return True
8+
elif v.lower() in ("no", "false", "f", "n", "0"):
9+
return False
10+
else:
11+
raise Exception("Boolean value expected.")
12+
313
def config_parser():
414

515
parser = argparse.ArgumentParser()
@@ -41,7 +51,11 @@ def config_parser():
4151

4252
ray = parser.add_argument_group("rays")
4353
ray.add_argument(
44-
"--use_pixel_centers", action="store_true", default=False,
54+
"--use_pixel_centers",
55+
type=str2bool,
56+
nargs="?",
57+
const=True,
58+
default=False,
4559
help="add a half pixel while generating rays"
4660
)
4761

@@ -55,19 +69,28 @@ def config_parser():
5569
"--testskip", type=int, default=8,
5670
help="will load 1/N images from test/val sets, useful for large datasets like deepvoxels",
5771
)
72+
dataset.add_argument(
73+
"--scene_scale", type=float, default=1,
74+
help="resize the scale of scenes"
75+
)
76+
dataset.add_argument(
77+
"--shuffle_train",
78+
type=str2bool,
79+
nargs="?",
80+
const=True,
81+
default=False,
82+
help="shuffle the train set"
83+
)
5884

5985
## blender flags
6086
blender = parser.add_argument_group("blender")
6187
blender.add_argument(
6288
"--white_bkgd",
63-
action="store_true",
89+
type=str2bool,
90+
nargs="?",
91+
const=True,
6492
help="set to render synthetic data on a white bkgd (always use for dvoxels)",
6593
)
66-
blender.add_argument(
67-
"--half_res",
68-
action="store_true",
69-
help="load blender synthetic data at 400x400 instead of 800x800",
70-
)
7194

7295
## llff flags
7396
llff = parser.add_argument_group("llff flags")
@@ -76,16 +99,23 @@ def config_parser():
7699
)
77100
llff.add_argument(
78101
"--no_ndc",
79-
action="store_true",
102+
type=str2bool,
103+
nargs="?",
104+
const=True,
80105
help="do not use normalized device coordinates (set for non-forward facing scenes)",
81106
)
82107
llff.add_argument(
83108
"--lindisp",
84-
action="store_true",
109+
type=str2bool,
110+
nargs="?",
111+
const=True,
85112
help="sampling linearly in disparity rather than depth",
86113
)
87114
llff.add_argument(
88-
"--spherify", action="store_true", help="set for spherical 360 scenes"
115+
"--spherify",
116+
type=str2bool,
117+
nargs="?",
118+
const=True,help="set for spherical 360 scenes"
89119
)
90120
llff.add_argument(
91121
"--llffhold",
@@ -100,20 +130,20 @@ def config_parser():
100130
"--i_print", type=int, default=1000,
101131
help="frequency of console printout and metric logging",
102132
)
103-
metadata.add_argument(
104-
"--i_weights", type=int, default=50000,
105-
help="frequency of storing weights"
106-
)
107133
metadata.add_argument(
108134
"--i_validation", type=int, default=50000,
109135
help="frequency of validation"
110136
)
111137
metadata.add_argument(
112-
"--debug", action="store_true", default=False,
138+
"--debug",
139+
type=str2bool,
140+
nargs="?",
141+
const=True,
142+
default=False,
113143
help="run with debug mode"
114144
)
115145
metadata.add_argument(
116-
"--expname", type=str, required=True, help="experiment name"
146+
"--expname", type=str, default=None, help="experiment name"
117147
)
118148
metadata.add_argument(
119149
"--basedir", type=str, default="./logs/",
@@ -126,22 +156,49 @@ def config_parser():
126156

127157
runmode = parser.add_argument_group("running mode")
128158
runmode.add_argument(
129-
"--train", action="store_true", default=False, help="run with train mode"
159+
"--train",
160+
type=str2bool,
161+
nargs="?",
162+
const=True,
163+
default=False,
164+
help="run with train mode"
130165
)
131166
runmode.add_argument(
132-
"--eval", action="store_true", default=False, help="run with eval mode"
167+
"--eval",
168+
type=str2bool,
169+
nargs="?",
170+
const=True,
171+
default=False,
172+
help="run with eval mode"
133173
)
134174
runmode.add_argument(
135-
"--bake", action="store_true", default=False, help="bake the trained model"
175+
"--bake",
176+
type=str2bool,
177+
nargs="?",
178+
const=True,
179+
default=False,
180+
help="bake the trained model"
136181
)
137182
runmode.add_argument(
138-
"--render", action="store_true", default=False, help="render to generate video"
183+
"--render",
184+
type=str2bool,
185+
nargs="?",
186+
const=True,
187+
default=False, help="render to generate video"
139188
)
140189
runmode.add_argument(
141-
"--skip_validation", action="store_true", default=False,
190+
"--skip_validation",
191+
type=str2bool,
192+
nargs="?",
193+
const=True,
194+
default=False,
142195
)
143196
runmode.add_argument(
144-
"--tpu", action="store_true", default=False, help="run with tpus"
197+
"--tpu",
198+
type=str2bool,
199+
nargs="?",
200+
const=True,
201+
default=False, help="run with tpus"
145202
)
146203
runmode.add_argument(
147204
"--tpu_num", type=int, default=0, help="number of tpu"
@@ -152,10 +209,26 @@ def config_parser():
152209
runmode.add_argument(
153210
"--seed", type=int, default=0, help="seed to fix"
154211
)
212+
runmode.add_argument(
213+
"--use_custom_optim",
214+
type=str2bool,
215+
nargs="?",
216+
const=True,
217+
default=False,
218+
help="Run with a custom optimization step"
219+
)
220+
runmode.add_argument(
221+
"--run_large_model",
222+
type=str2bool,
223+
nargs="?",
224+
const=True,
225+
default=False,
226+
help="For wandb sweep: run large nerf model"
227+
)
155228

156229
config = parser.add_argument_group("config")
157230
config.add_argument(
158231
"--config", type=str, default=None, help="path to config file"
159232
)
160233

161-
return parser.parse_args(), parser
234+
return parser.parse_known_args()[0], parser

configs/jaxnerf_torch/blender.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ lr_delay_mult: 0.2
1717
max_steps: 200000
1818

1919
i_print: 100
20-
i_weights: 50000
2120
i_validation: 50000
2221
use_pixel_centers: true
2322

configs/jaxnerf_torch/blender_large.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ lr_delay_mult: 0.01
1717
max_steps: 200000
1818

1919
i_print: 100
20-
i_weights: 50000
2120
i_validation: 50000
2221
use_pixel_centers: true
2322

configs/jaxnerf_torch/llff.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ lr_delay_mult: 1.
1919
max_steps: 200000
2020

2121
i_print: 100
22-
i_weights: 50000
2322
i_validation: 50000
2423
use_pixel_centers: true
2524

configs/jaxnerf_torch/llff_large.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ lr_delay_mult: 1.
1919
max_steps: 200000
2020

2121
i_print: 100
22-
i_weights: 50000
2322
i_validation: 50000
2423
use_pixel_centers: true
2524

configs/plenoxel_torch/blender.yaml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
dataset_type: blender
2+
model: plenoxel_torch
3+
batching: all_images_wo_replace
4+
5+
N_rand: 4096
6+
7+
max_steps: 200000
8+
9+
i_print: 100
10+
i_validation: 50000
11+
12+
no_ndc: true
13+
14+
reso: "[[256, 256, 256], [512, 512, 512]]"
15+
upsamp_every: 50000
16+
lr_sigma: 3.0e+1
17+
lr_sh: 1.0e-2
18+
lambda_tv: 1.0e-5
19+
lambda_tv_sh: 1.0e-3
20+
21+
use_pixel_centers: true
22+
white_bkgd: true
23+
scene_scale: 0.6666

configs/plenoxel_torch/llff.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
dataset_type: llff
2+
model: plenoxel_torch
3+
batching: all_images_wo_replace
4+
5+
N_rand: 4096
6+
max_steps: 200000
7+
8+
llffhold: 8
9+
factor: 4
10+
11+
i_print: 100
12+
i_validation: 50000
13+
use_pixel_centers: true
14+
15+
no_ndc: false
16+
17+
reso: "[[256, 256, 128], [512, 512, 128], [1408, 1156, 128]]"
18+
upsamp_every: 50000
19+
lr_sigma: 3.0e+1
20+
lr_sh: 1.0e-2
21+
thresh_type: "sigma"
22+
density_thresh: 5.0
23+
lambda_tv: 5.0e-4
24+
lambda_tv_sh: 5.0e-3
25+
lambda_sparsity: 1.0e-12
26+
background_brightness: 0.5
27+
last_sample_opaque: false,
28+
tv_early_only: 0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
dataset_type: tanks_and_temples
2+
model: plenoxel_torch
3+
batching: all_images
4+
5+
N_rand: 4096
6+
max_steps: 200000
7+
8+
i_print: 100
9+
i_validation: 50000
10+
use_pixel_centers: true
11+
12+
no_ndc: true
13+
chunk: 16384
14+
15+
upsamp_every: 50000
16+
reso: "[[128, 128, 128], [256, 256, 256], [512, 512, 512], [640, 640, 640]]"
17+
background_nlayers: 64
18+
background_reso: 1024
19+
lr_sigma: 3.0e+1
20+
lr_sh: 1.0e-2
21+
lr_sigma_delay_steps: 15000
22+
thresh_type: "weight"
23+
lambda_tv": 5.0e-5
24+
lambda_tv_sh": 5.0e-3
25+
lambda_tv_background_sigma": 1.0e-3
26+
lambda_tv_background_color: 1.0e-3
27+
lambda_beta: 1.0e-5
28+
lambda_sparsity: 1.0e-11
29+
background_brightness: 1.0
30+
tv_early_only: 0

0 commit comments

Comments
 (0)