-
Notifications
You must be signed in to change notification settings - Fork 3
/
opts.py
444 lines (435 loc) · 13.9 KB
/
opts.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
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
import argparse
def parse_opts():
parser = argparse.ArgumentParser()
parser.add_argument('--shot', type=int, default=1)
parser.add_argument('--query', type=int, default=5)
parser.add_argument('--train_way', type=int, default=30)
parser.add_argument('--test_way', type=int, default=5)
parser.add_argument('--nepisode', type=int, default=500)
parser.add_argument('--query_base', type=int, default=5)
parser.add_argument('--test_base_way', type=int, default=5)
parser.add_argument('--query_novel', type=int, default=5)
parser.add_argument('--test_novel_way', type=int, default=5)
parser.add_argument(
'--root_path',
default='/root/data/ActivityNet',
type=str,
help='Root directory path of data')
parser.add_argument(
'--video_path',
default='video_kinetics_jpg',
type=str,
help='Directory path of Videos')
parser.add_argument(
'--train_video_path',
default='video_kinetics_jpg',
type=str,
help='Directory path of Videos')
parser.add_argument(
'--val_video_path',
default='video_kinetics_jpg',
type=str,
help='Directory path of Videos')
parser.add_argument(
'--test_video_path',
default='video_kinetics_jpg',
type=str,
help='Directory path of Videos')
parser.add_argument(
'--test_novel_video_path',
default='video_kinetics_jpg',
type=str,
help='Directory path of Videos')
parser.add_argument(
'--test_base_video_path',
default='video_kinetics_jpg',
type=str,
help='Directory path of Videos')
parser.add_argument(
'--train_list_path',
default='video_kinetics_jpg',
type=str,
help='Directory path of Videos')
parser.add_argument(
'--val_list_path',
default='video_kinetics_jpg',
type=str,
help='Directory path of Videos')
parser.add_argument(
'--yfcc_root',
default='video_kinetics_jpg',
type=str,
help='Directory path of Videos')
parser.add_argument(
'--yfcc_video_list',
default='video_kinetics_jpg',
type=str,
help='Directory path of Videos')
parser.add_argument(
'--yfcc_clips',
default='video_kinetics_jpg',
type=str,
help='Directory path of Videos')
parser.add_argument(
'--test_list_path',
default='video_kinetics_jpg',
type=str,
help='Directory path of Videos')
parser.add_argument(
'--test_novel_list_path',
default='video_kinetics_jpg',
type=str,
help='Directory path of Videos')
parser.add_argument(
'--test_base_list_path',
default='video_kinetics_jpg',
type=str,
help='Directory path of Videos')
parser.add_argument(
'--split_path',
default='video_kinetics_jpg',
type=str,
help='Directory path of Videos')
parser.add_argument(
'--annotation_path',
default='kinetics.json',
type=str,
help='Annotation file path')
parser.add_argument(
'--result_path',
default='results',
type=str,
help='Result directory path')
parser.add_argument(
'--subset',
default='train',
type=str,
help='Result directory path')
parser.add_argument(
'--dataset',
default='kinetics',
type=str,
help='Used dataset (activitynet | kinetics | ucf101 | hmdb51)')
parser.add_argument(
'--n_classes',
default=400,
type=int,
help=
'Number of classes (activitynet: 200, kinetics: 400, ucf101: 101, hmdb51: 51)'
)
parser.add_argument(
'--n_finetune_classes',
default=400,
type=int,
help=
'Number of classes for fine-tuning. n_classes is set to the number when pretraining.'
)
parser.add_argument(
'--clip_size',
default=112,
type=int,
help='Height and width of inputs')
parser.add_argument(
'--clip_duration',
default=16,
type=int,
help='Temporal duration of inputs')
parser.add_argument(
'--emb_dim',
default=512,
type=int,
help='Temporal duration of inputs')
parser.add_argument(
'--num_videos_per_batch',
default=16,
type=int,
help='Temporal duration of inputs')
parser.add_argument(
'--initial_scale',
default=1.0,
type=float,
help='Initial scale for multiscale cropping')
parser.add_argument(
'--n_scales',
default=5,
type=int,
help='Number of scales for multiscale cropping')
parser.add_argument(
'--scale_step',
default=0.84089641525,
type=float,
help='Scale step for multiscale cropping')
parser.add_argument(
'--train_crop',
default='corner',
type=str,
help=
'Spatial cropping method in training. random is uniform. corner is selection from 4 corners and 1 center. ( fme | corner | center)'
)
parser.add_argument(
'--margin',
default=1,
type=float,
help=
'Initial learning rate (divided by 10 while training by lr scheduler)')
parser.add_argument(
'--learning_rate',
default=0.1,
type=float,
help=
'Initial learning rate (divided by 10 while training by lr scheduler)')
parser.add_argument('--momentum', default=0.9, type=float, help='Momentum')
parser.add_argument(
'--dampening', default=0.9, type=float, help='dampening of SGD')
parser.add_argument(
'--weight_decay', default=1e-2, type=float, help='Weight Decay')
parser.add_argument(
'--mean_dataset',
default='activitynet',
type=str,
help=
'dataset for mean values of mean subtraction (activitynet | kinetics)')
parser.add_argument(
'--no_mean_norm',
action='store_true',
help='If true, inputs are not normalized by mean.')
parser.set_defaults(no_mean_norm=False)
parser.add_argument(
'--std_norm',
action='store_true',
help='If true, inputs are normalized by standard deviation.')
parser.add_argument(
'--norm_value',
default=1,
type=int,
help=
'If 1, range of inputs is [0-255]. If 255, range of inputs is [0-1].')
parser.set_defaults(std_norm=False)
parser.add_argument(
'--nesterov', action='store_true', help='Nesterov momentum')
parser.set_defaults(nesterov=False)
parser.add_argument(
'--optimizer',
default='sgd',
type=str,
help='Currently only support SGD')
parser.add_argument(
'--lr_patience',
default=10,
type=int,
help='Patience of LR scheduler. See documentation of ReduceLROnPlateau.'
)
parser.add_argument(
'--lr',
default=0.001,
type=float,
help=
'Initial learning rate (divided by 10 while training by lr scheduler)')
parser.add_argument(
'--layer_lr',
nargs='+',
help='Reduce learning rate',
default=None,
type=float
)
parser.add_argument(
'--batch_size', default=64, type=int, help='Batch Size')
parser.add_argument(
'--n_epochs',
default=1000,
type=int,
help='Number of total epochs to run')
parser.add_argument(
'--nepoch',
default=5,
type=int,
help='Number of total epochs to run')
parser.add_argument(
'--begin_epoch',
default=1,
type=int,
help=
'Training begins at this epoch. Previous trained model indicated by resume_path is loaded.'
)
parser.add_argument(
'--sample_size',
default=112,
type=int,
help='Height and width of inputs')
parser.add_argument(
'--num_video_per_batch',
default=2,
type=int,
help='Height and width of inputs')
parser.add_argument(
'--num_clip_per_video',
default=16,
type=int,
help='Height and width of inputs')
parser.add_argument(
'--sample_duration',
default=16,
type=int,
help='Temporal duration of inputs')
parser.add_argument(
'--n_samples_for_each_video',
default=1,
type=int,
help='Number of validation samples for each activity')
parser.add_argument(
'--gem_p',
default=1,
type=int,
help='Number of validation samples for each activity')
parser.add_argument(
'--kshot',
default=None,
type=int,
help='# of examples per class.'
)
parser.add_argument(
'--weighting',
action='store_true',
help='If true, inputs are not normalized by mean.')
parser.add_argument(
'--n_val_samples',
default=3,
type=int,
help='Number of validation samples for each activity')
parser.add_argument(
'--num_clips_per_video',
default=1,
type=int,
help='Number of validation samples for each activity')
parser.add_argument(
'--resume_path',
default='',
type=str,
help='Save data (.pth) of previous training')
parser.add_argument(
'--pretrained_clip_model_path', default='', type=str, help='Pretrained model (.pth)')
parser.add_argument(
'--pretrain_path', default='', type=str, help='Pretrained model (.pth)')
parser.add_argument(
'--yfcc_feature_path', default='', type=str, help='Pretrained model (.pth)')
parser.add_argument(
'--feature_path', default='', type=str, help='Pretrained model (.pth)')
parser.add_argument(
'--novel_feature_path', default='', type=str, help='Pretrained model (.pth)')
parser.add_argument(
'--base_feature_path', default='', type=str, help='Pretrained model (.pth)')
parser.add_argument(
'--pca_path', default='/BS/YFCC100M/nobackup/r25d_sports_feature/pca_transform_Sports.pkl', type=str, help='Pretrained model (.pth)')
parser.add_argument(
'--scaler_path', default='/BS/YFCC100M/nobackup/r25d_sports_feature/std_scaler_Sports.pkl', type=str, help='Pretrained model (.pth)')
parser.add_argument(
'--ft_begin_index',
default=0,
type=int,
help='Begin block index of fine-tuning')
parser.add_argument(
'--topk',
default=5,
type=int,
help='Begin block index of fine-tuning')
parser.add_argument(
'--no_train',
action='store_true',
help='If true, training is not performed.')
parser.add_argument(
'--adam',
action='store_true',
help='If true, training is not performed.')
parser.add_argument(
'--no_last_fc',
action='store_true',
help='If true, training is not performed.')
parser.set_defaults(no_train=False)
parser.add_argument(
'--no_val',
action='store_true',
help='If true, validation is not performed.')
#parser.set_defaults(no_val=False)
parser.add_argument(
'--test', action='store_true', help='If true, test is performed.')
parser.set_defaults(test=False)
parser.add_argument(
'--scale_in_test',
default=1.0,
type=float,
help='Spatial scale in test')
parser.add_argument(
'--crop_position_in_test',
default='c',
type=str,
help='Cropping method (c | tl | tr | bl | br) in test')
parser.add_argument(
'--no_softmax_in_test',
action='store_true',
help='If true, output for each clip is not normalized using softmax.')
parser.set_defaults(no_softmax_in_test=False)
parser.add_argument(
'--no_cuda', action='store_true', help='If true, cuda is not used.')
parser.set_defaults(no_cuda=False)
parser.add_argument(
'--n_threads',
default=4,
type=int,
help='Number of threads for multi-thread loading')
parser.add_argument(
'--checkpoint',
default=10,
type=int,
help='Trained model is saved at every this epochs.')
parser.add_argument(
'--val_every',
default=10,
type=int,
help='Trained model is saved at every this epochs.')
parser.add_argument(
'--no_hflip',
action='store_true',
help='If true holizontal flipping is not performed.')
parser.set_defaults(no_hflip=False)
parser.add_argument(
'--clip_model',
default='resnet',
type=str,
help='(resnet | preresnet | wideresnet | resnext | densenet | ')
parser.add_argument(
'--outfile',
default='resnet',
type=str,
help='(resnet | preresnet | wideresnet | resnext | densenet | ')
parser.add_argument(
'--clip_model_depth',
default=18,
type=int,
help='Depth of resnet (10 | 18 | 34 | 50 | 101)')
parser.add_argument(
'--train_feat',
default='',
type=str,
help='Depth of resnet (10 | 18 | 34 | 50 | 101)')
parser.add_argument(
'--val_feat',
default='',
type=str,
help='Depth of resnet (10 | 18 | 34 | 50 | 101)')
parser.add_argument(
'--resnet_shortcut',
default='B',
type=str,
help='Shortcut type of resnet (A | B)')
parser.add_argument(
'--manual_seed', default=1, type=int, help='Manually set random seed')
parser.add_argument(
'--gpu', default = None, type = int, help = 'GPU id')
parser.add_argument(
'--distributed', default = False,)
parser.add_argument(
'--model', default = 'resnet', type = str,
help = '(resnet | preresnet | wideresnet | resnext | densenet | ')
parser.add_argument('--model_depth', default = 18, type = int, help = 'Depth of resnet (10 | 18 | 34 | 50 | 101)')
args = parser.parse_args()
return args