-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathopts.py
125 lines (104 loc) · 7.09 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
import argparse
import time
import yaml
from misc import utils
def parse_opts():
parser = argparse.ArgumentParser()
# ID of this run
parser.add_argument('--cfg_path', type=str, default='cfgs/basic_rnn.yml', help='')
parser.add_argument('--id', type=str, default='default', help='id of this run')
parser.add_argument('--gpu_id', type=str, nargs='+', default=['0'])
parser.add_argument('--seed', type=int, default=777)
parser.add_argument('--disable_cudnn', type=int, default=1, help='disable cudnn may solve some unknown bugs')
parser.add_argument('--debug', action='store_true', help='using mini-dataset for fast debugging')
# ***************************** INPUT DATA PATH *****************************
parser.add_argument('--train_caption_file', type=str,
default='data/captiondata/train_modified.json', help='')
parser.add_argument('--invalid_video_json', type=str, default='data/resnet_bn_invalid_videos.json')
parser.add_argument('--val_caption_file', type=str, default='data/captiondata/val_1.json')
parser.add_argument('--visual_feature_folder', type=str, default='data/resnet_bn')
parser.add_argument('--train_proposal_file', type=str, default='',
help='generated results on trainset of a Temporal Action Proposal model')
parser.add_argument('--visual_feature_type', type=str, default='c3d', choices=['c3d', 'resnet_bn', 'resnet'])
parser.add_argument('--feature_dim', type=int, default=500, help='dim of frame-level feature vector')
parser.add_argument('--dict_file', type=str, default='data/vocabulary_activitynet.json', help='')
parser.add_argument('--start_from', type=str, default='', help='id of the run with incomplete training')
parser.add_argument('--start_from_mode', type=str, choices=['best', 'best-RL', 'last'], default="last")
parser.add_argument('--pretrain', action='store_true')
parser.add_argument('--pretrain_path', type=str, default='', help='path of .pth')
# ***************************** DATALOADER OPTION *****************************
parser.add_argument('--nthreads', type=int, default=4)
parser.add_argument('--feature_sample_rate', type=int, default=1)
parser.add_argument('--train_proposal_sample_num', type=int,
default=24,
help='number of sampled proposals (or proposal sequence), a bigger value may be better')
parser.add_argument('--train_proposal_type', type=str, default='', help='gt, learnt_seq, learnt')
# ***************************** Event ENCODER *****************************
parser.add_argument('--event_encoder_type', type=str, choices=['basic', 'TSRM'], default='basic')
parser.add_argument('--hidden_dim', type=int, default=512, help='hidden size of all fc layers')
parser.add_argument('--group_num', type=int, default=16, help='')
parser.add_argument('--use_posit_branch', type=int, default=1, help='')
# ***************************** CAPTION DECODER *****************************
parser.add_argument('--wordRNN_input_feats_type', type=str, default='C', choices=['C', 'E', 'C+E'],
help='C:clip-level features, E: event-level features, C+E: both')
parser.add_argument('--caption_decoder_type', type=str, default="show_attend_tell",
choices=['show_attend_tell', 'hrnn', 'cmg_hrnn'])
parser.add_argument('--rnn_size', type=int, default=512,
help='size of the rnn in number of hidden nodes in each layer')
parser.add_argument('--num_layers', type=int, default=1, help='number of layers in the RNN')
parser.add_argument('--input_encoding_size', type=int, default=512,
help='the encoding size of each token in the vocabulary')
parser.add_argument('--att_hid_size', type=int, default=512, help='the hidden size of the attention MLP')
parser.add_argument('--drop_prob', type=float, default=0.5, help='strength of dropout in the Language Model RNN')
parser.add_argument('--max_caption_len', type=int, default=30, help='')
# ***************************** OPTIMIZER *****************************
# optimizer
parser.add_argument('--epoch', type=int, default=25)
parser.add_argument('--batch_size', type=int, default=1, help='batch_size must be 1 when using hrnn')
parser.add_argument('--grad_clip', type=float, default=100., help='clip gradients at this value')
parser.add_argument('--optimizer_type', type=str, default='adam')
parser.add_argument('--weight_decay', type=float, default=0, help='weight_decay')
# lr
parser.add_argument('--lr', type=float, default=1e-4, help='1e-4 for resnet feature and 5e-5 for C3D feature')
parser.add_argument('--learning_rate_decay_start', type=float, default=8)
parser.add_argument('--learning_rate_decay_every', type=float, default=3)
parser.add_argument('--learning_rate_decay_rate', type=float, default=0.5)
# scheduled sampling
parser.add_argument('--scheduled_sampling_start', type=int, default=-1,
help='at what iteration to start decay gt probability')
parser.add_argument('--basic_ss_prob', type=float, default=0, help='initial ss prob')
parser.add_argument('--scheduled_sampling_increase_every', type=int, default=2,
help='every how many iterations thereafter to gt probability')
parser.add_argument('--scheduled_sampling_increase_prob', type=float, default=0.05,
help='How much to update the prob')
parser.add_argument('--scheduled_sampling_max_prob', type=float, default=0.25,
help='Maximum scheduled sampling prob.')
# self critical learning
parser.add_argument('--self_critical_after', type=int, default=-1)
# ***************************** SAVING AND LOGGING *****************************
parser.add_argument('--min_epoch_when_save', type=int, default=-1)
parser.add_argument('--save_checkpoint_every', type=int, default=1)
parser.add_argument('--save_all_checkpoint', action='store_true')
parser.add_argument('--save_dir', type=str, default='./save', help='directory to store checkpointed models')
# ***************************** Evaluation *************************************
parser.add_argument('--eval_score_threshold', type=float, default=0.)
parser.add_argument('--eval_nms_threshold', type=float, default=1)
parser.add_argument('--eval_top_n', type=int, default=100)
args = parser.parse_args()
if args.cfg_path:
with open(args.cfg_path, 'r') as handle:
options_yaml = yaml.load(handle)
utils.update_values(options_yaml, vars(args))
args.raw_feature_dim = args.feature_dim
if args.debug:
args.id = 'debug_' + time.strftime("%Y-%m-%d_%H-%M-%S", time.localtime())
args.min_epoch_when_save = 0
args.save_checkpoint_every = 1
args.shuffle = 0
args.tap_epochs = 10
args.train_caption_file = 'data/captiondata/train_modified_small.json'
args.val_caption_file = 'data/captiondata/val_1_small.json'
return args
if __name__ == '__main__':
opt = parse_opts()
print(opt)