forked from nianticlabs/monodepth2
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathoptions.py
373 lines (357 loc) · 21.2 KB
/
options.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
# Copyright Niantic 2019. Patent Pending. All rights reserved.
#
# This software is licensed under the terms of the Monodepth2 licence
# which allows for non-commercial use only, the full terms of which are made
# available in the LICENSE file.
from __future__ import absolute_import, division, print_function
import os
import argparse
file_dir = os.path.dirname(__file__) # the directory that options.py resides in
class MonodepthOptions:
def __init__(self):
self.parser = argparse.ArgumentParser(description="Monodepthv2 options")
# PATHS
# self.parser.add_argument("--data_path",
# type=str,
# help="path to the training data",
# default=os.path.join(file_dir, "kitti_data")) ## comment this because written in trainer.py for easier cross-dataset training
# self.parser.add_argument("--log_dir",
# type=str,
# help="log directory",
# default=os.path.join(file_dir, "tmp"))
# # default=os.path.join(os.path.expanduser("~"), "tmp"))
self.parser.add_argument("--server",
type=str,
help="the name of the server to run on",
choices=["mcity", "sunny", "home"])
# DATASET options
self.parser.add_argument("--no_shuffle",
help="if set, do not shuffle dataset",
action="store_true")
self.parser.add_argument("--model_name",
type=str,
help="the name of the folder to save the model in",
default="mdp")
self.parser.add_argument("--split_train",
type=str,
nargs="+",
help="which training split to use",
choices=["eigen_zhou", "eigen_full", "odom", "benchmark", "TUM_split", "eigen_zhou_bench_as_val", "lyft", "lyft_all"],
default="eigen_zhou")
self.parser.add_argument("--split_val",
type=str,
nargs="+",
help="which validation split to use",
choices=["eigen_zhou", "eigen_full", "odom", "benchmark", "TUM_split", "eigen_zhou_bench_as_val", "lyft", "lyft_all"],
default="eigen_zhou") ## This is added for easier cross-dataset training
self.parser.add_argument("--num_layers",
type=int,
help="number of resnet layers",
default=18,
choices=[18, 34, 50, 101, 152])
self.parser.add_argument("--dataset",
type=str,
nargs="+",
help="dataset to train on",
default="kitti",
choices=["kitti", "kitti_odom", "kitti_depth", "kitti_test", "TUM", "lyft_1024", "vkitti"])
self.parser.add_argument("--dataset_val",
type=str,
nargs="+",
help="dataset to evaluate on",
default="kitti",
choices=["kitti", "kitti_odom", "kitti_depth", "kitti_test", "TUM", "lyft_1024", "vkitti"]) # ZMH: this option added by me
self.parser.add_argument("--png",
help="if set, trains from raw KITTI png files (instead of jpgs)",
action="store_true")
######## for val_set
self.parser.add_argument("--no_val_set",
help="if set, disable val_set",
action="store_true")
self.parser.add_argument("--val_set_only",
help="if set, only run val_set on pretrained weights",
action="store_true")
self.parser.add_argument("--load_weights_folder_parent",
type=str,
help="parent path of models to load, needed for val_set_only")
# self.parser.add_argument("--height",
# type=int,
# help="input image height",
# default=192)
# self.parser.add_argument("--width",
# type=int,
# help="input image width",
# default=640) ## comment this because written in trainer.py for easier cross-dataset training
# TRAINING options
self.parser.add_argument("--disparity_smoothness",
type=float,
help="disparity smoothness weight",
default=1e-3)
self.parser.add_argument("--scales",
nargs="+",
type=int,
help="scales used in the loss",
default=[0, 1, 2, 3])
self.parser.add_argument("--min_depth",
type=float,
help="minimum depth",
default=0.1)
self.parser.add_argument("--max_depth",
type=float,
help="maximum depth",
default=100.0)
self.parser.add_argument("--use_stereo",
help="if set, uses stereo pair for training",
action="store_true")
self.parser.add_argument("--frame_ids",
nargs="+",
type=int,
help="frames to load",
default=[0, -1, 1])
self.parser.add_argument("--ref_depth",
type=float,
help="ref depth r in r/(r+d)",
default=10.0)
self.parser.add_argument("--depth_ref_mode",
help="use r/(r+d) as disp",
action="store_true")
# OPTIMIZATION options
self.parser.add_argument("--batch_size",
type=int,
help="batch size",
default=12)
self.parser.add_argument("--iters_per_update",
type=int,
help="this value times batch_size is the effective batch size",
default=1) ### ZMH: added
self.parser.add_argument("--learning_rate",
type=float,
help="learning rate",
default=1e-4)
self.parser.add_argument("--num_epochs",
type=int,
help="number of epochs",
default=20)
self.parser.add_argument("--scheduler_step_size",
type=int,
help="step size of the scheduler",
default=15)
# ABLATION options
self.parser.add_argument("--v1_multiscale",
help="if set, uses monodepth v1 multiscale",
action="store_true")
self.parser.add_argument("--avg_reprojection",
help="if set, uses average reprojection loss",
action="store_true")
self.parser.add_argument("--disable_automasking",
help="if set, doesn't do auto-masking",
action="store_true")
self.parser.add_argument("--predictive_mask",
help="if set, uses a predictive masking scheme as in Zhou et al",
action="store_true")
self.parser.add_argument("--no_ssim",
help="if set, disables ssim in the loss",
action="store_true")
self.parser.add_argument("--weights_init",
type=str,
help="pretrained or scratch",
default="pretrained",
choices=["pretrained", "scratch"])
self.parser.add_argument("--pose_model_input",
type=str,
help="how many images the pose network gets",
default="pairs",
choices=["pairs", "all"])
self.parser.add_argument("--pose_model_type",
type=str,
help="normal or shared",
default="separate_resnet",
choices=["posecnn", "separate_resnet", "shared"])
## switch for enabling CVO loss
self.parser.add_argument("--cvo_loss",
help="if set, calculate cvo loss",
action="store_true")
self.parser.add_argument("--normalize_inprod_over_pts",
help="if set, inner product is divided by the product of total number of points in two pcls",
action="store_true")
self.parser.add_argument("--supervised_by_gt_depth",
help="if set, the CVO loss is computed by comparing with true depth",
action="store_true")
self.parser.add_argument("--cvo_as_loss",
help="if set, cvo loss is used for training",
action="store_true")
self.parser.add_argument("--sup_cvo_pose_lidar",
help="if set, cvo loss is used for supervising pose using lidar points",
action="store_true")
self.parser.add_argument("--disp_in_loss",
help="if set, disparity L1 difference is used in depth training",
action="store_true")
self.parser.add_argument("--depth_in_loss",
help="if set, depth L1 difference is used in depth training",
action="store_true")
self.parser.add_argument("--cvo_loss_dense",
help="if set, calculate cvo loss using dense image",
action="store_true")
self.parser.add_argument("--multithread",
help="if set, dense cvo loss is calculated multithreaded",
action="store_true")
self.parser.add_argument("--dense_flat_grid",
help="if set, calculate dense cvo loss using flat-grid correspondence",
action="store_true")
self.parser.add_argument("--mask_samp_as_lidar",
help="if set, the mask for image is sampled to have the same number of valid points as lidar projection mask",
action="store_true")
self.parser.add_argument("--use_panoptic",
help="if set, call panoptic network to produce features",
action="store_true")
self.parser.add_argument("--use_normal",
help="if set, calc normal vectors from depth and used in cvo calculation",
action="store_true")
self.parser.add_argument("--use_normal_v2",
help="if set, calc normal vectors from depth and used in cvo calculation, using the custom operation PtSampleInGridCalcNormal",
action="store_true")
self.parser.add_argument("--use_normal_v3",
help="if set, normal vectors of sparse pcls are from PtSampleInGridCalcNormal, while those of dense images are from NormalFromDepthDense",
action="store_true")
self.parser.add_argument("--neg_nkern_to_zero",
help="if set, negative normal kernels are truncated to zero, otherwise use absolute value of normel kernel",
action="store_true")
self.parser.add_argument("--random_ell",
help="if set, the length scale of geometric kernel is selected randomly following a certain distribution",
action="store_true")
self.parser.add_argument("--ell_basedist",
type=float,
help="if not zero, the length scale is proportional to the depth of gt points when the depth is larger than this value. If zero, ell is constant",
default=0)
self.parser.add_argument("--norm_in_dist",
help="if set, the normal information will be used in exp kernel besides as a coefficient term. Neet use_normal_v2 to be true to be effective",
action="store_true")
self.parser.add_argument("--res_mag_min",
type=float,
help="the minimum value for the normal kernel (or viewing it as a coefficient of geometric kernel)",
default=0.1)
self.parser.add_argument("--res_mag_max",
type=float,
help="the maximum value for the normal kernel (or viewing it as a coefficient of geometric kernel)",
default=2)
self.parser.add_argument("--disable_log",
help="if set, no logging of this training trial will be logged to hard drive",
action="store_true")
self.parser.add_argument("--align_preds",
help="if set, inner prod between predictions of adjacent frames are included in loss",
action="store_true")
self.parser.add_argument("--neighbor_range",
type=int,
help="neighbor range when calculating inner product",
default=2)
self.parser.add_argument("--normal_nrange",
type=int,
help="neighbor range when calculating normal direction on sparse point cloud",
default=5)
self.parser.add_argument("--ell_geo",
type=float,
help="the ell used in geometric kernel",
default=0.05)
self.parser.add_argument("--ell_min",
type=float,
help="the minimal ell used in geometric kernel",
default=0.05)
# self.parser.add_argument("--cross_set",
# help="if set, use lyft_1024 in training",
# action="store_true")
# SYSTEM options
self.parser.add_argument("--no_cuda",
help="if set disables CUDA",
action="store_true")
self.parser.add_argument("--num_workers",
type=int,
help="number of dataloader workers",
default=12)
self.parser.add_argument("--cuda_n",
type=int,
help="which GPU to use",
default=0)
# LOADING options
self.parser.add_argument("--load_weights_folder",
type=str,
help="name of model to load")
self.parser.add_argument("--models_to_load",
nargs="+",
type=str,
help="models to load",
default=["encoder", "depth", "pose_encoder", "pose"])
# LOGGING options
self.parser.add_argument("--log_frequency",
type=int,
help="number of batches between each tensorboard log",
default=250)
self.parser.add_argument("--save_frequency",
type=int,
help="number of epochs between each save",
default=1)
self.parser.add_argument("--save_pic_intv",
type=int,
help="interval between two image-saving iteration. Disabled if set to 0.",
default=0)
self.parser.add_argument("--save_nkern_pic",
help="if set, save nkern_pics as well",
action="store_true")
self.parser.add_argument("--save_pcd_intv",
type=int,
help="interval between two image-saving iteration. Disabled if set to 0.",
default=4000)
self.parser.add_argument("--save_pcd_pic_mode",
nargs="+",
type=str,
help="decide in which mode save pic/pcd files, to avoid train/val/val_set mixed up",
default="train",
choices=["train", "val", "val_set"])
self.parser.add_argument("--config_file",
type=str,
help="to load options from file")
# EVALUATION options
self.parser.add_argument("--eval_stereo",
help="if set evaluates in stereo mode",
action="store_true")
self.parser.add_argument("--eval_mono",
help="if set evaluates in mono mode",
action="store_true")
self.parser.add_argument("--disable_median_scaling",
help="if set disables median scaling in evaluation",
action="store_true")
self.parser.add_argument("--pred_depth_scale_factor",
help="if set multiplies predictions by this number",
type=float,
default=1)
self.parser.add_argument("--ext_disp_to_eval",
type=str,
help="optional path to a .npy disparities file to evaluate")
self.parser.add_argument("--eval_split",
type=str,
default="eigen",
choices=[
"eigen", "eigen_benchmark", "benchmark", "odom_9", "odom_10", "vkitti"],
help="which split to run eval on")
self.parser.add_argument("--save_pred_disps",
help="if set saves predicted disparities",
action="store_true")
self.parser.add_argument("--no_eval",
help="if set disables evaluation",
action="store_true")
self.parser.add_argument("--eval_eigen_to_benchmark",
help="if set assume we are loading eigen results from npy but "
"we want to evaluate using the new benchmark.",
action="store_true")
self.parser.add_argument("--eval_out_dir",
help="if set will output the disparities to this folder",
type=str)
self.parser.add_argument("--post_process",
help="if set will perform the flipping post processing "
"from the original monodepth paper",
action="store_true")
self.parser.add_argument("--ext_depth",
help="if set use npy files with depth instead of disp in compare_eval.py",
action="store_true")
def parse(self):
self.options, rest = self.parser.parse_known_args()
return self.options, rest