-
-
Notifications
You must be signed in to change notification settings - Fork 16.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ONNX conversion error for opencv dnn #10665
Comments
👋 Hello @RizwanRumi, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution. If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you. If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available. For business inquiries or professional support requests please visit https://ultralytics.com or email support@ultralytics.com. RequirementsPython>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started: git clone https://github.com/ultralytics/yolov5 # clone
cd yolov5
pip install -r requirements.txt # install EnvironmentsYOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training, validation, inference, export and benchmarks on MacOS, Windows, and Ubuntu every 24 hours and on every commit. |
Line 156 in c0ca1d2
set this flag False and try again. |
Hello @UNeedCryDear, Thank you for your reply. I have changed the flag value but it shows the same error. |
@RizwanRumi Thank you! Installing those versions of the packages worked for me! Then i just exported using
|
HI @glenn-jocher I am encountering same bug again, using google colab, torch=1.11.0, torchvision=0.12.0 onnx=1.12.0 and running export with --opset 12 still I am getting:
Same error on ubuntu 18 and also on MAC M1 12.2.1 |
hi @RizwanRumi upgrading opencv python to 4.7 did not help either:
|
Opencv does not support dynamic models. You need to export onnx without flag |
@RizwanRumi Thank you for the finding. I've encourned the same issue and have confirmed that this workaround worked for me. |
I have solve the problem by "python export.py --weights yolov5s.pt --include onnx --opset 12" |
@fenghuohuo2001 thank you for letting us know that your issue has been resolved by using the command "python export.py --weights yolov5s.pt --include onnx --opset 12" and your environment is "Python 3.8.0 torch-1.13.0+cu117". We're glad that the solution worked for you. Please don't hesitate to reach out to us if you have any further questions or concerns. |
After long search this is fixed my issue too. you dont need to edit the code. just specify in the command opset value as 12:
Here the issue is package version. Hope opencv 5.0 will fix this dynamic issue |
@yunus-temurlenk i'm glad to hear that specifying the opset value as 12 in the export command resolved your issue without needing to edit the code. It's always great when a solution simplifies the process. We're looking forward to potential fixes in future OpenCV releases as well. If you have any more questions or run into other issues, feel free to ask. Happy coding! 😊👍 |
I am using custom yolov8 for object detection. If the pre-train the yolov8n model it's working fine with opencv dnn framework using Yolov8CppInference. But in case of yolov8s it shows the following error. #5 0x0000000000493716 in cv::error(int, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, char const*, char const*, int) () |
@shubhamg2205 it seems like you're encountering an issue with OpenCV's DNN module when trying to use a custom YOLOv8 model. The error message you've provided indicates a problem during the import of the ONNX model into OpenCV, but it doesn't give specific details about the cause of the error. Here are a few general suggestions that might help you troubleshoot the issue:
If you continue to face issues, consider reaching out to the OpenCV community or the maintainers of the YOLOv8CppInference project for more targeted support. |
Search before asking
YOLOv5 Component
No response
Bug
Hi,
After converting the yolov5s.onnx (v6.1, v6.2) file, I am getting an error in opencv dnn. Why this is happening? Would you please tell me how to solve it? I am following this link
[ERROR:0@0.355] global onnx_importer.cpp:1054 cv::dnn::dnn4_v20221220::ONNXImporter::handleNode DNN/ONNX: ERROR during processing node with 2 inputs and 3 outputs: [Split]:(onnx_node!/model.24/Split) from domain='ai.onnx'
Traceback (most recent call last):
File "E:...\Inspection\main.py", line 125, in
net = cv2.dnn.readNet(modelWeights)
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'
Environment
Minimal Reproducible Example
No response
Additional
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: