opencv: OPENCV 4.0.0-beta onnx_importer.cpp:56: error: (-210:Unsupported format or combination of formats) Failed to parse onnx model in function 'ONNXImporter'

I try to export a PyTorch model from torchvision pretrained models into .onnx format. Then I try to read the network with cv::dnn::readNetFromONNX and I get the following error:

onnx_importer.cpp:56: error: (-210:Unsupported format or combination of formats) Failed to parse onnx model in function ‘ONNXImporter’

Aborted (core dumped)

The Python code is:

from torchvision import models
model = models.vggnet19_bn(pretrained=True)
dummy_input = torch.randn(1, 3, 224, 224)
torch.onnx.export(model, dummy_input, "vgg.onnx")

In C++:

cv::dnn::Net = cv::dnn::readNetFromONNX("vgg.onnx");

Any ideas? I have Opencv 4.0.0 beta and pytorch 4.0.1 cpu version

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 18 (8 by maintainers)

Most upvoted comments