|
|
|
@ -32,7 +32,7 @@ public: |
|
|
|
|
dnn::Net net; |
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
{ |
|
|
|
|
backend = (dnn::Backend)(int)get<0>(GetParam()); |
|
|
|
@ -48,15 +48,18 @@ public: |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Mat input(inHeight, inWidth, CV_32FC3); |
|
|
|
|
randu(input, 0.0f, 1.0f); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
weights = findDataFile(weights, false); |
|
|
|
|
if (!proto.empty()) |
|
|
|
|
proto = findDataFile(proto, false); |
|
|
|
|
if (!halide_scheduler.empty() && backend == DNN_BACKEND_HALIDE) |
|
|
|
|
halide_scheduler = findDataFile(std::string("dnn/halide_scheduler_") + (target == DNN_TARGET_OPENCL ? "opencl_" : "") + halide_scheduler, true); |
|
|
|
|
if (backend == DNN_BACKEND_HALIDE) |
|
|
|
|
{ |
|
|
|
|
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") |
|
|
|
|
{ |
|
|
|
|
net = cv::dnn::readNetFromCaffe(proto, weights); |
|
|
|
@ -80,7 +83,7 @@ public: |
|
|
|
|
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; |
|
|
|
|
net.getMemoryConsumption(netInputShape, weightsMemory, blobsMemory); |
|
|
|
|
int64 flops = net.getFLOPS(netInputShape); |
|
|
|
@ -104,40 +107,45 @@ public: |
|
|
|
|
PERF_TEST_P_(DNNTestNetwork, AlexNet) |
|
|
|
|
{ |
|
|
|
|
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) |
|
|
|
|
{ |
|
|
|
|
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) |
|
|
|
|
{ |
|
|
|
|
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) |
|
|
|
|
{ |
|
|
|
|
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) |
|
|
|
|
{ |
|
|
|
|
processNet("dnn/tensorflow_inception_graph.pb", "", |
|
|
|
|
"inception_5h.yml", |
|
|
|
|
224, 224, "softmax2", "tensorflow"); |
|
|
|
|
Mat(cv::Size(224, 224), CV_32FC3), "softmax2", "tensorflow"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
PERF_TEST_P_(DNNTestNetwork, ENet) |
|
|
|
|
{ |
|
|
|
|
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, |
|
|
|
|
testing::Combine( |
|
|
|
|