Merge pull request #18316 from sl-sergei:fix_18253

Fix loading of ONNX models with Resize operation with Opset 11 for newer versions of Pytorch

* Add reproducer for Resize operation from newer versions of Pytorch

* Fix loading of scales parameter for Resize layer

* Change check type for better diagnostic messages
pull/18354/head
Sergei Slashchinin 4 years ago committed by GitHub
parent 540982cc9d
commit fa953e4205
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      modules/dnn/src/onnx/onnx_importer.cpp
  2. 5
      modules/dnn/test/test_onnx_importer.cpp

@ -1588,7 +1588,9 @@ void ONNXImporter::populateNet(Net dstNet)
Mat shapes = getBlob(node_proto, constBlobs, node_proto.input_size() - 1);
CV_CheckEQ(shapes.size[0], 4, "");
CV_CheckEQ(shapes.size[1], 1, "");
CV_CheckTypeEQ(shapes.depth(), CV_32S, "");
CV_CheckDepth(shapes.depth(), shapes.depth() == CV_32S || shapes.depth() == CV_32F, "");
if (shapes.depth() == CV_32F)
shapes.convertTo(shapes, CV_32S);
int height = shapes.at<int>(2);
int width = shapes.at<int>(3);
if (node_proto.input_size() == 3)

@ -636,6 +636,11 @@ TEST_P(Test_ONNX_layers, MatmulWithTwoInputs)
testONNXModels("matmul_with_two_inputs");
}
TEST_P(Test_ONNX_layers, ResizeOpset11_Torch1_6)
{
testONNXModels("resize_opset11_torch1.6");
}
INSTANTIATE_TEST_CASE_P(/*nothing*/, Test_ONNX_layers, dnnBackendsAndTargets());
class Test_ONNX_nets : public Test_ONNX_layers

Loading…
Cancel
Save