Skip to content

Commit 0b688cd

Browse files
committed
Merge pull request opencv#10240 from alalek:dnn_perf_ssd
2 parents 682bd2e + d8a737b commit 0b688cd

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

modules/dnn/perf/perf_net.cpp

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class DNNTestNetwork : public ::perf::TestBaseWithParam< tuple<DNNBackend, DNNTa
3232
dnn::Net net;
3333

3434
void processNet(std::string weights, std::string proto, std::string halide_scheduler,
35-
int inWidth, int inHeight, const std::string& outputLayer,
35+
const Mat& input, const std::string& outputLayer,
3636
const std::string& framework)
3737
{
3838
backend = (dnn::Backend)(int)get<0>(GetParam());
@@ -48,15 +48,18 @@ class DNNTestNetwork : public ::perf::TestBaseWithParam< tuple<DNNBackend, DNNTa
4848
}
4949
}
5050

51-
Mat input(inHeight, inWidth, CV_32FC3);
5251
randu(input, 0.0f, 1.0f);
5352

54-
5553
weights = findDataFile(weights, false);
5654
if (!proto.empty())
5755
proto = findDataFile(proto, false);
58-
if (!halide_scheduler.empty() && backend == DNN_BACKEND_HALIDE)
59-
halide_scheduler = findDataFile(std::string("dnn/halide_scheduler_") + (target == DNN_TARGET_OPENCL ? "opencl_" : "") + halide_scheduler, true);
56+
if (backend == DNN_BACKEND_HALIDE)
57+
{
58+
if (halide_scheduler == "disabled")
59+
throw ::SkipTestException("Halide test is disabled");
60+
if (!halide_scheduler.empty())
61+
halide_scheduler = findDataFile(std::string("dnn/halide_scheduler_") + (target == DNN_TARGET_OPENCL ? "opencl_" : "") + halide_scheduler, true);
62+
}
6063
if (framework == "caffe")
6164
{
6265
net = cv::dnn::readNetFromCaffe(proto, weights);
@@ -80,7 +83,7 @@ class DNNTestNetwork : public ::perf::TestBaseWithParam< tuple<DNNBackend, DNNTa
8083
net.setHalideScheduler(halide_scheduler);
8184
}
8285

83-
MatShape netInputShape = shape(1, 3, inHeight, inWidth);
86+
MatShape netInputShape = shape(1, 3, input.rows, input.cols);
8487
size_t weightsMemory = 0, blobsMemory = 0;
8588
net.getMemoryConsumption(netInputShape, weightsMemory, blobsMemory);
8689
int64 flops = net.getFLOPS(netInputShape);
@@ -104,40 +107,45 @@ class DNNTestNetwork : public ::perf::TestBaseWithParam< tuple<DNNBackend, DNNTa
104107
PERF_TEST_P_(DNNTestNetwork, AlexNet)
105108
{
106109
processNet("dnn/bvlc_alexnet.caffemodel", "dnn/bvlc_alexnet.prototxt",
107-
"alexnet.yml", 227, 227, "prob", "caffe");
110+
"alexnet.yml", Mat(cv::Size(227, 227), CV_32FC3), "prob", "caffe");
108111
}
109112

110113
PERF_TEST_P_(DNNTestNetwork, GoogLeNet)
111114
{
112115
processNet("dnn/bvlc_googlenet.caffemodel", "dnn/bvlc_googlenet.prototxt",
113-
"", 224, 224, "prob", "caffe");
116+
"", Mat(cv::Size(224, 224), CV_32FC3), "prob", "caffe");
114117
}
115118

116119
PERF_TEST_P_(DNNTestNetwork, ResNet50)
117120
{
118121
processNet("dnn/ResNet-50-model.caffemodel", "dnn/ResNet-50-deploy.prototxt",
119-
"resnet_50.yml", 224, 224, "prob", "caffe");
122+
"resnet_50.yml", Mat(cv::Size(224, 224), CV_32FC3), "prob", "caffe");
120123
}
121124

122125
PERF_TEST_P_(DNNTestNetwork, SqueezeNet_v1_1)
123126
{
124127
processNet("dnn/squeezenet_v1.1.caffemodel", "dnn/squeezenet_v1.1.prototxt",
125-
"squeezenet_v1_1.yml", 227, 227, "prob", "caffe");
128+
"squeezenet_v1_1.yml", Mat(cv::Size(227, 227), CV_32FC3), "prob", "caffe");
126129
}
127130

128131
PERF_TEST_P_(DNNTestNetwork, Inception_5h)
129132
{
130133
processNet("dnn/tensorflow_inception_graph.pb", "",
131134
"inception_5h.yml",
132-
224, 224, "softmax2", "tensorflow");
135+
Mat(cv::Size(224, 224), CV_32FC3), "softmax2", "tensorflow");
133136
}
134137

135138
PERF_TEST_P_(DNNTestNetwork, ENet)
136139
{
137140
processNet("dnn/Enet-model-best.net", "", "enet.yml",
138-
512, 256, "l367_Deconvolution", "torch");
141+
Mat(cv::Size(512, 256), CV_32FC3), "l367_Deconvolution", "torch");
139142
}
140143

144+
PERF_TEST_P_(DNNTestNetwork, SSD)
145+
{
146+
processNet("dnn/VGG_ILSVRC2016_SSD_300x300_iter_440000.caffemodel", "dnn/ssd_vgg16.prototxt", "disabled",
147+
Mat(cv::Size(300, 300), CV_32FC3), "detection_out", "caffe");
148+
}
141149

142150
INSTANTIATE_TEST_CASE_P(/*nothing*/, DNNTestNetwork,
143151
testing::Combine(

0 commit comments

Comments
 (0)