圖像分割之 deeplab v1,v2,v3,v3+系列解讀

 

DeepLabv1:
Semantic Image Segmentation with Deep Convolutional Nets and Fully Connected CRFs

ICLR 2015

官網:https://bitbucket.org/deeplab/deeplab-public.

 

優點:

  1. 速度快,帶空洞卷積的基於VGG16基礎結構的DCNN,可以達到8fps,而後處理的全連接CRF只需要0.5s。
  2. 準確,取得了PASCAL VOC第一名的結果,高於第二名7.2%個點,在PASCAL VOC-2012測試集上達到71.6%IOU準確性
  3. 簡單,整個系統只包含DCNN和CRF兩部分

 

空洞卷積(atrous conv):

 

條件隨機場CRF:

條件隨機場可以優化物體的邊界,平滑帶噪聲的分割結果,去掉物體中間的預測的孔洞,使得分割結果更加準確。

recovering object boundaries at a level of detail that is well beyond the reach of existing methods conditional random fields (CRFs) have been employed to smooth noisy segmentation maps

x是像素的標籤分配。

P(xi)是像素i處的標籤分配概率。

第一項θi是對數概率。
第二項,θij,它是一個濾波器。當xi != xj時,μ= 1。當xi = xj時,μ= 0。

在括號中,它是兩個內核的加權和。第一個核取決於像素值差和像素位置差,這是一種雙邊的filter。雙邊濾波器具有保留邊緣的特性。可以促使具有相似顏色和位置的像素具有相同的label預測。第二個內核僅取決於像素位置差異,這是一個高斯濾波器,可以促進更加平滑的預測。那些σ(高斯核大小)和w(權重),通過交叉驗證找到。迭代次數爲10。

 

多尺度預測:

多尺度預測也可以提升精度,但是沒有CRF後處理提升的多

整體流程:

 

 


DeepLabv2:
DeepLab: Semantic Image Segmentation with Deep Convolutional Nets, Atrous Convolution, and Fully Connected CRFs

TPAMI 2018

官網:http://liangchiehchen.com/projects/DeepLab.html

 

相對deeplab v1的主要改進:

1.使用ResNet101替代vgg16,做基礎網絡的改進,可以得到更好的準確性。

