Ask Your Question

Revision history [back]

Issues loading pytorch -> onnx model using opencv dnn

Python: 3.6.6

Open-CV: 4.2.0-dev (built from source)

Operating System: Raspian 4.19

Torch: 1.1.0

I trained a mobilenet_v2_ssd model (attached) in pytorch and exported to onnx using Pytorch's built in exporter:

learn_eval = learn.model.eval()
dummy_input = torch.randn(1, 3, 480, 480).cuda()
torch_out = torch.onnx_export(learn_eval,
                               dummy_input,
                               model_path+"mobilenet_v2_ssd.onnx",
                               export_params=True)

Here's the traceback:

Traceback (most recent call last): File "predict_from_onnx.py", line 28, in <module> net = cv2.dnn.readNetFromONNX(args["model"]) cv2.error: OpenCV(4.2.0-dev) /home/pi/opencv_build/opencv/modules/dnn/src/onnx/onnx_importer.cpp:555: error: (-215:Assertion failed) blob.type() == 5 in function 'populateNet'

Issues loading pytorch -> onnx model using opencv dnnerror: (-215:Assertion failed) blob.type() == 5 in function 'populateNet'

Python: 3.6.6

Open-CV: 4.2.0-dev (built from source)

Operating System: Raspian 4.19

Torch: 1.1.0

I trained a mobilenet_v2_ssd model (attached) in pytorch and exported to onnx using Pytorch's built in exporter:

learn_eval = learn.model.eval()
dummy_input = torch.randn(1, 3, 480, 480).cuda()
torch_out = torch.onnx_export(learn_eval,
                               dummy_input,
                               model_path+"mobilenet_v2_ssd.onnx",
                               export_params=True)

Here's the traceback:

Traceback (most recent call last):
 File "predict_from_onnx.py", line 28, in <module>
 net = cv2.dnn.readNetFromONNX(args["model"])
 cv2.error: OpenCV(4.2.0-dev) /home/pi/opencv_build/opencv/modules/dnn/src/onnx/onnx_importer.cpp:555: error: (-215:Assertion failed) blob.type() == 5 in function 'populateNet'

'populateNet'