mmagic.models.editors.cyclegan.cyclegan_modules
¶
Module Contents¶
Classes¶
Define a Residual Block with dropout layers. |
|
This class implements an image buffer that stores previously generated |
- class mmagic.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.
- class mmagic.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.