yolov5导出ONNX
时间: 2023-09-11 17:10:45 浏览: 322
要将yolov5模型导出为带有softmax的ONNX格式,可以按照以下步骤进行操作:
1. 运行以下命令导出原始的ONNX模型:
```python
python export_cls.py --weights yolov5s-cls.pt --include onnx --dynamic
```
这将生成一个原始的ONNX模型文件。
2. 使用Python代码加载原始的ONNX模型:
```python
import torch
import onnx
output_path = "yolov5s-cls.onnx"
model = onnx.load(output_path)
```
3. 创建一个Softmax节点并插入到模型输出之前:
```python
import onnx.helper
output_name = model.graph.output<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* *3* [yolov5-cls部署之onnx导出](https://blog.csdn.net/yangjinyi1314/article/details/131326323)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]
阅读全文