Merge pull request #12596 from l-bat:l-bat/shufflenet_onnx

* Add Shufflenet support in ONNX

* Add test for transpose layer
pull/12776/head
Lubov Batanina 6 years ago committed by Alexander Alekhin
parent 449826288b
commit 50811e04f2
  1. 2
      modules/dnn/src/layers/permute_layer.cpp
  2. 5
      modules/dnn/src/onnx/onnx_importer.cpp
  3. 16
      modules/dnn/test/test_onnx_importer.cpp

@ -132,8 +132,6 @@ public:
for (size_t i = 0; i < inputs.size(); i++)
{
CV_Assert(inputs[i].size() == 4);
CV_Assert(inputs[i][2] == shapeBefore[2] && inputs[i][3] == shapeBefore[3]);
CV_Assert(total(inputs[i]) == total(shapeAfter));
outputs.push_back(shapeAfter);
}

@ -486,6 +486,11 @@ void ONNXImporter::populateNet(Net dstNet)
layerParams.set("num_output", layerParams.blobs[0].size[0]);
layerParams.set("bias_term", node_proto.input_size() == 3);
}
else if (layer_type == "Transpose")
{
layerParams.type = "Permute";
replaceLayerParam(layerParams, "perm", "order");
}
else if (layer_type == "Unsqueeze")
{
CV_Assert(node_proto.input_size() == 1);

@ -108,6 +108,14 @@ TEST_P(Test_ONNX_layers, BatchNormalization)
testONNXModels("batch_norm");
}
TEST_P(Test_ONNX_layers, Transpose)
{
if (backend == DNN_BACKEND_INFERENCE_ENGINE &&
(target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_OPENCL || target == DNN_TARGET_MYRIAD))
throw SkipTestException("");
testONNXModels("transpose");
}
TEST_P(Test_ONNX_layers, Multiplication)
{
if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16 ||
@ -351,6 +359,14 @@ TEST_P(Test_ONNX_nets, Inception_v1)
testONNXModels("inception_v1", pb);
}
TEST_P(Test_ONNX_nets, Shufflenet)
{
if (backend == DNN_BACKEND_INFERENCE_ENGINE &&
(target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_OPENCL || target == DNN_TARGET_MYRIAD))
throw SkipTestException("");
testONNXModels("shufflenet", pb);
}
INSTANTIATE_TEST_CASE_P(/**/, Test_ONNX_nets, dnnBackendsAndTargets());
}} // namespace

Loading…
Cancel
Save