机器视觉 - YoloV8 命令行使用示例
准备 data.yaml 文件
从roboflow 上下载 CS 游戏数据集, 因为只有CPU, 我对数据集做了瘦身, train: 689张, val: 23张, test:40张.
https://universe.roboflow.com/roboflow-100/csgo-videogame/dataset/2
train: ../train/images
val: ../valid/images
test: ../test/images
nc: 2
names: ['CT', 'T']
roboflow:
workspace: roboflow-100
project: csgo-videogame
version: 2
license: CC BY 4.0
url: https://universe.roboflow.com/roboflow-100/csgo-videogame/dataset/2
训练
# 使用 yolov8n.pt 预训练模型进行 train, 不含val
.\yolo task=detect mode=train val=False data=D:\my_workspace\data.yaml model=yolov8n.pt epochs=115 workers=1 imgsz=640
# 或者使用 yolov8n.pt 预训练模型进行 train+val
.\yolo task=detect mode=train val=True data=D:\my_workspace\data.yaml model=yolov8n.pt epochs=115 workers=1 imgsz=640
val
.\yolo task=detect mode=val split=val data=D:\my_workspace\data.yaml model=path\weights\best.pt workers=1 imgsz=640
命令行输出:
下图val过程的预测结果, 第一个图片没有识别出来, 说明train epoch还不够.
test
.\yolo task=detect mode=val split=test data=D:\my_workspace\data.yaml model=path\weights\best.pt workers=1 imgsz=640
predict
# predict 单张图片
.\yolo predict model=path\weights\best.pt conf=0.25 source='D:\my_workspace\my.jpg'
# predict 整个目录
.\yolo predict model=path\weights\best.pt conf=0.25 source='D:\my_workspace'
参考
yolov8 命令参数中文: https://blog.csdn.net/weixin_45921929/article/details/128673338