YOLOv8-TensorRT icon indicating copy to clipboard operation
YOLOv8-TensorRT copied to clipboard

How to inference with batch size > 1?

Open anidh opened this issue 1 year ago • 3 comments

Hi There,

I need to infer with a batch size of 2. I have exported the model to onnx format using the command -

yolo export model=best.pt format=onnx simplify=True opset=11 dynamic=True

This generates an onnx file with a batch size of -1 . I need help in converting this onnx file to an engine file which can have a batch size of 2 as well as help in inferencing of this engine file. I tried to generate the engine file directly from the ultralytics repo using the command

yolo export model=best.pt format=engine dynamic=True simplify=True opset=11

Then using this engine file with your repo gives the following error -

Traceback (most recent call last): File "/home/anidhsingh/YOLOv8-TensorRT/batch.py", line 87, in <module> main(args) File "/home/anidhsingh/YOLOv8-TensorRT/batch.py", line 44, in main bboxes, scores, labels = det_postprocess(data) File "/home/anidhsingh/YOLOv8-TensorRT/models/torch_utils.py", line 37, in det_postprocess assert len(data) == 4 AssertionError

Can you help infer with a batch size of 2 and how to generate the engine file for that? Thanks again for the great work on this repo.

anidh avatar May 03 '23 06:05 anidh

same question.

1224wxwx avatar May 09 '23 11:05 1224wxwx

same question.

Great I will add batch inference soon.

triple-Mu avatar May 10 '23 01:05 triple-Mu

Have you added batch inference? @triple-Mu

AnaRhisT94 avatar Jan 03 '24 11:01 AnaRhisT94