jishi tips for yolov5 project and python3.7

requirements python env yolov5 commit id yolov5 requirements.txt pip train code pytorch 转换为 tensorrt engine run pt run engine TODO requirements python env conda 22.9.0 python==3.7.4 yolov5 commit id yolov5 commit id: 3f02fdee1d8f1a6cf18a24be3438096466367d9f yolov5 requirements.txt # Usage: pip install -r requirements.txt # Base ------------------------------------------------------------------------ gitpython #>=3.1.30 matplotlib==3.2.2 #>=3.3 numpy==1.16.5 #>=1.22.2 opencv-python==4.6.0.66 #>=4.1.1 Pillow # >=10.0.1 psutil # system resources PyYAML>=5.3.1 requests>=2.23.0 scipy>=1.4.1 thop>=0.1.1 # FLOPs computation #torch>=1.8.0 # see https://pytorch....

November 29, 2023 · 14 min · 2866 words · lvsolo

jishi tips for ultralytics project and python3.8

environment building 安装tensorrt-8.6.1环境: 手动下载tensorrt lib8.6.1后上传至服务器安装(https://pypi.nvidia.com/tensorrt-libs/tensorrt_libs-8.6.1-py2.py3-none-manylinux_2_17_x86_64.whl) 安装pycuda前, sudo apt-get install python3.8-dev libxml2-dev libxslt-dev tips pt2onnx 转换生成的如果是static的onnx,那么就无法生成dynamic的engine了 reference TODO dynamic shape model: https://zhuanlan.zhihu.com/p/299845547 training tips 💡 Add –cache ram or –cache disk to speed up training (requires significant RAM/disk resources). experiments TODO 0.如何将dynamic输入的模型调通?使用不加padding的letterbox得到正确结果 1.ultralytics默认选项设置训练出来的模型,对于resize、letterbox的适应性试验; 2.如果适应很好,可以替换letterbox 3.如果适应不好,需要: 1)使用torch重构letterbox; 2)使用cuda memcp的stride格式(存在么?) 使用cuda memcpy可以从torch tensor中拷贝么?或者直接使用torch tensor的cuda显存? 优化目前的myletterbox 5)训练一个真正的dynamic输入的模型 4.如何训练出可以接受resize输入,不需要补齐黑边的模型

November 27, 2023 · 1 min · 54 words · lvsolo

dynamic|static X fp16|fp32 Tensrort Engine Inference Using Yolov5 Model

experiment condition: python==3.8.0 torch==2.1.0 ultralytics:77fc5ccf02ac0fdf9e7bb1eeb003e9bf3e719702 tensorrt==8.6.1.post1 dynamic static fp16 dynamic_fp16 static_fp16 fp32 static_fp32 另外训练时候的padding模式决定了模型inference时候的前处理形式,进而导致不同的运行时间,在letterbox函数进行 前处理的时候,以下代码都保证了模型的正确输出,但并不能保证此种调用方式是效率最佳的方式,还需要继续优化。 Dynamic_Fp16 inshape from get_binding_shape(0): (1, 3, -1, 640) outshape from get_binding_shape(1): (0) dynamic inshape: (1, 3, 640, 640) dynamicoutshape: (1, 7, 8400) trt_run.py:71: DeprecationWarning: Use set_input_shape instead. context.set_binding_shape(0, image.shape) trt_run.py:72: DeprecationWarning: Use set_input_shape instead. context.set_binding_shape(1, output.shape) [11/23/2023-23:19:05] [TRT] [E] 3: [executionContext.cpp::setBindingDimensions::1511] Error Code 3: API Usage Error (Parameter check failed at: runtime/api/executionContext.cpp::setBindingDimensions::1511, condition: mEngine.bindingIsInput(bindingIndex) ) set binding time: 0....

November 23, 2023 · 6 min · 1169 words · 🤽奔波鲅

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....

November 23, 2023 · 6 min · 1099 words · lvsolo