-
Notifications
You must be signed in to change notification settings - Fork 5
/
options.py
293 lines (276 loc) · 14.6 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
# 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
from layers import HomographyWarp
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"))
self.parser.add_argument("--log_dir",
type=str,
help="log directory",
default="./log")
# TRAINING options
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",
type=str,
help="which training split to use",
choices=["eigen_zhou", "eigen_full", "eigen_full_left", "odom", "benchmark"],
default="eigen_full_left")
self.parser.add_argument("--num_layers",
type=int,
help="number of resnet layers",
default=50,
choices=[18, 34, 50, 101, 152])
self.parser.add_argument("--dataset",
type=str,
help="dataset to train on",
default="kitti",
choices=["kitti", "kitti_odom", "kitti_depth", "kitti_test"])
self.parser.add_argument("--png",
help="if set, trains from raw KITTI png files (instead of jpgs)",
action="store_true")
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("--alpha_smooth",
type=float,
help="disparity smoothness weight",
default=0.04)
self.parser.add_argument("--self_distillation",
type=float,
help="self_distillation weight",
default=0.)
self.parser.add_argument("--gamma_smooth",
type=float,
help="gamma of smooth loss",
default=2)
self.parser.add_argument("--alpha_pc",
type=float,
help="perceptual loss weight",
default=0.1)
self.parser.add_argument("--disp_min",
type=float,
help="minimum depth",
default=2.)
self.parser.add_argument("--disp_max",
type=float,
help="maximum depth",
default=300.)
self.parser.add_argument("--disp_levels",
type=int,
help="num levels of disp",
default=49)
self.parser.add_argument("--disp_layers",
type=int,
help="num layers of disp",
default=2)
self.parser.add_argument("--novel_frame_ids",
nargs="+",
type=int,
help="frames to load",
default=[])
self.parser.add_argument("--net_type",
type=str,
help="train which network",
default="ResNet",
choices=["PladeNet", "ResNet", "FalNet"])
self.parser.add_argument("--num_ep",
type=int,
help="train which stage",
default=8)
self.parser.add_argument("--warp_type",
type=str,
help="the type of warp",
default="disp_warp",
choices=["depth_warp", "disp_warp", "homography_warp"])
self.parser.add_argument("--match_aug",
action="store_true",
help="if set, use color augmented data to compute loss")
self.parser.add_argument("--use_denseaspp",
action="store_true",
help="use DenseAspp block in ResNet")
self.parser.add_argument("--use_mom",
action="store_true",
help="use mirror occlusion mask")
self.parser.add_argument("--flip_right",
action="store_true",
help="use fliped right image to train")
self.parser.add_argument("--pc_net",
type=str,
help="the type of net to compute pc loss",
default="vgg19",
choices=["vgg19", "resnet18"])
self.parser.add_argument("--xz_levels",
type=int,
help="num levels of xz plane",
default=14)
self.parser.add_argument("--yz_levels",
type=int,
help="num levels of yz plane",
default=0)
self.parser.add_argument("--use_mixture_loss",
action="store_true",
help="use mixture loss")
self.parser.add_argument("--alpha_self",
type=float,
help="perceptual loss weight",
default=0.)
self.parser.add_argument("--depth_regression_space",
type=str,
help="how to compute regression depth",
default="inv",
choices=["inv", "exp"])
self.parser.add_argument("--render_probability",
action="store_true",
help="If set, render probability as NeRF")
self.parser.add_argument("--plane_residual",
action="store_true",
help="If set, use residual plane based on init plane")
self.parser.add_argument("--no_crop",
action="store_true",
help="if set, do not use resize crop data aug")
self.parser.add_argument("--pe_type",
type=str,
help="the type of positional embedding",
default="neural",
choices=["neural", "frequency"])
self.parser.add_argument("--use_colmap",
action="store_true",
help="if set, use colmap instead of predicting pose by posenet")
self.parser.add_argument("--colmap_path",
type=str,
help="path to the colmap data",
default="./kitti_colmap")
self.parser.add_argument("--no_stereo",
action="store_true",
help="if set, disable stereo supervised")
# OPTIMIZATION options
self.parser.add_argument("--batch_size",
type=int,
help="batch size",
default=8)
self.parser.add_argument("--learning_rate",
type=float,
help="learning rate",
default=1e-4)
self.parser.add_argument("--beta_1",
type=float,
help="beta1 of Adam",
default=0.5)
self.parser.add_argument("--beta_2",
type=float,
help="beta2 of Adam",
default=0.999)
self.parser.add_argument("--num_epochs",
type=int,
help="number of epochs",
default=50)
self.parser.add_argument("--start_epoch",
type=int,
help="number of epochs",
default=0)
self.parser.add_argument('--milestones',
default=[30, 40], nargs='*',
help='epochs at which learning rate is divided by 2')
self.parser.add_argument("--scheduler_step_size",
type=int,
help="epochs at which learning rate times 0.1",
default=15)
# ABLATION options
self.parser.add_argument("--avg_reprojection",
help="if set, uses average reprojection loss",
action="store_true")
self.parser.add_argument("--automask",
help="if set, do auto-masking",
action="store_true")
# SYSTEM options
self.parser.add_argument("--num_workers",
type=int,
help="number of dataloader workers",
default=12)
# 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"])
self.parser.add_argument("--stage1_weights_folder",
type=str,
help="path of teacher model to load")
# LOGGING options
self.parser.add_argument("--log_frequency",
type=int,
help="number of batches between each tensorboard log",
default=500)
self.parser.add_argument("--log_img_frequency",
type=int,
help="number of batches between each tensorboard log",
default=250)
self.parser.add_argument("--use_ssim",
help="if set, use ssim in the loss",
action="store_true")
# 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_raw",
choices=[
"eigen_raw", "eigen_improved", "eigen_benchmark", "benchmark", "odom_9", "odom_10", "city"],
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")
def parse(self):
self.options = self.parser.parse_args()
return self.options