语义分割--FCN中的Shift-and-stitch的详解
prediciton map size
和 label map size
不匹配时,除了 cropping
, resize
等暴力措施,且不采取 bilinear
, uppooling
, deconvolution
等decoder
结构, 为了实现 dense prediction , 该怎么做呢?shift and stitch
的做法其实就是:version
的 input
,输入网络后相应地产生 f2 个output
, 然后 stitch
(这个词不好翻译,先翻译成串联)所有 output
就实现了 dense prediciton
。(1)我们举一个简单的例子来直观地说明 shift and stitch 的做法:
设网络只有一层 2x2 的maxpooling
层,所以下采样因子 f =2
, 我们需要对input image
的 pixels
平移 (x,y)
个单位,即将 image
向左平移 x
个pixels
, 再向上平移y
个单位,整幅图像表现向左上方向平移,空出来的右下角就以0
padding
。我们当然可以采取 FCN
论文中的做法,将图像向右下角平移,空出来的左上角用 0 padding
,这两种做法产生的结果是一致的,没有本质区别。(x,y)
取(0
,0
), (0
,1
),(1
,0
),(1
,1
) 后,就产生了 f^2^
= 4
个input
。
4
个input
分别进行 2x2 的maxpooling
操作后,共产生了4
个output
,灰色区域代表 4个 output
中 值重复的区域:如黄色 output
中的第三列与红色 output
的第三列值重复,所以标为灰色,绿色 ouput
中的第三行与红色 ouput 中
的第三行值重复,所以也标为灰色,蓝色output
中的第三行与黄色 ouput
中的第三行值重复,第三列与绿色output
的第三列值重复,亦标位灰色。最后,stitch the 4 different output
获得 dense prediction
:
stitch
的呢?
FCN中:Process each of these f2 inputs, and interlace the outputs so that the predictions correspond to the pixels at the centers of their receptive fields
说的很明白了,output
中的每个pixel
都对应 original image
的不同 receptive field
,将receptive field
的中心c
填上这个来自output
的pixel
值,就是网络对original image
中像素 c
的prediction
。
为表述简洁,我用 “ 像素 i ” 表示“ 值为 i 的像素 ”。
红色
output
中的像素1
对应shifted input``(0,0)
的红色部分, 而对应original image
的部分,也即receptive field
仅仅为像素[1],
所以receptive field
的中心为像素[1]
, 该位置填上红色output
中像素 1 的值。黄色
output
中的像素4
对应shifted input
(1,0)
的黄色部分, 而对应original image
的部分,也即receptive field
为像素 [3,4] , 所以receptive field
的中心为像素[4], 该位置填上黄色output
中像素4
的值。以此类推..
到此就完成了对FCN
论文中的 Shift-and-stitch
的详尽解释。
参考:
关于FCN 论文中的 Shift-and-stitch 的详尽解释
https://www.jianshu.com/p/e534e2be5d7d