Conv2DBlock
- class lib.model.nn_blocks.Conv2DBlock(filters: int, kernel_size: int | tuple[int, int] = 5, strides: int | tuple[int, int] = 2, padding: str = 'same', normalization: str | None = None, activation: str | None = 'leakyrelu', use_depthwise: bool = False, relu_alpha: float = 0.1, **kwargs)
Bases:
objectA standard Convolution 2D layer which applies user specified configuration to the layer.
Adds reflection padding if it has been selected by the user, and other post-processing if requested by the plugin.
Adds instance normalization if requested. Adds a LeakyReLU if a residual block follows.
- Parameters:
filters (int) – The dimensionality of the output space (i.e. the number of output filters in the convolution)
kernel_size (int, optional) – An integer or tuple/list of 2 integers, specifying the height and width of the 2D convolution window. Can be a single integer to specify the same value for all spatial dimensions. NB: If use_depthwise is
Truethen a value must still be provided here, but it will be ignored. Default: 5strides (tuple or int, optional) – An integer or tuple/list of 2 integers, specifying the strides of the convolution along the height and width. Can be a single integer to specify the same value for all spatial dimensions. Default: 2
padding (["valid", "same"], optional) – The padding to use. NB: If reflect padding has been selected in the user configuration options, then this argument will be ignored in favor of reflect padding. Default: “same”
normalization (str or
None, optional) – Normalization to apply after the Convolution Layer. Select one of “batch” or “instance”. Set toNoneto not apply normalization. Default:Noneactivation (str or
None, optional) – The activation function to use. This is applied at the end of the convolution block. Select one of “leakyrelu”, “prelu” or “swish”. Set toNoneto not apply an activation function. Default: “leakyrelu”use_depthwise (bool, optional) – Set to
Trueto use a Depthwise Convolution 2D layer rather than a standard Convolution 2D layer. Default:Falserelu_alpha (float) – The alpha to use for LeakyRelu Activation. Default=`0.1`
kwargs (dict) – Any additional Keras standard layer keyword arguments to pass to the Convolutional 2D layer
Methods Summary
__call__(inputs)Call the Faceswap Convolutional Layer.
Methods Documentation
- __call__(inputs: KerasTensor) KerasTensor
Call the Faceswap Convolutional Layer.
- Parameters:
inputs (
keras.KerasTensor) – The input to the layer- Returns:
The output tensor from the Convolution 2D Layer
- Return type:
keras.KerasTensor
- __call__(inputs: KerasTensor) KerasTensor
Call the Faceswap Convolutional Layer.
- Parameters:
inputs (
keras.KerasTensor) – The input to the layer- Returns:
The output tensor from the Convolution 2D Layer
- Return type:
keras.KerasTensor