Shortcuts

mmagic.models.archs.aspp

Module Contents

Classes

ASPPPooling

ASPP Pooling module.

ASPP

ASPP module from DeepLabV3.

class mmagic.models.archs.aspp.ASPPPooling(in_channels: int, out_channels: int, conv_cfg: Optional[dict], norm_cfg: Optional[dict], act_cfg: Optional[dict])[source]

Bases: torch.nn.Sequential

ASPP Pooling module.

The code is adopted from https://github.com/pytorch/vision/blob/master/torchvision/models/ segmentation/deeplabv3.py

Parameters
  • in_channels (int) – Input channels of the module.

  • out_channels (int) – Output channels of the module.

  • conv_cfg (dict) – Config dict for convolution layer. If “None”, nn.Conv2d will be applied.

  • norm_cfg (dict) – Config dict for normalization layer.

  • act_cfg (dict) – Config dict for activation layer.

forward(x: torch.Tensor) torch.Tensor[source]

Forward function for ASPP Pooling module.

Parameters

x (Tensor) – Input tensor.

Returns

Output tensor.

Return type

Tensor

class mmagic.models.archs.aspp.ASPP(in_channels: int, out_channels: int = 256, mid_channels: int = 256, dilations: Sequence[int] = (12, 24, 36), conv_cfg: Optional[dict] = None, norm_cfg: Optional[dict] = dict(type='BN'), act_cfg: Optional[dict] = dict(type='ReLU'), separable_conv: bool = False)[source]

Bases: torch.nn.Module

ASPP module from DeepLabV3.

The code is adopted from https://github.com/pytorch/vision/blob/master/torchvision/models/ segmentation/deeplabv3.py

For more information about the module: “Rethinking Atrous Convolution for Semantic Image Segmentation”.

Parameters
  • in_channels (int) – Input channels of the module.

  • out_channels (int) – Output channels of the module. Default: 256.

  • mid_channels (int) – Output channels of the intermediate ASPP conv modules. Default: 256.

  • dilations (Sequence[int]) – Dilation rate of three ASPP conv module. Default: [12, 24, 36].

  • conv_cfg (dict) – Config dict for convolution layer. If “None”, nn.Conv2d will be applied. Default: None.

  • norm_cfg (dict) – Config dict for normalization layer. Default: dict(type=’BN’).

  • act_cfg (dict) – Config dict for activation layer. Default: dict(type=’ReLU’).

  • separable_conv (bool) – Whether replace normal conv with depthwise separable conv which is faster. Default: False.

forward(x: torch.Tensor) torch.Tensor[source]

Forward function for ASPP module.

Parameters

x (Tensor) – Input tensor with shape (N, C, H, W).

Returns

Output tensor.

Return type

Tensor

Read the Docs v: latest
Versions
latest
stable
0.x
Downloads
pdf
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.