def test():
    import os
    im_file = 'demo/004545.jpg'
    image = cv2.imread(im_file)
    model_file = '/home/zjwang/git/faster_rcnn_pytorch/VGGnet_fast_rcnn_iter_70000.h5'
    detector = FasterRCNN()
    network.load_net(model_file, detector)
    detector.cuda()
    detector.eval()
    print('load model successfully!')
    t = Timer()
    t.tic()
    (dets, scores, classes) = detector.detect(image, 0.7)
    runtime = t.toc()
    print('total spend: {}s'.format(runtime))
    im2show = np.copy(image)
    for (i, det) in enumerate(dets):
        det = tuple((int(x) for x in det))
        cv2.rectangle(im2show, det[0:2], det[2:4], (255, 205, 51), 2)
        cv2.putText(im2show, ('%s: %.3f' % (classes[i], scores[i])), (det[0], (det[1] + 15)), cv2.FONT_HERSHEY_PLAIN, 1.0, (0, 0, 255), thickness=1)
    cv2.imwrite(os.path.join('demo', 'out.jpg'), im2show)
    cv2.imshow('demo', im2show)
    cv2.waitKey(0)
def test():
    import os
    im_file = 'demo/004545.jpg'
    image = cv2.imread(im_file)
    model_file = '/home/zjwang/git/faster_rcnn_pytorch/VGGnet_fast_rcnn_iter_70000.h5'
    detector = FasterRCNN()
    network.load_net(model_file, detector)
    detector.cuda()
    detector.eval()
    print('load model successfully!')
    t = Timer()
    t.tic()
    (dets, scores, classes) = detector.detect(image, 0.7)
    runtime = t.toc()
    print('total spend: {}s'.format(runtime))
    im2show = np.copy(image)
    for (i, det) in enumerate(dets):
        det = tuple((int(x) for x in det))
        cv2.rectangle(im2show, det[0:2], det[2:4], (255, 205, 51), 2)
        cv2.putText(im2show, ('%s: %.3f' % (classes[i], scores[i])), (det[0], (det[1] + 15)), cv2.FONT_HERSHEY_PLAIN, 1.0, (0, 0, 255), thickness=1)
    cv2.imwrite(os.path.join('demo', 'out.jpg'), im2show)
    cv2.imshow('demo', im2show)
    cv2.waitKey(0)