sudo apt install virtualenv
Just run bash script and read output.
cd tests
./prepare_and_run_tests.sh
Something like below. The general idea is to test only inference speed, without preprocessing and decoding. Also, 1st inference must not count, because it will load all stuff into memory.
NB: be strict about Backend and Target
import cv2
class PixelLinkDetectorTest():
""" Cut version of PixelLinkDetector """
def __init__(self, xml_model_path: str):
self.net = cv2.dnn.readNet(xml_model_path, xml_model_path[:-3] + 'bin')
def detect(self, img: 'np.ndarray') -> None:
blob = cv2.dnn.blobFromImage(img, 1, (1280, 768))
self.net.setInput(blob)
out_layer_names = self.net.getUnconnectedOutLayersNames()
return self.net.forward(out_layer_names)
# check opencv version
cv2.__version__
# read img and network
img = cv2.imread('helloworld.png')
detector = PixelLinkDetectorTest('text-detection-0004.xml')
# select target & backend, please read the documentation for details:
# <https://docs.opencv.org/4.2.0/db/d30/classcv_1_1dnn_1_1Net.html#a9dddbefbc7f3defbe3eeb5dc3d3483f4>
detector.net.setPreferableTarget(cv2.dnn.DNN_TARGET_CPU)
detector.net.setPreferableBackend(cv2.dnn.DNN_BACKEND_INFERENCE_ENGINE)
# 1st inference does not count
links, pixels = detector.detect(img)
# use magic function
%timeit links, pixels = detector.detect(img)
short_video.mp4
from here (free)dislike.jpg
from rateme repositoryhelloworld.png
I either made it or forgot from where it downloaded from