Commit 0b688cd2 authored by Alexander Alekhin's avatar Alexander Alekhin

Merge pull request #10240 from alalek:dnn_perf_ssd

parents 682bd2ee d8a737b4
...@@ -32,7 +32,7 @@ public: ...@@ -32,7 +32,7 @@ public:
dnn::Net net; dnn::Net net;
void processNet(std::string weights, std::string proto, std::string halide_scheduler, void processNet(std::string weights, std::string proto, std::string halide_scheduler,
int inWidth, int inHeight, const std::string& outputLayer, const Mat& input, const std::string& outputLayer,
const std::string& framework) const std::string& framework)
{ {
backend = (dnn::Backend)(int)get<0>(GetParam()); backend = (dnn::Backend)(int)get<0>(GetParam());
...@@ -48,15 +48,18 @@ public: ...@@ -48,15 +48,18 @@ public:
} }
} }
Mat input(inHeight, inWidth, CV_32FC3);
randu(input, 0.0f, 1.0f); randu(input, 0.0f, 1.0f);
weights = findDataFile(weights, false); weights = findDataFile(weights, false);
if (!proto.empty()) if (!proto.empty())
proto = findDataFile(proto, false); proto = findDataFile(proto, false);
if (!halide_scheduler.empty() && backend == DNN_BACKEND_HALIDE) if (backend == DNN_BACKEND_HALIDE)
halide_scheduler = findDataFile(std::string("dnn/halide_scheduler_") + (target == DNN_TARGET_OPENCL ? "opencl_" : "") + halide_scheduler, true); {
if (halide_scheduler == "disabled")
throw ::SkipTestException("Halide test is disabled");
if (!halide_scheduler.empty())
halide_scheduler = findDataFile(std::string("dnn/halide_scheduler_") + (target == DNN_TARGET_OPENCL ? "opencl_" : "") + halide_scheduler, true);
}
if (framework == "caffe") if (framework == "caffe")
{ {
net = cv::dnn::readNetFromCaffe(proto, weights); net = cv::dnn::readNetFromCaffe(proto, weights);
...@@ -80,7 +83,7 @@ public: ...@@ -80,7 +83,7 @@ public:
net.setHalideScheduler(halide_scheduler); net.setHalideScheduler(halide_scheduler);
} }
MatShape netInputShape = shape(1, 3, inHeight, inWidth); MatShape netInputShape = shape(1, 3, input.rows, input.cols);
size_t weightsMemory = 0, blobsMemory = 0; size_t weightsMemory = 0, blobsMemory = 0;
net.getMemoryConsumption(netInputShape, weightsMemory, blobsMemory); net.getMemoryConsumption(netInputShape, weightsMemory, blobsMemory);
int64 flops = net.getFLOPS(netInputShape); int64 flops = net.getFLOPS(netInputShape);
...@@ -104,40 +107,45 @@ public: ...@@ -104,40 +107,45 @@ public:
PERF_TEST_P_(DNNTestNetwork, AlexNet) PERF_TEST_P_(DNNTestNetwork, AlexNet)
{ {
processNet("dnn/bvlc_alexnet.caffemodel", "dnn/bvlc_alexnet.prototxt", processNet("dnn/bvlc_alexnet.caffemodel", "dnn/bvlc_alexnet.prototxt",
"alexnet.yml", 227, 227, "prob", "caffe"); "alexnet.yml", Mat(cv::Size(227, 227), CV_32FC3), "prob", "caffe");
} }
PERF_TEST_P_(DNNTestNetwork, GoogLeNet) PERF_TEST_P_(DNNTestNetwork, GoogLeNet)
{ {
processNet("dnn/bvlc_googlenet.caffemodel", "dnn/bvlc_googlenet.prototxt", processNet("dnn/bvlc_googlenet.caffemodel", "dnn/bvlc_googlenet.prototxt",
"", 224, 224, "prob", "caffe"); "", Mat(cv::Size(224, 224), CV_32FC3), "prob", "caffe");
} }
PERF_TEST_P_(DNNTestNetwork, ResNet50) PERF_TEST_P_(DNNTestNetwork, ResNet50)
{ {
processNet("dnn/ResNet-50-model.caffemodel", "dnn/ResNet-50-deploy.prototxt", processNet("dnn/ResNet-50-model.caffemodel", "dnn/ResNet-50-deploy.prototxt",
"resnet_50.yml", 224, 224, "prob", "caffe"); "resnet_50.yml", Mat(cv::Size(224, 224), CV_32FC3), "prob", "caffe");
} }
PERF_TEST_P_(DNNTestNetwork, SqueezeNet_v1_1) PERF_TEST_P_(DNNTestNetwork, SqueezeNet_v1_1)
{ {
processNet("dnn/squeezenet_v1.1.caffemodel", "dnn/squeezenet_v1.1.prototxt", processNet("dnn/squeezenet_v1.1.caffemodel", "dnn/squeezenet_v1.1.prototxt",
"squeezenet_v1_1.yml", 227, 227, "prob", "caffe"); "squeezenet_v1_1.yml", Mat(cv::Size(227, 227), CV_32FC3), "prob", "caffe");
} }
PERF_TEST_P_(DNNTestNetwork, Inception_5h) PERF_TEST_P_(DNNTestNetwork, Inception_5h)
{ {
processNet("dnn/tensorflow_inception_graph.pb", "", processNet("dnn/tensorflow_inception_graph.pb", "",
"inception_5h.yml", "inception_5h.yml",
224, 224, "softmax2", "tensorflow"); Mat(cv::Size(224, 224), CV_32FC3), "softmax2", "tensorflow");
} }
PERF_TEST_P_(DNNTestNetwork, ENet) PERF_TEST_P_(DNNTestNetwork, ENet)
{ {
processNet("dnn/Enet-model-best.net", "", "enet.yml", processNet("dnn/Enet-model-best.net", "", "enet.yml",
512, 256, "l367_Deconvolution", "torch"); Mat(cv::Size(512, 256), CV_32FC3), "l367_Deconvolution", "torch");
} }
PERF_TEST_P_(DNNTestNetwork, SSD)
{
processNet("dnn/VGG_ILSVRC2016_SSD_300x300_iter_440000.caffemodel", "dnn/ssd_vgg16.prototxt", "disabled",
Mat(cv::Size(300, 300), CV_32FC3), "detection_out", "caffe");
}
INSTANTIATE_TEST_CASE_P(/*nothing*/, DNNTestNetwork, INSTANTIATE_TEST_CASE_P(/*nothing*/, DNNTestNetwork,
testing::Combine( testing::Combine(
......
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