-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.py
170 lines (156 loc) · 5.87 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
import argparse
def str2bool(v):
return v.lower() in ("true", "1")
arg_lists = []
parser = argparse.ArgumentParser()
def add_argument_group(name):
arg = parser.add_argument_group(name)
arg_lists.append(arg)
return arg
# -----------------------------------------------------------------------------
# Network
net_arg = add_argument_group("Network")
net_arg.add_argument(
"--net_channels", type=int, default=128, help=""
"number of channels in a layer. Default: 128")
net_arg.add_argument(
"--use_fundamental", type=str2bool, default=False, help=""
"train fundamental matrix estimation. Default: False")
net_arg.add_argument(
"--use_ratio", type=int, default=0, help=""
"use ratio test. 0: not use, 1: use before network, 2: use as side information. Default: 0")
net_arg.add_argument(
"--use_mutual", type=int, default=0, help=""
"use matual nearest neighbor check. 0: not use, 1: use before network, 2: use as side information. Default: 0")
net_arg.add_argument(
"--ratio_test_th", type=float, default=0.9, help=""
"ratio test threshold. Default: 0.8")
net_arg.add_argument(
"--sr", type=float, default=0.5, help=""
"sampling rate. Default: 0.5")
# -----------------------------------------------------------------------------
# Data
data_arg = add_argument_group("Data")
data_arg.add_argument(
"--data_tr", type=str, default='./data_dump/yfcc-sift-2000-train.hdf5', help=""
"name of the dataset for train")
data_arg.add_argument(
"--data_va", type=str, default='./data_dump/yfcc-sift-2000-val.hdf5', help=""
"name of the dataset for valid")
data_arg.add_argument(
"--data_te", type=str, default='./data_dump/yfcc-sift-2000-test.hdf5', help=""
"name of the unseen dataset for test")
# -----------------------------------------------------------------------------
# Objective
obj_arg = add_argument_group("obj")
obj_arg.add_argument(
"--obj_num_kp", type=int, default=2000, help=""
"number of keypoints per image")
obj_arg.add_argument(
"--obj_top_k", type=int, default=-1, help=""
"number of keypoints above the threshold to use for "
"essential matrix estimation. put -1 to use all. ")
obj_arg.add_argument(
"--obj_geod_type", type=str, default="episym",
choices=["sampson", "episqr", "episym"], help=""
"type of geodesic distance")
obj_arg.add_argument(
"--obj_geod_th", type=float, default=1e-4, help=""
"theshold for the good geodesic distance")
# -----------------------------------------------------------------------------
# Loss
loss_arg = add_argument_group("loss")
loss_arg.add_argument(
"--weight_decay", type=float, default=0, help=""
"l2 decay")
loss_arg.add_argument(
"--momentum", type=float, default=0.9, help=""
"momentum")
loss_arg.add_argument(
"--loss_classif", type=float, default=1.0, help=""
"weight of the classification loss")
loss_arg.add_argument(
"--loss_essential", type=float, default=0.5, help=""
"weight of the essential loss")
loss_arg.add_argument(
"--loss_essential_init_iter", type=int, default=20000, help=""
"initial iterations to run only the classification loss")
loss_arg.add_argument(
"--geo_loss_margin", type=float, default=0.1, help=""
"clamping argin in geometry loss")
loss_arg.add_argument(
"--ess_loss_margin", type=float, default=0.1, help=""
"clamping margin in contrastive loss")
# -----------------------------------------------------------------------------
# Training
train_arg = add_argument_group("Train")
train_arg.add_argument(
"--run_mode", type=str, default="train", help=""
"run_mode")
train_arg.add_argument(
"--load", type=bool, default=False, help=""
"load model")
train_arg.add_argument(
"--train_lr", type=float, default=1e-3, help=""
"learning rate")
train_arg.add_argument(
"--train_batch_size", type=int, default=32, help=""
"batch size")
train_arg.add_argument(
"--gpu_num", type=int, default=1, help='number of gpus')
train_arg.add_argument(
"--num_processor", type=int, default=8, help='numbers of used cpu')
train_arg.add_argument(
"--train_iter", type=int, default=500000, help=""
"training iterations to perform")
train_arg.add_argument(
"--lr_step", type=int, default=400000, help=""
"learning rate decay step")
train_arg.add_argument(
"--gamma", type=int, default=0.1, help=""
"gamma for learning rate decay")
train_arg.add_argument(
"--log_base", type=str, default="./logs/", help=""
"save directory name inside results")
train_arg.add_argument(
"--log_suffix", type=str, default="", help=""
"suffix of log dir")
train_arg.add_argument(
"--val_intv", type=int, default=10000, help=""
"validation interval")
train_arg.add_argument(
"--save_intv", type=int, default=1000, help=""
"summary interval")
# -----------------------------------------------------------------------------
# Testing
test_arg = add_argument_group("Test")
test_arg.add_argument(
"--use_ransac", type=str2bool, default=True, help=""
"use ransac when testing?")
test_arg.add_argument(
"--model_path", type=str, default="", help=""
"saved best model path for test")
test_arg.add_argument(
"--res_path", type=str, default="", help=""
"path for saving results")
test_arg.add_argument(
"--thr", type=float, default=3e-5, help=""
"threshold of inliers")
#------------------------------------------------------------------------------
log = add_argument_group('Logs')
log.add_argument(
'--input_pairs', type=str, default='',
help='Path to the list of image pairs')
log.add_argument(
'--input_dir', type=str, default='',
help='Path to the directory that contains the images')
log.add_argument(
'--output_dir', type=str, default='./logs/CLNet_yfcc_sift',
help='')
def get_config():
config, unparsed = parser.parse_known_args()
return config, unparsed
def print_usage():
parser.print_usage()
#
# config.py ends here