MCPcopy Index your code
hub / github.com/OpenGVLab/HumanBench / main

Function main

PATH/test.py:38–90  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

36 list(u'-+0123456789.'))
37
38def main():
39 args = parser.parse_args()
40 dist_init()
41
42 # auto resume strategy for spring.submit arun
43 if args.auto_resume is not None:
44 if os.path.isdir(args.auto_resume):
45 max_iter = 0
46 filename = os.listdir(args.auto_resume)
47 for file in filename:
48 if file.startswith('ckpt_task0') and file.endswith('.pth.tar'):
49 cur_iter = int(file.split('_')[-1].split('.')[0])
50 max_iter = max(max_iter, cur_iter)
51 if max_iter > 0:
52 args.load_path = os.path.join(args.auto_resume,
53 'ckpt_task_iter_{}.pth.tar'.format(str(max_iter)))
54 args.recover = True
55 args.ignore = []
56 print('auto-resume from: {}'.format(args.load_path))
57 elif args.auto_resume.endswith('.pth.tar'):
58 tmpl = args.auto_resume.replace('ckpt_task_', 'ckpt_task*_')
59 import glob
60 ckpt = glob.glob(tmpl)
61 if len(ckpt) > 0:
62 args.load_path = args.auto_resume
63 args.recover = True
64 args.ignore = []
65 print('auto-resume from: {}'.format(args.load_path))
66 else:
67 print('auto-resume not work:{}'.format(args.auto_resume))
68
69 #tmp = torch.Tensor(1).cuda()
70 C_train = Config(args.config, spec_ginfo_index=args.spec_ginfo_index)
71
72 with open(args.test_config) as f:
73 test_config = yaml.load(f, Loader=loader)
74 num_test_tasks = len(test_config['tasks'])
75
76 for test_spec_ginfo_index in range(num_test_tasks):
77 C_test = Config(args.test_config, spec_ginfo_index=test_spec_ginfo_index)
78 if args.expname is not None:
79 C_train.config['expname'] = args.expname
80
81 S = tester_entry(C_train, C_test)
82 config_save_to = os.path.join(S.ckpt_path, 'config.yaml')
83 test_config_save_to = os.path.join(S.ckpt_path, 'test_config_task{}.yaml'.format(test_spec_ginfo_index))
84 if not os.path.exists(config_save_to):
85 shutil.copy(args.config, config_save_to)
86 shutil.copy(args.test_config, test_config_save_to)
87
88 S.initialize(args)
89
90 S.run()
91
92
93if __name__ == '__main__':

Callers 1

test.pyFile · 0.70

Calls 6

dist_initFunction · 0.90
ConfigClass · 0.90
tester_entryFunction · 0.90
loadMethod · 0.45
initializeMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected