DeepLab

Utility

Decoder

class chainercv.links.model.deeplab.Decoder(in_channels, out_channels, proj_channels, depth_channels, bn_kwargs={})[source]

Decoder for DeepLab V3+.

Parameters
  • in_channels (int) – Number of channels of input arrays.

  • out_channels (int) – Number of channels of output arrays.

  • proj_channels (int) – Number of channels of output of first 1x1 convolution.

  • depth_channels (int) – Number of channels of output of convolution after concatenation.

  • bn_kwargs (dict) – Keywod arguments passed to initialize the batch normalization layers of chainercv.links.Conv2DBNActiv and chainercv.links.SeparableConv2DBNActiv.

DeepLabV3plus

class chainercv.links.model.deeplab.DeepLabV3plus(feature_extractor, aspp, decoder, min_input_size, scales=(1.0, ), flip=False)[source]

Base class of DeepLab V3+.

Parameters
  • fature_extractor (callable) – Feature extractor network. This network should return lowlevel and highlevel feature maps as (lowlevel, highlevel).

  • aspp (callable) – ASPP network.

  • decoder (callable) – Decoder network.

  • min_input_size (int or tuple of ints) – Minimum image size of inputs. if height or width is lower than this values, input images are padded to be this shape. The default value is (513, 513)

  • scales (tuple of floats) – Scales for multi-scale prediction. Final outputs are averaged after softmax activation. The default value is (1.0,).

  • flip (bool) – When this is true, a left-right flipped images are also input and finally averaged. When len(scales) are more than 1, flipped prediction is performed in each scales. The default value is False

predict(imgs)[source]

Conduct semantic segmentation from images.

Parameters

imgs (iterable of numpy.ndarray) – Arrays holding images. All images are in CHW and RGB format and the range of their values are \([0, 255]\).

Returns

List of integer labels predicted from each image in the input list.

Return type

list of numpy.ndarray

prepare(image)[source]

Preprocess an image for feature extraction.

  1. padded by mean pixel defined in feature extractor.

  2. scaled to [-1.0, 1.0]

After resizing the image, the image is subtracted by a mean image value self.mean.

Parameters

image (ndarray) – An image. This is in CHW and RGB format. The range of its value is \([0, 255]\).

Returns

A preprocessed image.

Return type

ndarray

SeparableASPP

class chainercv.links.model.deeplab.SeparableASPP(in_channels, out_channels, dilate_list=(12, 24, 36), bn_kwargs={})[source]

Atrous Spatial Pyramid Pooling with Separable Convolution.

average pooling with FC layer 1x1 Convolution

in –> Separable Convolution(k=12) –> concat –> 1x1 Convolution

Separable Convolution(k=24) Separable Convolution(k=36)

Parameters
  • in_channels (int) – Number of channels of input arrays.

  • out_channels (int) – Number of channels of output arrays.

  • dilate_list (tuple of ints) – Tuple of Dilation factors. the length of this tuple must be 3.

  • bn_kwargs (dict) – Keywod arguments passed to initialize the batch normalization layers of chainercv.links.Conv2DBNActiv and chainercv.links.SeparableConv2DBNActiv.

Xception65

class chainercv.links.model.deeplab.Xception65(bn_kwargs={})[source]

Xception65 for backbone network of DeepLab v3+.

Unlike original Xception65, this follows implementation in deeplab v3 (https://github.com/tensorflow/models/tree/master/research/deeplab). This returns lowlevel feature (an output of second convolution in second block in entryflow) and highlevel feature (an output before final average pooling in original).

Parameters

bn_kwargs (dict) – Keywod arguments passed to initialize the batch normalization layers of chainercv.links.Conv2DBNActiv and chainercv.links.SeparableConv2DBNActiv.

XceptionBlock

class chainercv.links.model.deeplab.XceptionBlock(in_channels, depthlist, stride=1, dilate=1, skip_type='conv', activ_first=True, bn_kwargs={}, dw_activ_list=[None, None, None], pw_activ_list=[<function relu>, <function relu>, None])[source]

A building block for Xceptions.

Not only final outputs, this block also returns unactivated outputs of second separable convolution.

Parameters
  • in_channels (int) – The number of channels of the input array.

  • depthlist (tuple of ints) – Tuple of integers which defines number of channels of intermediate arrays. The length of this tuple must be 3.

  • stride (int or tuple of ints) – Stride of filter application.

  • dilate (int or tuple of ints) – Dilation factor of filter applications. dilate=d and dilate=(d, d) are equivalent.

  • skip_type (string) – the type of skip connection. If sum, original input is summed to output of network directly. When conv, convolution layer is applied before summation. When none, skip connection is not used. The default value is conv.

  • activ_first (boolean) – If True, activation function is applied first in this block. The default value is True

  • bn_kwargs (dict) – Keywod arguments passed to initialize the batch normalization layers of chainercv.links.Conv2DBNActiv and chainercv.links.SeparableConv2DBNActiv.