mmagic.models.editors.iconvsr
¶
Package Contents¶
Classes¶
IconVSR network structure for video super-resolution. |
- class mmagic.models.editors.iconvsr.IconVSRNet(mid_channels=64, num_blocks=30, keyframe_stride=5, padding=2, spynet_pretrained=None, edvr_pretrained=None)[source]¶
Bases:
mmengine.model.BaseModule
IconVSR 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
- Parameters
mid_channels (int) – Channel number of the intermediate features. Default: 64.
num_blocks (int) – Number of residual blocks in each propagation branch. Default: 30.
keyframe_stride (int) – Number determining the keyframes. If stride=5, then the (0, 5, 10, 15, …)-th frame will be the keyframes. Default: 5.
padding (int) – Number of frames to be padded at two ends of the sequence. 2 for REDS and 3 for Vimeo-90K. Default: 2.
spynet_pretrained (str) – Pre-trained model path of SPyNet. Default: None.
edvr_pretrained (str) – Pre-trained model path of EDVR (for refill). Default: None.
- spatial_padding(lrs)[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
lrs (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
- check_if_mirror_extended(lrs)[source]¶
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.
- Parameters
lrs (tensor) – Input LR images with shape (n, t, c, h, w)
- compute_refill_features(lrs, keyframe_idx)[source]¶
Compute keyframe features for information-refill.
Since EDVR-M is used, padding is performed before feature computation. :param lrs: Input LR images with shape (n, t, c, h, w) :type lrs: Tensor :param keyframe_idx: The indices specifying the keyframes. :type keyframe_idx: list(int)
- Returns
- The keyframe features. Each key corresponds to the
indices in keyframe_idx.
- Return type
dict(Tensor)
- compute_flow(lrs)[source]¶
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)’.
- Parameters
lrs (tensor) – Input LR images with shape (n, t, c, h, w)
- Returns
- 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).
- Return type
tuple(Tensor)