在我前面的博文中对于农作物病虫害的检测识别已经做过了,不过那个主要是针对水稻的,文章如下:
《基于yolov5的轻量级水稻虫害目标检测项目实践》
感兴趣的话可以自行移步阅读。
这里主要是针对酸枣常见的几种病虫害检测检测识别,首先看下效果:
接下来看下数据集概况:
YOLO格式标注数据文件如下:
实例标注内容如下:
1 0.25 0.34507 0.036364 0.030986
1 0.211364 0.460563 0.027273 0.033803
1 0.132955 0.239437 0.029545 0.04507
1 0.15 0.149296 0.036364 0.033803
1 0.177841 0.103521 0.053409 0.057746
1 0.179545 0.026761 0.025 0.033803
1 0.239205 0.05 0.014773 0.038028
1 0.331818 0.039437 0.013636 0.033803
1 0.411932 0.011972 0.0375 0.015493
1 0.677273 0.052817 0.034091 0.043662
1 0.786364 0.057746 0.086364 0.112676
1 0.877273 0.069718 0.045455 0.026761
1 0.095455 0.505634 0.079545 0.129577
1 0.150568 0.63169 0.0625 0.05493
1 0.201136 0.708451 0.056818 0.061972
1 0.180114 0.546479 0.017045 0.033803
1 0.224432 0.543662 0.014773 0.033803
1 0.140341 0.39507 0.021591 0.023944
1 0.204545 0.391549 0.015909 0.030986
1 0.238636 0.391549 0.015909 0.025352
1 0.247159 0.449296 0.019318 0.033803
1 0.265909 0.551408 0.011364 0.023944
1 0.280114 0.725352 0.017045 0.039437
1 0.339773 0.452817 0.015909 0.023944
1 0.389773 0.530282 0.034091 0.043662
1 0.340909 0.685915 0.022727 0.033803
1 0.451136 0.580282 0.015909 0.028169
1 0.430682 0.51831 0.018182 0.03662
1 0.449432 0.207042 0.019318 0.019718
1 0.516477 0.217606 0.019318 0.021127
1 0.531818 0.159155 0.011364 0.022535
1 0.589773 0.125352 0.020455 0.028169
1 0.622159 0.11338 0.023864 0.026761
1 0.684091 0.116197 0.018182 0.015493
1 0.555114 0.225352 0.014773 0.042254
1 0.597159 0.380282 0.017045 0.039437
1 0.549432 0.628873 0.0375 0.111268
1 0.480682 0.756338 0.052273 0.090141
1 0.440341 0.926761 0.071591 0.073239
1 0.589773 0.825352 0.095455 0.222535
1 0.74375 0.70493 0.132955 0.153521
1 0.665909 0.55 0.022727 0.057746
1 0.626705 0.571831 0.023864 0.033803
1 0.728409 0.411268 0.061364 0.169014
1 0.781818 0.296479 0.036364 0.074648
1 0.736932 0.182394 0.044318 0.043662
1 0.807386 0.15493 0.019318 0.030986
1 0.836932 0.174648 0.019318 0.028169
1 0.901705 0.247183 0.017045 0.038028
1 0.849432 0.294366 0.014773 0.076056
1 0.829545 0.421127 0.059091 0.059155
1 0.803409 0.482394 0.022727 0.035211
1 0.788636 0.556338 0.034091 0.08169
1 0.186364 0.222535 0.027273 0.109859
1 0.238636 0.249296 0.043182 0.033803
VOC格式标注数据文件如下所示:
实例标注内容如下所示:
<annotation>
<folder>Data</folder>
<filename>1f4707fe-6d90-4115-80fd-b0e5e3d4b18f.jpg</filename>.
<source>
<database>The Database</database>
<annotation>Data</annotation>
<image>Data</image>
</source>
<owner>
<name>YSHC</name>
</owner>
<size>
<width>495</width>
<height>372</height>
<depth>3</depth>
</size>
<segmented>0</segmented>
<object>
<name>G</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>588</xmin>
<ymin>314</ymin>
<xmax>632</xmax>
<ymax>368</ymax>
</bndbox>
</object>
<object>
<name>G</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>784</xmin>
<ymin>526</ymin>
<xmax>807</xmax>
<ymax>534</ymax>
</bndbox>
</object>
<object>
<name>G</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>803</xmin>
<ymin>557</ymin>
<xmax>848</xmax>
<ymax>578</ymax>
</bndbox>
</object>
</annotation>
这里我使用的是yolov5s系列的模型,yaml文件如下所示:
#Parameters
nc: 3 # number of classes
depth_multiple: 0.33 # model depth multiple
width_multiple: 0.50 # layer channel multiple
anchors:
- [10,13, 16,30, 33,23] # P3/8
- [30,61, 62,45, 59,119] # P4/16
- [116,90, 156,198, 373,326] # P5/32
#Backbone
backbone:
# [from, number, module, args]
[[-1, 1, Conv, [64, 6, 2, 2]], # 0-P1/2
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4
[-1, 3, C3, [128]],
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8
[-1, 6, C3, [256]],
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16
[-1, 9, C3, [512]],
[-1, 1, Conv, [1024, 3, 2]], # 7-P5/32
[-1, 3, C3, [1024]],
[-1, 1, SPPF, [1024, 5]], # 9
]
#Head
head:
[[-1, 1, Conv, [512, 1, 1]],
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
[[-1, 6], 1, Concat, [1]], # cat backbone P4
[-1, 3, C3, [512, False]], # 13
[-1, 1, Conv, [256, 1, 1]],
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
[[-1, 4], 1, Concat, [1]], # cat backbone P3
[-1, 3, C3, [256, False]], # 17 (P3/8-small)
[-1, 1, Conv, [256, 3, 2]],
[[-1, 14], 1, Concat, [1]], # cat head P4
[-1, 3, C3, [512, False]], # 20 (P4/16-medium)
[-1, 1, Conv, [512, 3, 2]],
[[-1, 10], 1, Concat, [1]], # cat head P5
[-1, 3, C3, [1024, False]], # 23 (P5/32-large)
[[17, 20, 23], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5)
]
默认100epoch的迭代计算,结果详情如下:
混淆矩阵:
F1值曲线:
PR曲线:
batch计算实例:
后面有时间考虑集成一下新的Backbone网络。
CSDN现在这个写作平台太卡了,数据一粘贴完全卡成xiang......