Skip to content
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

OpenCV 4.5.3 shape_utils assertion failed #4471

Closed
nejcmedved opened this issue Aug 18, 2021 · 3 comments
Closed

OpenCV 4.5.3 shape_utils assertion failed #4471

nejcmedved opened this issue Aug 18, 2021 · 3 comments

Comments

@nejcmedved
Copy link

nejcmedved commented Aug 18, 2021

Hi all,

first thank you very much for sharing your code in this repo!

My current issue is code below

` import cv2

model = cv2.dnn.readNetFromONNX("runs/train/exp10/weights/best.onnx")
image = cv2.imread("data/images/bus.jpg")
resized = cv2.resize(image, (640, 640), interpolation = cv2.INTER_AREA)

input_blob = cv2.dnn.blobFromImage(
image=image,
scalefactor=1/255,
size=(640, 640), # img target size
swapRB=True, # BGR -> RGB
crop=True # center crop
)

model.setInput(input_blob)
output = model.forward()`

where result in last line is

opencv2/dnn/shape_utils.hpp:171: error: (-215:Assertion failed) start <= (int)shape.size() && end <= (int)shape.size() && start <= end in function 'cv::dnn::dnn4_v20210608::total'

did anyone came across this issue before?

for exporting my model I use

python export.py --weights=runs/train/exp10/weights/best.pt --include=onnx --simplify

@github-actions
Copy link
Contributor

github-actions bot commented Aug 18, 2021

👋 Hello @nejcmedved, 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 Glenn Jocher at glenn.jocher@ultralytics.com.

Requirements

Python>=3.6.0 with all requirements.txt installed including PyTorch>=1.7. To get started:

$ git clone https://github.com/ultralytics/yolov5
$ cd yolov5
$ pip install -r requirements.txt

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

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), validation (val.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

@glenn-jocher
Copy link
Member

glenn-jocher commented Aug 18, 2021

@nejcmedved you should submit a bug report in the repo where the error in your custom code originates, cv2 in your case.

Note you can also run inference with your onnx model directly with detect.py:

python export.py --weights yolov5s.pt --include onnx --dynamic
python detect.py --weights yolov5s.onnx

@nejcmedved
Copy link
Author

Hi Glen,

I agree. I should post this issue here.

Thanks again for very organized repo!

Best, Nejc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants