-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVal.py
More file actions
57 lines (33 loc) · 1.12 KB
/
Copy pathVal.py
File metadata and controls
57 lines (33 loc) · 1.12 KB
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
53
54
55
56
57
# -*- coding: utf-8 -*-
import torch.nn as nn
import torch
import torch.optim as optim
from torch.utils.data import DataLoader
import torch.nn.functional as F
import torch
import os
import numpy as np
from time import time
import math
import math
from Network.class_func import get_local_count
def test_phase(opt,net,testloader,log_save_path=None):
with torch.no_grad():
net.eval()
start = time()
for data in testloader:
inputs = data['image']
inputs = inputs.type(torch.float32)
inputs = inputs.cuda()
# process with SSDCNet
features = net(inputs)
div_res = net.resample(features)
merge_res = net.parse_merge(div_res)
outputs = merge_res['div'+str(net.div_times)]
del merge_res
pre = (outputs).sum()
end = time()
running_frame_rate = opt['test_batch_size'] * float( 1 / (end - start))
im_num = len(testloader)
test_dict=dict()
return test_dict, pre.cpu().item()