论文题目:《ECA-Net: Efficient Channel Attention for Deep Convolutional Neural Networks》
论文地址: https://arxiv.org/pdf/1910.03151.pdf
实验证明,将即插即用的ECA注意力模块嵌入到YOLOv5网络中,减少模型参数,同时带来明显的性能提升。
1.网络结构图
2.ECA模块代码
# class eca_layer(nn.Module):
# """Constructs a ECA module.
# Args:
# channel: Number of channels of the input feature map
# k_size: Adaptive selection of kernel size
# """
# def __init__(self, channel, k_size=3):
# super(eca_layer, self).__init__()
# self.avg_pool = nn.AdaptiveAvgPool2d(1)
# self.conv = nn.Conv1d(1, 1, kernel_size=k_size, padding=(k_size - 1) // 2, bias=False)
# self.sigmoid = nn.Sigmoid()
#
# def forward(self, x):
# # feature descriptor on the global spatial information
# y = self.avg_pool(x)
#
# # Two different branches of ECA module
# y = self.conv(y.squeeze(-1).transpose(-1, -2)).transpose(-1, -2).unsqueeze(-1)
#
# # Multi-scale information fusion
# y = self.sigmoid(y)
# x=x*y.expand_as(x)
#
# return x * y.expand_as(x)
如何嵌入YOLOv5网络,各位小伙伴请参考CBAM那篇博文~
版权声明:本文为m0_53578855原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。