Skip to content

OpenCV cannot import ONNX model: Can't create layer "..." of type "TopK" #22890

@ukoehler

Description

@ukoehler

System Information

OpenCV => Python opencv-python-rolling 4.6.0.20221112 (no update available)
Operating System / Platform Windows 10 64 bit
Python =>3.10.4

Detailed description

I converted the PointRend from PaddleSeg to ONNX:

https://github.com/PaddlePaddle/PaddleSeg/tree/release/2.7/configs/pointrend

This fails to load in OpenCV 4.6 pre-release:

[ERROR:0@0.392] global D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\onnx\onnx_importer.cpp (1053) cv::dnn::dnn4_v20220524::ONNXImporter::handleNode DNN/ONNX: ERROR during processing node with 2 inputs and 2 outputs: [TopK]:(onnx_node!p2o.TopK.0) from domain='ai.onnx'
Traceback (most recent call last):
  File "d:\Local\devel\Python\OpenCV\dnn_segmentation_paddle_pointrend_voc\inference.py", line 131, in <module>
    model = cv2.dnn.readNet(model_path)
cv2.error: OpenCV(4.6.0-dev) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\onnx\onnx_importer.cpp:1072: error: (-2:Unspecified error) in function 'cv::dnn::dnn4_v20220524::ONNXImporter::handleNode'
> Node [TopK@ai.onnx]:(onnx_node!p2o.TopK.0) parse error: OpenCV(4.6.0-dev) d:\a\opencv-python\opencv-python\opencv\modules\dnn\src\net_impl.hpp:107: error: (-2:Unspecified error) Can't create layer "onnx_node!p2o.TopK.0" of type "TopK" in function 'cv::dnn::dnn4_v20220524::Net::Impl::getLayerInstance'

Same result with the model after onnx simplify.

Steps to reproduce

model = cv2.dnn.readNet(model_path)

Find the ONNX file here: https://drive.google.com/file/d/1rKcUtoncMvorMtk6LdC6_QK2PSRS_pee/view?usp=sharing

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • 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)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions