在一些特殊场景诸如:环保、湿地公园、电力设施等,鸟类是一个很大的安全隐患,有效地监测到鸟类并及时预警驱逐对于安全正常地生产进行有着重要的作用。这里主要是基于前文的基础上开发构建的轻量级的鸟类检测系统,首先看下效果:
![](https://i-blog.csdnimg.cn/blog_migrate/caa7dfb0bb6f38dfa1fab75e2a1c9f95.gif)
接下来看下数据集:
![](https://i-blog.csdnimg.cn/blog_migrate/5898a0de587f1a1390840008a6f7c1f6.png)
![](https://i-blog.csdnimg.cn/blog_migrate/fd0961e305ff07bf7834a81ac9af6983.png)
YOLO格式标注文件如下:
![](https://i-blog.csdnimg.cn/blog_migrate/52c7f221d986f2b936d9944f7e4da5c1.png)
实例标注内容如下所示:
0 0.51875 0.501389 0.579167 0.863889
VOC格式标注文件如下所示:
![](https://i-blog.csdnimg.cn/blog_migrate/96c9bff4a497e54b5f2fa395da0c1ff3.png)
实例标注内容如下所示:
<annotation>
<folder>DDDD</folder>
<filename>00c25dd7-03f3-4cc8-bc82-c5d21088df21.jpg</filename>
<source>
<database>The DDDD Database</database>
<annotation>DDDD</annotation>
<image>DDDD</image>
</source>
<owner>
<name>YSHC</name>
</owner>
<size>
<width>361</width>
<height>500</height>
<depth>3</depth>
</size>
<segmented>0</segmented>
<object>
<name>Carolina_Wren</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>114</xmin>
<ymin>102</ymin>
<xmax>250</xmax>
<ymax>222</ymax>
</bndbox>
</object>
</annotation>
这里因为是单类别的检测,且整体数据集观察发现,数据是比较清晰直观的,所以直接采用了YOLOv5最轻量的n系列的模型,如下:
#Parameters
nc: 1 # number of classes
depth_multiple: 0.33 # model depth multiple
width_multiple: 0.25 # 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)
]
默认执行100次的迭代计算,如下:
混淆矩阵:
![](https://i-blog.csdnimg.cn/blog_migrate/7a94919dd61d2f6b0d65f4393af001b0.png)
F1曲线:
![](https://i-blog.csdnimg.cn/blog_migrate/18d4446db14bffdad282193a5cc287cf.png)
LABEL可视化:
![](https://i-blog.csdnimg.cn/blog_migrate/8ac177ee84e501c6179bf84900723ef5.png)
PR曲线:
![](https://i-blog.csdnimg.cn/blog_migrate/d83798524cb3ee60740a353f34ba1081.png)
batch计算实例:
![](https://i-blog.csdnimg.cn/blog_migrate/df70616751d0d9162aba86af02a9cdf4.jpeg)
![](https://i-blog.csdnimg.cn/blog_migrate/b8e8acf96494e17749f4ddebd25c120d.jpeg)
可以看到:检测识别的效果是非常不错的,而且置信度都很高。
可视化推理样例如下:
![](https://i-blog.csdnimg.cn/blog_migrate/fb5f110329a5a4d36e7aea077821f0d4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f841f24b723f62d3fcd6110cb20bfeee.png)