-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
executable file
·62 lines (40 loc) · 1.47 KB
/
run.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
from local_configs.run_parser import MainParser
import yaml
import argparse
import os
import torch.multiprocessing as mp
import torch
from mmcv.utils import Registry, Config, DictAction
from joint_train import Joint_Model_Train
from joint_test import Joint_Model_Test
from joint_test_samples import Joint_Model_Samples_Test
from joint_video_test import Joint_Model_Video_Test
def run_hyperparm_setting(opt, config):
space1 = "".rjust(5)
space2 = "".rjust(10)
print("🚀 HyperParameters")
for k, v in config.items():
if isinstance(v, dict):
print(space1 + f"{k}:")
for k2, v2 in v.items():
print(space2 + f"{k2}".ljust(20) + f"{v2}")
opt.__dict__[k2] = v2
else:
opt.__dict__[k] = v
print(space1 + f"{k}:".ljust(25) + f"{v}")
return opt
def main(opt: argparse.Namespace):
print("\n🚀🚀🚀 About the Parameters on this Project! 🚀🚀🚀")
cfg = Config.fromfile(opt.config)
opt = run_hyperparm_setting(opt, cfg)
opt.log_comment = opt.config[:-3].split('/')[-1]
if opt.mode == 'joint_train':
Joint_Model_Train(opt).train()
elif opt.mode == 'joint_test':
Joint_Model_Test(opt).test()
elif opt.mode == 'joint_samples_test':
Joint_Model_Samples_Test(opt).samples_test()
if __name__ == '__main__':
parser = MainParser()
opt = parser.parse()
main(opt)