Shortcuts

mmedit.models.editors.pggan.pggan_generator

Module Contents

Classes

PGGANGenerator

Generator for PGGAN.

class mmedit.models.editors.pggan.pggan_generator.PGGANGenerator(noise_size, out_scale, label_size=0, base_channels=8192, channel_decay=1.0, max_channels=512, fused_upconv=True, conv_module_cfg=None, fused_upconv_cfg=None, upsample_cfg=None)[源代码]

Bases: torch.nn.Module

Generator for PGGAN.

参数
  • noise_size (int) – Size of the input noise vector.

  • out_scale (int) – Output scale for the generated image.

  • label_size (int, optional) – Size of the label vector. Defaults to 0.

  • base_channels (int, optional) – The basic channel number of the generator. The other layers contains channels based on this number. Defaults to 8192.

  • channel_decay (float, optional) – Decay for channels of feature maps. Defaults to 1.0.

  • max_channels (int, optional) – Maximum channels for the feature maps in the generator block. Defaults to 512.

  • fused_upconv (bool, optional) – Whether use fused upconv. Defaults to True.

  • conv_module_cfg (dict, optional) – Config for the convolution module used in this generator. Defaults to None.

  • fused_upconv_cfg (dict, optional) – Config for the fused upconv module used in this generator. Defaults to None.

  • upsample_cfg (dict, optional) – Config for the upsampling operation. Defaults to None.

_default_fused_upconv_cfg[源代码]
_default_conv_module_cfg[源代码]
_default_upsample_cfg[源代码]
_get_torgb_layer(in_channels: int)[源代码]

Get the to-rgb layer based on in_channels.

参数

in_channels (int) – Number of input channels.

返回

To-rgb layer.

返回类型

nn.Module

_num_out_channels(log_scale: int)[源代码]

Calculate the number of output channels based on logarithm of current scale.

参数

log_scale (int) – The logarithm of the current scale.

返回

The current number of output channels.

返回类型

int

_get_upconv_block(in_channels, log_scale)[源代码]

Get the conv block for upsampling.

参数
  • in_channels (int) – The number of input channels.

  • log_scale (int) – The logarithmic of the current scale.

返回

The conv block for upsampling.

返回类型

nn.Module

forward(noise, label=None, num_batches=0, return_noise=False, transition_weight=1.0, curr_scale=- 1)[源代码]

Forward function.

参数
  • noise (torch.Tensor | callable | None) – You can directly give a batch of noise through a torch.Tensor or offer a callable function to sample a batch of noise data. Otherwise, the None indicates to use the default noise sampler.

  • label (Tensor, optional) – Label vector with shape [N, C]. Defaults to None.

  • num_batches (int, optional) – The number of batch size. Defaults to 0.

  • return_noise (bool, optional) – If True, noise_batch will be returned in a dict with fake_img. Defaults to False.

  • transition_weight (float, optional) – The weight used in resolution transition. Defaults to 1.0.

  • curr_scale (int, optional) – The scale for the current inference or training. Defaults to -1.

返回

If not return_noise, only the output image

will be returned. Otherwise, a dict contains fake_img and noise_batch will be returned.

返回类型

torch.Tensor | dict

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

Free document hosting provided by Read the Docs.