-2
opencv
module_error
ai_generated
partial
cv2.error: OpenCV(4.8.0) /tmp/opencv-4.8.0/modules/dnn/src/onnx/onnx_importer.cpp:203: error: (-2:Unspecified error) Failed to parse ONNX model: No Op registered for 'NonMaxSuppression' with domain_version of 12 in function 'readNetFromONNX'
ID: opencv/dnn-readnet-from-onnx-parse-error
80%Fix Rate
88%Confidence
1Evidence
2023-06-20First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 4.7.0 | active | — | — | — |
| 4.8.0 | active | — | — | — |
| 4.9.0 | active | — | — | — |
| 4.10.0 | active | — | — | — |
Root Cause
ONNX model uses an operator (e.g., NonMaxSuppression) that is not supported by the OpenCV DNN module for the given opset version.
generic中文
ONNX 模型使用了 OpenCV DNN 模块在给定操作集版本中不支持的操作符(例如 NonMaxSuppression)。
Official Documentation
https://docs.opencv.org/4.x/d6/d0f/group__dnn.html#ga29f34df9376379a603acd8df581ac8d7Workarounds
-
75% success Export the ONNX model with a lower opset version (e.g., 11) that includes all operators supported by OpenCV: `torch.onnx.export(model, dummy_input, 'model.onnx', opset_version=11)`
Export the ONNX model with a lower opset version (e.g., 11) that includes all operators supported by OpenCV: `torch.onnx.export(model, dummy_input, 'model.onnx', opset_version=11)`
-
70% success Use OpenCV's DNN with a different backend like Intel OpenVINO: `net.setPreferableBackend(cv2.dnn.DNN_BACKEND_INFERENCE_ENGINE)`
Use OpenCV's DNN with a different backend like Intel OpenVINO: `net.setPreferableBackend(cv2.dnn.DNN_BACKEND_INFERENCE_ENGINE)`
-
65% success Convert the ONNX model to a different format (e.g., TensorFlow SavedModel) and load with OpenCV's TensorFlow importer.
Convert the ONNX model to a different format (e.g., TensorFlow SavedModel) and load with OpenCV's TensorFlow importer.
中文步骤
Export the ONNX model with a lower opset version (e.g., 11) that includes all operators supported by OpenCV: `torch.onnx.export(model, dummy_input, 'model.onnx', opset_version=11)`
Use OpenCV's DNN with a different backend like Intel OpenVINO: `net.setPreferableBackend(cv2.dnn.DNN_BACKEND_INFERENCE_ENGINE)`
Convert the ONNX model to a different format (e.g., TensorFlow SavedModel) and load with OpenCV's TensorFlow importer.
Dead Ends
Common approaches that don't work:
-
60% fail
Downgrading OpenCV may remove support for newer ONNX opsets but won't add missing operators.
-
80% fail
ONNX Runtime is a separate inference engine; installing it doesn't modify OpenCV's DNN module.
-
90% fail
Changing the model file name or path doesn't affect operator parsing.