最近在运行yolov4_deepsort代码时出现报错:
Traceback (most recent call last):
File "D:/yolov4_deepsort/pytorch-yolov4-deepsort-main/yolov4_deepsort.py", line 174, in <module>
vdo_trk.run()
File "D:/yolov4_deepsort/pytorch-yolov4-deepsort-main/yolov4_deepsort.py", line 128, in run
outputs = self.deepsort.update(new_bbox, cls_conf, im)
File "D:\yolov4_deepsort\pytorch-yolov4-deepsort-main\deep_sort\deep_sort.py", line 39, in update
bbox_tlwh = self._xywh_to_tlwh(bbox_xywh)
File "D:\yolov4_deepsort\pytorch-yolov4-deepsort-main\deep_sort\deep_sort.py", line 87, in _xywh_to_tlwh
bbox_tlwh = np.zeros((bbox_xywh.shape[0],bbox_xywh.shape[1]))
IndexError: tuple index out of range
<class 'IndexError'> tuple index out of range <traceback object at 0x00000183BD7C5048>
根据评论区大佬提出的解决方案,在yolov4_deepsort.py第128行调用deepsort.update前加上限定条件就能解决
将 outputs = self.deepsort.update(new_bbox, cls_conf, im)前加入限定条件 if new_bbox != []:
if new_bbox != []:
outputs = self.deepsort.update(new_bbox, cls_conf, im)
YOLOv4-deepsort代码来源:https://blog.csdn.net/weixin_38757163/article/details/111150364?spm=1001.2014.3001.5501