1
1
import argparse
2
2
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
+
3
13
def config_parser ():
4
14
5
15
parser = argparse .ArgumentParser ()
@@ -41,7 +51,11 @@ def config_parser():
41
51
42
52
ray = parser .add_argument_group ("rays" )
43
53
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 ,
45
59
help = "add a half pixel while generating rays"
46
60
)
47
61
@@ -55,19 +69,28 @@ def config_parser():
55
69
"--testskip" , type = int , default = 8 ,
56
70
help = "will load 1/N images from test/val sets, useful for large datasets like deepvoxels" ,
57
71
)
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
+ )
58
84
59
85
## blender flags
60
86
blender = parser .add_argument_group ("blender" )
61
87
blender .add_argument (
62
88
"--white_bkgd" ,
63
- action = "store_true" ,
89
+ type = str2bool ,
90
+ nargs = "?" ,
91
+ const = True ,
64
92
help = "set to render synthetic data on a white bkgd (always use for dvoxels)" ,
65
93
)
66
- blender .add_argument (
67
- "--half_res" ,
68
- action = "store_true" ,
69
- help = "load blender synthetic data at 400x400 instead of 800x800" ,
70
- )
71
94
72
95
## llff flags
73
96
llff = parser .add_argument_group ("llff flags" )
@@ -76,16 +99,23 @@ def config_parser():
76
99
)
77
100
llff .add_argument (
78
101
"--no_ndc" ,
79
- action = "store_true" ,
102
+ type = str2bool ,
103
+ nargs = "?" ,
104
+ const = True ,
80
105
help = "do not use normalized device coordinates (set for non-forward facing scenes)" ,
81
106
)
82
107
llff .add_argument (
83
108
"--lindisp" ,
84
- action = "store_true" ,
109
+ type = str2bool ,
110
+ nargs = "?" ,
111
+ const = True ,
85
112
help = "sampling linearly in disparity rather than depth" ,
86
113
)
87
114
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"
89
119
)
90
120
llff .add_argument (
91
121
"--llffhold" ,
@@ -100,20 +130,20 @@ def config_parser():
100
130
"--i_print" , type = int , default = 1000 ,
101
131
help = "frequency of console printout and metric logging" ,
102
132
)
103
- metadata .add_argument (
104
- "--i_weights" , type = int , default = 50000 ,
105
- help = "frequency of storing weights"
106
- )
107
133
metadata .add_argument (
108
134
"--i_validation" , type = int , default = 50000 ,
109
135
help = "frequency of validation"
110
136
)
111
137
metadata .add_argument (
112
- "--debug" , action = "store_true" , default = False ,
138
+ "--debug" ,
139
+ type = str2bool ,
140
+ nargs = "?" ,
141
+ const = True ,
142
+ default = False ,
113
143
help = "run with debug mode"
114
144
)
115
145
metadata .add_argument (
116
- "--expname" , type = str , required = True , help = "experiment name"
146
+ "--expname" , type = str , default = None , help = "experiment name"
117
147
)
118
148
metadata .add_argument (
119
149
"--basedir" , type = str , default = "./logs/" ,
@@ -126,22 +156,49 @@ def config_parser():
126
156
127
157
runmode = parser .add_argument_group ("running mode" )
128
158
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"
130
165
)
131
166
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"
133
173
)
134
174
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"
136
181
)
137
182
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"
139
188
)
140
189
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 ,
142
195
)
143
196
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"
145
202
)
146
203
runmode .add_argument (
147
204
"--tpu_num" , type = int , default = 0 , help = "number of tpu"
@@ -152,10 +209,26 @@ def config_parser():
152
209
runmode .add_argument (
153
210
"--seed" , type = int , default = 0 , help = "seed to fix"
154
211
)
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
+ )
155
228
156
229
config = parser .add_argument_group ("config" )
157
230
config .add_argument (
158
231
"--config" , type = str , default = None , help = "path to config file"
159
232
)
160
233
161
- return parser .parse_args () , parser
234
+ return parser .parse_known_args ()[ 0 ] , parser
0 commit comments