yolov8 官方仓库: https://github.com/ultralytics/ultralytics
# 注:python其他版本在win10下,可能有坑,我已经替你踩坑了,这里python3.9亲测有效
conda create -n yolov8 python=3.9 -y
conda activate yolov8
pip install ultralytics -i https://pypi.tuna.tsinghua.edu.cn/simple
模型下载地址:
# download offical weights(".pt" file)
https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n.pt
https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8s.pt
https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8m.pt
https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8l.pt
https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8x.pt
https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8x6.pt
这里下载yolov8n为例子,原图图下图:
我们将图像和yolov8n.pt放到路径:d:/Data/
推理:
yolo predict model="d:/Data/yolov8n.pt" source="d:/Data/6406407.jpg"
效果如图:
在win10下,创建路径:D:\CodePython\yolov8,将这个5Mb的数据集下载并解压在目录,
coco128数据集下载地址(别担心,免费白嫖):文件分享
如下图:
新建train.py文件,代码如下:
from ultralytics import YOLO
# Load a model
# yaml会自动下载
model = YOLO("yolov8n.yaml") # build a new model from scratch
model = YOLO("d:/Data/yolov8n.pt") # load a pretrained model (recommended for training)
# Train the model
results = model.train(data="coco128.yaml", epochs=100, imgsz=640)
训练指令:
python train.py
如下图训练状态:
新建predict.py文件,代码如下:
from ultralytics import YOLO
# Load a model
model = YOLO("d:/Data/yolov8n.pt") # load an official model
# Predict with the model
results = model("d:/Data/6406407.jpg") # predict on an image
预测指令:
python predict.py
如下图预测窗口打印:
pip install onnx
yolo mode=export model="d:/Data/yolov8n.pt" format=onnx dynamic=True
《YOLOV8部署保姆教程》
https://blog.csdn.net/m0_72734364/article/details/128758544?spm=1001.2014.3001.5501
TensorRT-Alpha基于tensorrt+cuda c++实现模型end2end的gpu加速,支持win10、linux,在2023年已经更新模型:YOLOv8, YOLOv7, YOLOv6, YOLOv5, YOLOv4, YOLOv3, YOLOX, YOLOR,pphumanseg,u2net,EfficientDet。
TensorRT-Alpha:https://github.com/FeiYull/TensorRT-Alpha
快速看看yolov8n 在移动端RTX2070m(8G)的新能表现:
model | video resolution | model input size | GPU Memory-Usage | GPU-Util |
---|---|---|---|---|
yolov8n | 1920x1080 | 8x3x640x640 | 1093MiB/7982MiB | 14% |
下图是yolov8n的运行时间开销,单位是ms:
更多TensorRT-Alpha测试录像在B站视频:
B站:YOLOv8n
B站:YOLOv8s
更多训练指引,请看官方文档。
# yolov8 官方仓库: https://github.com/ultralytics/ultralytics # yolov8 官方中文教程:ultralytics/README.zh-CN.md at main · ultralytics/ultralytics · GitHub # yolov8 官方训练指引: https://docs.ultralytics.com/reference/base_trainer/ # yolov8 官方快速教程: https://docs.ultralytics.com/quickstart/