当前位置:网站首页>yolov5实现小数据集的目标检测--kolektor缺陷数据集
yolov5实现小数据集的目标检测--kolektor缺陷数据集
2022-07-25 09:22:00 【怪人i命】
要求:
我直接在colab上运行,直接不用管这些。
数据集:
可以使用自己做的数据集,我用的是kolektor数据集,下载地址https://www.vicos.si/Downloads/KolektorSDD
KSDD里面只有50个缺陷数据,我做了旋转,差不多一百个缺陷数据
(自己想做其他数据的检测原理也是一样的)
标注数据集就用labelImg标注,效果如下:


一、在colab上直接克隆源码,再下载requirements.txt文件:

% cd /content/yolov5
!git clone https://github.com/ultralytics/yolov5
!pip install -r requirements.txt 二、将数据集与yolov5文件放置同级(根据官网)
分别将图片和txt文件放到images和labels文件夹内。
然后根据自己数据集的类别,在路径yolov5/data/下写一个含有后缀.yaml的配置文件,我的只需要检测一类缺陷,nc为1,names为类名。
下面是我定义的,test.yaml:

三、进行训练(可以选择不同的版本:yolov5n/s/m/l/x)

! python train.py --img 640 --batch 30 --epochs 100 --data test.yaml --weights yolov5s.pt
可以自己定义batch、epochs
注意:在我第一次训练的时候,用的官网的batch 16 、epochs 3,导致我val_batch_pred.jpg的图片并没有预测信息,当我调大之后就有了。
训练之后的结果:



然后运行detect.py ,选择自己的图片验证:

!python detect.py --weights runs/train/exp4/weights/last.pt --source data/images/Part0.jpg --device 0 --save-txt有缺陷的:

无缺陷的:

边栏推荐
猜你喜欢

链表--基本操作

Swagger2显示get接口有问题,加注解就能解决

How to obtain location information (longitude and latitude) by uni app

~1 CCF 2022-06-2 treasure hunt! Big adventure!

关于C和OC

OC -- Foundation -- array

OC--Foundation--数组

初识Opencv4.X----图像直方图均衡

Swagger2 shows that there is a problem with the get interface, which can be solved with annotations

Redis installation (Ubuntu)
随机推荐
关于C和OC
[code source] daily question - queue
降低程序空间复杂度的一些技巧
Definition of cell
How to convert object data into arrays
[code source] a prime number of fun every day (BFS)
对象数据如何转化成数组
【cf】Round 128 C. Binary String
Browser access to swagger failed with error err_ UNSAFE_ PORT
TCP network application development process
【数据挖掘】第四章 分类任务(决策树)
MinkowskiEngine 安装
Redis set 结构命令
文件--初识
2022年的个人技术选型梳理
Job 7.15 shell script
Learning new technology language process
*6-3 save small experts
Sort out personal technology selection in 2022
Raspberry sect door ban system based on face recognition