Error while loading onnx model (exported from PyTorch model) in object detection program using dnn module of opencv

OS-windows 10(64 bit)
python 3.9.7
I’m working object detection model using opencv. First, i trained my custom model based on yolov5 algorithm and then export checkpoint (.pt) into onnx format with the help of ultralytics/yolov5 official
when i am trying to run my object detection program using opencv.
this code :point_right: net=cv2.dnn.readNetFromONNX (‘onnx model path’) throws error 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’

which version of opencv shall i install? thanks for your quick reponse :slightly_smiling_face:

a future version, im afraid

Hi, you solved this? I’m having the same issue