yolov5-opencv-cpp-python icon indicating copy to clipboard operation
yolov5-opencv-cpp-python copied to clipboard

Error launch yolo.py or yolo-tiny.py

Open romain87400 opened this issue 2 years ago • 4 comments

Hello,

When i test your program, with opencv 4.5.5, i have this error. Do you have an idear, what is the problem ?

Command : Traceback (most recent call last): File "python/yolo-tiny.py", line 40, in if confidence >= 0.4: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Thanks for your answer. Have a nice day.

romain87400 avatar Mar 23 '22 09:03 romain87400

yes you can't compare confidence to the number 0.4 because confidence is an array of values. So this can't ever have worked.

DrJaymz avatar Jun 30 '22 08:06 DrJaymz

I just changed the if to True to see what breaks next, and just fails on line 60. So what's happened is that there is a breaking change in OpenCV? Everything else is included in the repository so that shouldn't have broke itself.

Anyway - no good now.

DrJaymz avatar Jun 30 '22 09:06 DrJaymz

Download .pt model. https://github.com/ultralytics/YOLOv5/releases/download/v6.1/YOLOv5s.pt

And export to ONNX again git clone https://github.com/ultralytics/YOLOv5 cd YOLOv5 pip install -r requirements.txt pip install onnx python3 export.py --weights models/YOLOv5s.pt --include onnx

Use the new converted .onnx file can solve the problem!

ivanyipwf avatar Jul 15 '22 03:07 ivanyipwf

Make sure your openCV version is 4.5.4.60 pip install opencv-python==4.5.4.60

songyi1999 avatar Aug 28 '22 02:08 songyi1999