-
Notifications
You must be signed in to change notification settings - Fork 12
/
test.py
52 lines (40 loc) · 1.57 KB
/
test.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
# Testing script
# author: ynie
# date: April, 2020
from utils.project_utils import load_device, load_model, load_tester, load_dataloader
from utils.project_utils import CheckpointIO
from test_epoch import test
import wandb
def run(cfg):
if wandb.run is None:
resume = cfg.config['resume']
name = cfg.config['name']
id = cfg.config['log']['path'].split('/')[-1]
config = None if resume else cfg.config
wandb.init(project="deeppanocontext", config=config, dir=cfg.config['log']['path'],
name=name, id=id, resume=resume)
'''Begin to run network.'''
checkpoint = CheckpointIO(cfg)
'''Load save path'''
cfg.log_string('Data save path: %s' % (cfg.save_path))
'''Load device'''
cfg.log_string('Loading device settings.')
device = load_device(cfg)
'''Load data'''
cfg.log_string('Loading dataset.')
test_loader = load_dataloader(cfg.config, mode='test')
'''Load net'''
cfg.log_string('Loading model.')
net = load_model(cfg, device=device)
checkpoint.register_modules(net=net)
cfg.log_string(net)
'''Load existing checkpoint'''
checkpoint.parse_checkpoint()
'''Load tester'''
cfg.log_string('Loading tester.')
tester = load_tester(cfg=cfg, net=net, device=device)
'''Start to test'''
cfg.log_string('Start to test.')
cfg.log_string('Total number of parameters in {0:s}: {1:d}.'.format(cfg.config['method'], sum(p.numel() for p in net.parameters())))
test(cfg=cfg, tester=tester, test_loader=test_loader)
cfg.log_string('Testing finished.')