MCPcopy Create free account
hub / github.com/SegmentationBLWX/cssegmentation / Tester

Class Tester

csseg/test.py:29–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27
28'''Tester'''
29class Tester():
30 def __init__(self, cmd_args):
31 self.cmd_args = cmd_args
32 config_parser = ConfigParser()
33 self.cfg, _ = config_parser(cmd_args.cfgfilepath)
34 '''start'''
35 def start(self):
36 # initialize
37 assert torch.cuda.is_available(), 'cuda is not available'
38 cmd_args, runner_cfg = self.cmd_args, self.cfg.RUNNER_CFG
39 dist.init_process_group(backend=runner_cfg['parallel_cfg']['backend'], init_method=runner_cfg['parallel_cfg']['init_method'])
40 torch.cuda.set_device(cmd_args.local_rank)
41 torch.backends.cudnn.allow_tf32 = False
42 torch.backends.cuda.matmul.allow_tf32 = False
43 torch.backends.cudnn.benchmark = runner_cfg['benchmark']
44 # load ckpts
45 ckpts = loadckpts(cmd_args.ckptspath)
46 runner_cfg['task_id'] = ckpts['task_id']
47 runner_client = BuildRunner(mode='TEST', cmd_args=cmd_args, runner_cfg=runner_cfg)
48 runner_client.segmentor.load_state_dict(ckpts['segmentor'], strict=True)
49 # start to test and print results
50 results = runner_client.test(cur_epoch=ckpts['cur_epoch'])
51 if cmd_args.local_rank == 0:
52 runner_client.logger_handle.info(results)
53
54
55'''main'''

Callers 1

test.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected