Skip to content

Commit

Permalink
added timer
Browse files Browse the repository at this point in the history
  • Loading branch information
zisianw committed Jan 13, 2019
1 parent e18f5ef commit 01e5826
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import cv2
from models.faceboxes import FaceBoxes
from utils.box_utils import decode
from utils.timer import Timer

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

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

_t = {'forward_pass': Timer(), 'misc': Timer()}

# testing begin
for i, img_name in enumerate(test_dataset):
image_path = testset_folder + img_name + '.jpg'
Expand All @@ -107,7 +110,10 @@ def load_model(model, pretrained_path):
img = img.cuda()
scale = scale.cuda()

_t['forward_pass'].tic()
out = net(img) # forward pass
_t['forward_pass'].toc()
_t['misc'].tic()
priorbox = PriorBox(cfg, out[2], (im_height, im_width), phase='test')
priors = priorbox.forward()
if args.cuda:
Expand Down Expand Up @@ -136,6 +142,7 @@ def load_model(model, pretrained_path):

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

# save dets
if args.dataset == "FDDB":
Expand All @@ -159,5 +166,5 @@ def load_model(model, pretrained_path):
ymin += 0.2 * (ymax - ymin + 1)
score = dets[k, 4]
fw.write('{:s} {:.3f} {:.1f} {:.1f} {:.1f} {:.1f}\n'.format(img_name, score, xmin, ymin, xmax, ymax))
print('im_detect: {:d}/{:d}'.format(i + 1, num_images))
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))
fw.close()

0 comments on commit 01e5826

Please sign in to comment.