@@ -11,6 +11,8 @@ Test for Tensorflow models loading
11
11
12
12
#include " test_precomp.hpp"
13
13
#include " npy_blob.hpp"
14
+ #include < opencv2/core/ocl.hpp>
15
+ #include < opencv2/ts/ocl_test.hpp>
14
16
15
17
namespace cvtest
16
18
{
@@ -219,6 +221,43 @@ TEST(Test_TensorFlow, MobileNet_SSD)
219
221
normAssert (target[2 ].reshape (1 , 1 ), output[2 ].reshape (1 , 1 ), " " , 4e-5 , 1e-2 );
220
222
}
221
223
224
+ OCL_TEST (Test_TensorFlow, MobileNet_SSD)
225
+ {
226
+ std::string netPath = findDataFile (" dnn/ssd_mobilenet_v1_coco.pb" , false );
227
+ std::string netConfig = findDataFile (" dnn/ssd_mobilenet_v1_coco.pbtxt" , false );
228
+ std::string imgPath = findDataFile (" dnn/street.png" , false );
229
+
230
+ Mat inp;
231
+ resize (imread (imgPath), inp, Size (300 , 300 ));
232
+ inp = blobFromImage (inp, 1 .0f / 127.5 , Size (), Scalar (127.5 , 127.5 , 127.5 ), true );
233
+
234
+ std::vector<String> outNames (3 );
235
+ outNames[0 ] = " concat" ;
236
+ outNames[1 ] = " concat_1" ;
237
+ outNames[2 ] = " detection_out" ;
238
+
239
+ std::vector<Mat> target (outNames.size ());
240
+ for (int i = 0 ; i < outNames.size (); ++i)
241
+ {
242
+ std::string path = findDataFile (" dnn/tensorflow/ssd_mobilenet_v1_coco." + outNames[i] + " .npy" , false );
243
+ target[i] = blobFromNPY (path);
244
+ }
245
+
246
+ Net net = readNetFromTensorflow (netPath, netConfig);
247
+
248
+ net.setPreferableBackend (DNN_BACKEND_DEFAULT);
249
+ net.setPreferableTarget (DNN_TARGET_OPENCL);
250
+
251
+ net.setInput (inp);
252
+
253
+ std::vector<Mat> output;
254
+ net.forward (output, outNames);
255
+
256
+ normAssert (target[0 ].reshape (1 , 1 ), output[0 ].reshape (1 , 1 ));
257
+ normAssert (target[1 ].reshape (1 , 1 ), output[1 ].reshape (1 , 1 ), " " , 1e-5 , 2e-4 );
258
+ normAssert (target[2 ].reshape (1 , 1 ), output[2 ].reshape (1 , 1 ), " " , 4e-5 , 1e-2 );
259
+ }
260
+
222
261
TEST (Test_TensorFlow, lstm)
223
262
{
224
263
runTensorFlowNet (" lstm" , true );
0 commit comments