Shortcuts

mmedit.models.editors.cyclegan.cyclegan_modules

Module Contents

Classes

ResidualBlockWithDropout

Define a Residual Block with dropout layers.

GANImageBuffer

This class implements an image buffer that stores previously generated

class mmedit.models.editors.cyclegan.cyclegan_modules.ResidualBlockWithDropout(channels, padding_mode, norm_cfg=dict(type='BN'), use_dropout=True)[source]

Bases: torch.nn.Module

Define a Residual Block with dropout layers.

Ref: Deep Residual Learning for Image Recognition

A residual block is a conv block with skip connections. A dropout layer is added between two common conv modules.

Parameters
  • channels (int) – Number of channels in the conv layer.

  • padding_mode (str) – The name of padding layer: ‘reflect’ | ‘replicate’ | ‘zeros’.

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

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

forward(x)[source]

Forward function. Add skip connections without final ReLU.

Parameters

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

Returns

Forward results.

Return type

Tensor

class mmedit.models.editors.cyclegan.cyclegan_modules.GANImageBuffer(buffer_size, buffer_ratio=0.5)[source]

This class implements an image buffer that stores previously generated images.

This buffer allows us to update the discriminator using a history of generated images rather than the ones produced by the latest generator to reduce model oscillation.

Parameters
  • buffer_size (int) – The size of image buffer. If buffer_size = 0, no buffer will be created.

  • buffer_ratio (float) – The chance / possibility to use the images previously stored in the buffer. Default: 0.5.

query(images)[source]

Query current image batch using a history of generated images.

Parameters

images (Tensor) – Current image batch without history information.

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.