# Cv2 loads the training model abnormally

**URL:** <https://forum.opencv.org/t/cv2-loads-the-training-model-abnormally/12555>\
**Category:** Python\
**Tags:** dnn, onnx, yolov5\
**Created:** [March 28, 2023, 1:55am UTC](https://forum.opencv.org/t/cv2-loads-the-training-model-abnormally/12555 "2023-03-28T01:55:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sheng\_xu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/sheng_xu/32/7515_2.png) [@sheng\_xu](https://forum.opencv.org/u/sheng_xu)\
**Post date:** [March 28, 2023, 1:55am UTC](https://forum.opencv.org/t/cv2-loads-the-training-model-abnormally/12555/1 "2023-03-28T01:55:10Z")

</div>

I use yolov5 to train the model, and the verification model is normal, but after converting the onnx model, the verification is also successful; but with cv2, the loading model reports an error, the specific exception: [ERROR:0@0.011] global onnx\_importer.cpp:1054 cv::dnn::dnn4\_v20221220::ONNXImporter::handleNode DNN/ONNX: ERROR during processing node with 3 inputs and 1 outputs: [Conv]:(onnx\_node!/model.2/cv1/conv/Conv) from domain=‘ai.onnx’  
Traceback (most recent call last):  
File “D:\Demo\yolov5\test\_onnx.py”, line 2, in   
net = cv2.dnn.readNetFromONNX(‘mybest.onnx’)  
cv2.error: OpenCV(4.7.0) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\onnx\onnx\_importer.cpp:1073: error: (-2:Unspecified error) in function ‘cv::dnn::dnn4\_v20221220::ONNXImporter::handleNode’

> Node [Conv@ai.onnx]:(onnx\_node!/model.2/cv1/conv/Conv) parse error: OpenCV(4.7.0) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\layers\convolution\_layer.cpp:394: error: (-215:Assertion failed) !hasBias() || blobs[1].total() == (size\_t)weightShape[0] in function ‘cv::dnn::ConvolutionLayerImpl::getMemoryShapes’

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [March 28, 2023, 6:43am UTC](https://forum.opencv.org/t/cv2-loads-the-training-model-abnormally/12555/2 "2023-03-28T06:43:05Z")

</div>

when exporting your model to onnx, make sure to use

```
python export.py --opset 12 [...more args...]

```

(by default, it’s using opset 13, leading to above errors)
