|
|
@ -62,6 +62,7 @@ def printParams(backend, target): |
|
|
|
} |
|
|
|
} |
|
|
|
print('%s/%s' % (backendNames[backend], targetNames[target])) |
|
|
|
print('%s/%s' % (backendNames[backend], targetNames[target])) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
testdata_required = bool(os.environ.get('OPENCV_DNN_TEST_REQUIRE_TESTDATA', False)) |
|
|
|
|
|
|
|
|
|
|
|
class dnn_test(NewOpenCVTests): |
|
|
|
class dnn_test(NewOpenCVTests): |
|
|
|
|
|
|
|
|
|
|
@ -87,13 +88,15 @@ class dnn_test(NewOpenCVTests): |
|
|
|
self.dnnBackendsAndTargets.append([cv.dnn.DNN_BACKEND_INFERENCE_ENGINE, cv.dnn.DNN_TARGET_OPENCL_FP16]) |
|
|
|
self.dnnBackendsAndTargets.append([cv.dnn.DNN_BACKEND_INFERENCE_ENGINE, cv.dnn.DNN_TARGET_OPENCL_FP16]) |
|
|
|
|
|
|
|
|
|
|
|
def find_dnn_file(self, filename, required=True): |
|
|
|
def find_dnn_file(self, filename, required=True): |
|
|
|
|
|
|
|
if not required: |
|
|
|
|
|
|
|
required = testdata_required |
|
|
|
return self.find_file(filename, [os.environ.get('OPENCV_DNN_TEST_DATA_PATH', os.getcwd()), |
|
|
|
return self.find_file(filename, [os.environ.get('OPENCV_DNN_TEST_DATA_PATH', os.getcwd()), |
|
|
|
os.environ['OPENCV_TEST_DATA_PATH']], |
|
|
|
os.environ['OPENCV_TEST_DATA_PATH']], |
|
|
|
required=required) |
|
|
|
required=required) |
|
|
|
|
|
|
|
|
|
|
|
def checkIETarget(self, backend, target): |
|
|
|
def checkIETarget(self, backend, target): |
|
|
|
proto = self.find_dnn_file('dnn/layers/layer_convolution.prototxt', required=True) |
|
|
|
proto = self.find_dnn_file('dnn/layers/layer_convolution.prototxt') |
|
|
|
model = self.find_dnn_file('dnn/layers/layer_convolution.caffemodel', required=True) |
|
|
|
model = self.find_dnn_file('dnn/layers/layer_convolution.caffemodel') |
|
|
|
net = cv.dnn.readNet(proto, model) |
|
|
|
net = cv.dnn.readNet(proto, model) |
|
|
|
net.setPreferableBackend(backend) |
|
|
|
net.setPreferableBackend(backend) |
|
|
|
net.setPreferableTarget(target) |
|
|
|
net.setPreferableTarget(target) |
|
|
@ -134,8 +137,11 @@ class dnn_test(NewOpenCVTests): |
|
|
|
|
|
|
|
|
|
|
|
def test_model(self): |
|
|
|
def test_model(self): |
|
|
|
img_path = self.find_dnn_file("dnn/street.png") |
|
|
|
img_path = self.find_dnn_file("dnn/street.png") |
|
|
|
weights = self.find_dnn_file("dnn/MobileNetSSD_deploy.caffemodel") |
|
|
|
weights = self.find_dnn_file("dnn/MobileNetSSD_deploy.caffemodel", required=False) |
|
|
|
config = self.find_dnn_file("dnn/MobileNetSSD_deploy.prototxt") |
|
|
|
config = self.find_dnn_file("dnn/MobileNetSSD_deploy.prototxt", required=False) |
|
|
|
|
|
|
|
if weights is None or config is None: |
|
|
|
|
|
|
|
raise unittest.SkipTest("Missing DNN test files (dnn/MobileNetSSD_deploy.{prototxt/caffemodel}). Verify OPENCV_DNN_TEST_DATA_PATH configuration parameter.") |
|
|
|
|
|
|
|
|
|
|
|
frame = cv.imread(img_path) |
|
|
|
frame = cv.imread(img_path) |
|
|
|
model = cv.dnn_DetectionModel(weights, config) |
|
|
|
model = cv.dnn_DetectionModel(weights, config) |
|
|
|
model.setInputParams(size=(300, 300), mean=(127.5, 127.5, 127.5), scale=1.0/127.5) |
|
|
|
model.setInputParams(size=(300, 300), mean=(127.5, 127.5, 127.5), scale=1.0/127.5) |
|
|
@ -163,9 +169,11 @@ class dnn_test(NewOpenCVTests): |
|
|
|
|
|
|
|
|
|
|
|
def test_classification_model(self): |
|
|
|
def test_classification_model(self): |
|
|
|
img_path = self.find_dnn_file("dnn/googlenet_0.png") |
|
|
|
img_path = self.find_dnn_file("dnn/googlenet_0.png") |
|
|
|
weights = self.find_dnn_file("dnn/squeezenet_v1.1.caffemodel") |
|
|
|
weights = self.find_dnn_file("dnn/squeezenet_v1.1.caffemodel", required=False) |
|
|
|
config = self.find_dnn_file("dnn/squeezenet_v1.1.prototxt") |
|
|
|
config = self.find_dnn_file("dnn/squeezenet_v1.1.prototxt") |
|
|
|
ref = np.load(self.find_dnn_file("dnn/squeezenet_v1.1_prob.npy")) |
|
|
|
ref = np.load(self.find_dnn_file("dnn/squeezenet_v1.1_prob.npy")) |
|
|
|
|
|
|
|
if weights is None or config is None: |
|
|
|
|
|
|
|
raise unittest.SkipTest("Missing DNN test files (dnn/squeezenet_v1.1.{prototxt/caffemodel}). Verify OPENCV_DNN_TEST_DATA_PATH configuration parameter.") |
|
|
|
|
|
|
|
|
|
|
|
frame = cv.imread(img_path) |
|
|
|
frame = cv.imread(img_path) |
|
|
|
model = cv.dnn_ClassificationModel(config, weights) |
|
|
|
model = cv.dnn_ClassificationModel(config, weights) |
|
|
@ -177,9 +185,8 @@ class dnn_test(NewOpenCVTests): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_face_detection(self): |
|
|
|
def test_face_detection(self): |
|
|
|
testdata_required = bool(os.environ.get('OPENCV_DNN_TEST_REQUIRE_TESTDATA', False)) |
|
|
|
proto = self.find_dnn_file('dnn/opencv_face_detector.prototxt') |
|
|
|
proto = self.find_dnn_file('dnn/opencv_face_detector.prototxt', required=testdata_required) |
|
|
|
model = self.find_dnn_file('dnn/opencv_face_detector.caffemodel', required=False) |
|
|
|
model = self.find_dnn_file('dnn/opencv_face_detector.caffemodel', required=testdata_required) |
|
|
|
|
|
|
|
if proto is None or model is None: |
|
|
|
if proto is None or model is None: |
|
|
|
raise unittest.SkipTest("Missing DNN test files (dnn/opencv_face_detector.{prototxt/caffemodel}). Verify OPENCV_DNN_TEST_DATA_PATH configuration parameter.") |
|
|
|
raise unittest.SkipTest("Missing DNN test files (dnn/opencv_face_detector.{prototxt/caffemodel}). Verify OPENCV_DNN_TEST_DATA_PATH configuration parameter.") |
|
|
|
|
|
|
|
|
|
|
@ -216,9 +223,8 @@ class dnn_test(NewOpenCVTests): |
|
|
|
|
|
|
|
|
|
|
|
def test_async(self): |
|
|
|
def test_async(self): |
|
|
|
timeout = 10*1000*10**6 # in nanoseconds (10 sec) |
|
|
|
timeout = 10*1000*10**6 # in nanoseconds (10 sec) |
|
|
|
testdata_required = bool(os.environ.get('OPENCV_DNN_TEST_REQUIRE_TESTDATA', False)) |
|
|
|
proto = self.find_dnn_file('dnn/layers/layer_convolution.prototxt') |
|
|
|
proto = self.find_dnn_file('dnn/layers/layer_convolution.prototxt', required=testdata_required) |
|
|
|
model = self.find_dnn_file('dnn/layers/layer_convolution.caffemodel') |
|
|
|
model = self.find_dnn_file('dnn/layers/layer_convolution.caffemodel', required=testdata_required) |
|
|
|
|
|
|
|
if proto is None or model is None: |
|
|
|
if proto is None or model is None: |
|
|
|
raise unittest.SkipTest("Missing DNN test files (dnn/layers/layer_convolution.{prototxt/caffemodel}). Verify OPENCV_DNN_TEST_DATA_PATH configuration parameter.") |
|
|
|
raise unittest.SkipTest("Missing DNN test files (dnn/layers/layer_convolution.{prototxt/caffemodel}). Verify OPENCV_DNN_TEST_DATA_PATH configuration parameter.") |
|
|
|
|
|
|
|
|
|
|
|