Shortcuts

mmedit.models.editors.pix2pix.pix2pix_generator

Module Contents

Classes

UnetGenerator

Construct the Unet-based generator from the innermost layer to the

class mmedit.models.editors.pix2pix.pix2pix_generator.UnetGenerator(in_channels, out_channels, num_down=8, base_channels=64, norm_cfg=dict(type='BN'), use_dropout=False, init_cfg=dict(type='normal', gain=0.02))[source]

Bases: torch.nn.Module

Construct the Unet-based generator from the innermost layer to the outermost layer, which is a recursive process.

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

  • out_channels (int) – Number of channels in output images.

  • num_down (int) – Number of downsamplings in Unet. If num_down is 8, the image with size 256x256 will become 1x1 at the bottleneck. Default: 8.

  • base_channels (int) – Number of channels at the last conv layer. Default: 64.

  • norm_cfg (dict) – Config dict to build norm layer. Default: dict(type=’BN’).

  • use_dropout (bool) – Whether to use dropout layers. Default: False.

  • init_cfg (dict) – Config dict for initialization. type: The name of our initialization method. Default: ‘normal’. gain: Scaling factor for normal, xavier and orthogonal. Default: 0.02.

forward(x)[source]

Forward function.

Parameters

x (Tensor) – Input tensor with shape (n, c, h, w).

Returns

Forward results.

Return type

Tensor

init_weights(pretrained=None, strict=True)[source]

Initialize weights for the model.

Parameters
  • pretrained (str, optional) – Path for pretrained weights. If given None, pretrained weights will not be loaded. Default: None.

  • strict (bool, optional) – Whether to allow different params for the model and checkpoint. Default: True.

Read the Docs v: latest
Versions
master
latest
stable
zyh-re-docs
zyh-doc-notfound-extend
zyh-api-rendering
Downloads
pdf
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.