Today I encountered a lot of OpenCV loading model errors when debugging the yolov7 model conversion and loading problemm There is no way to fully display it due to the title length limit, I will post it here in its entirety.
[ERROR:0] global D:\opencv-python\opencv\modules\dnn\src\onnx\onnx_importer.cpp (720) cv::dnn::dnn4_v20211004: :ONNXImporter::handleNode DNN/ONNX: ERROR during processing node with 5 inputs and 1 outputs: [NonMaxSuppression]:(onnx::Gather_384)
cv2.error: OpenCV(4.5.4) D:\opencv-python\opencv\modules\dnn\src\onnx\onnx_importer.cpp:739: error: (- 2:Unspecified error) in function 'cv::dnn::dnn4_v20211004::ONNXImporter::handleNode'
cv2.error: OpenCV(4.5.4) D:\opencv-python\opencv\modules\dnn\src\onnx\onnx_importer.cpp:739: error: (- 2:Unspecified error) in function 'cv::dnn::dnn4_v20211004::ONNXImporter::handleNode'
> Node [NonMaxSuppression]:(onnx::Gather_384) parse error: OpenCV(4.5.4) D:\opencv-python\opencv\modules\dnn\src\dnn.cpp:615: error: (-2:Unspecified error) Can't create layer "onnx::Gather_384" of type "NonMaxSuppression" in function 'cv::dnn::dnn4_v20211004::LayerData::getLayerInstance&# 39;
At this time, I think of a way to compare my own model with the official model one by one,Comparison of one node and one node, Finally found the problem at the end.
[Official Model]
[My own model]
Seeing this, I’m wondering if there is such a big difference??It shouldn’t be,It’s all models built from the same code,So I started to trace the source,Sure enough Problem found.
At the position of my red frame, the official model ends here, and there is a large string of, tensor shapes for debugging both by printing, I guess that there may be a problem with the parameter settings during the model export process, So I tried to verify basically all the uncertain parameters, I found the problem.
In order to facilitate your understanding, I am giving my original conversion operation command here:
python export.py --weights best.pt --grid --end2end --simplify --topk-all 100 --iou-thres 0.65 --conf-thres 0.35 --img-size 640 640 --max-wh 640
This is the command after:
python38 export.py --weights best.pt --grid --simplify --topk-all 100 --iou-thres 0.65 --conf-thres 0.35 --img -size 640 640 --max-wh 640
See the difference, In fact, it is caused by the parameter end2end, After the modification, my model is as follows:
Because what I am doing here is the detection of the category, so the final output is: 1x25200x6, and the official one is: 1x25200x85.
Read More:
- onnx.onnx_cpp2py_export.checker.ValidationError
- [Solved] Could not find a version that satisfies the requirement onnx (from onnx-graphsurgeon0.2.6)
- Using onnx to deploy models in mmdetection
- onnx-tensorrt/builtin_op_importers.cpp:766:12: error: ‘class nvinfer1::IDeconvolutionLayer’ has no m
- Usage and examples of three important functions of tidyr package in R language: gather, spread and separate
- There is a solution to the problem: severity = corrected, type = physical layer, id = 00e5 or id = 00e8 (receiver ID) under Ubuntu
- The function of flatten layer in deep learning
- Layer loading failed! Exception from HResult: 0x80040228
- Error in tensorflow loading model valueerror: unknown layer: functional
- SSM project controller layer calls static method to report an error
- Spring boot does not take effect when using @ size to verify a single set parameter of the control layer
- How to solve the problem of undefined layer
- How to Configure Inter VLAN Routing on Layer 3 Switches?
- After introducing sass into Vue project, start to report error typeerror [err]_ INVALID_ ARG_ Type]: the “path” argument must be of type string
- Solve the interceptor calling service layer to display null pointer.
- Error type referred to is not an annotation type:RedisCache
- Type error: cannot unpack non Iterable non type object appears when starting Bert server in Ubuntu system
- Es error mapper of different type, current_ Type “text” solution
- Unity Error:InvalidCastException: Cannot cast from source type to destination type.
- [Solved] RuntimeError: Expected object of scalar type Float but got scalar type Double for argument #2 ‘mat1‘