forked from hitachi-rd-cv/bcar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_trainer.py
96 lines (88 loc) · 2.82 KB
/
run_trainer.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
import argparse
from lib import trainer
def get_args():
parser = argparse.ArgumentParser()
parser.add_argument(
'--root_path', type=str, required=True,
)
parser.add_argument(
'--log_path', type=str, required=True,
)
parser.add_argument(
'--student_class_module', type=str, required=True,
)
parser.add_argument(
'--teacher_class_module', type=str, required=True,
)
parser.add_argument(
'--student_class_name', type=str, required=True,
)
parser.add_argument(
'--teacher_class_name', type=str, required=True,
)
parser.add_argument(
'--train_targets', type=str, nargs='+', required=True,
)
parser.add_argument(
'--test_targets', type=str, nargs='+', required=True,
)
parser.add_argument(
'--test_camera_base', action='store_true',
)
parser.add_argument(
'--augmentation_types', type=str, nargs='+', default=[],
)
parser.add_argument(
'--batch_size', type=int, default=64,
)
parser.add_argument(
'--n_workers', type=int, default=7,
)
parser.add_argument(
'--save_interval', type=int, default=1,
)
parser.add_argument(
'--n_saved', type=int, default=1,
)
parser.add_argument(
'--gpu_ids', type=int, nargs='+', default=[0],
)
parser.add_argument(
'--max_epochs', type=int, default=150,
)
parser.add_argument(
'--lr_decay_step', type=int, default=100,
)
parser.add_argument(
'--init_lr_student_conv', type=float, default=.01,
)
parser.add_argument(
'--init_lr_teacher_conv', type=float, default=.01,
)
parser.add_argument(
'--init_lr_student_classifier', type=float, default=.01,
)
parser.add_argument(
'--init_lr_teacher_classifier', type=float, default=.02,
)
parser.add_argument(
'--init_interval', type=int, default=1,
)
parser.add_argument(
'--hard_ratio', type=float, default=.3,
)
args = parser.parse_args()
return args
def main(args):
trainer.run(
args.root_path, args.log_path, args.student_class_module,
args.teacher_class_module, args.student_class_name, args.teacher_class_name, args.init_interval, args.hard_ratio,
args.train_targets, args.test_targets, args.test_camera_base, args.augmentation_types, args.batch_size,
args.n_workers, args.save_interval, args.n_saved, args.gpu_ids, max_epochs=args.max_epochs,
init_lr_student_conv=args.init_lr_student_conv, init_lr_teacher_conv=args.init_lr_teacher_conv,
init_lr_student_classifier=args.init_lr_student_classifier,
init_lr_teacher_classifier=args.init_lr_teacher_classifier, lr_decay_step=args.lr_decay_step
)
if __name__ == '__main__':
args = get_args()
main(args)