CV中的Attention机制汇总(三):PAN
PAN: Pyramid Attention Network
论文链接:《Pyramid Attention Network for Segmantic Segmentation》
一、摘要
PAN网络结构:
Pyramid Attention Network (PAN)将注意力机制与空间金字塔相结合来更准确地提取密集特征,提高语义分割的准确率。该方法要解决的问题(motivation)和主要贡献包括:
1.1 提出 Feature Pyramid Attention(FPA) Module
- Motivation
The existence of objects at multiple scales cause difficulty in classification of categories.
同一类别物体的尺寸不一增加了分类难度,而现有算法采用膨胀卷积(ASPP)或金字塔汇聚(PSPNet)的方式增加分类准确率,但是分别存在网格效应和丢失了像素级位置信息的问题。 - FPA module
FPA module performs spatial pyramid attention structure on high-level output and combine global pooling to learn a better feature representation. (包含空间金字塔和全局汇聚,作用于深层网络的输出)
1.2 提出 Global Attention Upsample(GAU) Module
- Motivation
high-level features are skilled in making category classification, while weak in restructuring original resolution binary prediction.
深层网络的可以提取更精确的类别信息,但是丢失了位置信息,这对预测某类物体的位置是不利的。 - GAU module
GAU module acts on each decoder layer to provide global context as a guidance of low-level features to select category localization details, (深层网络的感受野更大,包含更准确的类别信息,浅层网络包含更准确的位置信息,可以将二者的特点结合提高分割效果。
二、模块详解
2.1 Feature Pyramid Attention
① 提取局部特征(pixel-wise)
FPA模块分别使用
3
×
3
,
5
×
5
,
7
×
7
3\times 3, 5\times 5, 7\times 7
3×3,5×5,7×7三个尺寸的卷积核进一步提取特征图包含的特征,然后将三种尺寸的特征图依次相加融合;
② 提取全局特征(channel-wise)
增加Global Pooling支路,提取通道特征。(这里思路类似SE模块,区别在于只用了一层卷积,SE用了两层)
2.2 Global Attention Upsample
主要思想:
The main character of decoder module is to repair category pixel localization. Furthermore, high-level features with abundant category information can be used to weight low-level information to select precise resolution details.
“解码”的目的是为了得到每个类别所包含的像素,实现像素级的分类。而深层网络的输出包含了更丰富的类别信息,浅层网络的输出包含更准备的位置信息,因此,可以使用深层网络提取的类别特征引导浅层网络实现更准确的像素级分类。
实现细节:
- 使用 3 × 3 3\times 3 3×3的卷积减少low-level特征图的通道数量;
- 使用global average pooling 提取high-level的全局信息, 1 × 1 1\times 1 1×1卷积后加BN层与ReLU激活函数;
- high-level输出经过上采样与加权后的low-level的输出特征图逐像素相加。
三、PyTorch代码实现
参考:https://github.com/JaveyWang/Pyramid-Attention-Networks-pytorch