@@ -254,6 +254,13 @@ class Test_Darknet_nets : public DNNTestLayer
254
254
255
255
}
256
256
257
+ if (cvIsNaN (iouDiff))
258
+ {
259
+ if (b == 0 )
260
+ std::cout << " Skip accuracy checks" << std::endl;
261
+ continue ;
262
+ }
263
+
257
264
normAssertDetections (refClassIds[b], refConfidences[b], refBoxes[b], nms_classIds,
258
265
nms_confidences, nms_boxes, format (" batch size %d, sample %d\n " , batch_size, b).c_str (), confThreshold, scoreDiff, iouDiff);
259
266
}
@@ -449,7 +456,7 @@ TEST_P(Test_Darknet_nets_async, Accuracy)
449
456
}
450
457
451
458
INSTANTIATE_TEST_CASE_P (/* */ , Test_Darknet_nets_async, Combine(
452
- Values (" yolo-voc" , " tiny-yolo-voc" , " yolov3" , " yolov4" ),
459
+ Values (" yolo-voc" , " tiny-yolo-voc" , " yolov3" , " yolov4" , " yolov4-tiny " ),
453
460
dnnBackendsAndTargets()
454
461
));
455
462
@@ -587,6 +594,63 @@ TEST_P(Test_Darknet_nets, YOLOv4)
587
594
}
588
595
}
589
596
597
+ TEST_P (Test_Darknet_nets, YOLOv4_tiny)
598
+ {
599
+ applyTestTag (
600
+ target == DNN_TARGET_CPU ? CV_TEST_TAG_MEMORY_512MB : CV_TEST_TAG_MEMORY_1GB
601
+ );
602
+
603
+ const double confThreshold = 0.5 ;
604
+ // batchId, classId, confidence, left, top, right, bottom
605
+ const int N0 = 2 ;
606
+ const int N1 = 3 ;
607
+ static const float ref_[/* (N0 + N1) * 7 */ ] = {
608
+ 0 , 7 , 0 .85935f , 0 .593484f , 0 .141211f , 0 .920356f , 0 .291593f ,
609
+ 0 , 16 , 0 .795188f , 0 .169207f , 0 .386886f , 0 .423753f , 0 .933004f ,
610
+
611
+ 1 , 2 , 0 .996832f , 0 .653802f , 0 .464573f , 0 .815193f , 0 .653292f ,
612
+ 1 , 2 , 0 .963325f , 0 .451151f , 0 .458915f , 0 .496255f , 0 .52241f ,
613
+ 1 , 0 , 0 .926244f , 0 .194851f , 0 .361743f , 0 .260277f , 0 .632364f ,
614
+ };
615
+ Mat ref (N0 + N1, 7 , CV_32FC1, (void *)ref_);
616
+
617
+ double scoreDiff = 0 .01f ;
618
+ double iouDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.15 : 0 .01f ;
619
+
620
+ std::string config_file = " yolov4-tiny.cfg" ;
621
+ std::string weights_file = " yolov4-tiny.weights" ;
622
+
623
+ #if defined(INF_ENGINE_RELEASE)
624
+ if (target == DNN_TARGET_MYRIAD) // bad accuracy
625
+ iouDiff = std::numeric_limits<double >::quiet_NaN ();
626
+ if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_OPENCL)
627
+ iouDiff = std::numeric_limits<double >::quiet_NaN ();
628
+ if ((backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 ||
629
+ backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH) && DNN_TARGET_OPENCL_FP16)
630
+ iouDiff = std::numeric_limits<double >::quiet_NaN ();
631
+ #endif
632
+
633
+ {
634
+ SCOPED_TRACE (" batch size 1" );
635
+ testDarknetModel (config_file, weights_file, ref.rowRange (0 , N0), scoreDiff, iouDiff, confThreshold);
636
+ }
637
+
638
+ {
639
+ SCOPED_TRACE (" batch size 2" );
640
+ testDarknetModel (config_file, weights_file, ref, scoreDiff, iouDiff, confThreshold);
641
+ }
642
+
643
+ #if defined(INF_ENGINE_RELEASE)
644
+ if (target == DNN_TARGET_MYRIAD) // bad accuracy
645
+ applyTestTag (CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
646
+ if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_OPENCL)
647
+ applyTestTag (CV_TEST_TAG_DNN_SKIP_IE_OPENCL, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
648
+ if ((backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 ||
649
+ backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH) && DNN_TARGET_OPENCL_FP16)
650
+ applyTestTag (CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
651
+ #endif
652
+ }
653
+
590
654
591
655
INSTANTIATE_TEST_CASE_P (/* */ , Test_Darknet_nets, dnnBackendsAndTargets());
592
656
0 commit comments