Skip to content

onnx model loading error in object detection using dnn module of opencv #20660

@chandra-ps612

Description

@chandra-ps612

OS-windows 10(64 bit)
python 3.9.7
opencv-python==4.5.3.56

Have been working on object detection using opencv. Firstly, i trained custom yolov5 model and then export checkpoint (.pt) into onnx format with the help of ultralytics/yolov5 official export.py file.
when i run my object detection program using opencv.
This perticular line of code 👉 net=cv2.dnn.readNetFromONNX (‘onnx model path’) throws errors given below-

global C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-sn_xpupm\opencv\modules\dnn\src\onnx\onnx_importer.cpp (2127) cv::dnn::dnn4_v20210608::ONNXImporter::handleNode DNN/ONNX: ERROR during processing node with 2 inputs and 1 outputs: [Unsqueeze]:(391)

cv2.error: OpenCV(4.5.3) C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-sn_xpupm\opencv\modules\dnn\src\onnx\onnx_importer.cpp:2146: error: (-2:Unspecified error) in function ‘cv::dnn::dnn4_v20210608::ONNXImporter::handleNode’

Node [Unsqueeze]:(391) parse error: OpenCV(4.5.3) C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-sn_xpupm\opencv\modules\dnn\src\onnx\onnx_importer.cpp:1551: error: (-215:Assertion failed) node_proto.input_size() == 1 in function ‘cv::dnn::dnn4_v20210608::ONNXImporter::handleNode’
Any suggestions to fix this issue!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions