数据集包含多种虫类检测
数据集可见主页下载资源
路径代码(我是把yolo放到桌面的)
path: ./insects # dataset root dir
train: images/train # train images (relative to 'path') 128 images
val: images/val # val images (relative to 'path') 128 images
test: # test images (optional)
# Classes
names:
0: a #毒蛾
1: b #柳毒蛾
2: c #胡椒木
3: d #毛虫
4: e #松毛虫
5: f #松茸毒蛾
6: g #舞毒蛾
7: h #甜菜夜蛾
8: i #尺蛾
9: j #黏虫
10: k #陆地棉
11: l #棉铃虫
12: m #蚜虫
13: o #红蜘蛛
14: p #豹蠹蛾
15: q #蛾
16: r #冥蛾
17: s #天牛
18: t #叶甲
19: u #白蚁
20: v #蝗虫
21: w #枯叶蛾
22: x #夜蛾
写好数据集后放进yolov5的文件夹中 并且在终端运行vscode或者pycharm或者在anaconda prompt里面切换到yolo环境里面运行代码。
python train.py --batch 4 --epochs 100 --data bvn.yaml --cfg models/yolov5s.yaml --weights yolov5s.pt
其中--date 后面是上面路径代码的名字,之后开始训练。
可以运行detect代码
python detect.py --source insects/images/val --weights runs/train/exp/weights/best.pt
后面就会检测你训练集中的图片。