mmagic.models.editors.pggan.pggan_discriminator
¶
Module Contents¶
Classes¶
Discriminator for PGGAN. |
- class mmagic.models.editors.pggan.pggan_discriminator.PGGANDiscriminator(in_scale, label_size=0, base_channels=8192, max_channels=512, in_channels=3, channel_decay=1.0, mbstd_cfg=dict(group_size=4), fused_convdown=True, conv_module_cfg=None, fused_convdown_cfg=None, fromrgb_layer_cfg=None, downsample_cfg=None)[source]¶
Bases:
mmengine.model.BaseModule
Discriminator for PGGAN.
- Parameters
in_scale (int) – The scale of the input 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.
max_channels (int, optional) – Maximum channels for the feature maps in the discriminator block. Defaults to 512.
in_channels (int, optional) – Number of channels in input images. Defaults to 3.
channel_decay (float, optional) – Decay for channels of feature maps. Defaults to 1.0.
mbstd_cfg (dict, optional) – Configs for minibatch-stddev layer. Defaults to dict(group_size=4).
fused_convdown (bool, optional) – Whether use fused downconv. Defaults to True.
conv_module_cfg (dict, optional) – Config for the convolution module used in this generator. Defaults to None.
fused_convdown_cfg (dict, optional) – Config for the fused downconv module used in this discriminator. Defaults to None.
fromrgb_layer_cfg (dict, optional) – Config for the fromrgb layer. Defaults to None.
downsample_cfg (dict, optional) – Config for the downsampling operation. Defaults to None.
- _num_out_channels(log_scale: int) int [source]¶
Calculate the number of output channels of the current network from logarithm of current scale.
- Parameters
log_scale (int) – The logarithm of the current scale.
- Returns
The number of output channels.
- Return type
int
- _get_fromrgb_layer(in_channels: int, log2_scale: int) torch.nn.Module [source]¶
Get the ‘fromrgb’ layer from logarithm of current scale.
- Parameters
in_channels (int) – The number of input channels.
log2_scale (int) – The logarithm of the current scale.
- Returns
The built from-rgb layer.
- Return type
nn.Module
- _get_convdown_block(in_channels: int, log2_scale: int) torch.nn.Module [source]¶
Get the downsample layer from logarithm of current scale.
- Parameters
in_channels (int) – The number of input channels.
log2_scale (int) – The logarithm of the current scale.
- Returns
The built Conv layer.
- Return type
nn.Module
- forward(x, transition_weight=1.0, curr_scale=- 1)[source]¶
Forward function.
- Parameters
x (torch.Tensor) – Input image tensor.
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.
- Returns
Predict score for the input image.
- Return type
Tensor