目录
Pre
0、下载源码
1、下载权重
2、安装环境
3、实例分割 Predict
4、导出 ONNX格式
或者
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install ultralytics
yolo task=segment mode=predict model=yolov8n-seg.pt source='/home/jason/file/01-bytetrack-deepsort/1.mp4' show=True
yolo export model=yolov8n-seg.pt format=onnx
输出如下:
(yolo) jason@honor:~/PycharmProjects/pytorch_learn/yolo/ultralytics-main-yolov8$ yolo export model=yolov8n-seg.pt format=onnx
Ultralytics YOLOv8.0.94 Python-3.8.13 torch-2.0.0+cu117 CPU
YOLOv8n-seg summary (fused): 195 layers, 3404320 parameters, 0 gradients, 12.6 GFLOPs
PyTorch: starting from yolov8n-seg.pt with input shape (1, 3, 640, 640) BCHW and output shape(s) ((1, 116, 8400), (1, 32, 160, 160)) (6.7 MB)
ONNX: starting export with onnx 1.13.1 opset 17...
============= Diagnostic Run torch.onnx.export version 2.0.0+cu117 =============
verbose: False, log level: Level.ERROR
======================= 0 NONE 0 NOTE 0 WARNING 0 ERROR ========================
ONNX: export success ✅ 0.9s, saved as yolov8n-seg.onnx (13.2 MB)
Export complete (1.6s)
Results saved to /home/jason/PycharmProjects/pytorch_learn/yolo/ultralytics-main-yolov8
Predict: yolo predict task=segment model=yolov8n-seg.onnx imgsz=640
Validate: yolo val task=segment model=yolov8n-seg.onnx imgsz=640 data=coco.yaml
Visualize: https://netron.app
用netron查看下ONNX格式模型
注意看有两个输出
参考 :
名声大噪的YOLO迎来YOLOv8,迅速包揽目标检测、实例分割新SOTA-腾讯云开发者社区-腾讯云