Shortcuts

mmedit.models.editors.basicvsr.basicvsr_net

Module Contents

Classes

BasicVSRNet

BasicVSR network structure for video super-resolution.

ResidualBlocksWithInputConv

Residual blocks with a convolution in front.

SPyNet

SPyNet network structure.

SPyNetBasicModule

Basic Module for SPyNet.

class mmedit.models.editors.basicvsr.basicvsr_net.BasicVSRNet(mid_channels=64, num_blocks=30, spynet_pretrained=None)[源代码]

Bases: mmengine.model.BaseModule

BasicVSR network structure for video super-resolution.

Support only x4 upsampling.

Paper:

BasicVSR: The Search for Essential Components in Video Super-Resolution and Beyond, CVPR, 2021

参数
  • mid_channels (int) – Channel number of the intermediate features. Default: 64.

  • num_blocks (int) – Number of residual blocks in each propagation branch. Default: 30.

  • spynet_pretrained (str) – Pre-trained model path of SPyNet. Default: None.

check_if_mirror_extended(lrs)[源代码]

Check whether the input is a mirror-extended sequence.

If mirror-extended, the i-th (i=0, …, t-1) frame is equal to the (t-1-i)-th frame.

参数

lrs (tensor) – Input LR images with shape (n, t, c, h, w)

compute_flow(lrs)[源代码]

Compute optical flow using SPyNet for feature warping.

Note that if the input is an mirror-extended sequence, ‘flows_forward’ is not needed, since it is equal to ‘flows_backward.flip(1)’.

参数

lrs (tensor) – Input LR images with shape (n, t, c, h, w)

返回

Optical flow. ‘flows_forward’ corresponds to the

flows used for forward-time propagation (current to previous). ‘flows_backward’ corresponds to the flows used for backward-time propagation (current to next).

返回类型

tuple(Tensor)

forward(lrs)[源代码]

Forward function for BasicVSR.

参数

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

返回

Output HR sequence with shape (n, t, c, 4h, 4w).

返回类型

Tensor

class mmedit.models.editors.basicvsr.basicvsr_net.ResidualBlocksWithInputConv(in_channels, out_channels=64, num_blocks=30)[源代码]

Bases: mmengine.model.BaseModule

Residual blocks with a convolution in front.

参数
  • in_channels (int) – Number of input channels of the first conv.

  • out_channels (int) – Number of channels of the residual blocks. Default: 64.

  • num_blocks (int) – Number of residual blocks. Default: 30.

forward(feat)[源代码]

Forward function for ResidualBlocksWithInputConv.

参数

feat (Tensor) – Input feature with shape (n, in_channels, h, w)

返回

Output feature with shape (n, out_channels, h, w)

返回类型

Tensor

class mmedit.models.editors.basicvsr.basicvsr_net.SPyNet(pretrained)[源代码]

Bases: mmengine.model.BaseModule

SPyNet network structure.

The difference to the SPyNet in [tof.py] is that
  1. more SPyNetBasicModule is used in this version, and

  2. no batch normalization is used in this version.

Paper:

Optical Flow Estimation using a Spatial Pyramid Network, CVPR, 2017

参数

pretrained (str) – path for pre-trained SPyNet. Default: None.

compute_flow(ref, supp)[源代码]

Compute flow from ref to supp.

Note that in this function, the images are already resized to a multiple of 32.

参数
  • ref (Tensor) – Reference image with shape of (n, 3, h, w).

  • supp (Tensor) – Supporting image with shape of (n, 3, h, w).

返回

Estimated optical flow: (n, 2, h, w).

返回类型

Tensor

forward(ref, supp)[源代码]

Forward function of SPyNet.

This function computes the optical flow from ref to supp.

参数
  • ref (Tensor) – Reference image with shape of (n, 3, h, w).

  • supp (Tensor) – Supporting image with shape of (n, 3, h, w).

返回

Estimated optical flow: (n, 2, h, w).

返回类型

Tensor

class mmedit.models.editors.basicvsr.basicvsr_net.SPyNetBasicModule[源代码]

Bases: mmengine.model.BaseModule

Basic Module for SPyNet.

Paper:

Optical Flow Estimation using a Spatial Pyramid Network, CVPR, 2017

forward(tensor_input)[源代码]
参数

tensor_input (Tensor) – Input tensor with shape (b, 8, h, w). 8 channels contain: [reference image (3), neighbor image (3), initial flow (2)].

返回

Refined flow with shape (b, 2, h, w)

返回类型

Tensor

Read the Docs v: latest
Versions
master
latest
stable
zyh-doc-notfound-extend
Downloads
pdf
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.