hpc203 / yolov5-dnn-cpp-python-v2

用opencv的dnn模块做yolov5目标检测,包含C++和Python两个版本的程序,优化后的
114 stars 30 forks source link

ValueError: operands could not be broadcast together with shapes (1,2,85) (19200,2) #13

Closed doleron closed 2 years ago

doleron commented 2 years ago

Hi!

I'm getting the following error:

$ python3 main_yolov5.py --net_type yolov5n
Traceback (most recent call last):
  File "main_yolov5.py", line 111, in <module>
    dets = yolonet.detect(srcimg)
  File "main_yolov5.py", line 95, in detect
    outs[row_ind:row_ind+length, 0:2] = (outs[row_ind:row_ind+length, 0:2] * 2. - 0.5 + np.tile(self.grid[i],(self.na, 1))) * int(self.stride[i])
ValueError: operands could not be broadcast together with shapes (1,2,85) (19200,2) 

I'm using OpenCV 4.5.3 and Python 3.8.10

My yolov5s.onnx file was generated using:

git clone https://github.com/ultralytics/yolov5
cd yolov5
pip install -r requirements.txt
python3 export.py --weights yolov5s.pt --img 640 --include onnx

Any ideas what could be wrong?