Shortcuts

mmagic.models.editors.plain.plain_decoder

Module Contents

Classes

MaxUnpool2dop

We warp the torch.nn.functional.max_unpool2d with an extra symbolic

MaxUnpool2d

This module is modified from Pytorch MaxUnpool2d module.

PlainDecoder

Simple decoder from Deep Image Matting.

class mmagic.models.editors.plain.plain_decoder.MaxUnpool2dop(*args, **kwargs)[source]

Bases: torch.autograd.Function

We warp the torch.nn.functional.max_unpool2d with an extra symbolic method, which is needed while exporting to ONNX.

Users should not call this function directly.

static forward(ctx, input, indices, kernel_size, stride, padding, output_size)[source]

Forward function of MaxUnpool2dop.

Parameters
  • input (Tensor) – Tensor needed to upsample.

  • indices (Tensor) – Indices output of the previous MaxPool.

  • kernel_size (Tuple) – Size of the max pooling window.

  • stride (Tuple) – Stride of the max pooling window.

  • padding (Tuple) – Padding that was added to the input.

  • output_size (List or Tuple) – The shape of output tensor.

Returns

Output tensor.

Return type

Tensor

static symbolic(g, input, indices, kernel_size, stride, padding, output_size)[source]

This is the function to define the module of MaxUnpool.

Parameters
  • g (_type_) – _description_

  • input (Tensor) – Tensor needed to upsample.

  • indices (Tensor) – Indices output of the previous MaxPool.

  • kernel_size (int) – Size of the max pooling window.

  • stride (Tuple) – Stride of the max pooling window.

  • padding (Tuple) – Padding that was added to the input.

  • output_size (List or Tuple) – The shape of output tensor.

Returns

_description_

Return type

_type_

class mmagic.models.editors.plain.plain_decoder.MaxUnpool2d(kernel_size, stride=None, padding=0)[source]

Bases: torch.nn.modules.pooling._MaxUnpoolNd

This module is modified from Pytorch MaxUnpool2d module.

Parameters
  • kernel_size (int or tuple) – Size of the max pooling window.

  • stride (int or tuple) – Stride of the max pooling window. Default: None (It is set to kernel_size by default).

  • padding (int or tuple) – Padding that is added to the input. Default: 0.

forward(input, indices, output_size=None)[source]

Forward function of MaxUnpool2d.

Parameters
  • input (Tensor) – Tensor needed to upsample.

  • indices (Tensor) – Indices output of the previous MaxPool.

  • output_size (List or Tuple) – The shape of output tensor. Default: None.

Returns

Output tensor.

Return type

Tensor

class mmagic.models.editors.plain.plain_decoder.PlainDecoder(in_channels, init_cfg: Optional[dict] = None)[source]

Bases: mmengine.model.BaseModule

Simple decoder from Deep Image Matting.

Parameters
  • in_channels (int) – Channel num of input features.

  • init_cfg (dict, optional) – Initialization config dict. Default: None.

init_weights()[source]

Init weights for the module.

forward(inputs)[source]

Forward function of PlainDecoder.

Parameters

inputs (dict) –

Output dictionary of the VGG encoder containing:

  • out (Tensor): Output of the VGG encoder.

  • max_idx_1 (Tensor): Index of the first maxpooling layer in the VGG encoder.

  • max_idx_2 (Tensor): Index of the second maxpooling layer in the VGG encoder.

  • max_idx_3 (Tensor): Index of the third maxpooling layer in the VGG encoder.

  • max_idx_4 (Tensor): Index of the fourth maxpooling layer in the VGG encoder.

  • max_idx_5 (Tensor): Index of the fifth maxpooling layer in the VGG encoder.

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.