-
-
Notifications
You must be signed in to change notification settings - Fork 55.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The onnx model was loadable in 4.5.4 but not in 4.6.0 #22139
Comments
Thanks @afterdm, this bug is caused by the |
OpenCV DNN does not support ONNX models with dynamic input shape. However, you can load a ONNX model with fixed input shape and infer with other input shapes using OpenCV DNN. You can download YuNet with fixed size input and demos from https://github.com/fengyuentau/opencv_zoo/tree/master/models/face_detection_yunet. |
@fengyuentau thanks. How can I convert a model to fixed size input?
|
@fisakhan This error is exactly caused by trying to load a dynamic shape ONNX model with OpenCV DNN. You can have a try with https://github.com/daquexian/onnx-simplifier for your purpose. |
@fengyuentau After conversion using onnx-simplifier, I still get the same error. You can find both the models (savedmodel and onnx) at https://github.com/fisakhan/Face_Pose/tree/master/models. netron.app shows this for .onnx model |
@fisakhan Obviously the input shape is still dynamic. You need to set it fixed using onnx-simplifier. |
|
Now I get the following error:
|
opencv 4.5.4 and 4.6.0
Operating System / Platform => Windows 11 64 bit
Compiler => Visual Studio 2022
onnx
https://github.com/afterdm/onnx/blob/master/yunet.onnx
[ INFO:0@20.685] global C:\build\opencv-4.6.0\modules\dnn\src\onnx\onnx_importer.cpp (797) cv::dnn::dnn4_v20220524::ONNXImporter::populateNet DNN/ONNX: loading ONNX v6 model produced by 'pytorch':1.9. Number of nodes = 111, initializers = 92, inputs = 1, outputs = 3
[ INFO:0@20.685] global C:\build\opencv-4.6.0\modules\dnn\src\onnx\onnx_importer.cpp (713) cv::dnn::dnn4_v20220524::ONNXImporter::parseOperatorSet DNN/ONNX: ONNX opset version = 9
[ERROR:0@20.708] global C:\build\opencv-4.6.0\modules\dnn\src\onnx\onnx_importer.cpp (2845) cv::dnn::dnn4_v20220524::ONNXImporter::parseShape DNN/ONNX(Shape): dynamic 'zero' shapes are not supported, input 243 [ 0 0 0 51 ]
OpenCV(4.6.0) Error: Assertion failed (!isDynamicShape) in cv::dnn::dnn4_v20220524::ONNXImporter::parseShape, file C:\build\opencv-4.6.0\modules\dnn\src\onnx\onnx_importer.cpp, line 2846
[ERROR:0@20.716] global C:\build\opencv-4.6.0\modules\dnn\src\onnx\onnx_importer.cpp (1021) cv::dnn::dnn4_v20220524::ONNXImporter::handleNode DNN/ONNX: ERROR during processing node with 1 inputs and 1 outputs: [Shape]:(onnx_node!Shape_70) from domain='ai.onnx'
[ INFO:0@20.716] global C:\build\opencv-4.6.0\modules\dnn\src\onnx\onnx_importer.cpp (1025) cv::dnn::dnn4_v20220524::ONNXImporter::handleNode Input[0] = '243'
[ INFO:0@20.716] global C:\build\opencv-4.6.0\modules\dnn\src\onnx\onnx_importer.cpp (1029) cv::dnn::dnn4_v20220524::ONNXImporter::handleNode Output[0] = '265'
OpenCV(4.6.0) Error: Unspecified error (> Node [Shape@ai.onnx]:(onnx_node!Shape_70) parse error: OpenCV(4.6.0) C:\build\opencv-4.6.0\modules\dnn\src\onnx\onnx_importer.cpp:2846: error: (-215:Assertion failed) !isDynamicShape in function 'cv::dnn::dnn4_v20220524::ONNXImporter::parseShape'
The text was updated successfully, but these errors were encountered: