mmagic.models.editors.real_basicvsr.real_basicvsr
¶
Module Contents¶
Classes¶
RealBasicVSR model for real-world video super-resolution. |
- class mmagic.models.editors.real_basicvsr.real_basicvsr.RealBasicVSR(generator, discriminator=None, gan_loss=None, pixel_loss=None, cleaning_loss=None, perceptual_loss=None, is_use_sharpened_gt_in_pixel=False, is_use_sharpened_gt_in_percep=False, is_use_sharpened_gt_in_gan=False, is_use_ema=False, train_cfg=None, test_cfg=None, init_cfg=None, data_preprocessor=None)[source]¶
Bases:
mmagic.models.editors.real_esrgan.RealESRGAN
RealBasicVSR model for real-world video super-resolution.
Ref: Investigating Tradeoffs in Real-World Video Super-Resolution, arXiv
- Parameters
generator (dict) – Config for the generator.
discriminator (dict, optional) – Config for the discriminator. Default: None.
gan_loss (dict, optional) – Config for the gan loss. Note that the loss weight in gan loss is only for the generator.
pixel_loss (dict, optional) – Config for the pixel loss. Default: None.
cleaning_loss (dict, optional) – Config for the image cleaning loss. Default: None.
perceptual_loss (dict, optional) – Config for the perceptual loss. Default: None.
is_use_sharpened_gt_in_pixel (bool, optional) – Whether to use the image sharpened by unsharp masking as the GT for pixel loss. Default: False.
is_use_sharpened_gt_in_percep (bool, optional) – Whether to use the image sharpened by unsharp masking as the GT for perceptual loss. Default: False.
is_use_sharpened_gt_in_gan (bool, optional) – Whether to use the image sharpened by unsharp masking as the GT for adversarial loss. Default: False.
train_cfg (dict) – Config for training. Default: None. You may change the training of gan by setting: disc_steps: how many discriminator updates after one generate update; disc_init_steps: how many discriminator updates at the start of the training. These two keys are useful when training with WGAN.
test_cfg (dict) – Config for testing. Default: None.
init_cfg (dict, optional) – The weight initialized config for
BaseModule
. Default: None.data_preprocessor (dict, optional) – The pre-process config of
BaseDataPreprocessor
. Default: None.
- extract_gt_data(data_samples)[source]¶
extract gt data from data samples.
- Parameters
data_samples (list) – List of DataSample.
- Returns
Extract gt data.
- Return type
Tensor
- g_step(batch_outputs, batch_gt_data)[source]¶
G step of GAN: Calculate losses of generator.
- Parameters
batch_outputs (Tensor) – Batch output of generator.
batch_gt_data (Tuple[Tensor]) – Batch GT data.
- Returns
Dict of losses.
- Return type
dict
- train_step(data: List[dict], optim_wrapper: mmengine.optim.OptimWrapperDict) Dict[str, torch.Tensor] [source]¶
Train step of GAN-based method.
- Parameters
data (List[dict]) – Data sampled from dataloader.
optim_wrapper (OptimWrapper) – OptimWrapper instance used to update model parameters.
- Returns
A
dict
of tensor for logging.- Return type
Dict[str, torch.Tensor]
- forward_train(batch_inputs, data_samples=None)[source]¶
Forward Train.
Run forward of generator with
return_lqs=True
- Parameters
batch_inputs (Tensor) – Batch inputs.
data_samples (List[DataSample]) – Data samples of Editing. Default:None
- Returns
- Result of generator.
(outputs, lqs)
- Return type
Tuple[Tensor]