使用 DeepStream-Yolo 的导出脚本为了确保模型能顺利适配 DeepStream 的后处理流程最佳做法是使用DeepStream-Yolo项目提供的专用脚本export_yoloV8.py来完成转换。准备环境与模型克隆并安装 Ultralytics 库:git clonehttps://github.com/ultralytics/ultralytics.git进入目录并安装:cd ultralytics pip3 install -e .准备脚本: 将DeepStream-Yolo/utils目录下的export_yolo11.py文件复制到ultralytics文件夹内。下载模型: 下载官方发布的.pt预训练权重文件例如wgethttps://github.com/ultralytics/assets/releases/download/v8.4.0/yolo11s.pt。执行转换命令 在ultralytics目录下运行以下命令生成 ONNX 模型bashpython3 export_yolo11.py -w yolo11s.pt --dynamic --simplify-w yolo11s.pt: 指定你的.pt模型文件路径。--dynamic: 推荐启用动态批次大小需要 DeepStream 6.1 或更高版本。--simplify: 推荐简化 ONNX 模型有助于提升性能和转换成功率需要 DeepStream 6.0 或更高版本。安装onnxpip install onnx onnxslim onnxruntime日志(deepstream) PS D:\jetson\ultralytics-main\ultralytics-main python export_yolo11.py -w yolo11n.pt --dynamic --simplify Starting: yolo11n.pt Opening YOLO11 model YOLO11n summary (fused): 100 layers, 2,616,248 parameters, 0 gradients, 6.5 GFLOPs Creating labels.txt file Exporting the model to ONNX W0528 13:55:17.682000 55984 site-packages\torch\onnx\_internal\exporter\_compat.py:133] Setting ONNX exporter to use operator set version 18 because the requested opset_version 17 is a lower version than we have implementations for. Automatic version conversion will be performed, which may not be successful at converting to the requested version. If version conversion is unsuccessful, the opset version of the exported model will be kept at 18. Please consider setting opset_version 18 to leverage latest ONNX features The model version conversion is not supported by the onnxscript version converter and fallback is enabled. The model will be converted using the onnx C API (target version: 17). Failed to convert the model to the target version 17 using the ONNX C API. The model was not modified Traceback (most recent call last): File D:\program\miniconda3\envs\deepstream\lib\site-packages\onnxscript\version_converter\__init__.py, line 137, in call converted_proto _c_api_utils.call_onnx_api( File D:\program\miniconda3\envs\deepstream\lib\site-packages\onnxscript\version_converter\_c_api_utils.py, line 65, in call_onnx_api result func(proto) File D:\program\miniconda3\envs\deepstream\lib\site-packages\onnxscript\version_converter\__init__.py, line 132, in _partial_convert_version return onnx.version_converter.convert_version( File D:\program\miniconda3\envs\deepstream\lib\site-packages\onnx\version_converter.py, line 39, in convert_version converted_model_str C.convert_version(model_str, target_version) RuntimeError: D:\a\onnx\onnx\onnx/version_converter/BaseConverter.h:64: adapter_lookup: Assertion false failed: No Adapter To Version $17 for Resize Simplifying the ONNX model Done: yolo11n.onnx踩坑1这里默认导出的是 opset18的这个版本。 2注意指定onnx模型导出的分辨率