mirror of
https://github.com/opencv/opencv.git
synced 2024-11-25 11:40:44 +08:00
Merge pull request #14847 from alalek:dnn_fix_test_data_searching
This commit is contained in:
commit
f8c96cb18a
@ -38,7 +38,7 @@ namespace opencv_test {
|
||||
|
||||
static caffe::Net<float>* initNet(std::string proto, std::string weights)
|
||||
{
|
||||
proto = findDataFile(proto, false);
|
||||
proto = findDataFile(proto);
|
||||
weights = findDataFile(weights, false);
|
||||
|
||||
#ifdef HAVE_CLCAFFE
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
|
||||
weights = findDataFile(weights, false);
|
||||
if (!proto.empty())
|
||||
proto = findDataFile(proto, false);
|
||||
proto = findDataFile(proto);
|
||||
if (backend == DNN_BACKEND_HALIDE)
|
||||
{
|
||||
if (halide_scheduler == "disabled")
|
||||
@ -198,10 +198,10 @@ PERF_TEST_P_(DNNTestNetwork, YOLOv3)
|
||||
{
|
||||
if (backend == DNN_BACKEND_HALIDE)
|
||||
throw SkipTestException("");
|
||||
Mat sample = imread(findDataFile("dnn/dog416.png", false));
|
||||
Mat sample = imread(findDataFile("dnn/dog416.png"));
|
||||
Mat inp;
|
||||
sample.convertTo(inp, CV_32FC3);
|
||||
processNet("dnn/yolov3.cfg", "dnn/yolov3.weights", "", inp / 255);
|
||||
processNet("dnn/yolov3.weights", "dnn/yolov3.cfg", "", inp / 255);
|
||||
}
|
||||
|
||||
PERF_TEST_P_(DNNTestNetwork, EAST_text_detection)
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
|
||||
weights = findDataFile(weights, false);
|
||||
if (!proto.empty())
|
||||
proto = findDataFile(proto, false);
|
||||
proto = findDataFile(proto);
|
||||
|
||||
// Create two networks - with default backend and target and a tested one.
|
||||
Net netDefault = readNet(weights, proto);
|
||||
@ -51,7 +51,7 @@ public:
|
||||
net.setPreferableTarget(target);
|
||||
if (backend == DNN_BACKEND_HALIDE && !halideScheduler.empty())
|
||||
{
|
||||
halideScheduler = findDataFile(halideScheduler, false);
|
||||
halideScheduler = findDataFile(halideScheduler);
|
||||
net.setHalideScheduler(halideScheduler);
|
||||
}
|
||||
Mat out = net.forward(outputLayer).clone();
|
||||
@ -171,7 +171,7 @@ TEST_P(DNNTestNetwork, MobileNet_SSD_Caffe)
|
||||
applyTestTag(CV_TEST_TAG_MEMORY_512MB);
|
||||
if (backend == DNN_BACKEND_HALIDE)
|
||||
throw SkipTestException("");
|
||||
Mat sample = imread(findDataFile("dnn/street.png", false));
|
||||
Mat sample = imread(findDataFile("dnn/street.png"));
|
||||
Mat inp = blobFromImage(sample, 1.0f / 127.5, Size(300, 300), Scalar(127.5, 127.5, 127.5), false);
|
||||
float diffScores = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 1.5e-2 : 0.0;
|
||||
float diffSquares = (target == DNN_TARGET_MYRIAD) ? 0.063 : 0.0;
|
||||
@ -190,7 +190,7 @@ TEST_P(DNNTestNetwork, MobileNet_SSD_Caffe_Different_Width_Height)
|
||||
&& getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)
|
||||
throw SkipTestException("Test is disabled for MyriadX");
|
||||
#endif
|
||||
Mat sample = imread(findDataFile("dnn/street.png", false));
|
||||
Mat sample = imread(findDataFile("dnn/street.png"));
|
||||
Mat inp = blobFromImage(sample, 1.0f / 127.5, Size(300, 560), Scalar(127.5, 127.5, 127.5), false);
|
||||
float diffScores = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.029 : 0.0;
|
||||
float diffSquares = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.09 : 0.0;
|
||||
@ -204,7 +204,7 @@ TEST_P(DNNTestNetwork, MobileNet_SSD_v1_TensorFlow)
|
||||
applyTestTag(target == DNN_TARGET_CPU ? "" : CV_TEST_TAG_MEMORY_512MB);
|
||||
if (backend == DNN_BACKEND_HALIDE)
|
||||
throw SkipTestException("");
|
||||
Mat sample = imread(findDataFile("dnn/street.png", false));
|
||||
Mat sample = imread(findDataFile("dnn/street.png"));
|
||||
Mat inp = blobFromImage(sample, 1.0f, Size(300, 300), Scalar(), false);
|
||||
float l1 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.095 : 0.0;
|
||||
float lInf = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.09 : 0.0;
|
||||
@ -223,7 +223,7 @@ TEST_P(DNNTestNetwork, MobileNet_SSD_v1_TensorFlow_Different_Width_Height)
|
||||
&& getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)
|
||||
throw SkipTestException("Test is disabled for MyriadX");
|
||||
#endif
|
||||
Mat sample = imread(findDataFile("dnn/street.png", false));
|
||||
Mat sample = imread(findDataFile("dnn/street.png"));
|
||||
Mat inp = blobFromImage(sample, 1.0f, Size(300, 560), Scalar(), false);
|
||||
float l1 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.012 : 0.0;
|
||||
float lInf = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.06 : 0.0;
|
||||
@ -237,7 +237,7 @@ TEST_P(DNNTestNetwork, MobileNet_SSD_v2_TensorFlow)
|
||||
applyTestTag(target == DNN_TARGET_CPU ? CV_TEST_TAG_MEMORY_512MB : CV_TEST_TAG_MEMORY_1GB);
|
||||
if (backend == DNN_BACKEND_HALIDE)
|
||||
throw SkipTestException("");
|
||||
Mat sample = imread(findDataFile("dnn/street.png", false));
|
||||
Mat sample = imread(findDataFile("dnn/street.png"));
|
||||
Mat inp = blobFromImage(sample, 1.0f, Size(300, 300), Scalar(), false);
|
||||
float l1 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.013 : 2e-5;
|
||||
float lInf = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.062 : 0.0;
|
||||
@ -254,7 +254,7 @@ TEST_P(DNNTestNetwork, SSD_VGG16)
|
||||
throw SkipTestException("");
|
||||
double scoreThreshold = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.0325 : 0.0;
|
||||
const float lInf = (target == DNN_TARGET_MYRIAD) ? 0.032 : 0.0;
|
||||
Mat sample = imread(findDataFile("dnn/street.png", false));
|
||||
Mat sample = imread(findDataFile("dnn/street.png"));
|
||||
Mat inp = blobFromImage(sample, 1.0f, Size(300, 300), Scalar(), false);
|
||||
processNet("dnn/VGG_ILSVRC2016_SSD_300x300_iter_440000.caffemodel",
|
||||
"dnn/ssd_vgg16.prototxt", inp, "detection_out", "", scoreThreshold, lInf);
|
||||
@ -337,7 +337,7 @@ TEST_P(DNNTestNetwork, opencv_face_detector)
|
||||
{
|
||||
if (backend == DNN_BACKEND_HALIDE)
|
||||
throw SkipTestException("");
|
||||
Mat img = imread(findDataFile("gpu/lbpcascade/er.png", false));
|
||||
Mat img = imread(findDataFile("gpu/lbpcascade/er.png"));
|
||||
Mat inp = blobFromImage(img, 1.0, Size(), Scalar(104.0, 177.0, 123.0), false, false);
|
||||
processNet("dnn/opencv_face_detector.caffemodel", "dnn/opencv_face_detector.prototxt",
|
||||
inp, "detection_out");
|
||||
@ -357,7 +357,7 @@ TEST_P(DNNTestNetwork, Inception_v2_SSD_TensorFlow)
|
||||
#endif
|
||||
if (backend == DNN_BACKEND_HALIDE)
|
||||
throw SkipTestException("");
|
||||
Mat sample = imread(findDataFile("dnn/street.png", false));
|
||||
Mat sample = imread(findDataFile("dnn/street.png"));
|
||||
Mat inp = blobFromImage(sample, 1.0f, Size(300, 300), Scalar(), false);
|
||||
float l1 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.015 : 0.0;
|
||||
float lInf = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.0731 : 0.0;
|
||||
@ -400,7 +400,7 @@ TEST_P(DNNTestNetwork, FastNeuralStyle_eccv16)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Mat img = imread(findDataFile("dnn/googlenet_1.png", false));
|
||||
Mat img = imread(findDataFile("dnn/googlenet_1.png"));
|
||||
Mat inp = blobFromImage(img, 1.0, Size(320, 240), Scalar(103.939, 116.779, 123.68), false, false);
|
||||
// Output image has values in range [-143.526, 148.539].
|
||||
float l1 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.4 : 4e-5;
|
||||
|
@ -48,7 +48,7 @@ namespace opencv_test { namespace {
|
||||
template<typename TString>
|
||||
static std::string _tf(TString filename)
|
||||
{
|
||||
return (getOpenCVExtraDir() + "/dnn/") + filename;
|
||||
return findDataFile(std::string("dnn/") + filename);
|
||||
}
|
||||
|
||||
class Test_Caffe_nets : public DNNTestLayer
|
||||
@ -58,11 +58,11 @@ public:
|
||||
double scoreDiff = 0.0, double iouDiff = 0.0)
|
||||
{
|
||||
checkBackend();
|
||||
Net net = readNetFromCaffe(findDataFile("dnn/" + proto, false),
|
||||
Net net = readNetFromCaffe(findDataFile("dnn/" + proto),
|
||||
findDataFile("dnn/" + model, false));
|
||||
net.setPreferableBackend(backend);
|
||||
net.setPreferableTarget(target);
|
||||
Mat img = imread(findDataFile("dnn/dog416.png", false));
|
||||
Mat img = imread(findDataFile("dnn/dog416.png"));
|
||||
resize(img, img, Size(800, 600));
|
||||
Mat blob = blobFromImage(img, 1.0, Size(), Scalar(102.9801, 115.9465, 122.7717), false, false);
|
||||
Mat imInfo = (Mat_<float>(1, 3) << img.rows, img.cols, 1.6f);
|
||||
@ -80,11 +80,12 @@ public:
|
||||
|
||||
TEST(Test_Caffe, memory_read)
|
||||
{
|
||||
const string proto = findDataFile("dnn/bvlc_googlenet.prototxt", false);
|
||||
const string proto = findDataFile("dnn/bvlc_googlenet.prototxt");
|
||||
const string model = findDataFile("dnn/bvlc_googlenet.caffemodel", false);
|
||||
|
||||
std::vector<char> dataProto;
|
||||
readFileContent(proto, dataProto);
|
||||
|
||||
std::vector<char> dataModel;
|
||||
readFileContent(model, dataModel);
|
||||
|
||||
@ -163,7 +164,7 @@ TEST_P(Reproducibility_AlexNet, Accuracy)
|
||||
bool readFromMemory = get<0>(GetParam());
|
||||
Net net;
|
||||
{
|
||||
const string proto = findDataFile("dnn/bvlc_alexnet.prototxt", false);
|
||||
const string proto = findDataFile("dnn/bvlc_alexnet.prototxt");
|
||||
const string model = findDataFile("dnn/bvlc_alexnet.caffemodel", false);
|
||||
if (readFromMemory)
|
||||
{
|
||||
@ -204,8 +205,8 @@ TEST(Reproducibility_FCN, Accuracy)
|
||||
|
||||
Net net;
|
||||
{
|
||||
const string proto = findDataFile("dnn/fcn8s-heavy-pascal.prototxt", false);
|
||||
const string model = findDataFile("dnn/fcn8s-heavy-pascal.caffemodel", false);
|
||||
const string proto = findDataFile("dnn/fcn8s-heavy-pascal.prototxt");
|
||||
const string model = findDataFile("dnn/fcn8s-heavy-pascal.caffemodel");
|
||||
net = readNetFromCaffe(proto, model);
|
||||
ASSERT_FALSE(net.empty());
|
||||
}
|
||||
@ -233,7 +234,7 @@ TEST(Reproducibility_SSD, Accuracy)
|
||||
applyTestTag(CV_TEST_TAG_MEMORY_512MB, CV_TEST_TAG_DEBUG_LONG);
|
||||
Net net;
|
||||
{
|
||||
const string proto = findDataFile("dnn/ssd_vgg16.prototxt", false);
|
||||
const string proto = findDataFile("dnn/ssd_vgg16.prototxt");
|
||||
const string model = findDataFile("dnn/VGG_ILSVRC2016_SSD_300x300_iter_440000.caffemodel", false);
|
||||
net = readNetFromCaffe(proto, model);
|
||||
ASSERT_FALSE(net.empty());
|
||||
@ -331,7 +332,7 @@ TEST_P(Reproducibility_ResNet50, Accuracy)
|
||||
if (!ocl::useOpenCL() && targetId != DNN_TARGET_CPU)
|
||||
throw SkipTestException("OpenCL is disabled");
|
||||
|
||||
Net net = readNetFromCaffe(findDataFile("dnn/ResNet-50-deploy.prototxt", false),
|
||||
Net net = readNetFromCaffe(findDataFile("dnn/ResNet-50-deploy.prototxt"),
|
||||
findDataFile("dnn/ResNet-50-model.caffemodel", false));
|
||||
|
||||
net.setPreferableBackend(DNN_BACKEND_OPENCV);
|
||||
@ -369,7 +370,7 @@ TEST_P(Reproducibility_SqueezeNet_v1_1, Accuracy)
|
||||
int targetId = GetParam();
|
||||
if(targetId == DNN_TARGET_OPENCL_FP16)
|
||||
throw SkipTestException("This test does not support FP16");
|
||||
Net net = readNetFromCaffe(findDataFile("dnn/squeezenet_v1.1.prototxt", false),
|
||||
Net net = readNetFromCaffe(findDataFile("dnn/squeezenet_v1.1.prototxt"),
|
||||
findDataFile("dnn/squeezenet_v1.1.caffemodel", false));
|
||||
net.setPreferableBackend(DNN_BACKEND_OPENCV);
|
||||
net.setPreferableTarget(targetId);
|
||||
@ -400,18 +401,18 @@ TEST(Reproducibility_AlexNet_fp16, Accuracy)
|
||||
const float l1 = 1e-5;
|
||||
const float lInf = 3e-3;
|
||||
|
||||
const string proto = findDataFile("dnn/bvlc_alexnet.prototxt", false);
|
||||
const string proto = findDataFile("dnn/bvlc_alexnet.prototxt");
|
||||
const string model = findDataFile("dnn/bvlc_alexnet.caffemodel", false);
|
||||
|
||||
shrinkCaffeModel(model, "bvlc_alexnet.caffemodel_fp16");
|
||||
Net net = readNetFromCaffe(proto, "bvlc_alexnet.caffemodel_fp16");
|
||||
net.setPreferableBackend(DNN_BACKEND_OPENCV);
|
||||
|
||||
Mat sample = imread(findDataFile("dnn/grace_hopper_227.png", false));
|
||||
Mat sample = imread(findDataFile("dnn/grace_hopper_227.png"));
|
||||
|
||||
net.setInput(blobFromImage(sample, 1.0f, Size(227, 227), Scalar(), false));
|
||||
net.setInput(blobFromImage(sample, 1.0f, Size(227, 227), Scalar()));
|
||||
Mat out = net.forward();
|
||||
Mat ref = blobFromNPY(findDataFile("dnn/caffe_alexnet_prob.npy", false));
|
||||
Mat ref = blobFromNPY(findDataFile("dnn/caffe_alexnet_prob.npy"));
|
||||
normAssert(ref, out, "", l1, lInf);
|
||||
}
|
||||
|
||||
@ -420,7 +421,7 @@ TEST(Reproducibility_GoogLeNet_fp16, Accuracy)
|
||||
const float l1 = 1e-5;
|
||||
const float lInf = 3e-3;
|
||||
|
||||
const string proto = findDataFile("dnn/bvlc_googlenet.prototxt", false);
|
||||
const string proto = findDataFile("dnn/bvlc_googlenet.prototxt");
|
||||
const string model = findDataFile("dnn/bvlc_googlenet.caffemodel", false);
|
||||
|
||||
shrinkCaffeModel(model, "bvlc_googlenet.caffemodel_fp16");
|
||||
@ -506,7 +507,7 @@ TEST_P(Test_Caffe_nets, DenseNet_121)
|
||||
|
||||
TEST(Test_Caffe, multiple_inputs)
|
||||
{
|
||||
const string proto = findDataFile("dnn/layers/net_input.prototxt", false);
|
||||
const string proto = findDataFile("dnn/layers/net_input.prototxt");
|
||||
Net net = readNetFromCaffe(proto);
|
||||
net.setPreferableBackend(DNN_BACKEND_OPENCV);
|
||||
|
||||
@ -534,8 +535,8 @@ TEST(Test_Caffe, multiple_inputs)
|
||||
|
||||
TEST(Test_Caffe, shared_weights)
|
||||
{
|
||||
const string proto = findDataFile("dnn/layers/shared_weights.prototxt", false);
|
||||
const string model = findDataFile("dnn/layers/shared_weights.caffemodel", false);
|
||||
const string proto = findDataFile("dnn/layers/shared_weights.prototxt");
|
||||
const string model = findDataFile("dnn/layers/shared_weights.caffemodel");
|
||||
|
||||
Net net = readNetFromCaffe(proto, model);
|
||||
|
||||
@ -563,7 +564,7 @@ TEST_P(opencv_face_detector, Accuracy)
|
||||
dnn::Target targetId = (dnn::Target)(int)get<1>(GetParam());
|
||||
|
||||
Net net = readNetFromCaffe(proto, model);
|
||||
Mat img = imread(findDataFile("gpu/lbpcascade/er.png", false));
|
||||
Mat img = imread(findDataFile("gpu/lbpcascade/er.png"));
|
||||
Mat blob = blobFromImage(img, 1.0, Size(), Scalar(104.0, 177.0, 123.0), false, false);
|
||||
|
||||
net.setPreferableBackend(DNN_BACKEND_OPENCV);
|
||||
|
@ -82,7 +82,7 @@ TEST(Test_Darknet, read_yolo_voc_stream)
|
||||
Mat ref;
|
||||
Mat sample = imread(_tf("dog416.png"));
|
||||
Mat inp = blobFromImage(sample, 1.0/255, Size(416, 416), Scalar(), true, false);
|
||||
const std::string cfgFile = findDataFile("dnn/yolo-voc.cfg", false);
|
||||
const std::string cfgFile = findDataFile("dnn/yolo-voc.cfg");
|
||||
const std::string weightsFile = findDataFile("dnn/yolo-voc.weights", false);
|
||||
// Import by paths.
|
||||
{
|
||||
@ -110,12 +110,13 @@ class Test_Darknet_layers : public DNNTestLayer
|
||||
public:
|
||||
void testDarknetLayer(const std::string& name, bool hasWeights = false)
|
||||
{
|
||||
std::string cfg = findDataFile("dnn/darknet/" + name + ".cfg", false);
|
||||
Mat inp = blobFromNPY(findDataFile("dnn/darknet/" + name + "_in.npy"));
|
||||
Mat ref = blobFromNPY(findDataFile("dnn/darknet/" + name + "_out.npy"));
|
||||
|
||||
std::string cfg = findDataFile("dnn/darknet/" + name + ".cfg");
|
||||
std::string model = "";
|
||||
if (hasWeights)
|
||||
model = findDataFile("dnn/darknet/" + name + ".weights", false);
|
||||
Mat inp = blobFromNPY(findDataFile("dnn/darknet/" + name + "_in.npy", false));
|
||||
Mat ref = blobFromNPY(findDataFile("dnn/darknet/" + name + "_out.npy", false));
|
||||
|
||||
checkBackend(&inp, &ref);
|
||||
|
||||
@ -152,7 +153,7 @@ public:
|
||||
|
||||
Mat inp = blobFromImages(samples, 1.0/255, Size(416, 416), Scalar(), true, false);
|
||||
|
||||
Net net = readNet(findDataFile("dnn/" + cfg, false),
|
||||
Net net = readNet(findDataFile("dnn/" + cfg),
|
||||
findDataFile("dnn/" + weights, false));
|
||||
net.setPreferableBackend(backend);
|
||||
net.setPreferableTarget(target);
|
||||
|
@ -58,7 +58,7 @@ TEST_P(Reproducibility_GoogLeNet, Batching)
|
||||
const int targetId = GetParam();
|
||||
if(targetId == DNN_TARGET_OPENCL_FP16)
|
||||
throw SkipTestException("This test does not support FP16");
|
||||
Net net = readNetFromCaffe(findDataFile("dnn/bvlc_googlenet.prototxt", false),
|
||||
Net net = readNetFromCaffe(findDataFile("dnn/bvlc_googlenet.prototxt"),
|
||||
findDataFile("dnn/bvlc_googlenet.caffemodel", false));
|
||||
net.setPreferableBackend(DNN_BACKEND_OPENCV);
|
||||
net.setPreferableTarget(targetId);
|
||||
@ -89,7 +89,7 @@ TEST_P(Reproducibility_GoogLeNet, IntermediateBlobs)
|
||||
const int targetId = GetParam();
|
||||
if(targetId == DNN_TARGET_OPENCL_FP16)
|
||||
throw SkipTestException("This test does not support FP16");
|
||||
Net net = readNetFromCaffe(findDataFile("dnn/bvlc_googlenet.prototxt", false),
|
||||
Net net = readNetFromCaffe(findDataFile("dnn/bvlc_googlenet.prototxt"),
|
||||
findDataFile("dnn/bvlc_googlenet.caffemodel", false));
|
||||
net.setPreferableBackend(DNN_BACKEND_OPENCV);
|
||||
net.setPreferableTarget(targetId);
|
||||
@ -120,7 +120,7 @@ TEST_P(Reproducibility_GoogLeNet, SeveralCalls)
|
||||
const int targetId = GetParam();
|
||||
if(targetId == DNN_TARGET_OPENCL_FP16)
|
||||
throw SkipTestException("This test does not support FP16");
|
||||
Net net = readNetFromCaffe(findDataFile("dnn/bvlc_googlenet.prototxt", false),
|
||||
Net net = readNetFromCaffe(findDataFile("dnn/bvlc_googlenet.prototxt"),
|
||||
findDataFile("dnn/bvlc_googlenet.caffemodel", false));
|
||||
net.setPreferableBackend(DNN_BACKEND_OPENCV);
|
||||
net.setPreferableTarget(targetId);
|
||||
|
@ -62,18 +62,18 @@ TEST(imagesFromBlob, Regression)
|
||||
|
||||
TEST(readNet, Regression)
|
||||
{
|
||||
Net net = readNet(findDataFile("dnn/squeezenet_v1.1.prototxt", false),
|
||||
Net net = readNet(findDataFile("dnn/squeezenet_v1.1.prototxt"),
|
||||
findDataFile("dnn/squeezenet_v1.1.caffemodel", false));
|
||||
EXPECT_FALSE(net.empty());
|
||||
net = readNet(findDataFile("dnn/opencv_face_detector.caffemodel", false),
|
||||
findDataFile("dnn/opencv_face_detector.prototxt", false));
|
||||
findDataFile("dnn/opencv_face_detector.prototxt"));
|
||||
EXPECT_FALSE(net.empty());
|
||||
net = readNet(findDataFile("dnn/openface_nn4.small2.v1.t7", false));
|
||||
EXPECT_FALSE(net.empty());
|
||||
net = readNet(findDataFile("dnn/tiny-yolo-voc.cfg", false),
|
||||
net = readNet(findDataFile("dnn/tiny-yolo-voc.cfg"),
|
||||
findDataFile("dnn/tiny-yolo-voc.weights", false));
|
||||
EXPECT_FALSE(net.empty());
|
||||
net = readNet(findDataFile("dnn/ssd_mobilenet_v1_coco.pbtxt", false),
|
||||
net = readNet(findDataFile("dnn/ssd_mobilenet_v1_coco.pbtxt"),
|
||||
findDataFile("dnn/ssd_mobilenet_v1_coco.pb", false));
|
||||
EXPECT_FALSE(net.empty());
|
||||
}
|
||||
|
@ -12,15 +12,18 @@
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
template<typename TString>
|
||||
static std::string _tf(TString filename)
|
||||
static std::string _tf(TString filename, bool required = true)
|
||||
{
|
||||
String rootFolder = "dnn/onnx/";
|
||||
return findDataFile(rootFolder + filename, false);
|
||||
return findDataFile(std::string("dnn/onnx/") + filename, required);
|
||||
}
|
||||
|
||||
class Test_ONNX_layers : public DNNTestLayer
|
||||
{
|
||||
public:
|
||||
bool required;
|
||||
|
||||
Test_ONNX_layers() : required(true) { }
|
||||
|
||||
enum Extension
|
||||
{
|
||||
npy,
|
||||
@ -31,7 +34,7 @@ public:
|
||||
const double l1 = 0, const float lInf = 0, const bool useSoftmax = false,
|
||||
bool checkNoFallbacks = true)
|
||||
{
|
||||
String onnxmodel = _tf("models/" + basename + ".onnx");
|
||||
String onnxmodel = _tf("models/" + basename + ".onnx", required);
|
||||
Mat inp, ref;
|
||||
if (ext == npy) {
|
||||
inp = blobFromNPY(_tf("data/input_" + basename + ".npy"));
|
||||
@ -285,11 +288,16 @@ TEST_P(Test_ONNX_layers, Softmax)
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(/*nothing*/, Test_ONNX_layers, dnnBackendsAndTargets());
|
||||
|
||||
class Test_ONNX_nets : public Test_ONNX_layers {};
|
||||
class Test_ONNX_nets : public Test_ONNX_layers
|
||||
{
|
||||
public:
|
||||
Test_ONNX_nets() { required = false; }
|
||||
};
|
||||
|
||||
TEST_P(Test_ONNX_nets, Alexnet)
|
||||
{
|
||||
applyTestTag(target == DNN_TARGET_CPU ? CV_TEST_TAG_MEMORY_512MB : CV_TEST_TAG_MEMORY_1GB);
|
||||
const String model = _tf("models/alexnet.onnx");
|
||||
const String model = _tf("models/alexnet.onnx", false);
|
||||
|
||||
Net net = readNetFromONNX(model);
|
||||
ASSERT_FALSE(net.empty());
|
||||
@ -319,7 +327,7 @@ TEST_P(Test_ONNX_nets, Googlenet)
|
||||
if (backend == DNN_BACKEND_INFERENCE_ENGINE)
|
||||
throw SkipTestException("");
|
||||
|
||||
const String model = _tf("models/googlenet.onnx");
|
||||
const String model = _tf("models/googlenet.onnx", false);
|
||||
|
||||
Net net = readNetFromONNX(model);
|
||||
ASSERT_FALSE(net.empty());
|
||||
@ -537,7 +545,7 @@ TEST_P(Test_ONNX_nets, Resnet34_kinetics)
|
||||
if (backend != DNN_BACKEND_INFERENCE_ENGINE || target != DNN_TARGET_CPU)
|
||||
throw SkipTestException("Only DLIE backend on CPU is supported");
|
||||
|
||||
String onnxmodel = findDataFile("dnn/resnet-34_kinetics.onnx");
|
||||
String onnxmodel = findDataFile("dnn/resnet-34_kinetics.onnx", false);
|
||||
Mat image0 = imread(findDataFile("dnn/dog416.png"));
|
||||
Mat image1 = imread(findDataFile("dnn/street.png"));
|
||||
|
||||
|
@ -74,7 +74,7 @@ TEST(Test_TensorFlow, inception_accuracy)
|
||||
|
||||
static std::string path(const std::string& file)
|
||||
{
|
||||
return findDataFile("dnn/tensorflow/" + file, false);
|
||||
return findDataFile("dnn/tensorflow/" + file);
|
||||
}
|
||||
|
||||
class Test_TensorFlow_layers : public DNNTestLayer
|
||||
@ -360,15 +360,15 @@ TEST_P(Test_TensorFlow_nets, MobileNet_SSD)
|
||||
#endif
|
||||
|
||||
checkBackend();
|
||||
std::string imgPath = findDataFile("dnn/street.png");
|
||||
std::string netConfig = findDataFile("dnn/ssd_mobilenet_v1_coco.pbtxt");
|
||||
std::string netPath = findDataFile("dnn/ssd_mobilenet_v1_coco.pb", false);
|
||||
std::string netConfig = findDataFile("dnn/ssd_mobilenet_v1_coco.pbtxt", false);
|
||||
std::string imgPath = findDataFile("dnn/street.png", false);
|
||||
|
||||
Mat inp;
|
||||
resize(imread(imgPath), inp, Size(300, 300));
|
||||
inp = blobFromImage(inp, 1.0f / 127.5, Size(), Scalar(127.5, 127.5, 127.5), true);
|
||||
|
||||
Mat ref = blobFromNPY(findDataFile("dnn/tensorflow/ssd_mobilenet_v1_coco.detection_out.npy", false));
|
||||
Mat ref = blobFromNPY(findDataFile("dnn/tensorflow/ssd_mobilenet_v1_coco.detection_out.npy"));
|
||||
|
||||
Net net = readNetFromTensorflow(netPath, netConfig);
|
||||
net.setPreferableBackend(backend);
|
||||
@ -397,11 +397,11 @@ TEST_P(Test_TensorFlow_nets, Inception_v2_SSD)
|
||||
#endif
|
||||
|
||||
checkBackend();
|
||||
std::string proto = findDataFile("dnn/ssd_inception_v2_coco_2017_11_17.pbtxt", false);
|
||||
Mat img = imread(findDataFile("dnn/street.png"));
|
||||
std::string proto = findDataFile("dnn/ssd_inception_v2_coco_2017_11_17.pbtxt");
|
||||
std::string model = findDataFile("dnn/ssd_inception_v2_coco_2017_11_17.pb", false);
|
||||
|
||||
Net net = readNetFromTensorflow(model, proto);
|
||||
Mat img = imread(findDataFile("dnn/street.png", false));
|
||||
Mat blob = blobFromImage(img, 1.0f, Size(300, 300), Scalar(), true, false);
|
||||
|
||||
net.setPreferableBackend(backend);
|
||||
@ -434,11 +434,11 @@ TEST_P(Test_TensorFlow_nets, MobileNet_v1_SSD)
|
||||
throw SkipTestException("Test is disabled for MyriadX");
|
||||
#endif
|
||||
|
||||
std::string proto = findDataFile("dnn/ssd_mobilenet_v1_coco_2017_11_17.pbtxt");
|
||||
std::string model = findDataFile("dnn/ssd_mobilenet_v1_coco_2017_11_17.pb", false);
|
||||
std::string proto = findDataFile("dnn/ssd_mobilenet_v1_coco_2017_11_17.pbtxt", false);
|
||||
|
||||
Net net = readNetFromTensorflow(model, proto);
|
||||
Mat img = imread(findDataFile("dnn/dog416.png", false));
|
||||
Mat img = imread(findDataFile("dnn/dog416.png"));
|
||||
Mat blob = blobFromImage(img, 1.0f, Size(300, 300), Scalar(), true, false);
|
||||
|
||||
net.setPreferableBackend(backend);
|
||||
@ -473,13 +473,13 @@ TEST_P(Test_TensorFlow_nets, Faster_RCNN)
|
||||
double scoresDiff = backend == DNN_BACKEND_INFERENCE_ENGINE ? 2.9e-5 : 1e-5;
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
std::string proto = findDataFile("dnn/" + names[i] + ".pbtxt", false);
|
||||
std::string proto = findDataFile("dnn/" + names[i] + ".pbtxt");
|
||||
std::string model = findDataFile("dnn/" + names[i] + ".pb", false);
|
||||
|
||||
Net net = readNetFromTensorflow(model, proto);
|
||||
net.setPreferableBackend(backend);
|
||||
net.setPreferableTarget(target);
|
||||
Mat img = imread(findDataFile("dnn/dog416.png", false));
|
||||
Mat img = imread(findDataFile("dnn/dog416.png"));
|
||||
Mat blob = blobFromImage(img, 1.0f, Size(800, 600), Scalar(), true, false);
|
||||
|
||||
net.setInput(blob);
|
||||
@ -498,12 +498,12 @@ TEST_P(Test_TensorFlow_nets, MobileNet_v1_SSD_PPN)
|
||||
#endif
|
||||
|
||||
checkBackend();
|
||||
std::string proto = findDataFile("dnn/ssd_mobilenet_v1_ppn_coco.pbtxt", false);
|
||||
std::string proto = findDataFile("dnn/ssd_mobilenet_v1_ppn_coco.pbtxt");
|
||||
std::string model = findDataFile("dnn/ssd_mobilenet_v1_ppn_coco.pb", false);
|
||||
|
||||
Net net = readNetFromTensorflow(model, proto);
|
||||
Mat img = imread(findDataFile("dnn/dog416.png", false));
|
||||
Mat ref = blobFromNPY(findDataFile("dnn/tensorflow/ssd_mobilenet_v1_ppn_coco.detection_out.npy", false));
|
||||
Mat img = imread(findDataFile("dnn/dog416.png"));
|
||||
Mat ref = blobFromNPY(findDataFile("dnn/tensorflow/ssd_mobilenet_v1_ppn_coco.detection_out.npy"));
|
||||
Mat blob = blobFromImage(img, 1.0f, Size(300, 300), Scalar(), true, false);
|
||||
|
||||
net.setPreferableBackend(backend);
|
||||
@ -521,11 +521,11 @@ TEST_P(Test_TensorFlow_nets, MobileNet_v1_SSD_PPN)
|
||||
TEST_P(Test_TensorFlow_nets, opencv_face_detector_uint8)
|
||||
{
|
||||
checkBackend();
|
||||
std::string proto = findDataFile("dnn/opencv_face_detector.pbtxt", false);
|
||||
std::string proto = findDataFile("dnn/opencv_face_detector.pbtxt");
|
||||
std::string model = findDataFile("dnn/opencv_face_detector_uint8.pb", false);
|
||||
|
||||
Net net = readNetFromTensorflow(model, proto);
|
||||
Mat img = imread(findDataFile("gpu/lbpcascade/er.png", false));
|
||||
Mat img = imread(findDataFile("gpu/lbpcascade/er.png"));
|
||||
Mat blob = blobFromImage(img, 1.0, Size(), Scalar(104.0, 177.0, 123.0), false, false);
|
||||
|
||||
net.setPreferableBackend(backend);
|
||||
@ -572,11 +572,11 @@ TEST_P(Test_TensorFlow_nets, EAST_text_detection)
|
||||
checkBackend();
|
||||
|
||||
std::string netPath = findDataFile("dnn/frozen_east_text_detection.pb", false);
|
||||
std::string imgPath = findDataFile("cv/ximgproc/sources/08.png", false);
|
||||
std::string refScoresPath = findDataFile("dnn/east_text_detection.scores.npy", false);
|
||||
std::string refGeometryPath = findDataFile("dnn/east_text_detection.geometry.npy", false);
|
||||
std::string imgPath = findDataFile("cv/ximgproc/sources/08.png");
|
||||
std::string refScoresPath = findDataFile("dnn/east_text_detection.scores.npy");
|
||||
std::string refGeometryPath = findDataFile("dnn/east_text_detection.geometry.npy");
|
||||
|
||||
Net net = readNet(findDataFile("dnn/frozen_east_text_detection.pb", false));
|
||||
Net net = readNet(netPath);
|
||||
|
||||
net.setPreferableBackend(backend);
|
||||
net.setPreferableTarget(target);
|
||||
@ -793,11 +793,11 @@ TEST(Test_TensorFlow, two_inputs)
|
||||
TEST(Test_TensorFlow, Mask_RCNN)
|
||||
{
|
||||
applyTestTag(CV_TEST_TAG_MEMORY_1GB, CV_TEST_TAG_DEBUG_VERYLONG);
|
||||
std::string proto = findDataFile("dnn/mask_rcnn_inception_v2_coco_2018_01_28.pbtxt", false);
|
||||
Mat img = imread(findDataFile("dnn/street.png"));
|
||||
std::string proto = findDataFile("dnn/mask_rcnn_inception_v2_coco_2018_01_28.pbtxt");
|
||||
std::string model = findDataFile("dnn/mask_rcnn_inception_v2_coco_2018_01_28.pb", false);
|
||||
|
||||
Net net = readNetFromTensorflow(model, proto);
|
||||
Mat img = imread(findDataFile("dnn/street.png", false));
|
||||
Mat refDetections = blobFromNPY(path("mask_rcnn_inception_v2_coco_2018_01_28.detection_out.npy"));
|
||||
Mat refMasks = blobFromNPY(path("mask_rcnn_inception_v2_coco_2018_01_28.detection_masks.npy"));
|
||||
Mat blob = blobFromImage(img, 1.0f, Size(800, 800), Scalar(), true, false);
|
||||
|
@ -53,13 +53,13 @@ using namespace cv;
|
||||
using namespace cv::dnn;
|
||||
|
||||
template<typename TStr>
|
||||
static std::string _tf(TStr filename, bool inTorchDir = true)
|
||||
static std::string _tf(TStr filename, bool inTorchDir = true, bool required = true)
|
||||
{
|
||||
String path = "dnn/";
|
||||
if (inTorchDir)
|
||||
path += "torch/";
|
||||
path += filename;
|
||||
return findDataFile(path, false);
|
||||
return findDataFile(path, required);
|
||||
}
|
||||
|
||||
TEST(Torch_Importer, simple_read)
|
||||
@ -274,7 +274,7 @@ TEST_P(Test_Torch_nets, OpenFace_accuracy)
|
||||
net.setPreferableBackend(backend);
|
||||
net.setPreferableTarget(target);
|
||||
|
||||
Mat sample = imread(findDataFile("cv/shared/lena.png", false));
|
||||
Mat sample = imread(findDataFile("cv/shared/lena.png"));
|
||||
Mat sampleF32(sample.size(), CV_32FC3);
|
||||
sample.convertTo(sampleF32, sampleF32.type());
|
||||
sampleF32 /= 255;
|
||||
@ -415,7 +415,7 @@ TEST_P(Test_Torch_nets, FastNeuralStyle_accuracy)
|
||||
net.setPreferableBackend(backend);
|
||||
net.setPreferableTarget(target);
|
||||
|
||||
Mat img = imread(findDataFile("dnn/googlenet_1.png", false));
|
||||
Mat img = imread(findDataFile("dnn/googlenet_1.png"));
|
||||
Mat inputBlob = blobFromImage(img, 1.0, Size(), Scalar(103.939, 116.779, 123.68), false);
|
||||
|
||||
net.setInput(inputBlob);
|
||||
|
@ -75,7 +75,7 @@ TEST_P(Objdetect_QRCode, regression)
|
||||
ASSERT_TRUE(qrcode.detect(src, corners));
|
||||
#endif
|
||||
|
||||
const std::string dataset_config = findDataFile(root + "dataset_config.json", false);
|
||||
const std::string dataset_config = findDataFile(root + "dataset_config.json");
|
||||
FileStorage file_config(dataset_config, FileStorage::READ);
|
||||
ASSERT_TRUE(file_config.isOpened()) << "Can't read validation data: " << dataset_config;
|
||||
{
|
||||
|
@ -911,25 +911,35 @@ void addDataSearchSubDirectory(const std::string& subdir)
|
||||
|
||||
static std::string findData(const std::string& relative_path, bool required, bool findDirectory)
|
||||
{
|
||||
#define TEST_TRY_FILE_WITH_PREFIX(prefix) \
|
||||
#define CHECK_FILE_WITH_PREFIX(prefix, result) \
|
||||
{ \
|
||||
result.clear(); \
|
||||
std::string path = path_join(prefix, relative_path); \
|
||||
/*printf("Trying %s\n", path.c_str());*/ \
|
||||
if (findDirectory) \
|
||||
{ \
|
||||
if (isDirectory(path)) \
|
||||
return path; \
|
||||
result = path; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
FILE* f = fopen(path.c_str(), "rb"); \
|
||||
if(f) { \
|
||||
fclose(f); \
|
||||
return path; \
|
||||
result = path; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define TEST_TRY_FILE_WITH_PREFIX(prefix) \
|
||||
{ \
|
||||
std::string result__; \
|
||||
CHECK_FILE_WITH_PREFIX(prefix, result__); \
|
||||
if (!result__.empty()) \
|
||||
return result__; \
|
||||
}
|
||||
|
||||
|
||||
const std::vector<std::string>& search_path = TS::ptr()->data_search_path;
|
||||
for(size_t i = search_path.size(); i > 0; i--)
|
||||
{
|
||||
@ -956,7 +966,17 @@ static std::string findData(const std::string& relative_path, bool required, boo
|
||||
{
|
||||
const std::string& subdir = search_subdir[i - 1];
|
||||
std::string prefix = path_join(datapath, subdir);
|
||||
TEST_TRY_FILE_WITH_PREFIX(prefix);
|
||||
std::string result_;
|
||||
CHECK_FILE_WITH_PREFIX(prefix, result_);
|
||||
#if 1 // check for misused 'optional' mode
|
||||
if (!required && !result_.empty())
|
||||
{
|
||||
std::cout << "TEST ERROR: Don't use 'optional' findData() for " << relative_path << std::endl;
|
||||
CV_Assert(required || result_.empty());
|
||||
}
|
||||
#endif
|
||||
if (!result_.empty())
|
||||
return result_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user