-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_sequential_eval.py
100 lines (80 loc) · 3.56 KB
/
run_sequential_eval.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
import os
import argparse
from data_loader import get_loader
from solver import Solver
import copy
from torch.backends import cudnn
def main(config):
# cudnn.benchmark = True
data_loader = get_loader(config.model, config.image_path, config.metadata_path, config.mode, config.batch_size,
config.shuffle)
solver = Solver(data_loader, config)
if config.mode == 'train':
solver.train()
elif config.mode == 'test':
solver.test()
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--mode', type=str, default='train', choices=['train', 'test'])
parser.add_argument('--sequential_mode', type=str, default=None,
choices=[None, 'model', 'fixed_weight', 'batch_size', 'learning_rate', 'beta'])
parser.add_argument('--lr', type=float, default=0.0002)
parser.add_argument('--beta', type=float, default=500)
parser.add_argument('--dropout_rate', type=float, default=0.0, help='range 0.0 to 1.0')
parser.add_argument('--shuffle', type=bool, default=True)
parser.add_argument('--fixed_weight', type=bool, default=False)
parser.add_argument('--model', type=str, default='Resnet', choices=['Googlenet', 'Resnet'])
parser.add_argument('--pretrained_model', type=str, default=None)
parser.add_argument('--image_path', type=str, default='/mnt/data2/image_based_localization/posenet/KingsCollege')
parser.add_argument('--metadata_path', type=str,
default='/mnt/data2/image_based_localization/posenet/KingsCollege/dataset_train.txt')
# Training settings
parser.add_argument('--gpu_ids', type=str, default='0', help='gpu ids: e.g. 0 1 2 3') # selection of gpu id (single gpu)
# parser.add_argument('--dataset', type=str, default='Oxford', choices=['NCLT', 'VKITTI', 'Oxford', 'QUT'])
parser.add_argument('--num_epochs', type=int, default=400)
parser.add_argument('--num_epochs_decay', type=int, default=10)
parser.add_argument('--batch_size', type=int, default=64) # 16
# Test settings
parser.add_argument('--test_model', type=str, default='399')
# Misc
parser.add_argument('--use_tensorboard', type=bool, default=True)
# Step size
parser.add_argument('--log_step', type=int, default=10)
parser.add_argument('--model_save_step', type=int, default=40)
config_default = parser.parse_args()
# -------------------------
# -------------------------
# Evaluate fixed weight
# config = copy.deepcopy(config_default)
#
# config.sequential_mode = 'fixed_weight'
# list_roi = [False, True]
#
# for val in list_roi:
# config.fixed_weight = val
# config.mode = 'train'
# main(config)
# config.mode = 'test'
# main(config)
# Evaluate learning rate
config = copy.deepcopy(config_default)
config.sequential_mode = 'learning_rate'
list_roi = [0.0001]#, 0.0005, 0.001]
for val in list_roi:
config.lr = val
config.mode = 'train'
main(config)
config.metadata_path = '/mnt/data2/image_based_localization/posenet/KingsCollege/dataset_test.txt'
config.mode = 'test'
main(config)
# # Evaluate beta
# config = copy.deepcopy(config_default)
# config.sequential_mode = 'beta'
# list_roi = [500, 1000, 1500]
# for val in list_roi:
# config.beta = val
# config.mode = 'train'
# main(config)
# config.mode = 'test'
# config.metadata_path = '/mnt/data2/image_based_localization/posenet/KingsCollege/dataset_test.txt'
# main(config)