Cv2.dnn read model error [How to Solve]

cv2.dnn read model error:

D:\ProgramData\Miniconda3\python.exe D:/project/detect/face/yolov5-face-landmarks-opencv/main_new.py
[ERROR:0] global C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-oduouqig\opencv\modules\dnn\src\onnx\onnx_importer.cpp (1878) cv::dnn::dnn4_v20201117::ONNXImporter::handleNode DNN/ONNX: ERROR during processing node with 2 inputs and 1 outputs: [Add]:(430)
Traceback (most recent call last):
  File "D:/project/detect/face/yolov5-face-landmarks-opencv/main_new.py", line 126, in <module>
    yolonet = yolov5(confThreshold=args.confThreshold, nmsThreshold=args.nmsThreshold, objThreshold=args.objThreshold)
  File "D:/project/detect/face/yolov5-face-landmarks-opencv/main_new.py", line 23, in __init__
    self.net = cv2.dnn.readNet(r'D:\project\detect\face\yolov5-face-master\yolov5n-face.onnx')
cv2.error: OpenCV(4.5.1) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-oduouqig\opencv\modules\dnn\src\onnx\onnx_importer.cpp:1887: error: (-2:Unspecified error) in function 'cv::dnn::dnn4_v20201117::ONNXImporter::handleNode'
> Node [Add]:(430) parse error: OpenCV(4.5.1) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-oduouqig\opencv\modules\dnn\src\onnx\onnx_importer.cpp:780: error: (-215:Assertion failed) blob_0.size == blob_1.size in function 'cv::dnn::dnn4_v20201117::ONNXImporter::handleNode'
>
Process finished with exit code 1

Reason:
opencv4.5.1 torch 1.9.0
torch1.9.0 export onnx,opencv4.5.1not supported

Solution:
torch change to version 1.7.1, torchvision 0.8.2 version  —–the other version wil report an error.


Read More: