Upscale2xBlock

class lib.model.nn_blocks.Upscale2xBlock(filters: int, kernel_size: int | tuple[int, int] = 3, padding: str = 'same', activation: str | None = 'leakyrelu', interpolation: str = 'bilinear', sr_ratio: float = 0.5, scale_factor: int = 2, fast: bool = False, **kwargs)

Bases: object

Custom hybrid upscale layer for sub-pixel up-scaling.

Most of up-scaling is approximating lighting gradients which can be accurately achieved using linear fitting. This layer attempts to improve memory consumption by splitting with bilinear and convolutional layers so that the sub-pixel update will get details whilst the bilinear filter will get lighting.

Adds reflection padding if it has been selected by the user, and other post-processing if requested by the plugin.

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. Default: 3

  • padding (["valid", "same"], optional) – The padding to use. Default: “same”

  • activation (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 to None to not apply an activation function. Default: “leakyrelu”

  • interpolation (["nearest", "bilinear"], optional) – Interpolation to use for up-sampling. Default: “bilinear”

  • scale_factor (int, optional) – The amount to upscale the image. Default: 2

  • sr_ratio (float, optional) – The proportion of super resolution (pixel shuffler) filters to use. Non-fast mode only. Default: 0.5

  • fast (bool, optional) – Use a faster up-scaling method that may appear more rugged. Default: False

  • kwargs (dict) – Any additional Keras standard layer keyword arguments to pass to the Convolutional 2D layer

Methods Summary

__call__(inputs)

Call the Faceswap Upscale 2x Layer.

Methods Documentation

__call__(inputs: KerasTensor) KerasTensor

Call the Faceswap Upscale 2x Layer.

Parameters:

inputs (keras.KerasTensor) – The input to the layer

Returns:

The output tensor from the Upscale Layer

Return type:

keras.KerasTensor

__call__(inputs: KerasTensor) KerasTensor

Call the Faceswap Upscale 2x Layer.

Parameters:

inputs (keras.KerasTensor) – The input to the layer

Returns:

The output tensor from the Upscale Layer

Return type:

keras.KerasTensor