最近在运行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 != []:文章来源:https://www.toymoban.com/news/detail-525354.html
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文章来源地址https://www.toymoban.com/news/detail-525354.html
到了这里,关于解决报错 IndexError: tuple index out of range的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!