2.提出atrous spatial pyramid pooling (ASPP)來替代多尺度預測,可以大大增加感受野,感受野從普通卷積的k*k增大到(k + (k - 1)(r - 1)*k + (k - 1)(r - 1)

3.PASCAL VOC-2012 測試集達到了79.7%mIOU準確性

4.deeplab v2和deeplab v1一樣,都有全連接的CRF後處理模塊。


 

DeepLabv3:

Rethinking Atrous Convolution for Semantic Image Segmentation

Github:https://github.com/leonndong/DeepLabV3-Tensorflow

 

相對deeplab v2的主要改進:

1.網絡變得更深,對Resnet101進行改進,在第4個block後面,重複的堆疊了3個第四個block模塊,形成了block5, block6,block7模塊。同時對網絡結構的下采樣率進行了調整,原始的Resnet101進行了5次下采樣,而修改後的deeplab v3只進行了4次下采樣,從第三個block之後,就不需要進行下采樣操作。

2.增加了基於cascade的spp模塊。也就是block4, block5, block6,block7模塊。

3.修改了ASPP模塊,去掉了deeplab v2中ASPP模塊中的rate=24的3*3卷積,增加了1*1卷積和全局pooling模塊。也可以理解爲將原始的rate=24的3*3卷積模塊替換爲1*1卷積模塊。

爲什麼需要這樣做呢?因爲隨着空洞卷積採樣率變大,空洞卷積的權值就會變得稀疏,例如3*3的卷積核中,只有中間位置的權值有效,其餘的都變的很小,都不發揮作用了。因此效果上也就等價於1*1卷積了,所以可以使用1*1卷積替代rate=24的3*3空洞卷積。

as the sampling rate becomes larger, the number of valid filter weights (i.e., the weights that are applied to the valid feature region, instead of padded zeros) becomes smaller

4.去掉了DenseCRF後處理模塊

5.PASCAL VOC-2012 測試集達到了86.9%mIOU準確性


 

DeepLabv3+:

Encoder-Decoder with Atrous Separable Convolution for Semantic Image Segmentation

Github:https://github.com/tensorflow/models/tree/master/research/deeplab

https://github.com/rishizek/tensorflow-deeplab-v3-plus

 

相對deeplab v3的主要改進:

1.網絡結構增加了decoder模塊,整體結構變成Encoder-Decoder模塊。

a圖爲deeplab v2的結構,b圖爲Encoder-Decoder結構,c圖將a,b圖的結構進行了整和,也就是deeplab v3的結構。

2.基礎結構從Resnet101修改爲Xception,這樣引入了深度可分離卷積的思想,同時對其進行改進,將深度可分離卷積替代爲空洞深度可分離卷積。可以獲得比Resnet101更好的效果,更快的速度。

In particular, we explore the Xception model [26], similar to [31] for their COCO 2017 detection challenge submission, and show improvement in terms of both accuracy and speed for the task of semantic segmentation.

對Xception結構的改進主要有

    a.深度進行了加深,Middle Flow從原始的重複8次變爲重複16次

    b.Max pooling換成了stride=2的深度可分離卷積

    c.在3*3的深度可分離卷積後面增加BN+Relu

3.和v3版本一樣,沒有DenseCRF後處理模塊。

4.PASCAL VOC-2012 測試集達到了89.0%mIOU準確性。

 

整體結構:

另外,好多分割的框架中,數據增強這塊都會有一個_IGNORE_LABEL = 255的問題,這個是爲什麼呢?

因爲語義分割的時候,背景類別也是一個類別,網絡訓練的時候一般都是固定輸入大小的,數據增強有crop,resize,padding操作,padding的時候補的是0,並且padding的像素是不希望計算loss的。因此,爲了達到這個目的,實際操作的時候,首先,將label-_IGNORE_LABEL,然後再做padding=0操作,然後再label+_IGNORE_LABEL,這樣就可以通過忽略255的像素值,達到忽略padding的像素的目的。

def random_crop_or_pad_image_and_label(image, label, crop_height, crop_width, ignore_label):
  """Crops and/or pads an image to a target width and height.
  Resizes an image to a target width and height by rondomly
  cropping the image or padding it evenly with zeros.
  Args:
    image: 3-D Tensor of shape `[height, width, channels]`.
    label: 3-D Tensor of shape `[height, width, 1]`.
    crop_height: The new height.
    crop_width: The new width.
    ignore_label: Label class to be ignored.
  Returns:
    Cropped and/or padded image.
    If `images` was 3-D, a 3-D float Tensor of shape
    `[new_height, new_width, channels]`.
  """
  label = label - ignore_label  # Subtract due to 0 padding.
  label = tf.to_float(label)
  image_height = tf.shape(image)[0]
  image_width = tf.shape(image)[1]
  image_and_label = tf.concat([image, label], axis=2)
  image_and_label_pad = tf.image.pad_to_bounding_box(
      image_and_label, 0, 0,
      tf.maximum(crop_height, image_height),
      tf.maximum(crop_width, image_width))
  image_and_label_crop = tf.random_crop(
      image_and_label_pad, [crop_height, crop_width, 4])

  image_crop = image_and_label_crop[:, :, :3]
  label_crop = image_and_label_crop[:, :, 3:]
  label_crop += ignore_label
  label_crop = tf.to_int32(label_crop)

  return image_crop, label_crop

整體總結:

提升分割精度的方法,

  1. 空洞卷積提高感受野(large field-of-viewLargeFOV
  2. 多尺度預測(MSc
  3. 條件隨機場(CRF
  4. 基於並行或者cascade的空洞空間金字塔(ASPP),可以獲得不同尺度的更豐富的紋理信息。
  5. 更深的網絡結構,Xceptionresnet101效果更好,速度更快,
  6. Encoder-Decoder結構,decoder模塊可以獲得更好的邊界分割效果

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章