Skip to content

Commit c012490

Browse files
authored
Merge pull request opencv#18393 from mshabunin:fix-dnn-test
* dnn: fixed HighLevelApi tests
1 parent e937d9b commit c012490

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

modules/dnn/test/test_ie_models.cpp

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,15 @@ static const std::map<std::string, OpenVINOModelTestCaseInfo>& getOpenVINOTestMo
103103
#if INF_ENGINE_RELEASE >= 2020010000
104104
// Downloaded using these parameters for Open Model Zoo downloader (2020.1):
105105
// ./downloader.py -o ${OPENCV_DNN_TEST_DATA_PATH}/omz_intel_models --cache_dir ${OPENCV_DNN_TEST_DATA_PATH}/.omz_cache/ \
106-
// --name person-detection-retail-0013
106+
// --name person-detection-retail-0013,age-gender-recognition-retail-0013
107107
{ "person-detection-retail-0013", { // IRv10
108108
"intel/person-detection-retail-0013/FP32/person-detection-retail-0013",
109109
"intel/person-detection-retail-0013/FP16/person-detection-retail-0013"
110110
}},
111+
{ "age-gender-recognition-retail-0013", {
112+
"intel/age-gender-recognition-retail-0013/FP16/age-gender-recognition-retail-0013",
113+
"intel/age-gender-recognition-retail-0013/FP32/age-gender-recognition-retail-0013"
114+
}},
111115
#endif
112116
};
113117

@@ -123,6 +127,21 @@ static const std::vector<std::string> getOpenVINOTestModelsList()
123127
return result;
124128
}
125129

130+
inline static std::string getOpenVINOModel(const std::string &modelName, bool isFP16)
131+
{
132+
const std::map<std::string, OpenVINOModelTestCaseInfo>& models = getOpenVINOTestModels();
133+
const auto it = models.find(modelName);
134+
if (it != models.end())
135+
{
136+
OpenVINOModelTestCaseInfo modelInfo = it->second;
137+
if (isFP16 && modelInfo.modelPathFP16)
138+
return std::string(modelInfo.modelPathFP16);
139+
else if (!isFP16 && modelInfo.modelPathFP32)
140+
return std::string(modelInfo.modelPathFP32);
141+
}
142+
return std::string();
143+
}
144+
126145
static inline void genData(const InferenceEngine::TensorDesc& desc, Mat& m, Blob::Ptr& dataPtr)
127146
{
128147
const std::vector<size_t>& dims = desc.getDims();
@@ -310,11 +329,8 @@ TEST_P(DNNTestOpenVINO, models)
310329

311330
bool isFP16 = (targetId == DNN_TARGET_OPENCL_FP16 || targetId == DNN_TARGET_MYRIAD);
312331

313-
const std::map<std::string, OpenVINOModelTestCaseInfo>& models = getOpenVINOTestModels();
314-
const auto it = models.find(modelName);
315-
ASSERT_TRUE(it != models.end()) << modelName;
316-
OpenVINOModelTestCaseInfo modelInfo = it->second;
317-
std::string modelPath = isFP16 ? modelInfo.modelPathFP16 : modelInfo.modelPathFP32;
332+
const std::string modelPath = getOpenVINOModel(modelName, isFP16);
333+
ASSERT_FALSE(modelPath.empty()) << modelName;
318334

319335
std::string xmlPath = findDataFile(modelPath + ".xml", false);
320336
std::string binPath = findDataFile(modelPath + ".bin", false);
@@ -358,10 +374,9 @@ TEST_P(DNNTestHighLevelAPI, predict)
358374

359375
Target target = (dnn::Target)(int)GetParam();
360376
bool isFP16 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD);
361-
362-
OpenVINOModelTestCaseInfo modelInfo = getOpenVINOTestModels().find("age-gender-recognition-retail-0013")->second;
363-
364-
std::string modelPath = isFP16 ? modelInfo.modelPathFP16 : modelInfo.modelPathFP32;
377+
const std::string modelName = "age-gender-recognition-retail-0013";
378+
const std::string modelPath = getOpenVINOModel(modelName, isFP16);
379+
ASSERT_FALSE(modelPath.empty()) << modelName;
365380

366381
std::string xmlPath = findDataFile(modelPath + ".xml");
367382
std::string binPath = findDataFile(modelPath + ".bin");

0 commit comments

Comments
 (0)