论文地址: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)
]
在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
yolo.py中添加如下代码:
本人更多YOLOv5实战内容导航🍀🌟🚀
-
手把手带你Yolov5 (v6.2)添加注意力机制(一)(并附上30多种顶会Attention原理图)🌟强烈推荐🍀新增8种
-
空间金字塔池化改进 SPP / SPPF / SimSPPF / ASPP / RFB / SPPCSPC / SPPFCSPC🚀
参考文献:
文章出处登录后可见!
已经登录?立即刷新