Pytorch Onnx Tensorrt Transfer Methods, Advantages and Disadvantages Using Yolov5 Model
experiment condition: python==3.8.0 torch==2.1.0 ultralytics:77fc5ccf02ac0fdf9e7bb1eeb003e9bf3e719702 tensorrt==8.6.1.post1 一. pt转onnx 1.ultralytics工程自带的model.export功能 1.1 dynamic input and output 1.2 static input and output 2.torch自带的export功能 2.1 dynamic input and output 2.2 static input and output 二. onnx转tensorrt-engine 1.torch自带的export功能 三.使用ultralytic中的model.export直接pt转为engine 主要是以yolov5模型为例,记录该模型在不同转换工具下的转换方法、转换后模型调用方式、模型调用效率测试。 想要从pt文件转换为tensorrt的engine类型,有两种大路径,其中又可以分化: pt–>onnx–>engine using torch.export to realize pt–>onnx convertion torch.onnx.export(model, input_tensor, model_name, opset_version=11, input_names=['input'], output_names=['output0','output1','output2','output3'], dynamic_axes=None) using model.export in ultralytics to realize pt–>onnx convertion path = model.export(format="onnx", dynamic=True, simplify=True, half=True) pt–>engine using model.export in ultralytics to directly realize pt–>engine convertion model....