Skip to content

Commit 01e5826

Browse files
committed
added timer
1 parent e18f5ef commit 01e5826

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

test.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import cv2
1111
from models.faceboxes import FaceBoxes
1212
from utils.box_utils import decode
13+
from utils.timer import Timer
1314

1415
parser = argparse.ArgumentParser(description='FaceBoxes')
1516

@@ -92,6 +93,8 @@ def load_model(model, pretrained_path):
9293
elif args.dataset == "AFW":
9394
resize = 1
9495

96+
_t = {'forward_pass': Timer(), 'misc': Timer()}
97+
9598
# testing begin
9699
for i, img_name in enumerate(test_dataset):
97100
image_path = testset_folder + img_name + '.jpg'
@@ -107,7 +110,10 @@ def load_model(model, pretrained_path):
107110
img = img.cuda()
108111
scale = scale.cuda()
109112

113+
_t['forward_pass'].tic()
110114
out = net(img) # forward pass
115+
_t['forward_pass'].toc()
116+
_t['misc'].tic()
111117
priorbox = PriorBox(cfg, out[2], (im_height, im_width), phase='test')
112118
priors = priorbox.forward()
113119
if args.cuda:
@@ -136,6 +142,7 @@ def load_model(model, pretrained_path):
136142

137143
# keep top-K faster NMS
138144
dets = dets[:args.keep_top_k, :]
145+
_t['misc'].toc()
139146

140147
# save dets
141148
if args.dataset == "FDDB":
@@ -159,5 +166,5 @@ def load_model(model, pretrained_path):
159166
ymin += 0.2 * (ymax - ymin + 1)
160167
score = dets[k, 4]
161168
fw.write('{:s} {:.3f} {:.1f} {:.1f} {:.1f} {:.1f}\n'.format(img_name, score, xmin, ymin, xmax, ymax))
162-
print('im_detect: {:d}/{:d}'.format(i + 1, num_images))
169+
print('im_detect: {:d}/{:d} forward_pass_time: {:.4f}s misc: {:.4f}s'.format(i + 1, num_images, _t['forward_pass'].average_time, _t['misc'].average_time))
163170
fw.close()

0 commit comments

Comments
 (0)