meituan / YOLOv6

YOLOv6: a single-stage object detection framework dedicated to industrial applications.
GNU General Public License v3.0
5.72k stars 1.04k forks source link

ZeroDivisionError: float division by zero #588

Open deepxiaobai opened 2 years ago

deepxiaobai commented 2 years ago

Before Asking

Search before asking

Question

(yolov6) D:\work\YOLOv6-main>python tools/infer.py --weights yolov6s.pt --source test.mp4 Namespace(agnostic_nms=False, classes=None, conf_thres=0.4, device='0', half=False, hide_conf=False, hide_labels=False, img_size=[640, 640], iou_thres=0.45, max_det=1000, name='exp', project='runs/inference', save_dir=None, save_img=True, save_txt=False, source='te st.mp4', view_img=False, weights='yolov6s.pt', yaml='data/coco.yaml') Save directory already existed Loading checkpoint from yolov6s.pt

Fusing model... Switch model to deploy modality. D:\soft\anaconda3\envs\yolov6\lib\site-packages\torch\functional.py:568: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at C:\cb\pytorch_1000000000000\work\aten\src\ATen\native\TensorSh ape.cpp:2228.) return _VF.meshgrid(tensors, kwargs) # type: ignore[attr-defined] 0%| | 0/1 [00:00<?, ?it/s]t 1: 1667541017.5683622 t2 1667541017.584088 t1: 1667541017.5918918 t2 1667541017.5918918 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 25.55it/s] Traceback (most recent call last): File "tools/infer.py", line 116, in main(args) File "tools/infer.py", line 111, in main run(vars(args)) File "D:\soft\anaconda3\envs\yolov6\lib\site-packages\torch\autograd\grad_mode.py", line 27, in decorate_context return func(*args, **kwargs) File "tools/infer.py", line 104, in run inferer.infer(conf_thres, iou_thres, classes, agnostic_nms, max_det, save_dir, save_txt, save_img, hide_labels, hide_conf, view_img) File "D:\work\YOLOv6-main\yolov6\core\inferer.py", line 115, in infer fps_calculator.update(1.0 / (t2 - t1)) ZeroDivisionError: float division by zero

Additional

No response

Chilicyy commented 2 years ago

这边可以加个判断,如果t2-t1>0才走这一步。按道理,时间差不应该为0.

deepxiaobai commented 2 years ago

这边可以加个判断,如果t2-t1>0才走这一步。按道理,时间差不应该为0.

按照这种方式规避,发现结果视频中帧率波动非常大

Chilicyy commented 2 years ago

建议排查下各个模块的耗时,从您提供的日志信息来看,耗时瓶颈不在模型推理。另外,出现模型推理时间差为0的情况,是不是此时的图像帧有问题?

deepxiaobai commented 2 years ago

我在计算更新帧率之前添加了以下代码: if t2 - t1 == 0: cv2.imshow('test', img_ori) cv2.waitKey(0) fps_calculator.update(1.0 / (t2 - t1)) avg_fps = fps_calculator.accumulate()

当时间差为0时,显示如下: 1