mmagic.models.editors.basicvsr_plusplus_net.basicvsr_plusplus_net
¶
Module Contents¶
Classes¶
BasicVSR++ network structure. |
|
Second-order deformable alignment module. |
- class mmagic.models.editors.basicvsr_plusplus_net.basicvsr_plusplus_net.BasicVSRPlusPlusNet(mid_channels=64, num_blocks=7, max_residue_magnitude=10, is_low_res_input=True, spynet_pretrained=None, cpu_cache_length=100)[源代码]¶
Bases:
mmengine.model.BaseModule
BasicVSR++ network structure.
Support either x4 upsampling or same size output.
- Paper:
BasicVSR++: Improving Video Super-Resolution with Enhanced Propagation and Alignment
- 参数
mid_channels (int, optional) – Channel number of the intermediate features. Default: 64.
num_blocks (int, optional) – The number of residual blocks in each propagation branch. Default: 7.
max_residue_magnitude (int) – The maximum magnitude of the offset residue (Eq. 6 in paper). Default: 10.
is_low_res_input (bool, optional) – Whether the input is low-resolution or not. If False, the output resolution is equal to the input resolution. Default: True.
spynet_pretrained (str, optional) – Pre-trained model path of SPyNet. Default: None.
cpu_cache_length (int, optional) – When the length of sequence is larger than this value, the intermediate features are sent to CPU. This saves GPU memory, but slows down the inference speed. You can increase this number if you have a GPU with large memory. Default: 100.
- check_if_mirror_extended(lqs)[源代码]¶
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.
- 参数
lqs (tensor) – Input low quality (LQ) sequence with shape (n, t, c, h, w).
- compute_flow(lqs)[源代码]¶
Compute optical flow using SPyNet for feature alignment.
Note that if the input is an mirror-extended sequence, ‘flows_forward’ is not needed, since it is equal to ‘flows_backward.flip(1)’.
- 参数
lqs (tensor) – Input low quality (LQ) sequence 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)
- propagate(feats, flows, module_name)[源代码]¶
Propagate the latent features throughout the sequence.
- 参数
dict (feats) – Features from previous branches. Each component is a list of tensors with shape (n, c, h, w).
flows (tensor) – Optical flows with shape (n, t - 1, 2, h, w).
module_name (str) – The name of the propagation branches. Can either be ‘backward_1’, ‘forward_1’, ‘backward_2’, ‘forward_2’.
- 返回
- A dictionary containing all the propagated
features. Each key in the dictionary corresponds to a propagation branch, which is represented by a list of tensors.
- 返回类型
dict(list[tensor])
- class mmagic.models.editors.basicvsr_plusplus_net.basicvsr_plusplus_net.SecondOrderDeformableAlignment(*args, **kwargs)[源代码]¶
Bases:
mmcv.ops.ModulatedDeformConv2d
Second-order deformable alignment module.
- 参数
in_channels (int) – Same as nn.Conv2d.
out_channels (int) – Same as nn.Conv2d.
kernel_size (int or tuple[int]) – Same as nn.Conv2d.
stride (int or tuple[int]) – Same as nn.Conv2d.
padding (int or tuple[int]) – Same as nn.Conv2d.
dilation (int or tuple[int]) – Same as nn.Conv2d.
groups (int) – Same as nn.Conv2d.
bias (bool or str) – If specified as auto, it will be decided by the norm_cfg. Bias will be set as True if norm_cfg is None, otherwise False.
max_residue_magnitude (int) – The maximum magnitude of the offset residue (Eq. 6 in paper). Default: 10.