@@ -21,9 +21,18 @@ static void initDLDTDataPath()
21
21
static bool initialized = false ;
22
22
if (!initialized)
23
23
{
24
+ #if INF_ENGINE_RELEASE <= 2018050000
24
25
const char * dldtTestDataPath = getenv (" INTEL_CVSDK_DIR" );
25
26
if (dldtTestDataPath)
26
- cvtest::addDataSearchPath (cv::utils::fs::join (dldtTestDataPath, " deployment_tools" ));
27
+ cvtest::addDataSearchPath (dldtTestDataPath);
28
+ #else
29
+ const char * omzDataPath = getenv (" OPENCV_OPEN_MODEL_ZOO_DATA_PATH" );
30
+ if (omzDataPath)
31
+ cvtest::addDataSearchPath (omzDataPath);
32
+ const char * dnnDataPath = getenv (" OPENCV_DNN_TEST_DATA_PATH" );
33
+ if (dnnDataPath)
34
+ cvtest::addDataSearchPath (std::string (dnnDataPath) + " /omz_intel_models" );
35
+ #endif
27
36
initialized = true ;
28
37
}
29
38
#endif
@@ -33,6 +42,76 @@ using namespace cv;
33
42
using namespace cv ::dnn;
34
43
using namespace InferenceEngine ;
35
44
45
+ struct OpenVINOModelTestCaseInfo
46
+ {
47
+ const char * modelPathFP32;
48
+ const char * modelPathFP16;
49
+ };
50
+
51
+ static const std::map<std::string, OpenVINOModelTestCaseInfo>& getOpenVINOTestModels ()
52
+ {
53
+ static std::map<std::string, OpenVINOModelTestCaseInfo> g_models {
54
+ #if INF_ENGINE_RELEASE <= 2018050000
55
+ { " age-gender-recognition-retail-0013" , {
56
+ " deployment_tools/intel_models/age-gender-recognition-retail-0013/FP32/age-gender-recognition-retail-0013" ,
57
+ " deployment_tools/intel_models/age-gender-recognition-retail-0013/FP16/age-gender-recognition-retail-0013"
58
+ }},
59
+ { " face-person-detection-retail-0002" , {
60
+ " deployment_tools/intel_models/face-person-detection-retail-0002/FP32/face-person-detection-retail-0002" ,
61
+ " deployment_tools/intel_models/face-person-detection-retail-0002/FP16/face-person-detection-retail-0002"
62
+ }},
63
+ { " head-pose-estimation-adas-0001" , {
64
+ " deployment_tools/intel_models/head-pose-estimation-adas-0001/FP32/head-pose-estimation-adas-0001" ,
65
+ " deployment_tools/intel_models/head-pose-estimation-adas-0001/FP16/head-pose-estimation-adas-0001"
66
+ }},
67
+ { " person-detection-retail-0002" , {
68
+ " deployment_tools/intel_models/person-detection-retail-0002/FP32/person-detection-retail-0002" ,
69
+ " deployment_tools/intel_models/person-detection-retail-0002/FP16/person-detection-retail-0002"
70
+ }},
71
+ { " vehicle-detection-adas-0002" , {
72
+ " deployment_tools/intel_models/vehicle-detection-adas-0002/FP32/vehicle-detection-adas-0002" ,
73
+ " deployment_tools/intel_models/vehicle-detection-adas-0002/FP16/vehicle-detection-adas-0002"
74
+ }}
75
+ #else
76
+ // layout is defined by open_model_zoo/model_downloader
77
+ // Downloaded using these parameters for Open Model Zoo downloader (2019R1):
78
+ // ./downloader.py -o ${OPENCV_DNN_TEST_DATA_PATH}/omz_intel_models --cache_dir ${OPENCV_DNN_TEST_DATA_PATH}/.omz_cache/ \
79
+ // --name face-person-detection-retail-0002,face-person-detection-retail-0002-fp16,age-gender-recognition-retail-0013,age-gender-recognition-retail-0013-fp16,head-pose-estimation-adas-0001,head-pose-estimation-adas-0001-fp16,person-detection-retail-0002,person-detection-retail-0002-fp16,vehicle-detection-adas-0002,vehicle-detection-adas-0002-fp16
80
+ { " age-gender-recognition-retail-0013" , {
81
+ " Retail/object_attributes/age_gender/dldt/age-gender-recognition-retail-0013" ,
82
+ " Retail/object_attributes/age_gender/dldt/age-gender-recognition-retail-0013-fp16"
83
+ }},
84
+ { " face-person-detection-retail-0002" , {
85
+ " Retail/object_detection/face_pedestrian/rmnet-ssssd-2heads/0002/dldt/face-person-detection-retail-0002" ,
86
+ " Retail/object_detection/face_pedestrian/rmnet-ssssd-2heads/0002/dldt/face-person-detection-retail-0002-fp16"
87
+ }},
88
+ { " head-pose-estimation-adas-0001" , {
89
+ " Transportation/object_attributes/headpose/vanilla_cnn/dldt/head-pose-estimation-adas-0001" ,
90
+ " Transportation/object_attributes/headpose/vanilla_cnn/dldt/head-pose-estimation-adas-0001-fp16"
91
+ }},
92
+ { " person-detection-retail-0002" , {
93
+ " Retail/object_detection/pedestrian/hypernet-rfcn/0026/dldt/person-detection-retail-0002" ,
94
+ " Retail/object_detection/pedestrian/hypernet-rfcn/0026/dldt/person-detection-retail-0002-fp16"
95
+ }},
96
+ { " vehicle-detection-adas-0002" , {
97
+ " Transportation/object_detection/vehicle/mobilenet-reduced-ssd/dldt/vehicle-detection-adas-0002" ,
98
+ " Transportation/object_detection/vehicle/mobilenet-reduced-ssd/dldt/vehicle-detection-adas-0002-fp16"
99
+ }}
100
+ #endif
101
+ };
102
+
103
+ return g_models;
104
+ }
105
+
106
+ static const std::vector<std::string> getOpenVINOTestModelsList ()
107
+ {
108
+ std::vector<std::string> result;
109
+ const std::map<std::string, OpenVINOModelTestCaseInfo>& models = getOpenVINOTestModels ();
110
+ for (const auto & it : models)
111
+ result.push_back (it.first );
112
+ return result;
113
+ }
114
+
36
115
static inline void genData (const std::vector<size_t >& dims, Mat& m, Blob::Ptr& dataPtr)
37
116
{
38
117
std::vector<int > reversedDims (dims.begin (), dims.end ());
@@ -172,25 +251,23 @@ void runCV(Target target, const std::string& xmlPath, const std::string& binPath
172
251
}
173
252
}
174
253
175
- typedef TestWithParam<tuple<Target, String > > DNNTestOpenVINO;
254
+ typedef TestWithParam<tuple<Target, std::string > > DNNTestOpenVINO;
176
255
TEST_P (DNNTestOpenVINO, models)
177
256
{
257
+ initDLDTDataPath ();
258
+
178
259
Target target = (dnn::Target)(int )get<0 >(GetParam ());
179
260
std::string modelName = get<1 >(GetParam ());
180
- std::string precision = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? " FP16" : " FP32" ;
181
- std::string prefix;
261
+ bool isFP16 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD);
182
262
183
- #ifdef INF_ENGINE_RELEASE
184
- #if INF_ENGINE_RELEASE <= 2018050000
185
- prefix = utils::fs::join (" intel_models" ,
186
- utils::fs::join (modelName,
187
- utils::fs::join (precision, modelName)));
188
- #endif
189
- #endif
263
+ const std::map<std::string, OpenVINOModelTestCaseInfo>& models = getOpenVINOTestModels ();
264
+ const auto it = models.find (modelName);
265
+ ASSERT_TRUE (it != models.end ()) << modelName;
266
+ OpenVINOModelTestCaseInfo modelInfo = it->second ;
267
+ std::string modelPath = isFP16 ? modelInfo.modelPathFP16 : modelInfo.modelPathFP32 ;
190
268
191
- initDLDTDataPath ();
192
- std::string xmlPath = findDataFile (prefix + " .xml" );
193
- std::string binPath = findDataFile (prefix + " .bin" );
269
+ std::string xmlPath = findDataFile (modelPath + " .xml" );
270
+ std::string binPath = findDataFile (modelPath + " .bin" );
194
271
195
272
std::map<std::string, cv::Mat> inputsMap;
196
273
std::map<std::string, cv::Mat> ieOutputsMap, cvOutputsMap;
@@ -210,16 +287,12 @@ TEST_P(DNNTestOpenVINO, models)
210
287
}
211
288
}
212
289
290
+
213
291
INSTANTIATE_TEST_CASE_P (/* */ ,
214
292
DNNTestOpenVINO,
215
293
Combine (testing::ValuesIn(getAvailableTargets(DNN_BACKEND_INFERENCE_ENGINE)),
216
- testing::Values(
217
- " age-gender-recognition-retail-0013" ,
218
- " face-person-detection-retail-0002" ,
219
- " head-pose-estimation-adas-0001" ,
220
- " person-detection-retail-0002" ,
221
- " vehicle-detection-adas-0002"
222
- ))
294
+ testing::ValuesIn(getOpenVINOTestModelsList())
295
+ )
223
296
);
224
297
225
298
}}
0 commit comments