basicsr.archs.duf_arch

class basicsr.archs.duf_arch.DUF(scale=4, num_layer=52, adapt_official_weights=False)[source]

Bases: Module

Network architecture for DUF

Paper: Deep Video Super-Resolution Network Using Dynamic Upsampling Filters Without Explicit Motion Compensation

Reference: https://github.com/yhjo09/VSR-DUF

For all the models below, ‘adapt_official_weights’ is only necessary when loading the weights converted from the official TensorFlow weights. Please set it to False if you are training the model from scratch.

There are three models with different model size: DUF16Layers, DUF28Layers, and DUF52Layers. This class is the base class for these models.

Parameters:
  • scale (int) – The upsampling factor. Default: 4.

  • num_layer (int) – The number of layers. Default: 52.

  • adapt_official_weights_weights (bool) – Whether to adapt the weights translated from the official implementation. Set to false if you want to train from scratch. Default: False.

forward(x)[source]
Parameters:

x (Tensor) – Input with shape (b, 7, c, h, w)

Returns:

Output with shape (b, c, h * scale, w * scale)

Return type:

Tensor

training: bool
class basicsr.archs.duf_arch.DenseBlocks(num_block, num_feat=64, num_grow_ch=16, adapt_official_weights=False)[source]

Bases: Module

A concatenation of N dense blocks.

Parameters:
  • num_feat (int) – Number of channels in the blocks. Default: 64.

  • num_grow_ch (int) – Growing factor of the dense blocks. Default: 32.

  • num_block (int) – Number of dense blocks. The values are: DUF-S (16 layers): 3 DUF-M (18 layers): 9 DUF-L (52 layers): 21

  • adapt_official_weights (bool) – Whether to adapt the weights translated from the official implementation. Set to false if you want to train from scratch. Default: False.

forward(x)[source]
Parameters:

x (Tensor) – Input tensor with shape (b, num_feat, t, h, w).

Returns:

Output with shape (b, num_feat + num_block * num_grow_ch, t, h, w).

Return type:

Tensor

training: bool
class basicsr.archs.duf_arch.DenseBlocksTemporalReduce(num_feat=64, num_grow_ch=32, adapt_official_weights=False)[source]

Bases: Module

A concatenation of 3 dense blocks with reduction in temporal dimension.

Note that the output temporal dimension is 6 fewer the input temporal dimension, since there are 3 blocks.

Parameters:
  • num_feat (int) – Number of channels in the blocks. Default: 64.

  • num_grow_ch (int) – Growing factor of the dense blocks. Default: 32

  • adapt_official_weights (bool) – Whether to adapt the weights translated from the official implementation. Set to false if you want to train from scratch. Default: False.

forward(x)[source]
Parameters:

x (Tensor) – Input tensor with shape (b, num_feat, t, h, w).

Returns:

Output with shape (b, num_feat + num_grow_ch * 3, 1, h, w).

Return type:

Tensor

training: bool
class basicsr.archs.duf_arch.DynamicUpsamplingFilter(filter_size=(5, 5))[source]

Bases: Module

Dynamic upsampling filter used in DUF.

Reference: https://github.com/yhjo09/VSR-DUF

It only supports input with 3 channels. And it applies the same filters to 3 channels.

Parameters:

filter_size (tuple) – Filter size of generated filters. The shape is (kh, kw). Default: (5, 5).

forward(x, filters)[source]

Forward function for DynamicUpsamplingFilter.

Parameters:
  • x (Tensor) – Input image with 3 channels. The shape is (n, 3, h, w).

  • filters (Tensor) – Generated dynamic filters. The shape is (n, filter_prod, upsampling_square, h, w). filter_prod: prod of filter kernel size, e.g., 1*5*5=25. upsampling_square: similar to pixel shuffle, upsampling_square = upsampling * upsampling. e.g., for x 4 upsampling, upsampling_square= 4*4 = 16

Returns:

Filtered image with shape (n, 3*upsampling_square, h, w)

Return type:

Tensor

training: bool