basicsr.archs.basicvsr_arch

class basicsr.archs.basicvsr_arch.BasicVSR(num_feat=64, num_block=15, spynet_path=None)[source]

Bases: Module

A recurrent network for video SR. Now only x4 is supported.

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

  • num_block (int) – Number of residual blocks for each branch. Default: 15

  • spynet_path (str) – Path to the pretrained weights of SPyNet. Default: None.

forward(x)[source]

Forward function of BasicVSR.

Parameters:

x – Input frames with shape (b, n, c, h, w). n is the temporal dimension / number of frames.

get_flow(x)[source]
training: bool
class basicsr.archs.basicvsr_arch.ConvResidualBlocks(num_in_ch=3, num_out_ch=64, num_block=15)[source]

Bases: Module

Conv and residual block used in BasicVSR.

Parameters:
  • num_in_ch (int) – Number of input channels. Default: 3.

  • num_out_ch (int) – Number of output channels. Default: 64.

  • num_block (int) – Number of residual blocks. Default: 15.

forward(fea)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class basicsr.archs.basicvsr_arch.EDVRFeatureExtractor(num_input_frame, num_feat, load_path)[source]

Bases: Module

EDVR feature extractor used in IconVSR.

Parameters:
  • num_input_frame (int) – Number of input frames.

  • num_feat (int) – Number of feature channels

  • load_path (str) – Path to the pretrained weights of EDVR. Default: None.

forward(x)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class basicsr.archs.basicvsr_arch.IconVSR(num_feat=64, num_block=15, keyframe_stride=5, temporal_padding=2, spynet_path=None, edvr_path=None)[source]

Bases: Module

IconVSR, proposed also in the BasicVSR paper.

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

  • num_block (int) – Number of residual blocks for each branch. Default: 15.

  • keyframe_stride (int) – Keyframe stride. Default: 5.

  • temporal_padding (int) – Temporal padding. Default: 2.

  • spynet_path (str) – Path to the pretrained weights of SPyNet. Default: None.

  • edvr_path (str) – Path to the pretrained EDVR model. Default: None.

forward(x)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

get_flow(x)[source]
get_keyframe_feature(x, keyframe_idx)[source]
pad_spatial(x)[source]

Apply padding spatially.

Since the PCD module in EDVR requires that the resolution is a multiple of 4, we apply padding to the input LR images if their resolution is not divisible by 4.

Parameters:

x (Tensor) – Input LR sequence with shape (n, t, c, h, w).

Returns:

Padded LR sequence with shape (n, t, c, h_pad, w_pad).

Return type:

Tensor

training: bool