ultralytics / yolov5

YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
50.67k stars 16.33k forks source link

Fail to use yolov5x - 7.0 in OpenCV 4.6.0 c++ #11628

Closed jeffreyhaoau closed 1 year ago

jeffreyhaoau commented 1 year ago

Search before asking

YOLOv5 Component

No response

Bug

Fail to use yolov5x - 7.0 in OpenCV 4.6.0 c++ Fail to use yolov5x - 7.0 in OpenCV 4.7.0 c++ Success to use yolov5x - 7.0 in OpenCV 4.6.0 Python

Success to use yolov5x - 6.2 in OpenCV 4.6.0 c++ Success to use yolov5x - 6.2 in OpenCV 4.6.0 Python

Success to use yolov5x - 6.1 in OpenCV 4.6.0 c++ Success to use yolov5x - 6.1 in OpenCV 4.6.0 Python

It only happens on yolov5x. No issue with yolov5l, yolov5m.

https://raw.githubusercontent.com/spmallick/learnopencv/master/Object-Detection-using-YOLOv5-and-OpenCV-DNN-in-CPP-and-Python/yolov5.cpp

Convert to onnx for opencv dnn. $ python export.py --weights yolov5x.pt --include onnx

This error (Segmentation Fault) is relevant to this: line 77: const int rows = 25200; The loop (line79-118) will crash.

Environment

Ubuntu 22.04 CPU Yolov5 - 7.0 OpenCV 4.6.0, c++ DNN API

Minimal Reproducible Example

No response

Additional

No response

Are you willing to submit a PR?

github-actions[bot] commented 1 year ago

👋 Hello @jeffreyhaoau, 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 a minimum reproducible example to help us debug it.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.

Requirements

Python>=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

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

YOLOv5 CI

If 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.

Introducing YOLOv8 🚀

We're excited to announce the launch of our latest state-of-the-art (SOTA) object detection model for 2023 - YOLOv8 🚀!

Designed to be fast, accurate, and easy to use, YOLOv8 is an ideal choice for a wide range of object detection, image segmentation and image classification tasks. With YOLOv8, you'll be able to quickly and accurately detect objects in real-time, streamline your workflows, and achieve new levels of accuracy in your projects.

Check out our YOLOv8 Docs for details and get started with:

pip install ultralytics
glenn-jocher commented 1 year ago

Hello @jeffreyhaoau,

Thank you for reporting this issue. We're sorry to hear that you're encountering this problem with using YOLOv5 - 7.0 in OpenCV 4.6.0 C++.

We appreciate you including all of the environment information and other details in your report as well. This will help us to more effectively determine the root of the issue.

Regarding your point about the segmentation faults, it seems like the variable declaration const int rows = 25200 may be causing the issue. We suggest reviewing other parts of your codebase to determine the cause of the segmentation fault in your program.

If you have any further questions or concerns, please do not hesitate to ask. We'll do our best to help you resolve this issue. Thank you for your attention to this matter.

Best regards, Glenn Jocher

jeffreyhaoau commented 1 year ago

@glenn-jocher glenn-jocher Sorry, I forgot this: It only happens on yolov5x. No issue with yolov5l, yolov5m.

glenn-jocher commented 1 year ago

Hi @jeffreyhaoau,

Thank you for providing that additional information. It's helpful to know that the issue only appears to occur with YOLOv5x and not with YOLOv5l or YOLOv5m.

Given that, it's possible that there may be some differences in the implementation or structure of these models that could be causing the issue with YOLOv5x in OpenCV 4.6.0 C++. We suggest reviewing your code and checking for any differences in these areas that could be contributing to the problem.

If you have any further questions or concerns, please don't hesitate to ask. We'll continue to do our best to assist you in troubleshooting this issue.

Best regards, Glenn Jocher