-
Notifications
You must be signed in to change notification settings - Fork 1
/
options.py
362 lines (311 loc) · 17.3 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
import os
import argparse
class SharinOptions:
def __init__(self):
self.parser = argparse.ArgumentParser(description="sharinDVSO options")
# PATHS
# self.parser.add_argument("--data_path",
# type=str,
# help="path to the training data",
# default=os.path.join(file_dir, "kitti_data"))
# self.parser.add_argument("--log_dir",
# type=str,
# help="log directory",
# default=os.path.join(os.path.expanduser("~"), "tmp"))
# TRAINING options
self.parser.add_argument("--exp",
type=str,
help="the name of the folder to save the model in")
# self.parser.add_argument("--model_name",
# type=str,
# help="the name of the folder to save the model in",
# required=True,
# choices=["Gen_Baseline", "PTNet_Baseline", "Joint"])
self.parser.add_argument("--num_layers_T",
type=int,
help="number of resnet layers for task net",
default=18,
choices=[18, 34, 50, 101, 152])
self.parser.add_argument("--num_layers_G",
type=int,
help="number of resnet layers for generator net",
default=18,
choices=[18, 34, 50, 101, 152])
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)
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("--frame_ids",
nargs="+",
type=int,
help="frames to load",
default=[0, -1, 1])
self.parser.add_argument("--stereo_mode",
type=str,
default="none",
choices=["none", "monodepth2", "sharinGAN"])
self.parser.add_argument("--netG_mode",
type=str,
default="monodepth2",
choices=["monodepth2", "sharinGAN"])
self.parser.add_argument("--pretrained_model_G",
type=str,
default=None,
help="path of pretrained generator model")
self.parser.add_argument("--pretrained_model_T",
type=str,
default=None,
help="path of pretrained task model")
self.parser.add_argument("--resume",
default=None,
help="The resumed joint model to load")
# NOTE: OPTIONS for loss weights
self.parser.add_argument("--temp_reproj_weight",
type=float,
default=1.0)
self.parser.add_argument("--stereo_gc_weight",
type=float,
default=1.0)
self.parser.add_argument("--recon_loss_weight",
type=float,
default=10,
help="for both real and syn")
self.parser.add_argument("--gt_depth_weight",
type=float,
default=1.0,
help="loss weight for ground-truth depth")
self.parser.add_argument("--lr_loss_weight",
type=float,
help="used only when --predict_right_disp",
default=1.0)
self.parser.add_argument("--disparity_smoothness",
type=float,
help="disparity smoothness weight",
default=1e-1)
self.parser.add_argument("--add_sharinGAN_gc",
help="if set will disable sharinGAN gc for monodepth2 loss style",
action="store_true")
# NOTE: PARAMS for joint model training
self.parser.add_argument("--correct_D_loss",
help="if set will use torch.abs() for D_syn - D_real",
action="store_true")
self.parser.add_argument("--D_multi_scale",
help="if set will use multi scale losses for D",
action="store_true")
# OPTIMIZATION options
self.parser.add_argument("--batch_size",
type=int,
help="batch size: (1) 16 for PTNet_Baseline (2) 6 for Gen_Baseline (3) 2 for Joint",
required=True)
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)
self.parser.add_argument("--top_k_val",
type=int,
help="number of models to save based on val_loss",
default=3)
self.parser.add_argument("--total_iterations",
type=int,
help="total_iterations",
default=200000)
self.parser.add_argument("--ngpus",
type=int,
help="number of gpus to use",
default=1)
self.parser.add_argument("--vbaseline",
type=float,
default=0.532725,
help="baseline of virtual kitti")
self.parser.add_argument("--predict_right_disp",
help="if set predict the right disparity and use lr consistency loss",
action="store_true")
self.parser.add_argument("--direct_raw_img",
help="if set will use raw img for direct photometric loss, otherwise use the shared feat",
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=8)
self.parser.add_argument("--avg_reprojection",
help="if set, uses average reprojection loss",
action="store_true")
self.parser.add_argument("--hpc",
help="disable tqdm in HPC",
action="store_true")
self.parser.add_argument("--preload_virtual_data",
help="preload depth and image data of virtual dataset into memory",
action="store_true")
self.parser.add_argument('--dist-url',
default='env://',
type=str,
help='url used to set up distributed training')
self.parser.add_argument('--dist-backend',
default='nccl',
type=str,
help='distributed backend')
# 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)
# EVALUATION options
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("--val",
help="if set will use val.txt otherwise test.txt",
action="store_true")
self.parser.add_argument("--val_average_disp",
help="if set will average disp prediction from all scales",
action="store_true")
self.parser.add_argument("--val_depth_mode",
type=str,
default="disp",
choices=["disp", "normalized_depth"])
self.parser.add_argument("--val_iter",
default=None,
type=int)
self.parser.add_argument("--val_seq",
default=None,
type=str)
self.parser.add_argument("--save_feat",
help="only used in save_depth.py, will only save features",
action="store_true")
# DVSO FINETUNE options
self.parser.add_argument("--dvso_epochs",
type=int,
default=5,
help="dvso will be run at the beginning of each epoch")
self.parser.add_argument("--dvso_train_seqs",
type=str,
nargs="+",
default=["00", "01", "02", "03", "04", "05", "06", "07", "08"],
help="e.g. 00 01 02")
self.parser.add_argument("--dvso_test_seqs",
type=str,
nargs="+",
default=["09", "10"],
help="e.g. 09 10")
self.parser.add_argument("--dvso_resume_exp",
type=str,
default=None,
help="domain adaptation experiment name to resume, e.g. local-0614a")
self.parser.add_argument("--dvso_resume_iter",
type=int,
default=None,
help="the iteration model of the resumed, e.g. 125999")
self.parser.add_argument("--dvso_param",
type=str,
default="Before_Ori_Hit_1_2_2_1_1_1",
help="wStereoPosFlag wCorrectedFlag wGradFlag wStereo scaleENergyLeftTHR scaleWJI2SumTHR warpright checkWarpValid maskWarpGrad")
self.parser.add_argument("--dvso_home_path",
type=str,
default="/home/szha2609",
help="used in DVSO_Finetune/run_dvso.sh")
self.parser.add_argument("--use_dvso_depth",
help="use dvso sparse depth for supervision",
action="store_true")
self.parser.add_argument("--dvso_depth_weight",
type=float,
default=1.0,
help="loss weight for dvso depth")
self.parser.add_argument("--dvso_netT_only",
help="only finetune netT during ",
action="store_true")
self.parser.add_argument("--dvso_real_only",
help="only use real dataset during dvso finetuning. Only take effect for --dvso_netT_only",
action="store_true")
self.parser.add_argument("--dvso_maintain_disp",
help="if set, will maintain the intermediate disps to save space, otherwise will clean them",
action="store_true")
self.parser.add_argument("--dvso_disp_exist",
help="if set, will use the previously maintained disp rather than recomputing them",
action="store_true")
self.parser.add_argument("--dvso_test_only",
help="only test the loaded model and then quit",
action="store_true")
self.parser.add_argument("--use_pose_loss",
help="use L2 loss for dvso axisangle and translation vec6 poses",
action="store_true")
self.parser.add_argument("--rot_weight",
type=float,
default=100.,
help="weight for rotation loss")
self.parser.add_argument("--trans_weight",
type=float,
default=1.,
help="weight for translation loss")
self.parser.add_argument("--use_dvso_photo",
help="use dvso poses for temporal photometric consistency loss",
action="store_true")
self.parser.add_argument("--dvso_photo_weight",
type=float,
default=1.)
self.parser.add_argument("--dvso_netT_lr",
type=float,
default=1e-5)
# CORRECT TRAIN/VAL/TEST split
self.parser.add_argument("--kitti_folder",
type=str,
default="Kitti-Zhan",
help="the folder name under dataset_files")
# FOR TESTING BEST DVSO FINETUNE MODELS
self.parser.add_argument("--dvso_test_best",
help="only test the loaded model, --dvso_test_exp, --dvso_test_iter, --dvso_test_T, and use --dvso_test_seqs",
action="store_true")
self.parser.add_argument("--dvso_test_T",
help="test pretrain-T models, where netT use raw images rather than netG results",
action="store_true")
self.parser.add_argument("--dvso_test_exp",
type=str,
default=None)
self.parser.add_argument("--dvso_test_iter",
type=int,
default=None)
self.parser.add_argument("--dvso_test_run",
type=int,
default=5,
help="run 5 times of DVSO and take the median")
def parse(self):
self.options = self.parser.parse_args()
return self.options