From: Li Peng Date: Tue, 19 Dec 2017 08:59:46 +0000 (+0800) Subject: add ocl accuracy test for tf mobilenet ssd X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~269^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3b84acfc48426dc5f6177cf9638edba2ef9872d9;p=platform%2Fupstream%2Fopencv.git add ocl accuracy test for tf mobilenet ssd Signed-off-by: Li Peng --- diff --git a/modules/dnn/test/test_tf_importer.cpp b/modules/dnn/test/test_tf_importer.cpp index fbb90a7..1badf74 100644 --- a/modules/dnn/test/test_tf_importer.cpp +++ b/modules/dnn/test/test_tf_importer.cpp @@ -11,6 +11,8 @@ Test for Tensorflow models loading #include "test_precomp.hpp" #include "npy_blob.hpp" +#include +#include namespace cvtest { @@ -219,6 +221,43 @@ TEST(Test_TensorFlow, MobileNet_SSD) normAssert(target[2].reshape(1, 1), output[2].reshape(1, 1), "", 4e-5, 1e-2); } +OCL_TEST(Test_TensorFlow, MobileNet_SSD) +{ + std::string netPath = findDataFile("dnn/ssd_mobilenet_v1_coco.pb", false); + std::string netConfig = findDataFile("dnn/ssd_mobilenet_v1_coco.pbtxt", false); + std::string imgPath = findDataFile("dnn/street.png", false); + + Mat inp; + resize(imread(imgPath), inp, Size(300, 300)); + inp = blobFromImage(inp, 1.0f / 127.5, Size(), Scalar(127.5, 127.5, 127.5), true); + + std::vector outNames(3); + outNames[0] = "concat"; + outNames[1] = "concat_1"; + outNames[2] = "detection_out"; + + std::vector target(outNames.size()); + for (int i = 0; i < outNames.size(); ++i) + { + std::string path = findDataFile("dnn/tensorflow/ssd_mobilenet_v1_coco." + outNames[i] + ".npy", false); + target[i] = blobFromNPY(path); + } + + Net net = readNetFromTensorflow(netPath, netConfig); + + net.setPreferableBackend(DNN_BACKEND_DEFAULT); + net.setPreferableTarget(DNN_TARGET_OPENCL); + + net.setInput(inp); + + std::vector output; + net.forward(output, outNames); + + normAssert(target[0].reshape(1, 1), output[0].reshape(1, 1)); + normAssert(target[1].reshape(1, 1), output[1].reshape(1, 1), "", 1e-5, 2e-4); + normAssert(target[2].reshape(1, 1), output[2].reshape(1, 1), "", 4e-5, 1e-2); +} + TEST(Test_TensorFlow, lstm) { runTensorFlowNet("lstm", true);