Skip to content

Instantly share code, notes, and snippets.

@YimianDai
Last active December 8, 2021 16:42
Show Gist options
  • Save YimianDai/d4a8951cbee01967ed9f163aa917f777 to your computer and use it in GitHub Desktop.
Save YimianDai/d4a8951cbee01967ed9f163aa917f777 to your computer and use it in GitHub Desktop.
Attention to Scale: Scale-aware Semantic Image Segmentation

Attention to Scale: Scale-aware Semantic Image Segmentation

这是一篇较早的文章了,10 Nov 2015 挂到了 arXiv 上,是 CVPR 2016 的文章。不管是 Object Detection 还是 Semantic Segmentation,性能要好的一个关键在于利用好 multi-scale features。

论文试图解决的问题是:如何利用 multi-scale 的 feature?

论文尝试给出的途径是,将各个 scale 独立预测的 score map 做一个 weighted sum,其实是一个决策级的融合。这个权重来源于共享的 Attention Module,具体由另一个 FCN 实现。

1. multi-scale features 的来源

在深度网络里,一般 multi-scale features 的来源有两种:

  1. 一种叫作 skip-net, 输入是单一 scale 的,深度网络的 intermediate layers 产生尺度不同的中间特征,这些特征就是 skip-net 的 multi-scale features;
  2. 另一种叫作 share-net,输入就是 multi-scale 的,将 the input image resizes 成 several scales,通过一个共享的深度网络后,由于输入尺度不同,得到的输出自然也就是 multi-scale 的,这些特征就是 share-net 的 multi-scale features。

2. 怎么利用(融合) multi-scale features

方式 1:Concatenated Features

对于不管是 skip-net 还是 share-net 来说,最简单的方式就是将不同尺度的 Features Concatenated 起来。最早提出 Concatenated Features 这种方式的文章是下面两篇:

  1. C. Farabet, C. Couprie, L. Najman, and Y. LeCun. Learning hierarchical features for scene labeling. PAMI, 35(8):1915– 1929, 2013.
  2. G. Lin, C. Shen, I. Reid, et al. Efficient piecewise training of deep structured models for semantic segmentation. arXiv:1504.01013, 2015.

上图 (a) 所示的是 skip-net 做 Concatenated Features 的方式,而上面两篇文章都是 share-net 采用 Concatenated Features。Concatenated Features 这种方式比较简单,但是巨耗内存,训练很慢。

方式 2:Average- or Max-Pooling Over Scales

除了对 Features 做 Concatenate 之外,还可以对这些 Share-Net 的 Score Map 做 Average- or Max-Pooling Over Scales(沿着 Scale 维度做 Pooling)。

由上图 (a) 所示,上图 (a) 里面不同尺度的 score map 融合的权重给定方式是实现确定好的,Average Pooling 就是 Averaging,Max Pooling 就是根据 score 挑选 Max。下面这些文章都是这类范式。

  1. P. F. Felzenszwalb, R. B. Girshick, D. McAllester, and D. Ra-manan. Object detection with discriminatively trained part-based models. PAMI, 32(9):1627–1645, 2010.
  2. D. Ciresan, U. Meier, and J. Schmidhuber. Multi-column deep neural networks for image classification. In CVPR, 2012.
  3. G. Papandreou, L.-C. Chen, K. Murphy, and A. L. Yuille. Weakly- and semi-supervised learning of a dcnn for semantic image segmentation. In ICCV, 2015.
  4. J. Dai, K. He, and J. Sun. Boxsup: Exploiting bounding boxes to supervise convolutional networks for semantic seg- mentation. In ICCV, 2015.

可不可以对不同 Scale 的 Features 做 Pooling?

方式 3:Generalized Average- or Max-Pooling Over Scales

本文方法本质上是一种 Generalized Average- or Max-Pooling Over Scales,Average Pooling 是对每个 Scale 的 Score Map 分配一样的权重,而 Max-Pooling 则是分配 0、1 权重。而本文就是用一个 Attention Module 给各个 Scale 的 Score Map 产生相应的 Weight Map。具体方式由上图 (b) 所示。

这篇论文的 Motivation 就在于,之前 share-net 计算出来的最后的特征图往往就是通过 average pooling 或者 max pooling 融合的,而本文则是想对这些不同 scale 下的 score map 做一个 加权平均,得到最后融合的 score map。

那么这个 权重 是怎么计算出来的呢?这篇文章里面的 Attention Model 也就是权重计算机制也是一个 FCN,这样才能够输出同样 dense 的 weight map,跟做分割的 FCN share 前面的若干层。

具体模型图如下图所示

Attention 的 FCNHead 和 产生 Score Map 的 FCNHead share 同一个 Backbone,唯一的区别就是,Attention 的 FCNHead 输出还要经过一个 Softmax,而 产生 Score Map 的 FCNHead 的不需要,本质上这个网络就是一个带了两个 FCNHead 的 FCN。

终于明白本文 标题 Attention to Scale 的意思了,作者是觉得以前 Attention 的论文有对 Channel、Spatial、Temporal 这些维度做 Attention 的,而本文是对 Scale 这一维度。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment