赞
踩
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 mode=predict model="d:/Data/yolov8n.pt" source="d:/Data/6406407.jpg" save show
效果图默认保存在路径:ultralytics\runs\detect\predict,效果如下:
直接把source改成视频文件路径即可,命令如下:
yolo mode=predict model="d:/Data/yolov8n.pt" source="d:/Data/people.mp4" save show
bash窗口打印如下:
指令如下:
yolo mode=predict model="d:/Data/yolov8n.pt" source=0 show
在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", save=True) # predict on an image
预测指令:
python predict.py
如下图预测窗口打印,图片默认保存在: D:\CodePython\ultralytics\runs\detect\predict
- pip install onnx
- yolo mode=export model="d:/Data/yolov8n.pt" format=onnx dynamic=True opset=12
- 《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
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。