1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 08:13:04 +04:00

Merge remote-tracking branch 'upstream/3.4' into merge-3.4

This commit is contained in:
Alexander Alekhin
2019-12-02 16:18:07 +03:00
51 changed files with 3276 additions and 496 deletions
+23 -9
View File
@@ -254,14 +254,16 @@ void runIE(Target target, const std::string& xmlPath, const std::string& binPath
infRequest.Infer();
}
void runCV(Target target, const std::string& xmlPath, const std::string& binPath,
void runCV(Backend backendId, Target targetId, const std::string& xmlPath, const std::string& binPath,
const std::map<std::string, cv::Mat>& inputsMap,
std::map<std::string, cv::Mat>& outputsMap)
{
Net net = readNet(xmlPath, binPath);
for (auto& it : inputsMap)
net.setInput(it.second, it.first);
net.setPreferableTarget(target);
net.setPreferableBackend(backendId);
net.setPreferableTarget(targetId);
std::vector<String> outNames = net.getUnconnectedOutLayersNames();
std::vector<Mat> outs;
@@ -275,14 +277,26 @@ void runCV(Target target, const std::string& xmlPath, const std::string& binPath
}
}
typedef TestWithParam<tuple<Target, std::string> > DNNTestOpenVINO;
typedef TestWithParam<tuple< tuple<Backend, Target>, std::string> > DNNTestOpenVINO;
TEST_P(DNNTestOpenVINO, models)
{
initDLDTDataPath();
Target target = (dnn::Target)(int)get<0>(GetParam());
const Backend backendId = get<0>(get<0>(GetParam()));
const Target targetId = get<1>(get<0>(GetParam()));
if (backendId != DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && backendId != DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
throw SkipTestException("No support for async forward");
if (backendId == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
setInferenceEngineBackendType(CV_DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_API);
else if (backendId == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
setInferenceEngineBackendType(CV_DNN_BACKEND_INFERENCE_ENGINE_NGRAPH);
else
FAIL() << "Unknown backendId";
std::string modelName = get<1>(GetParam());
bool isFP16 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD);
bool isFP16 = (targetId == DNN_TARGET_OPENCL_FP16 || targetId == DNN_TARGET_MYRIAD);
const std::map<std::string, OpenVINOModelTestCaseInfo>& models = getOpenVINOTestModels();
const auto it = models.find(modelName);
@@ -296,10 +310,10 @@ TEST_P(DNNTestOpenVINO, models)
std::map<std::string, cv::Mat> inputsMap;
std::map<std::string, cv::Mat> ieOutputsMap, cvOutputsMap;
// Single Myriad device cannot be shared across multiple processes.
if (target == DNN_TARGET_MYRIAD)
if (targetId == DNN_TARGET_MYRIAD)
resetMyriadDevice();
runIE(target, xmlPath, binPath, inputsMap, ieOutputsMap);
runCV(target, xmlPath, binPath, inputsMap, cvOutputsMap);
runIE(targetId, xmlPath, binPath, inputsMap, ieOutputsMap);
runCV(backendId, targetId, xmlPath, binPath, inputsMap, cvOutputsMap);
EXPECT_EQ(ieOutputsMap.size(), cvOutputsMap.size());
for (auto& srcIt : ieOutputsMap)
@@ -314,7 +328,7 @@ TEST_P(DNNTestOpenVINO, models)
INSTANTIATE_TEST_CASE_P(/**/,
DNNTestOpenVINO,
Combine(testing::ValuesIn(getAvailableTargets(DNN_BACKEND_INFERENCE_ENGINE)),
Combine(dnnBackendsAndTargetsIE(),
testing::ValuesIn(getOpenVINOTestModelsList())
)
);