Commit 13a782c0 authored by Alexander Alekhin's avatar Alexander Alekhin

test: fix usage of findDataFile()

misused 'optional' mode
parent 264679a7
...@@ -38,7 +38,7 @@ namespace opencv_test { ...@@ -38,7 +38,7 @@ namespace opencv_test {
static caffe::Net<float>* initNet(std::string proto, std::string weights) static caffe::Net<float>* initNet(std::string proto, std::string weights)
{ {
proto = findDataFile(proto, false); proto = findDataFile(proto);
weights = findDataFile(weights, false); weights = findDataFile(weights, false);
#ifdef HAVE_CLCAFFE #ifdef HAVE_CLCAFFE
......
...@@ -35,7 +35,7 @@ public: ...@@ -35,7 +35,7 @@ public:
weights = findDataFile(weights, false); weights = findDataFile(weights, false);
if (!proto.empty()) if (!proto.empty())
proto = findDataFile(proto, false); proto = findDataFile(proto);
if (backend == DNN_BACKEND_HALIDE) if (backend == DNN_BACKEND_HALIDE)
{ {
if (halide_scheduler == "disabled") if (halide_scheduler == "disabled")
...@@ -198,10 +198,10 @@ PERF_TEST_P_(DNNTestNetwork, YOLOv3) ...@@ -198,10 +198,10 @@ PERF_TEST_P_(DNNTestNetwork, YOLOv3)
{ {
if (backend == DNN_BACKEND_HALIDE) if (backend == DNN_BACKEND_HALIDE)
throw SkipTestException(""); throw SkipTestException("");
Mat sample = imread(findDataFile("dnn/dog416.png", false)); Mat sample = imread(findDataFile("dnn/dog416.png"));
Mat inp; Mat inp;
sample.convertTo(inp, CV_32FC3); 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) PERF_TEST_P_(DNNTestNetwork, EAST_text_detection)
......
...@@ -37,7 +37,7 @@ public: ...@@ -37,7 +37,7 @@ public:
weights = findDataFile(weights, false); weights = findDataFile(weights, false);
if (!proto.empty()) if (!proto.empty())
proto = findDataFile(proto, false); proto = findDataFile(proto);
// Create two networks - with default backend and target and a tested one. // Create two networks - with default backend and target and a tested one.
Net netDefault = readNet(weights, proto); Net netDefault = readNet(weights, proto);
...@@ -51,7 +51,7 @@ public: ...@@ -51,7 +51,7 @@ public:
net.setPreferableTarget(target); net.setPreferableTarget(target);
if (backend == DNN_BACKEND_HALIDE && !halideScheduler.empty()) if (backend == DNN_BACKEND_HALIDE && !halideScheduler.empty())
{ {
halideScheduler = findDataFile(halideScheduler, false); halideScheduler = findDataFile(halideScheduler);
net.setHalideScheduler(halideScheduler); net.setHalideScheduler(halideScheduler);
} }
Mat out = net.forward(outputLayer).clone(); Mat out = net.forward(outputLayer).clone();
...@@ -171,7 +171,7 @@ TEST_P(DNNTestNetwork, MobileNet_SSD_Caffe) ...@@ -171,7 +171,7 @@ TEST_P(DNNTestNetwork, MobileNet_SSD_Caffe)
applyTestTag(CV_TEST_TAG_MEMORY_512MB); applyTestTag(CV_TEST_TAG_MEMORY_512MB);
if (backend == DNN_BACKEND_HALIDE) if (backend == DNN_BACKEND_HALIDE)
throw SkipTestException(""); 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); 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 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; float diffSquares = (target == DNN_TARGET_MYRIAD) ? 0.063 : 0.0;
...@@ -190,7 +190,7 @@ TEST_P(DNNTestNetwork, MobileNet_SSD_Caffe_Different_Width_Height) ...@@ -190,7 +190,7 @@ TEST_P(DNNTestNetwork, MobileNet_SSD_Caffe_Different_Width_Height)
&& getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X) && getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)
throw SkipTestException("Test is disabled for MyriadX"); throw SkipTestException("Test is disabled for MyriadX");
#endif #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); 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 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; 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) ...@@ -204,7 +204,7 @@ TEST_P(DNNTestNetwork, MobileNet_SSD_v1_TensorFlow)
applyTestTag(target == DNN_TARGET_CPU ? "" : CV_TEST_TAG_MEMORY_512MB); applyTestTag(target == DNN_TARGET_CPU ? "" : CV_TEST_TAG_MEMORY_512MB);
if (backend == DNN_BACKEND_HALIDE) if (backend == DNN_BACKEND_HALIDE)
throw SkipTestException(""); 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); 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 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; 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) ...@@ -223,7 +223,7 @@ TEST_P(DNNTestNetwork, MobileNet_SSD_v1_TensorFlow_Different_Width_Height)
&& getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X) && getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)
throw SkipTestException("Test is disabled for MyriadX"); throw SkipTestException("Test is disabled for MyriadX");
#endif #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); 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 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; 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) ...@@ -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); applyTestTag(target == DNN_TARGET_CPU ? CV_TEST_TAG_MEMORY_512MB : CV_TEST_TAG_MEMORY_1GB);
if (backend == DNN_BACKEND_HALIDE) if (backend == DNN_BACKEND_HALIDE)
throw SkipTestException(""); 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); 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 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; float lInf = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.062 : 0.0;
...@@ -254,7 +254,7 @@ TEST_P(DNNTestNetwork, SSD_VGG16) ...@@ -254,7 +254,7 @@ TEST_P(DNNTestNetwork, SSD_VGG16)
throw SkipTestException(""); throw SkipTestException("");
double scoreThreshold = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.0325 : 0.0; 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; 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); Mat inp = blobFromImage(sample, 1.0f, Size(300, 300), Scalar(), false);
processNet("dnn/VGG_ILSVRC2016_SSD_300x300_iter_440000.caffemodel", processNet("dnn/VGG_ILSVRC2016_SSD_300x300_iter_440000.caffemodel",
"dnn/ssd_vgg16.prototxt", inp, "detection_out", "", scoreThreshold, lInf); "dnn/ssd_vgg16.prototxt", inp, "detection_out", "", scoreThreshold, lInf);
...@@ -337,7 +337,7 @@ TEST_P(DNNTestNetwork, opencv_face_detector) ...@@ -337,7 +337,7 @@ TEST_P(DNNTestNetwork, opencv_face_detector)
{ {
if (backend == DNN_BACKEND_HALIDE) if (backend == DNN_BACKEND_HALIDE)
throw SkipTestException(""); 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); 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", processNet("dnn/opencv_face_detector.caffemodel", "dnn/opencv_face_detector.prototxt",
inp, "detection_out"); inp, "detection_out");
...@@ -357,7 +357,7 @@ TEST_P(DNNTestNetwork, Inception_v2_SSD_TensorFlow) ...@@ -357,7 +357,7 @@ TEST_P(DNNTestNetwork, Inception_v2_SSD_TensorFlow)
#endif #endif
if (backend == DNN_BACKEND_HALIDE) if (backend == DNN_BACKEND_HALIDE)
throw SkipTestException(""); 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); 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 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; float lInf = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.0731 : 0.0;
...@@ -400,7 +400,7 @@ TEST_P(DNNTestNetwork, FastNeuralStyle_eccv16) ...@@ -400,7 +400,7 @@ TEST_P(DNNTestNetwork, FastNeuralStyle_eccv16)
#endif #endif
#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); 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]. // 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; float l1 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.4 : 4e-5;
......
...@@ -48,7 +48,7 @@ namespace opencv_test { namespace { ...@@ -48,7 +48,7 @@ namespace opencv_test { namespace {
template<typename TString> template<typename TString>
static std::string _tf(TString filename) static std::string _tf(TString filename)
{ {
return (getOpenCVExtraDir() + "/dnn/") + filename; return findDataFile(std::string("dnn/") + filename);
} }
class Test_Caffe_nets : public DNNTestLayer class Test_Caffe_nets : public DNNTestLayer
...@@ -58,11 +58,11 @@ public: ...@@ -58,11 +58,11 @@ public:
double scoreDiff = 0.0, double iouDiff = 0.0) double scoreDiff = 0.0, double iouDiff = 0.0)
{ {
checkBackend(); checkBackend();
Net net = readNetFromCaffe(findDataFile("dnn/" + proto, false), Net net = readNetFromCaffe(findDataFile("dnn/" + proto),
findDataFile("dnn/" + model, false)); findDataFile("dnn/" + model, false));
net.setPreferableBackend(backend); net.setPreferableBackend(backend);
net.setPreferableTarget(target); net.setPreferableTarget(target);
Mat img = imread(findDataFile("dnn/dog416.png", false)); Mat img = imread(findDataFile("dnn/dog416.png"));
resize(img, img, Size(800, 600)); resize(img, img, Size(800, 600));
Mat blob = blobFromImage(img, 1.0, Size(), Scalar(102.9801, 115.9465, 122.7717), false, false); 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); Mat imInfo = (Mat_<float>(1, 3) << img.rows, img.cols, 1.6f);
...@@ -80,11 +80,12 @@ public: ...@@ -80,11 +80,12 @@ public:
TEST(Test_Caffe, memory_read) 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); const string model = findDataFile("dnn/bvlc_googlenet.caffemodel", false);
std::vector<char> dataProto; std::vector<char> dataProto;
readFileContent(proto, dataProto); readFileContent(proto, dataProto);
std::vector<char> dataModel; std::vector<char> dataModel;
readFileContent(model, dataModel); readFileContent(model, dataModel);
...@@ -163,7 +164,7 @@ TEST_P(Reproducibility_AlexNet, Accuracy) ...@@ -163,7 +164,7 @@ TEST_P(Reproducibility_AlexNet, Accuracy)
bool readFromMemory = get<0>(GetParam()); bool readFromMemory = get<0>(GetParam());
Net net; 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); const string model = findDataFile("dnn/bvlc_alexnet.caffemodel", false);
if (readFromMemory) if (readFromMemory)
{ {
...@@ -204,8 +205,8 @@ TEST(Reproducibility_FCN, Accuracy) ...@@ -204,8 +205,8 @@ TEST(Reproducibility_FCN, Accuracy)
Net net; Net net;
{ {
const string proto = findDataFile("dnn/fcn8s-heavy-pascal.prototxt", false); const string proto = findDataFile("dnn/fcn8s-heavy-pascal.prototxt");
const string model = findDataFile("dnn/fcn8s-heavy-pascal.caffemodel", false); const string model = findDataFile("dnn/fcn8s-heavy-pascal.caffemodel");
net = readNetFromCaffe(proto, model); net = readNetFromCaffe(proto, model);
ASSERT_FALSE(net.empty()); ASSERT_FALSE(net.empty());
} }
...@@ -233,7 +234,7 @@ TEST(Reproducibility_SSD, Accuracy) ...@@ -233,7 +234,7 @@ TEST(Reproducibility_SSD, Accuracy)
applyTestTag(CV_TEST_TAG_MEMORY_512MB, CV_TEST_TAG_DEBUG_LONG); applyTestTag(CV_TEST_TAG_MEMORY_512MB, CV_TEST_TAG_DEBUG_LONG);
Net net; 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); const string model = findDataFile("dnn/VGG_ILSVRC2016_SSD_300x300_iter_440000.caffemodel", false);
net = readNetFromCaffe(proto, model); net = readNetFromCaffe(proto, model);
ASSERT_FALSE(net.empty()); ASSERT_FALSE(net.empty());
...@@ -331,7 +332,7 @@ TEST_P(Reproducibility_ResNet50, Accuracy) ...@@ -331,7 +332,7 @@ TEST_P(Reproducibility_ResNet50, Accuracy)
if (!ocl::useOpenCL() && targetId != DNN_TARGET_CPU) if (!ocl::useOpenCL() && targetId != DNN_TARGET_CPU)
throw SkipTestException("OpenCL is disabled"); 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)); findDataFile("dnn/ResNet-50-model.caffemodel", false));
net.setPreferableBackend(DNN_BACKEND_OPENCV); net.setPreferableBackend(DNN_BACKEND_OPENCV);
...@@ -369,7 +370,7 @@ TEST_P(Reproducibility_SqueezeNet_v1_1, Accuracy) ...@@ -369,7 +370,7 @@ TEST_P(Reproducibility_SqueezeNet_v1_1, Accuracy)
int targetId = GetParam(); int targetId = GetParam();
if(targetId == DNN_TARGET_OPENCL_FP16) if(targetId == DNN_TARGET_OPENCL_FP16)
throw SkipTestException("This test does not support 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)); findDataFile("dnn/squeezenet_v1.1.caffemodel", false));
net.setPreferableBackend(DNN_BACKEND_OPENCV); net.setPreferableBackend(DNN_BACKEND_OPENCV);
net.setPreferableTarget(targetId); net.setPreferableTarget(targetId);
...@@ -400,18 +401,18 @@ TEST(Reproducibility_AlexNet_fp16, Accuracy) ...@@ -400,18 +401,18 @@ TEST(Reproducibility_AlexNet_fp16, Accuracy)
const float l1 = 1e-5; const float l1 = 1e-5;
const float lInf = 3e-3; 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); const string model = findDataFile("dnn/bvlc_alexnet.caffemodel", false);
shrinkCaffeModel(model, "bvlc_alexnet.caffemodel_fp16"); shrinkCaffeModel(model, "bvlc_alexnet.caffemodel_fp16");
Net net = readNetFromCaffe(proto, "bvlc_alexnet.caffemodel_fp16"); Net net = readNetFromCaffe(proto, "bvlc_alexnet.caffemodel_fp16");
net.setPreferableBackend(DNN_BACKEND_OPENCV); 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 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); normAssert(ref, out, "", l1, lInf);
} }
...@@ -420,7 +421,7 @@ TEST(Reproducibility_GoogLeNet_fp16, Accuracy) ...@@ -420,7 +421,7 @@ TEST(Reproducibility_GoogLeNet_fp16, Accuracy)
const float l1 = 1e-5; const float l1 = 1e-5;
const float lInf = 3e-3; 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); const string model = findDataFile("dnn/bvlc_googlenet.caffemodel", false);
shrinkCaffeModel(model, "bvlc_googlenet.caffemodel_fp16"); shrinkCaffeModel(model, "bvlc_googlenet.caffemodel_fp16");
...@@ -506,7 +507,7 @@ TEST_P(Test_Caffe_nets, DenseNet_121) ...@@ -506,7 +507,7 @@ TEST_P(Test_Caffe_nets, DenseNet_121)
TEST(Test_Caffe, multiple_inputs) 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 net = readNetFromCaffe(proto);
net.setPreferableBackend(DNN_BACKEND_OPENCV); net.setPreferableBackend(DNN_BACKEND_OPENCV);
...@@ -534,8 +535,8 @@ TEST(Test_Caffe, multiple_inputs) ...@@ -534,8 +535,8 @@ TEST(Test_Caffe, multiple_inputs)
TEST(Test_Caffe, shared_weights) TEST(Test_Caffe, shared_weights)
{ {
const string proto = findDataFile("dnn/layers/shared_weights.prototxt", false); const string proto = findDataFile("dnn/layers/shared_weights.prototxt");
const string model = findDataFile("dnn/layers/shared_weights.caffemodel", false); const string model = findDataFile("dnn/layers/shared_weights.caffemodel");
Net net = readNetFromCaffe(proto, model); Net net = readNetFromCaffe(proto, model);
...@@ -563,7 +564,7 @@ TEST_P(opencv_face_detector, Accuracy) ...@@ -563,7 +564,7 @@ TEST_P(opencv_face_detector, Accuracy)
dnn::Target targetId = (dnn::Target)(int)get<1>(GetParam()); dnn::Target targetId = (dnn::Target)(int)get<1>(GetParam());
Net net = readNetFromCaffe(proto, model); 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); Mat blob = blobFromImage(img, 1.0, Size(), Scalar(104.0, 177.0, 123.0), false, false);
net.setPreferableBackend(DNN_BACKEND_OPENCV); net.setPreferableBackend(DNN_BACKEND_OPENCV);
......
...@@ -82,7 +82,7 @@ TEST(Test_Darknet, read_yolo_voc_stream) ...@@ -82,7 +82,7 @@ TEST(Test_Darknet, read_yolo_voc_stream)
Mat ref; Mat ref;
Mat sample = imread(_tf("dog416.png")); Mat sample = imread(_tf("dog416.png"));
Mat inp = blobFromImage(sample, 1.0/255, Size(416, 416), Scalar(), true, false); 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); const std::string weightsFile = findDataFile("dnn/yolo-voc.weights", false);
// Import by paths. // Import by paths.
{ {
...@@ -110,12 +110,13 @@ class Test_Darknet_layers : public DNNTestLayer ...@@ -110,12 +110,13 @@ class Test_Darknet_layers : public DNNTestLayer
public: public:
void testDarknetLayer(const std::string& name, bool hasWeights = false) 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 = ""; std::string model = "";
if (hasWeights) if (hasWeights)
model = findDataFile("dnn/darknet/" + name + ".weights", false); 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); checkBackend(&inp, &ref);
...@@ -152,7 +153,7 @@ public: ...@@ -152,7 +153,7 @@ public:
Mat inp = blobFromImages(samples, 1.0/255, Size(416, 416), Scalar(), true, false); 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)); findDataFile("dnn/" + weights, false));
net.setPreferableBackend(backend); net.setPreferableBackend(backend);
net.setPreferableTarget(target); net.setPreferableTarget(target);
......
...@@ -58,7 +58,7 @@ TEST_P(Reproducibility_GoogLeNet, Batching) ...@@ -58,7 +58,7 @@ TEST_P(Reproducibility_GoogLeNet, Batching)
const int targetId = GetParam(); const int targetId = GetParam();
if(targetId == DNN_TARGET_OPENCL_FP16) if(targetId == DNN_TARGET_OPENCL_FP16)
throw SkipTestException("This test does not support 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)); findDataFile("dnn/bvlc_googlenet.caffemodel", false));
net.setPreferableBackend(DNN_BACKEND_OPENCV); net.setPreferableBackend(DNN_BACKEND_OPENCV);
net.setPreferableTarget(targetId); net.setPreferableTarget(targetId);
...@@ -89,7 +89,7 @@ TEST_P(Reproducibility_GoogLeNet, IntermediateBlobs) ...@@ -89,7 +89,7 @@ TEST_P(Reproducibility_GoogLeNet, IntermediateBlobs)
const int targetId = GetParam(); const int targetId = GetParam();
if(targetId == DNN_TARGET_OPENCL_FP16) if(targetId == DNN_TARGET_OPENCL_FP16)
throw SkipTestException("This test does not support 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)); findDataFile("dnn/bvlc_googlenet.caffemodel", false));
net.setPreferableBackend(DNN_BACKEND_OPENCV); net.setPreferableBackend(DNN_BACKEND_OPENCV);
net.setPreferableTarget(targetId); net.setPreferableTarget(targetId);
...@@ -120,7 +120,7 @@ TEST_P(Reproducibility_GoogLeNet, SeveralCalls) ...@@ -120,7 +120,7 @@ TEST_P(Reproducibility_GoogLeNet, SeveralCalls)
const int targetId = GetParam(); const int targetId = GetParam();
if(targetId == DNN_TARGET_OPENCL_FP16) if(targetId == DNN_TARGET_OPENCL_FP16)
throw SkipTestException("This test does not support 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)); findDataFile("dnn/bvlc_googlenet.caffemodel", false));
net.setPreferableBackend(DNN_BACKEND_OPENCV); net.setPreferableBackend(DNN_BACKEND_OPENCV);
net.setPreferableTarget(targetId); net.setPreferableTarget(targetId);
......
...@@ -62,18 +62,18 @@ TEST(imagesFromBlob, Regression) ...@@ -62,18 +62,18 @@ TEST(imagesFromBlob, Regression)
TEST(readNet, 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)); findDataFile("dnn/squeezenet_v1.1.caffemodel", false));
EXPECT_FALSE(net.empty()); EXPECT_FALSE(net.empty());
net = readNet(findDataFile("dnn/opencv_face_detector.caffemodel", false), 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()); EXPECT_FALSE(net.empty());
net = readNet(findDataFile("dnn/openface_nn4.small2.v1.t7", false)); net = readNet(findDataFile("dnn/openface_nn4.small2.v1.t7", false));
EXPECT_FALSE(net.empty()); 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)); findDataFile("dnn/tiny-yolo-voc.weights", false));
EXPECT_FALSE(net.empty()); 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)); findDataFile("dnn/ssd_mobilenet_v1_coco.pb", false));
EXPECT_FALSE(net.empty()); EXPECT_FALSE(net.empty());
} }
......
...@@ -12,15 +12,18 @@ ...@@ -12,15 +12,18 @@
namespace opencv_test { namespace { namespace opencv_test { namespace {
template<typename TString> template<typename TString>
static std::string _tf(TString filename) static std::string _tf(TString filename, bool required = true)
{ {
String rootFolder = "dnn/onnx/"; return findDataFile(std::string("dnn/onnx/") + filename, required);
return findDataFile(rootFolder + filename, false);
} }
class Test_ONNX_layers : public DNNTestLayer class Test_ONNX_layers : public DNNTestLayer
{ {
public: public:
bool required;
Test_ONNX_layers() : required(true) { }
enum Extension enum Extension
{ {
npy, npy,
...@@ -31,7 +34,7 @@ public: ...@@ -31,7 +34,7 @@ public:
const double l1 = 0, const float lInf = 0, const bool useSoftmax = false, const double l1 = 0, const float lInf = 0, const bool useSoftmax = false,
bool checkNoFallbacks = true) bool checkNoFallbacks = true)
{ {
String onnxmodel = _tf("models/" + basename + ".onnx"); String onnxmodel = _tf("models/" + basename + ".onnx", required);
Mat inp, ref; Mat inp, ref;
if (ext == npy) { if (ext == npy) {
inp = blobFromNPY(_tf("data/input_" + basename + ".npy")); inp = blobFromNPY(_tf("data/input_" + basename + ".npy"));
...@@ -275,11 +278,16 @@ TEST_P(Test_ONNX_layers, Softmax) ...@@ -275,11 +278,16 @@ TEST_P(Test_ONNX_layers, Softmax)
INSTANTIATE_TEST_CASE_P(/*nothing*/, Test_ONNX_layers, dnnBackendsAndTargets()); 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) TEST_P(Test_ONNX_nets, Alexnet)
{ {
applyTestTag(target == DNN_TARGET_CPU ? CV_TEST_TAG_MEMORY_512MB : CV_TEST_TAG_MEMORY_1GB); 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); Net net = readNetFromONNX(model);
ASSERT_FALSE(net.empty()); ASSERT_FALSE(net.empty());
...@@ -309,7 +317,7 @@ TEST_P(Test_ONNX_nets, Googlenet) ...@@ -309,7 +317,7 @@ TEST_P(Test_ONNX_nets, Googlenet)
if (backend == DNN_BACKEND_INFERENCE_ENGINE) if (backend == DNN_BACKEND_INFERENCE_ENGINE)
throw SkipTestException(""); throw SkipTestException("");
const String model = _tf("models/googlenet.onnx"); const String model = _tf("models/googlenet.onnx", false);
Net net = readNetFromONNX(model); Net net = readNetFromONNX(model);
ASSERT_FALSE(net.empty()); ASSERT_FALSE(net.empty());
...@@ -527,7 +535,7 @@ TEST_P(Test_ONNX_nets, Resnet34_kinetics) ...@@ -527,7 +535,7 @@ TEST_P(Test_ONNX_nets, Resnet34_kinetics)
if (backend != DNN_BACKEND_INFERENCE_ENGINE || target != DNN_TARGET_CPU) if (backend != DNN_BACKEND_INFERENCE_ENGINE || target != DNN_TARGET_CPU)
throw SkipTestException("Only DLIE backend on CPU is supported"); 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 image0 = imread(findDataFile("dnn/dog416.png"));
Mat image1 = imread(findDataFile("dnn/street.png")); Mat image1 = imread(findDataFile("dnn/street.png"));
......
...@@ -74,7 +74,7 @@ TEST(Test_TensorFlow, inception_accuracy) ...@@ -74,7 +74,7 @@ TEST(Test_TensorFlow, inception_accuracy)
static std::string path(const std::string& file) 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 class Test_TensorFlow_layers : public DNNTestLayer
...@@ -360,15 +360,15 @@ TEST_P(Test_TensorFlow_nets, MobileNet_SSD) ...@@ -360,15 +360,15 @@ TEST_P(Test_TensorFlow_nets, MobileNet_SSD)
#endif #endif
checkBackend(); 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 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; Mat inp;
resize(imread(imgPath), inp, Size(300, 300)); resize(imread(imgPath), inp, Size(300, 300));
inp = blobFromImage(inp, 1.0f / 127.5, Size(), Scalar(127.5, 127.5, 127.5), true); 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 net = readNetFromTensorflow(netPath, netConfig);
net.setPreferableBackend(backend); net.setPreferableBackend(backend);
...@@ -397,11 +397,11 @@ TEST_P(Test_TensorFlow_nets, Inception_v2_SSD) ...@@ -397,11 +397,11 @@ TEST_P(Test_TensorFlow_nets, Inception_v2_SSD)
#endif #endif
checkBackend(); 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); std::string model = findDataFile("dnn/ssd_inception_v2_coco_2017_11_17.pb", false);
Net net = readNetFromTensorflow(model, proto); 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); Mat blob = blobFromImage(img, 1.0f, Size(300, 300), Scalar(), true, false);
net.setPreferableBackend(backend); net.setPreferableBackend(backend);
...@@ -434,11 +434,11 @@ TEST_P(Test_TensorFlow_nets, MobileNet_v1_SSD) ...@@ -434,11 +434,11 @@ TEST_P(Test_TensorFlow_nets, MobileNet_v1_SSD)
throw SkipTestException("Test is disabled for MyriadX"); throw SkipTestException("Test is disabled for MyriadX");
#endif #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 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); 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); Mat blob = blobFromImage(img, 1.0f, Size(300, 300), Scalar(), true, false);
net.setPreferableBackend(backend); net.setPreferableBackend(backend);
...@@ -473,13 +473,13 @@ TEST_P(Test_TensorFlow_nets, Faster_RCNN) ...@@ -473,13 +473,13 @@ TEST_P(Test_TensorFlow_nets, Faster_RCNN)
double scoresDiff = backend == DNN_BACKEND_INFERENCE_ENGINE ? 2.9e-5 : 1e-5; double scoresDiff = backend == DNN_BACKEND_INFERENCE_ENGINE ? 2.9e-5 : 1e-5;
for (int i = 0; i < 2; ++i) 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); std::string model = findDataFile("dnn/" + names[i] + ".pb", false);
Net net = readNetFromTensorflow(model, proto); Net net = readNetFromTensorflow(model, proto);
net.setPreferableBackend(backend); net.setPreferableBackend(backend);
net.setPreferableTarget(target); 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); Mat blob = blobFromImage(img, 1.0f, Size(800, 600), Scalar(), true, false);
net.setInput(blob); net.setInput(blob);
...@@ -498,12 +498,12 @@ TEST_P(Test_TensorFlow_nets, MobileNet_v1_SSD_PPN) ...@@ -498,12 +498,12 @@ TEST_P(Test_TensorFlow_nets, MobileNet_v1_SSD_PPN)
#endif #endif
checkBackend(); 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); std::string model = findDataFile("dnn/ssd_mobilenet_v1_ppn_coco.pb", false);
Net net = readNetFromTensorflow(model, proto); Net net = readNetFromTensorflow(model, proto);
Mat img = imread(findDataFile("dnn/dog416.png", false)); Mat img = imread(findDataFile("dnn/dog416.png"));
Mat ref = blobFromNPY(findDataFile("dnn/tensorflow/ssd_mobilenet_v1_ppn_coco.detection_out.npy", false)); 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); Mat blob = blobFromImage(img, 1.0f, Size(300, 300), Scalar(), true, false);
net.setPreferableBackend(backend); net.setPreferableBackend(backend);
...@@ -521,11 +521,11 @@ TEST_P(Test_TensorFlow_nets, MobileNet_v1_SSD_PPN) ...@@ -521,11 +521,11 @@ TEST_P(Test_TensorFlow_nets, MobileNet_v1_SSD_PPN)
TEST_P(Test_TensorFlow_nets, opencv_face_detector_uint8) TEST_P(Test_TensorFlow_nets, opencv_face_detector_uint8)
{ {
checkBackend(); 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); std::string model = findDataFile("dnn/opencv_face_detector_uint8.pb", false);
Net net = readNetFromTensorflow(model, proto); 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); Mat blob = blobFromImage(img, 1.0, Size(), Scalar(104.0, 177.0, 123.0), false, false);
net.setPreferableBackend(backend); net.setPreferableBackend(backend);
...@@ -572,11 +572,11 @@ TEST_P(Test_TensorFlow_nets, EAST_text_detection) ...@@ -572,11 +572,11 @@ TEST_P(Test_TensorFlow_nets, EAST_text_detection)
checkBackend(); checkBackend();
std::string netPath = findDataFile("dnn/frozen_east_text_detection.pb", false); std::string netPath = findDataFile("dnn/frozen_east_text_detection.pb", false);
std::string imgPath = findDataFile("cv/ximgproc/sources/08.png", false); std::string imgPath = findDataFile("cv/ximgproc/sources/08.png");
std::string refScoresPath = findDataFile("dnn/east_text_detection.scores.npy", false); std::string refScoresPath = findDataFile("dnn/east_text_detection.scores.npy");
std::string refGeometryPath = findDataFile("dnn/east_text_detection.geometry.npy", false); 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.setPreferableBackend(backend);
net.setPreferableTarget(target); net.setPreferableTarget(target);
...@@ -793,11 +793,11 @@ TEST(Test_TensorFlow, two_inputs) ...@@ -793,11 +793,11 @@ TEST(Test_TensorFlow, two_inputs)
TEST(Test_TensorFlow, Mask_RCNN) TEST(Test_TensorFlow, Mask_RCNN)
{ {
applyTestTag(CV_TEST_TAG_MEMORY_1GB, CV_TEST_TAG_DEBUG_VERYLONG); 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); std::string model = findDataFile("dnn/mask_rcnn_inception_v2_coco_2018_01_28.pb", false);
Net net = readNetFromTensorflow(model, proto); 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 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 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); Mat blob = blobFromImage(img, 1.0f, Size(800, 800), Scalar(), true, false);
......
...@@ -53,13 +53,13 @@ using namespace cv; ...@@ -53,13 +53,13 @@ using namespace cv;
using namespace cv::dnn; using namespace cv::dnn;
template<typename TStr> 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/"; String path = "dnn/";
if (inTorchDir) if (inTorchDir)
path += "torch/"; path += "torch/";
path += filename; path += filename;
return findDataFile(path, false); return findDataFile(path, required);
} }
TEST(Torch_Importer, simple_read) TEST(Torch_Importer, simple_read)
...@@ -274,7 +274,7 @@ TEST_P(Test_Torch_nets, OpenFace_accuracy) ...@@ -274,7 +274,7 @@ TEST_P(Test_Torch_nets, OpenFace_accuracy)
net.setPreferableBackend(backend); net.setPreferableBackend(backend);
net.setPreferableTarget(target); 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); Mat sampleF32(sample.size(), CV_32FC3);
sample.convertTo(sampleF32, sampleF32.type()); sample.convertTo(sampleF32, sampleF32.type());
sampleF32 /= 255; sampleF32 /= 255;
...@@ -415,7 +415,7 @@ TEST_P(Test_Torch_nets, FastNeuralStyle_accuracy) ...@@ -415,7 +415,7 @@ TEST_P(Test_Torch_nets, FastNeuralStyle_accuracy)
net.setPreferableBackend(backend); net.setPreferableBackend(backend);
net.setPreferableTarget(target); 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); Mat inputBlob = blobFromImage(img, 1.0, Size(), Scalar(103.939, 116.779, 123.68), false);
net.setInput(inputBlob); net.setInput(inputBlob);
......
...@@ -75,7 +75,7 @@ TEST_P(Objdetect_QRCode, regression) ...@@ -75,7 +75,7 @@ TEST_P(Objdetect_QRCode, regression)
ASSERT_TRUE(qrcode.detect(src, corners)); ASSERT_TRUE(qrcode.detect(src, corners));
#endif #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); FileStorage file_config(dataset_config, FileStorage::READ);
ASSERT_TRUE(file_config.isOpened()) << "Can't read validation data: " << dataset_config; ASSERT_TRUE(file_config.isOpened()) << "Can't read validation data: " << dataset_config;
{ {
......
...@@ -911,25 +911,35 @@ void addDataSearchSubDirectory(const std::string& subdir) ...@@ -911,25 +911,35 @@ void addDataSearchSubDirectory(const std::string& subdir)
static std::string findData(const std::string& relative_path, bool required, bool findDirectory) 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); \ std::string path = path_join(prefix, relative_path); \
/*printf("Trying %s\n", path.c_str());*/ \ /*printf("Trying %s\n", path.c_str());*/ \
if (findDirectory) \ if (findDirectory) \
{ \ { \
if (isDirectory(path)) \ if (isDirectory(path)) \
return path; \ result = path; \
} \ } \
else \ else \
{ \ { \
FILE* f = fopen(path.c_str(), "rb"); \ FILE* f = fopen(path.c_str(), "rb"); \
if(f) { \ if(f) { \
fclose(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; const std::vector<std::string>& search_path = TS::ptr()->data_search_path;
for(size_t i = search_path.size(); i > 0; i--) 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 ...@@ -956,7 +966,17 @@ static std::string findData(const std::string& relative_path, bool required, boo
{ {
const std::string& subdir = search_subdir[i - 1]; const std::string& subdir = search_subdir[i - 1];
std::string prefix = path_join(datapath, subdir); 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_;
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment