-
Notifications
You must be signed in to change notification settings - Fork 130
/
config.py
303 lines (233 loc) · 7.6 KB
/
config.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
import os
import numpy as np
class Config:
def __init__(self):
self._configs = {}
self._configs["dataset"] = None
self._configs["sampling_function"] = "kp_detection"
# Training Config
self._configs["display"] = 5
self._configs["snapshot"] = 5000
self._configs["stepsize"] = 450000
self._configs["learning_rate"] = 0.00025
self._configs["decay_rate"] = 10
self._configs["max_iter"] = 500000
self._configs["val_iter"] = 100
self._configs["batch_size"] = 1
self._configs["snapshot_name"] = None
self._configs["prefetch_size"] = 100
self._configs["weight_decay"] = False
self._configs["weight_decay_rate"] = 1e-5
self._configs["weight_decay_type"] = "l2"
self._configs["pretrain"] = None
self._configs["opt_algo"] = "adam"
self._configs["chunk_sizes"] = None
self._configs["use_crop"] = False
# Directories
self._configs["data_dir"] = "./data"
self._configs["cache_dir"] = "./cache"
self._configs["config_dir"] = "./config"
self._configs["result_dir"] = "./results"
# Split
self._configs["train_split"] = "trainval"
self._configs["val_split"] = "minival"
self._configs["test_split"] = "testdev"
# Rng
self._configs["data_rng"] = np.random.RandomState(123)
self._configs["nnet_rng"] = np.random.RandomState(317)
# MSDETR Model Setting
self._configs["res_layers"] = [2, 2, 2, 2]
self._configs["res_dims"] = [64, 128, 256, 512]
self._configs["res_strides"] = [1, 2, 2, 2]
self._configs["attn_dim"] = 64
self._configs["dim_feedforward"] = 4 * 64
self._configs["drop_out"] = 0.1
self._configs["num_heads"] = 8
self._configs["enc_layers"] = 6
self._configs["dec_layers"] = 6
self._configs["lsp_dim"] = 8
self._configs["mlp_layers"] = 3
self._configs["aux_loss"] = True
self._configs["pos_type"] = 'sine'
self._configs["pre_norm"] = False
self._configs["return_intermediate"] = True
self._configs["block"] = "BasicBlock"
self._configs["lane_categories"] = 2
self._configs["num_queries"] = 100
# LaneDetection Setting
self._configs["max_lanes"] = None
@property
def max_lanes(self):
return self._configs["max_lanes"]
@property
def num_queries(self):
return self._configs["num_queries"]
@property
def lane_categories(self):
return self._configs["lane_categories"]
@property
def block(self):
return self._configs["block"]
@property
def return_intermediate(self):
return self._configs["return_intermediate"]
@property
def pre_norm(self):
return self._configs["pre_norm"]
@property
def pos_type(self):
return self._configs["pos_type"]
@property
def aux_loss(self):
return self._configs["aux_loss"]
@property
def mlp_layers(self):
return self._configs["mlp_layers"]
@property
def lsp_dim(self):
return self._configs["lsp_dim"]
@property
def dec_layers(self):
return self._configs["dec_layers"]
@property
def enc_layers(self):
return self._configs["enc_layers"]
@property
def num_heads(self):
return self._configs["num_heads"]
@property
def drop_out(self):
return self._configs["drop_out"]
@property
def dim_feedforward(self):
return self._configs["dim_feedforward"]
@property
def attn_dim(self):
return self._configs["attn_dim"]
@property
def res_strides(self):
return self._configs["res_strides"]
@property
def res_dims(self):
return self._configs["res_dims"]
@property
def res_layers(self):
return self._configs["res_layers"]
@property
def chunk_sizes(self):
return self._configs["chunk_sizes"]
@property
def use_crop(self):
return self._configs["use_crop"]
@property
def train_split(self):
return self._configs["train_split"]
@property
def val_split(self):
return self._configs["val_split"]
@property
def test_split(self):
return self._configs["test_split"]
@property
def full(self):
return self._configs
@property
def sampling_function(self):
return self._configs["sampling_function"]
@property
def data_rng(self):
return self._configs["data_rng"]
@property
def nnet_rng(self):
return self._configs["nnet_rng"]
@property
def opt_algo(self):
return self._configs["opt_algo"]
@property
def weight_decay_type(self):
return self._configs["weight_decay_type"]
@property
def prefetch_size(self):
return self._configs["prefetch_size"]
@property
def pretrain(self):
return self._configs["pretrain"]
@property
def weight_decay_rate(self):
return self._configs["weight_decay_rate"]
@property
def weight_decay(self):
return self._configs["weight_decay"]
@property
def result_dir(self):
result_dir = os.path.join(self._configs["result_dir"], self.snapshot_name)
if not os.path.exists(result_dir):
os.makedirs(result_dir)
return result_dir
@property
def dataset(self):
return self._configs["dataset"]
@property
def snapshot_name(self):
return self._configs["snapshot_name"]
@property
def snapshot_dir(self):
snapshot_dir = os.path.join(self.cache_dir, "nnet", self.snapshot_name)
if not os.path.exists(snapshot_dir):
os.makedirs(snapshot_dir)
return snapshot_dir
@property
def snapshot_file(self):
snapshot_file = os.path.join(self.snapshot_dir, self.snapshot_name + "_{}.pkl")
return snapshot_file
@property
def box_snapshot_dir(self):
box_snaptshot_dir = os.path.join(self.box_cache_dir, 'nnet', self.snapshot_name)
return box_snaptshot_dir
@property
def box_snapshot_file(self):
box_snapshot_file = os.path.join(self.box_snapshot_dir, self.snapshot_name + "_{}.pkl")
return box_snapshot_file
@property
def config_dir(self):
return self._configs["config_dir"]
@property
def batch_size(self):
return self._configs["batch_size"]
@property
def max_iter(self):
return self._configs["max_iter"]
@property
def learning_rate(self):
return self._configs["learning_rate"]
@property
def decay_rate(self):
return self._configs["decay_rate"]
@property
def stepsize(self):
return self._configs["stepsize"]
@property
def snapshot(self):
return self._configs["snapshot"]
@property
def display(self):
return self._configs["display"]
@property
def val_iter(self):
return self._configs["val_iter"]
@property
def data_dir(self):
return self._configs["data_dir"]
@property
def cache_dir(self):
if not os.path.exists(self._configs["cache_dir"]):
os.makedirs(self._configs["cache_dir"])
return self._configs["cache_dir"]
@property
def box_cache_dir(self):
return self._configs['box_cache_dir']
def update_config(self, new):
for key in new:
if key in self._configs:
self._configs[key] = new[key]
system_configs = Config()