-
Notifications
You must be signed in to change notification settings - Fork 17
/
infer.py
executable file
·26 lines (23 loc) · 900 Bytes
/
infer.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
from torch.utils.data import DataLoader
import torch
import numpy as np
from model import Model
from dataset import Dataset
from test import test
import option
import time
if __name__ == '__main__':
args = option.parser.parse_args()
device = torch.device("cuda")
test_loader = DataLoader(Dataset(args, test_mode=True),
batch_size=5, shuffle=False,
num_workers=args.workers, pin_memory=True)
model = Model(args)
model = model.to(device)
model_dict = model.load_state_dict(
{k.replace('module.', ''): v for k, v in torch.load('ckpt/wsanodet_mix2.pkl').items()})
gt = np.load(args.gt)
st = time.time()
pr_auc, pr_auc_online = test(test_loader, model, device, gt)
print('Time:{}'.format(time.time()-st))
print('offline pr_auc:{0:.4}; online pr_auc:{1:.4}\n'.format(pr_auc, pr_auc_online))