basicsr.archs.hifacegan_arch¶
- class basicsr.archs.hifacegan_arch.HiFaceGAN(num_in_ch=3, num_feat=64, use_vae=False, z_dim=256, crop_size=512, norm_g='spectralspadesyncbatch3x3', is_train=True, init_train_phase=3)[source]¶
Bases:
SPADEGenerator
HiFaceGAN: SPADEGenerator with a learnable feature encoder Current encoder design: LIPEncoder
- encode(input_tensor)[source]¶
Encode input_tensor into feature maps, can be overridden in derived classes Default: nearest downsampling of 2**5 = 32 times
- training: bool¶
- class basicsr.archs.hifacegan_arch.HiFaceGANDiscriminator(num_in_ch=3, num_out_ch=3, conditional_d=True, num_d=2, n_layers_d=4, num_feat=64, norm_d='spectralinstance', keep_features=True)[source]¶
Bases:
BaseNetwork
Inspired by pix2pixHD multiscale discriminator.
- Parameters:
num_in_ch (int) – Channel number of inputs. Default: 3.
num_out_ch (int) – Channel number of outputs. Default: 3.
conditional_d (bool) – Whether use conditional discriminator. Default: True.
num_d (int) – Number of Multiscale discriminators. Default: 3.
n_layers_d (int) – Number of downsample layers in each D. Default: 4.
num_feat (int) – Channel number of base intermediate features. Default: 64.
norm_d (str) – String to determine normalization layers in D. Choices: [spectral][instance/batch/syncbatch] Default: ‘spectralinstance’.
keep_features (bool) – Keep intermediate features for matching loss, etc. Default: True.
- forward(x)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- training: bool¶
- class basicsr.archs.hifacegan_arch.NLayerDiscriminator(input_nc, n_layers_d, num_feat, norm_d, keep_features)[source]¶
Bases:
BaseNetwork
Defines the PatchGAN discriminator with the specified arguments.
- forward(x)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- training: bool¶
- class basicsr.archs.hifacegan_arch.SPADEGenerator(num_in_ch=3, num_feat=64, use_vae=False, z_dim=256, crop_size=512, norm_g='spectralspadesyncbatch3x3', is_train=True, init_train_phase=3)[source]¶
Bases:
BaseNetwork
Generator with SPADEResBlock
- encode(input_tensor)[source]¶
Encode input_tensor into feature maps, can be overridden in derived classes Default: nearest downsampling of 2**5 = 32 times
- forward(x)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- mixed_guidance_forward(input_x, seg=None, n=0, mode='progressive')[source]¶
A helper class for subspace visualization. Input and seg are different images. For the first n levels (including encoder) we use input, for the rest we use seg.
If mode = ‘progressive’, the output’s like: AAABBB If mode = ‘one_plug’, the output’s like: AAABAA If mode = ‘one_ablate’, the output’s like: BBBABB
- training: bool¶