Shortcuts

mmagic.models.editors.esrgan.rrdb_net

Module Contents

Classes

RRDBNet

Networks consisting of Residual in Residual Dense Block, which is used

ResidualDenseBlock

Residual Dense Block.

RRDB

Residual in Residual Dense Block.

class mmagic.models.editors.esrgan.rrdb_net.RRDBNet(in_channels, out_channels, mid_channels=64, num_blocks=23, growth_channels=32, upscale_factor=4, init_cfg=None)[source]

Bases: mmengine.model.BaseModule

Networks consisting of Residual in Residual Dense Block, which is used in ESRGAN and Real-ESRGAN.

ESRGAN: Enhanced Super-Resolution Generative Adversarial Networks. Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data. # noqa: E501 Currently, it supports [x1/x2/x4] upsampling scale factor.

Parameters
  • in_channels (int) – Channel number of inputs.

  • out_channels (int) – Channel number of outputs.

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

  • num_blocks (int) – Block number in the trunk network. Defaults: 23

  • growth_channels (int) – Channels for each growth. Default: 32.

  • upscale_factor (int) – Upsampling factor. Support x1, x2 and x4. Default: 4.

  • init_cfg (dict, optional) – Initialization config dict. Default: None.

_supported_upscale_factors = [1, 2, 4][source]
forward(x)[source]

Forward function.

Parameters

x (Tensor) – Input tensor with shape (n, c, h, w).

Returns

Forward results.

Return type

Tensor

init_weights()[source]

Init weights for models.

class mmagic.models.editors.esrgan.rrdb_net.ResidualDenseBlock(mid_channels=64, growth_channels=32)[source]

Bases: torch.nn.Module

Residual Dense Block.

Used in RRDB block in ESRGAN.

Parameters
  • mid_channels (int) – Channel number of intermediate features. Default: 64.

  • growth_channels (int) – Channels for each growth. Default: 32.

init_weights()[source]

Init weights for ResidualDenseBlock.

Use smaller std for better stability and performance. We empirically use 0.1. See more details in “ESRGAN: Enhanced Super-Resolution Generative Adversarial Networks”

forward(x)[source]

Forward function.

Parameters

x (Tensor) – Input tensor with shape (n, c, h, w).

Returns

Forward results.

Return type

Tensor

class mmagic.models.editors.esrgan.rrdb_net.RRDB(mid_channels, growth_channels=32)[source]

Bases: torch.nn.Module

Residual in Residual Dense Block.

Used in RRDB-Net in ESRGAN.

Parameters
  • mid_channels (int) – Channel number of intermediate features.

  • growth_channels (int) – Channels for each growth. Default: 32.

forward(x)[source]

Forward function.

Parameters

x (Tensor) – Input tensor with shape (n, c, h, w).

Returns

Forward results.

Return type

Tensor

Read the Docs v: latest
Versions
latest
stable
0.x
Downloads
pdf
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.