-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.py
33 lines (26 loc) · 926 Bytes
/
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
import torch
from tqdm import tqdm
from base import Tester
def main():
torch.backends.cudnn.benchmark = True
tester = Tester()
tester._make_model()
tester._make_batch_loader()
eval_result = {}
cur_sample_idx = 0
for iteration, (inputs, targets, meta_info) in enumerate(tqdm(tester.batch_loader)):
with torch.no_grad():
outs = tester.model(inputs)
outs = {k: v.cpu().numpy() for k, v in outs.items()}
meta_info = {k: v.cpu().numpy() for k, v in meta_info.items()}
# evaluate
cur_eval_result = tester._evaluate(outs, meta_info, cur_sample_idx)
for k, v in cur_eval_result.items():
if k in eval_result:
eval_result[k] += v
else:
eval_result[k] = v
cur_sample_idx += inputs['img'].shape[0]
tester._print_eval_result(eval_result)
if __name__ == '__main__':
main()