Shortcuts

mmedit.models.editors.swinir.swinir_modules

Module Contents

Classes

PatchEmbed

Image to Patch Embedding

PatchUnEmbed

Image to Patch Unembedding

Upsample

Upsample module.

UpsampleOneStep

UpsampleOneStep module (the difference with Upsample is that it always

class mmedit.models.editors.swinir.swinir_modules.PatchEmbed(img_size=224, patch_size=4, in_chans=3, embed_dim=96, norm_layer=None)[source]

Bases: torch.nn.Module

Image to Patch Embedding :param img_size: Image size. Default: 224. :type img_size: int :param patch_size: Patch token size. Default: 4. :type patch_size: int :param in_chans: Number of input image channels. Default: 3. :type in_chans: int :param embed_dim: Number of linear projection output channels.

Default: 96.

Parameters

norm_layer (nn.Module, optional) – Normalization layer. Default: None

forward(x)[source]

Forward function.

Parameters

x (Tensor) – Input tensor with shape (B, C, Ph, Pw).

Returns

Forward results.

Return type

Tensor

class mmedit.models.editors.swinir.swinir_modules.PatchUnEmbed(img_size=224, patch_size=4, in_chans=3, embed_dim=96, norm_layer=None)[source]

Bases: torch.nn.Module

Image to Patch Unembedding :param img_size: Image size. Default: 224. :type img_size: int :param patch_size: Patch token size. Default: 4. :type patch_size: int :param in_chans: Number of input image channels. Default: 3. :type in_chans: int :param embed_dim: Number of linear projection output channels.

Default: 96.

Parameters

norm_layer (nn.Module, optional) – Normalization layer. Default: None

forward(x, x_size)[source]

Forward function.

Parameters
  • x (Tensor) – Input tensor with shape (B, L, C).

  • x_size (tuple[int]) – Resolution of input feature.

Returns

Forward results.

Return type

Tensor

class mmedit.models.editors.swinir.swinir_modules.Upsample(scale, num_feat)[source]

Bases: torch.nn.Sequential

Upsample module.

Parameters
  • scale (int) – Scale factor. Supported scales: 2^n and 3.

  • num_feat (int) – Channel number of intermediate features.

class mmedit.models.editors.swinir.swinir_modules.UpsampleOneStep(scale, num_feat, num_out_ch, input_resolution=None)[source]

Bases: torch.nn.Sequential

UpsampleOneStep module (the difference with Upsample is that it always only has 1conv + 1pixelshuffle) Used in lightweight SR to save parameters.

Parameters
  • scale (int) – Scale factor. Supported scales: 2^n and 3.

  • num_feat (int) – Channel number of intermediate features.

  • num_out_ch (int) – Channel number for PixelShuffle.

  • input_resolution (tuple[int], optional) – Input resolution. Default: None

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

Free document hosting provided by Read the Docs.