-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathargs.py
213 lines (190 loc) · 6.18 KB
/
args.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
import argparse
import os
DEFAULT_DATASET_DIR = ""
DEFAULT_CKPT_DIR = ""
TRANSFORMERS_PATH = ""
SSD_DIR = ""
def get_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"--dataset",
type=str,
)
parser.add_argument(
"--baseline",
type=str,
default="",
choices=["", "qa"],
help="qa baseline does not use the video, video baseline does not use the question",
)
parser.add_argument(
"--n_layers",
type=int,
default=2,
help="number of layers in the multi-modal transformer",
)
parser.add_argument(
"--n_heads",
type=int,
default=8,
help="number of attention heads in the multi-modal transformer",
)
parser.add_argument(
"--embd_dim",
type=int,
default=512,
help="multi-modal transformer and final embedding dimension",
)
parser.add_argument(
"--ff_dim",
type=int,
default=2048,
help="multi-modal transformer feed-forward dimension",
)
parser.add_argument(
"--dropout",
type=float,
default=0.1,
help="dropout rate in the multi-modal transformer",
)
parser.add_argument(
"--sentence_dim",
type=int,
default=2048,
help="sentence dimension for the differentiable bag-of-words embedding the answers",
)
parser.add_argument(
"--qmax_words",
type=int,
default=20,
help="maximum number of words in the question",
)
parser.add_argument(
"--amax_words",
type=int,
default=10,
help="maximum number of words in the answer",
)
parser.add_argument(
"--max_feats",
type=int,
default=20,
help="maximum number of video features considered",
)
# Paths
parser.add_argument(
"--dataset_dir",
type=str,
default='./gsmt_data/datasets/',
help="folder where the datasets folders are stored",
)
parser.add_argument(
"--feature_dir",
type=str,
default='../data/feats/',
help="folder where the datasets folders are stored",
)
parser.add_argument(
"--checkpoint_predir",
type=str,
default=DEFAULT_CKPT_DIR,
help="folder to store checkpoints",
)
parser.add_argument(
"--checkpoint_dir", type=str, default="", help="subfolder to store checkpoint"
)
parser.add_argument(
"--pretrain_path", type=str, default="", help="path to pretrained checkpoint"
)
parser.add_argument(
"--bert_path",
type=str,
default=TRANSFORMERS_PATH,
help="path to transformer models checkpoints",
)
parser.add_argument("--batch_size", type=int, default=256)
parser.add_argument("--batch_size_val", type=int, default=2048)
parser.add_argument(
"--n_pair",
type=int,
default=32,
help="number of clips per video to consider to train on HowToVQA69M",
)
parser.add_argument("--seed", type=int, default=1)
parser.add_argument("--epochs", type=int, default=20)
parser.add_argument(
"--test", type=int, default=0, help="use to evaluate without training"
)
parser.add_argument(
"--lr", type=float, default=0.00005, help="initial learning rate"
)
parser.add_argument("--weight_decay", type=float, default=0, help="weight decay")
parser.add_argument(
"--clip",
type=float,
default=12,
help="gradient clipping",
)
# Print
parser.add_argument(
"--freq_display", type=int, default=3, help="number of train prints per epoch"
)
parser.add_argument(
"--num_thread_reader", type=int, default=16, help="number of workers"
)
# Masked Language Modeling and Cross-Modal Matching parameters
parser.add_argument("--mlm_prob", type=float, default=0.15)
parser.add_argument("--n_negs", type=int, default=1)
parser.add_argument("--lr_decay", type=float, default=0.9)
parser.add_argument("--min_time", type=int, default=10)
parser.add_argument("--min_words", type=int, default=10)
# Demo parameters
parser.add_argument(
"--question_example", type=str, default="", help="demo question text"
)
parser.add_argument("--video_example", type=str, default="", help="demo video path")
parser.add_argument("--port", type=int, default=8899, help="demo port")
parser.add_argument(
"--pretrain_path2", type=str, default="", help="second demo model"
)
parser.add_argument(
"--save_dir", type=str, default="./save_models/", help="path to save dir"
)
parser.add_argument(
"--mc", type=int, default=5, help="number of multiple choices"
)
parser.add_argument(
"--bnum", type=int, default=10, help="number of region proposal"
)
parser.add_argument(
"--feature_dim", type=int, default=2048, help="whether to finetune the weights pretrained on WebVid"
)
parser.add_argument(
"--topk-selector-dataloading", type=int, default=0
)
parser.add_argument(
"--num-frames-in-feature-file", type=int, default=32
)
parser.add_argument(
"--use-gss", type=int, default=0
)
parser.add_argument(
"--use-attn", type=int, default=0
)
parser.add_argument(
"--use-conv", type=int, default=0
)
parser.add_argument(
"--upper-gss", type=int, default=0
)
args = parser.parse_args()
os.environ["TRANSFORMERS_CACHE"] = args.bert_path
args.word_dim = 768
load_path = os.path.join(args.dataset_dir, args.dataset)
args.load_path = load_path
args.features_path = os.path.join(args.feature_dir, args.dataset)
args.train_csv_path = os.path.join(load_path, "train.csv")
args.val_csv_path = os.path.join(load_path, "val.csv")
args.test_csv_path = os.path.join(load_path, "test.csv")
args.vocab_path = os.path.join(load_path, "vocab.json")
return args