biapy.models.wdsr

This module implements the Wide Activation for Efficient and Accurate Image Super-Resolution (WDSR) model.

WDSR is a convolutional neural network designed for single image super-resolution. It introduces “wide activation” (using a larger number of feature maps in intermediate layers of residual blocks) and employs weight normalization to stabilize training and improve performance. The model consists of an initial convolutional layer, a series of residual blocks, a final reconstruction layer, and a skip connection with a PixelShuffle layer for upsampling.

Classes:

  • wdsr: The main WDSR model.

  • Block: The residual block used within the WDSR architecture.

Reference: Wide Activation for Efficient and Accurate Image Super-Resolution.

Adapted from: https://github.com/yjn870/WDSR-pytorch/tree/master

class biapy.models.wdsr.wdsr(scale, num_filters=32, num_res_blocks=16, res_block_expansion=6, num_channels=1)[source]

Bases: Module

WDSR (Wide Activation for Efficient and Accurate Image Super-Resolution) model.

This model is designed for single image super-resolution, aiming to reconstruct a high-resolution image from a low-resolution input. It utilizes residual blocks with wide activations and weight normalization for improved efficiency and accuracy.

Reference: Wide Activation for Efficient and Accurate Image Super-Resolution.

Adapted from here.

forward(x) Tensor[source]

Perform the forward pass of the WDSR model.

The input x first passes through the main body of the network. A skip connection (potentially with a convolution) is added to the output of the main body. Finally, the combined features are passed through the PixelShuffle layer for super-resolution.

Parameters:

x (torch.Tensor) – The input low-resolution image tensor. Expected shape: (batch_size, num_channels, H_lr, W_lr).

Returns:

The super-resolved high-resolution image tensor. Expected shape: (batch_size, num_channels, H_hr, W_hr), where H_hr = H_lr * scale and W_hr = W_lr * scale.

Return type:

torch.Tensor

class biapy.models.wdsr.Block(num_residual_units, kernel_size, width_multiplier=1, weight_norm=<function weight_norm>, res_scale=1)[source]

Bases: Module

Residual block used in the WDSR model.

This block implements the “wide activation” concept by expanding the number of channels in its intermediate convolutional layer. It includes a residual connection and applies weight normalization.

forward(x)[source]

Perform the forward pass of the residual block.

The input x is processed through the convolutional path. The output of this path is then added to the original input x via a residual connection.

Parameters:

x (torch.Tensor) – The input feature tensor to the residual block.

Returns:

The output feature tensor after applying the residual block. Same shape as input x.

Return type:

torch.Tensor