forked from yusong-tan/MARS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
opts.py
230 lines (222 loc) · 6.22 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
import argparse
def parse_opts(arguments=None):
parser = argparse.ArgumentParser()
# Datasets
parser.add_argument(
'--frame_dir',
default='dataset/HMDB51/',
type=str,
help='path of jpg files')
parser.add_argument(
'--annotation_path',
default='dataset/HMDB51_labels',
type=str,
help='label paths')
parser.add_argument(
'--dataset',
default='HMDB51',
type=str,
help='(HMDB51, UCF101, Kinectics)')
parser.add_argument(
'--split',
default=1,
type=str,
help='(for HMDB51 and UCF101)')
parser.add_argument(
'--modality',
default='RGB',
type=str,
help='(RGB, Flow)')
parser.add_argument(
'--input_channels',
default=3,
type=int,
help='(3, 2)')
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=51,
type=int,
help=
'Number of classes for fine-tuning. n_classes is set to the number when pretraining.')
parser.add_argument(
'--only_RGB',
action='store_true',
help='Extracted only RGB frames')
parser.set_defaults(only_RGB = False)
# Model parameters
parser.add_argument(
'--output_layers',
action='append',
help='layer to output on forward pass')
parser.set_defaults(output_layers=[])
parser.add_argument(
'--model',
default='resnext',
type=str,
help='Model base architecture')
parser.add_argument(
'--model_depth',
default=101,
type=int,
help='Number of layers in model')
parser.add_argument(
'--resnet_shortcut',
default='B',
type=str,
help='Shortcut type of resnet (A | B)')
parser.add_argument(
'--resnext_cardinality',
default=32,
type=int,
help='ResNeXt cardinality')
parser.add_argument(
'--ft_begin_index',
default=4,
type=int,
help='Begin block index of fine-tuning')
parser.add_argument(
'--sample_size',
default=112,
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(
'--training',
action='store_true',
help='training/testing')
parser.set_defaults(training=True)
parser.add_argument(
'--freeze_BN',
action='store_true',
help='freeze_BN/testing')
parser.set_defaults(freeze_BN=False)
parser.add_argument(
'--batch_size',
default=20,
type=int,
help='Batch Size')
parser.add_argument(
'--n_workers',
default=4,
type=int,
help='Number of workers for dataloader')
# optimizer parameters
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-3,
type=float,
help='Weight Decay')
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(
'--MARS_alpha',
default=50,
type=float,
help='Weight of Flow augemented MSE loss')
parser.add_argument(
'--n_epochs',
default=400,
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.')
# options for logging
parser.add_argument(
'--result_path',
default='',
type=str,
help='result_path')
parser.add_argument(
'--MARS',
action='store_true',
help='test MARS')
parser.set_defaults(MARS=False)
parser.add_argument(
'--pretrain_path',
default='',
type=str,
help='Pretrained model (.pth)')
parser.add_argument(
'--MARS_pretrain_path',
default='',
type=str,
help='Pretrained model (.pth)')
parser.add_argument(
'--MARS_resume_path',
default='',
type=str,
help='MARS resume model (.pth)')
parser.add_argument(
'--resume_path1',
default='',
type=str,
help='Save data (.pth) of previous training')
parser.add_argument(
'--resume_path2',
default='',
type=str,
help='Save data (.pth) of previous training')
parser.add_argument(
'--resume_path3',
default='',
type=str,
help='Save data (.pth) of previous training')
parser.add_argument(
'--log',
default=1,
type=int,
help='Log training and validation')
parser.add_argument(
'--checkpoint',
default=2,
type=int,
help='Trained model is saved at every this epochs.')
parser.add_argument(
'--manual_seed', default=1, type=int, help='Manually set random seed')
parser.add_argument(
'--random_seed', default=1, type=bool, help='Manually set random seed of sampling validation clip')
if arguments is None:
args = parser.parse_args()
else:
args = parser.parse_args(arguments)
return args