ModelBuilder

build_enhanced_resnet(upsample_factor=2, num_filters=64, num_rrdb_blocks=16, num_dense_blocks=3, num_convs=4, kernel_size=3, residual_scaling_factor=0.2, input_dims=None, None)[source]

Residual-in-Residual Dense Block Network as specified in ESRGAN paper (https://arxiv.org/abs/1809.00219).

Parameters
  • upsample_factor – Factor for increase in resolution, needs to be in [2, 4, 8].

  • num_filters – Number of filters in convolutional blocks.

  • num_rrdb_blocks – Number of residual-in-residual dense building blocks.

  • num_dense_blocks – Number of dense blocks inside rrdb blocks.

  • num_convs – Number of convolutions inside dense blocks.

  • kernel_size – Kernel size of filter for convolutions.

  • residual_scaling_factor – Scaling factor between dense blocks inside rrdb blocks.

  • input_dims – Tuple of (Height, Width) for input to network - may be (None, None) for fully convolutional architecture.

Returns

Object of type Keras.model.

build_resnet(upsample_factor=2, num_filters=64, num_res_blocks=16, momentum=0.8, input_dims=None, None, batch_normalization=True)[source]

Resnet as specified in SRGAN paper (https://arxiv.org/abs/1609.04802)

Parameters
  • upsample_factor – Factor for increase in resolution, needs to be in [2, 4, 8].

  • num_filters – Number of filters in convolutional blocks.

  • num_res_blocks – Number of residual blocks.

  • momentum – Momentum for batch normalization.

  • input_dims – Tuple of (Height, Width) for input to network - may be (None, None) for fully convolutional architecture.

  • batch_normalization – Whether to include batch normalization layers in architecture.

Returns

Object of type Keras.model.

build_discriminator(input_dims=None, None, num_filters=64, alpha=0.2, kernel_size=3, momentum=0.8, relativistic=False, initializer=None)[source]

Discriminator for SRGAN/ESRGAN as specified in both papers.

Parameters
  • input_dims – Tuple of (Height, Width) for input images to discriminator.

  • num_filters – Number of filters in convolutional blocks.

  • alpha – Alpha value for LeakyReLU activation function.

  • kernel_size – Kernel size of filter for convolutions.

  • momentum – Momentum for batch normalization.

  • relativistic

    Whether discriminator will be used in a standard GAN setting, or in a relativistic GAN setting.
    When relativistic is True, no Sigmoid layer will be added as the last layer of the network.

  • initializer

    Initializer for network layers.
    If none He normal initialization with a scale of 0.2 will be used.

Returns

Object of type Keras.model.

build_vgg_19(input_shape=None, None, load_custom_weights=False, custom_weights_path=None)[source]

Builds a copy of VGG19. This way it is possible to obtain feature maps before activation layers, whereas in the original VGG19 the activations are baked into the convolutional layers and therefore can’t be accessed.

Parameters
  • input_shape – Tuple of (Height, Width) for input to network - may be (None, None) for fully convolutional architecture.

  • load_custom_weights – Initialize network with custom weights, for instance from a network trained

on face recognition. :param custom_weights_path: Path to custom weights file (.h5 file). :return: Object of type Keras.model.

build_vgg_16(input_shape, load_custom_weights=False, custom_weights_path=None)[source]

Builds a copy of VGG16. This way it is possible to obtain feature maps before activation layers, whereas in the original VGG16 the activations are baked into the convolutional layers and therefore can’t be accessed.

Parameters
  • input_shape – Tuple of (Height, Width) for input to network - may be (None, None) for fully convolutional architecture.

  • load_custom_weights – Initialize network with custom weights, for instance from a network trained

on face recognition. :param custom_weights_path: Path to custom weights file (.h5 file). :return: Object of type Keras.model.