Skip to content
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

OpenCV fails to import ONNX model: of type "Where" #22541

Closed
4 tasks done
ukoehler opened this issue Sep 20, 2022 · 5 comments
Closed
4 tasks done

OpenCV fails to import ONNX model: of type "Where" #22541

ukoehler opened this issue Sep 20, 2022 · 5 comments
Assignees
Labels
category: dnn (onnx) ONNX suport issues in DNN module category: dnn

Comments

@ukoehler
Copy link

  • OpenCV => Python opencv-python-rolling-5.0.0.20220903
  • Operating System / Platform Windows 10 64 bit
  • Python =>3.10.4
Detailed description

I converted a model to ONNX and tried to load it with OpenCV 5.6 Windows 10 (Python) and got the same error message. Find the model here:
https://drive.google.com/file/d/15wdXCiS1Yr7a4wFTUb7jQB_GjbkB_a-G/view?usp=sharing
Original model from here: https://github.com/clovaai/rexnet

I checked the ONNX using Pythin and onnx, as well as onnxruntime. Both claim that the model is OK. OpenCV, however, reports:

[ERROR:0@0.104] global D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\onnx\onnx_importer.cpp (1044) cv::dnn::dnn5_v20220821::ONNXImporter::handleNode DNN/ONNX: ERROR during processing node with 3 inputs and 1 outputs: [Where]:(onnx_node!Where_46) from domain='ai.onnx'
Traceback (most recent call last):
  File "d:\Local\devel\Python\OpenCV\image_classification_rexnet_lite\inference.py", line 94, in <module>
    model = cv2.dnn.readNet(model_path)
cv2.error: OpenCV(5.0.0-pre) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\onnx\onnx_importer.cpp:1063: error: (-2:Unspecified error) in function 'cv::dnn::dnn5_v20220821::ONNXImporter::handleNode'
> Node [Where@ai.onnx]:(onnx_node!Where_46) parse error: OpenCV(5.0.0-pre) d:\a\opencv-python\opencv-python\opencv\modules\dnn\src\layer_internals.hpp:110: error: (-2:Unspecified error) Can't create layer "onnx_node!Where_46" of type "Where" in function 'cv::dnn::dnn5_v20220821::detail::LayerData::getLayerInstance'>
Steps to reproduce

model = cv2.dnn.readNet(model_path)

  • Reproducible: yes
  • Enforceable: yes
Issue submission checklist
  • I report the issue, it's not a question

  • I checked the problem with documentation, FAQ, open issues,

  • I updated to the latest OpenCV version and the issue is still there

  • There is reproducer code and related data files: videos, images, onnx, etc

@fengyuentau
Copy link
Member

fengyuentau commented Sep 20, 2022

Thank you for the feedback! You should simplify this model with onnx-simplifier, and the where operator should be eliminated.

rexnet_lite_1.0.simplified.onnx.zip

I can see this model still have some operators not supported in the current version of OpenCV DNN, such as ScatterND. There is a pull request working on the support of ScatterND.

@fengyuentau fengyuentau added the category: dnn (onnx) ONNX suport issues in DNN module label Sep 20, 2022
@fengyuentau fengyuentau self-assigned this Sep 20, 2022
@ukoehler
Copy link
Author

Confirmed with opencv-python-rolling 5.0.0.20220903 and a version of the model that I simplified myself. I am left with not supported ScatterND.

@asmorkalov
Copy link
Contributor

OpenCV does not support control-flow onnx operations for now.

@fengyuentau
Copy link
Member

Confirmed with opencv-python-rolling 5.0.0.20220903 and a version of the model that I simplified myself. I am left with not supported ScatterND.

The PR for supporting ScatterND has been merged. Please have a try with latest OpenCV. You need to either compile OpenCV from source for now, or wait for the release of opencv-python-rolling on this Saturday (20221022).

@ukoehler
Copy link
Author

Hi @fengyuentau,

fix confirmed with version opencv-python-rolling-4.6.0.20221022.

Many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: dnn (onnx) ONNX suport issues in DNN module category: dnn
Projects
None yet
Development

No branches or pull requests

3 participants