论文地址:https://arxiv.org/abs/2109.15099
代码地址:https://github.com/ngnquan/PP-LCNet
我们提出了一种基于MKLDNN加速策略的轻量级CPU网络,名为PP LCNet,它提高了轻量级模型在多个任务上的性能。本文列出了在延迟几乎不变的情况下可以提高网络准确性的技术。通过这些改进,PP LCNet的精度可以在相同的分类推理时间下大大超过以前的网络结构。如图1所示,它优于最先进的模型。对于计算机视觉的下游任务,它也表现得很好,例如对象检测、语义分割等。我们所有的实验都是基于PaddlePaddle1实现的。PaddleClas2提供代码和预训练模型。
PP-LCNet网路结构
将YOLOv5主干网络替换为PP-LCNet:
yolov5lPP-LC.yaml
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license
# Parameters
nc: 80 # number of classes
depth_multiple: 1.0 # model depth multiple
width_multiple: 1.0 # 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
# PP-LCNet backbone
backbone:
# [from, number, module, args]
[[-1, 1, Conv, [16, 3, 2, 1]], # 0-P1/2 ch_out, kernel, stride, padding
[-1, 1, DepthSepConv, [32, 3, 1, False]], # 1
[-1, 1, DepthSepConv, [64, 3, 2, False]], # 2-P2/4
[-1, 1, DepthSepConv, [64, 3, 1, False]], # 3
[-1, 1, DepthSepConv, [128, 3, 2, False]], # 4-P3/8
[-1, 1, DepthSepConv, [128, 3, 1, False]], # 5
[-1, 1, DepthSepConv, [256, 3, 2, False]], # 6-P4/16
[-1, 5, DepthSepConv, [256, 5, 1, False]], # 7
[-1, 1, DepthSepConv, [512, 5, 2, True]], # 8-P5/32
[-1, 1, DepthSepConv, [512, 5, 1, True]], # 9
]
# YOLOv5 v6.0 head
head:
[[-1, 1, Conv, [512, 1, 1]], # 11
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
[[-1, 7], 1, Concat, [1]], # cat backbone P4
[-1, 3, C3, [512, False]], # 14
[-1, 1, Conv, [256, 1, 1]],
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
[[-1, 5], 1, Concat, [1]], # cat backbone P3
[-1, 3, C3, [256, False]], # 18 (P3/8-small)
[-1, 1, Conv, [256, 3, 2]],
[[-1, 13], 1, Concat, [1]], # cat head P4
[-1, 3, C3, [512, False]], # 21 (P4/16-medium)
[-1, 1, Conv, [512, 3, 2]],
[[-1, 10], 1, Concat, [1]], # cat head P5
[-1, 3, C3, [1024, False]], # 24 (P5/32-large)
[[17, 20, 23], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5)
]
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
在YOLOv5项目中添加方式:
common.py中加入以下代码:
class DepthSepConv(nn.Module):
def __init__(self, inp, oup, dw_size, stride, use_se):
super(DepthSepConv, self).__init__()
self.stride = stride
self.inp = inp
self.oup = oup
self.dw_size = dw_size
self.dw_sp = nn.Sequential(
nn.Conv2d(self.inp, self.inp, kernel_size=self.dw_size, stride=self.stride, padding=(dw_size - 1) // 2, groups=self.inp, bias=False),
nn.BatchNorm2d(self.inp),
nn.Hardswish(),
SeBlock(self.inp, reduction=16) if use_se else nn.Sequential(),
nn.Conv2d(self.inp, self.oup, kernel_size=1, stride=1, padding=0, bias=False),
nn.BatchNorm2d(self.oup),
nn.Hardswish())
def forward(self, x):
y = self.dw_sp(x)
return y
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
yolo.py中添加如下代码:
本人更多YOLOv5实战内容导航🍀🌟🚀
-
手把手带你调参Yolo v5 (v6.2)(推理)🌟强烈推荐
-
手把手带你调参Yolo v5 (v6.2)(训练)🚀
-
手把手带你调参Yolo v5 (v6.2)(验证)
-
如何快速使用自己的数据集训练Yolov5模型
-
手把手带你Yolov5 (v6.2)添加注意力机制(一)(并附上30多种顶会Attention原理图)🌟强烈推荐🍀新增8种
-
手把手带你Yolov5 (v6.2)添加注意力机制(二)(在C3模块中加入注意力机制)
-
Yolov5如何更换激活函数?
-
Yolov5如何更换BiFPN?
-
Yolov5 (v6.2)数据增强方式解析
-
Yolov5更换上采样方式( 最近邻 / 双线性 / 双立方 / 三线性 / 转置卷积)
-
Yolov5如何更换EIOU / alpha IOU / SIoU?
-
Yolov5更换主干网络之《旷视轻量化卷积神经网络ShuffleNetv2》
-
YOLOv5应用轻量级通用上采样算子CARAFE
-
空间金字塔池化改进 SPP / SPPF / SimSPPF / ASPP / RFB / SPPCSPC / SPPFCSPC🚀
-
用于低分辨率图像和小物体的模块SPD-Conv
-
GSConv+Slim-neck 减轻模型的复杂度同时提升精度🍀
-
头部解耦 | 将YOLOX解耦头添加到YOLOv5 | 涨点杀器🍀
-
Stand-Alone Self-Attention | 搭建纯注意力FPN+PAN结构🍀
-
YOLOv5模型剪枝实战🚀
-
YOLOv5知识蒸馏实战🚀
-
YOLOv7知识蒸馏实战🚀
-
改进YOLOv5 | 引入密集连接卷积网络DenseNet思想 | 搭建密集连接模块🍀
-
YOLOv5 框架引入 Google 轻量化网络 MobileNet V3🍀
-
YOLOv5更换骨干网络之 EfficientNet-B0🍀
参考文献:
https://github.com/Gumpest/YOLOv5-Multibackbone-Compression