当前位置:   article > 正文

目标检测算法——YOLOv5/YOLOv7改进之GSConv+Slim Neck(优化成本)_基于vovgscsp的slimneck

基于vovgscsp的slimneck

>>>深度学习Tricks,第一时间送达<<<

目录

(一)前言

1.GSConv模块

2.Slim Neck(GSBottleneck+VoVGSCSP)

(二)YOLOv5改进之GSConv+Slim Neck

1.配置common.py文件

2.配置yolo.py文件

3.配置YOLOv5/YOLOv7_GSConv.yaml文件


论文题目:Slim-neck by GSConv: A better design paradigm of detector architectures for autonomous vehicles

论文地址:https://arxiv.org/abs/2206.02424

代码地址:https://github.com/AlanLi1997/Slim-neck-by-GSConv


(一)前言

作者提出了一种新方法 GSConv 来减轻模型的复杂度并保持准确性。GSConv可以更好地平衡模型的准确性和速度。并且,提供了一种设计范式Slim Neck,以实现检测器更高的计算成本效益。实验过程中,与原始网络相比,改进方法获得了最优秀的检测结果。

如上图所示,作者在 SODA10M 的无人驾驶数据集上比较了最先进的Slim Neck 检测器和原始检测器的速度和准确度,并证实了该方法的有效性。

1.GSConv模块

2.Slim Neck(GSBottleneck+VoVGSCSP)

(二)YOLOv5改进之GSConv+Slim Neck

1.配置common.py文件

复制粘贴以下代码:

  1. #GSConv_______________________________________________________
  2. class GSConv(nn.Module):
  3. def __init__(self, c1, c2, k=1, s=1, g=1, act=True):
  4. super().__init__()
  5. c_ = c2 // 2
  6. self.cv1 = Conv(c1, c_, k, s, None, g, act)
  7. self.cv2 = Conv(c_, c_, 5, 1, None, c_, act)
  8. def forward(self, x):
  9. x1 = self.cv1(x)
  10. x2 = torch.cat((x1, self.cv2(x1)), 1)
  11. # shuffle
  12. b, n, h, w = x2.data.size()
  13. b_n = b * n // 2
  14. y = x2.reshape(b_n, 2, h * w)
  15. y = y.permute(1, 0, 2)
  16. y = y.reshape(2, -1, n // 2, h, w)
  17. return torch.cat((y[0], y[1]), 1)

2.配置yolo.py文件

找到相应位置,加入GSConv

  1. if m in [Conv, GhostConv, Bottleneck, GhostBottleneck, SPP,
  2. DWConv, MixConv2d, Focus, CrossConv, BottleneckCSP, C3, C3TR, GSConv]:

3.配置YOLOv5/YOLOv7_GSConv.yaml文件

下面以YOLOv5为例。

  1. # anchors
  2. anchors:
  3. - [10,13, 16,30, 33,23] # P3/8
  4. - [30,61, 62,45, 59,119] # P4/16
  5. - [116,90, 156,198, 373,326] # P5/32
  6. # YOLOv5 backbone
  7. backbone:
  8. # [from, number, module, args]
  9. [[-1, 1, Focus, [64, 3]], # 0-P1/2
  10. [-1, 1, GSConv, [128, 3, 2]], # 1-P2/4
  11. [-1, 3, C3, [128]],
  12. [-1, 1, GSConv, [256, 3, 2]], # 3-P3/8
  13. [-1, 9, C3, [256]],
  14. [-1, 1, GSConv, [512, 3, 2]], # 5-P4/16
  15. [-1, 9, C3, [512]],
  16. [-1, 1, GSConv, [1024, 3, 2]], # 7-P5/32
  17. [-1, 1, SPP, [1024, [5, 9, 13]]],
  18. [-1, 3, C3, [1024, False]], # 9
  19. ]
  20. # YOLOv5 head
  21. head:
  22. [[-1, 1, GSConv, [512, 1, 1]],
  23. [-1, 1, nn.Upsample, [None, 2, 'nearest']],
  24. [[-1, 6], 1, Concat, [1]], # cat backbone P4
  25. [-1, 3, C3, [512, False]], # 13
  26. [-1, 1, GSConv, [256, 1, 1]],
  27. [-1, 1, nn.Upsample, [None, 2, 'nearest']],
  28. [[-1, 4], 1, Concat, [1]], # cat backbone P3
  29. [-1, 3, C3, [256, False]], # 17 (P3/8-small)
  30. [-1, 1, GSConv, [256, 3, 2]],
  31. [[-1, 14], 1, Concat, [1]], # cat head P4
  32. [-1, 3, C3, [512, False]], # 20 (P4/16-medium)
  33. [-1, 1, GSConv, [512, 3, 2]],
  34. [[-1, 10], 1, Concat, [1]], # cat head P5
  35. [-1, 3, C3, [1024, False]], # 23 (P5/32-large)
  36. [[17, 20, 23], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5)
  37. ]

小伙伴们改进过程有问题或需要Slim Neck的可直接私信博主~


声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/459299

推荐阅读
相关标签