LSH9832 / yolov8_trt

A quick TensorRT deoloyment solution for YOLOv8.
Apache License 2.0
34 stars 9 forks source link

batch的问题 #3

Closed WANGCHAO1996 closed 1 year ago

WANGCHAO1996 commented 1 year ago

你好 感谢您的工作 当设置batch>1时 输出onnx依然是1x3x640x640请问怎么实现多batch

LSH9832 commented 1 year ago

感谢反馈,将ultralytics/yolo/engine/exporter.py 中第165行注释掉即可

WANGCHAO1996 commented 1 year ago

谢谢您的回复 我按照您说的注释后导出的onnx float32[8,3,640,640] 转为trt后在测试中单帧时间是减少的 但是batch=8视频测试感觉速度很慢 尽管显示的推理时间减少 ,请问这是什么原因

batch=1: [02/09/2023-08:11:13] [I] preprocess time = 1.55475; infer time = 4.24176; postprocess time = 0.207648 [02/09/2023-08:11:13] [I] preprocess time = 1.56528; infer time = 4.70144; postprocess time = 0.446816 [02/09/2023-08:11:13] [I] preprocess time = 1.55267; infer time = 4.42013; postprocess time = 0.532928 [02/09/2023-08:11:13] [I] preprocess time = 1.55062; infer time = 4.35418; postprocess time = 0.318272 [02/09/2023-08:11:13] [I] preprocess time = 1.55472; infer time = 4.92086; postprocess time = 0.352256 [02/09/2023-08:11:13] [I] preprocess time = 1.54694; infer time = 4.4991; postprocess time = 0.202784 [02/09/2023-08:11:13] [I] preprocess time = 1.54602; infer time = 4.53914; postprocess time = 0.19776 [02/09/2023-08:11:13] [I] preprocess time = 1.55939; infer time = 4.22522; postprocess time = 0.19568

batch=8: [02/09/2023-08:10:27] [I] preprocess time = 0.50718; infer time = 3.5722; postprocess time = 0.502048 [02/09/2023-08:10:28] [I] preprocess time = 0.508036; infer time = 3.58598; postprocess time = 0.509088 [02/09/2023-08:10:28] [I] preprocess time = 0.507736; infer time = 3.26151; postprocess time = 0.504344 [02/09/2023-08:10:28] [I] preprocess time = 0.507856; infer time = 3.25583; postprocess time = 0.505184 [02/09/2023-08:10:29] [I] preprocess time = 0.507544; infer time = 3.26184; postprocess time = 0.504592 [02/09/2023-08:10:29] [I] preprocess time = 0.508048; infer time = 3.25737; postprocess time = 0.502216 [02/09/2023-08:10:29] [I] preprocess time = 0.507568; infer time = 3.25582; postprocess time = 0.508636 [02/09/2023-08:10:30] [I] preprocess time = 0.507796; infer time = 3.24886; postprocess time = 0.5033 [02/09/2023-08:10:30] [I] preprocess time = 0.5073; infer time = 3.25684; postprocess time = 0.502984 [02/09/2023-08:10:30] [I] preprocess time = 0.550244; infer time = 3.49358; postprocess time = 0.506428 [02/09/2023-08:10:31] [I] preprocess time = 0.55456; infer time = 3.47292; postprocess time = 0.529296 [02/09/2023-08:10:31] [I] preprocess time = 0.48488; infer time = 3.0887; postprocess time = 0.504836 [02/09/2023-08:10:32] [I] preprocess time = 0.484532; infer time = 3.08768; postprocess time = 0.504032 [02/09/2023-08:10:32] [I] preprocess time = 0.485148; infer time = 3.09106; postprocess time = 0.50042 [02/09/2023-08:10:32] [I] preprocess time = 0.484668; infer time = 3.07816; postprocess time = 0.500792 [02/09/2023-08:10:33] [I] preprocess time = 0.484952; infer time = 3.08939; postprocess time = 0.499584

LSH9832 commented 1 year ago

单进程中每处理8帧后再一起显示,所以感觉一卡一卡的,如果想要观感流畅,需要至少两个进程,一个进程负责推理,另一个负责显示图像,可参考https://github.com/LSH9832/edgeyolo中的batch_detect.py写一个多进程脚本

WANGCHAO1996 commented 1 year ago

单进程中每处理8帧后再一起显示,所以感觉一卡一卡的,如果想要观感流畅,需要至少两个进程,一个进程负责推理,另一个负责显示图像,可参考https://github.com/LSH9832/edgeyolo中的batch_detect.py写一个多进程脚本 好的 感谢!!