我们主要是对yolov5的推理进行改进,我们使用yolov5自带的export.py文件对模型进行导出
参见yolov5官网(6.0版本之后才有)
python export.py --weights yolov5s.pt --include torchscript onnx
备注:在导出前需要先安装onnx库
输出如下:
export: data=data/coco128.yaml, weights=[‘yolov5s.pt’], imgsz=[640, 640], batch_size=1, device=cpu, half=False, inplace=False, train=False, keras=False, optimize=False, int8=False, dynamic=False, simplify=False, opset=12, verbose=False, workspace=4, nms=False, agnostic_nms=False, topk_per_class=100, topk_all=100, iou_thres=0.45, conf_thres=0.25, include=[‘torchscript’, ‘onnx’]
YOLOv5 v6.2-104-ge3e5122 Python-3.7.13 torch-1.12.1+cu113 CPU
Downloading https://github.com/ultralytics/yolov5/releases/download/v6.2/yolov5s.pt to yolov5s.pt…
100% 14.1M/14.1M [00:00<00:00