Skip to content

Commit fa953e4

Browse files
authored
Merge pull request opencv#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
1 parent 540982c commit fa953e4

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

modules/dnn/src/onnx/onnx_importer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,9 @@ void ONNXImporter::populateNet(Net dstNet)
15881588
Mat shapes = getBlob(node_proto, constBlobs, node_proto.input_size() - 1);
15891589
CV_CheckEQ(shapes.size[0], 4, "");
15901590
CV_CheckEQ(shapes.size[1], 1, "");
1591-
CV_CheckTypeEQ(shapes.depth(), CV_32S, "");
1591+
CV_CheckDepth(shapes.depth(), shapes.depth() == CV_32S || shapes.depth() == CV_32F, "");
1592+
if (shapes.depth() == CV_32F)
1593+
shapes.convertTo(shapes, CV_32S);
15921594
int height = shapes.at<int>(2);
15931595
int width = shapes.at<int>(3);
15941596
if (node_proto.input_size() == 3)

modules/dnn/test/test_onnx_importer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,11 @@ TEST_P(Test_ONNX_layers, MatmulWithTwoInputs)
636636
testONNXModels("matmul_with_two_inputs");
637637
}
638638

639+
TEST_P(Test_ONNX_layers, ResizeOpset11_Torch1_6)
640+
{
641+
testONNXModels("resize_opset11_torch1.6");
642+
}
643+
639644
INSTANTIATE_TEST_CASE_P(/*nothing*/, Test_ONNX_layers, dnnBackendsAndTargets());
640645

641646
class Test_ONNX_nets : public Test_ONNX_layers

0 commit comments

Comments
 (0)