Shortcuts

mmagic.models.editors.dic.dic_net

Module Contents

Classes

DICNet

DIC network structure for face super-resolution.

FeedbackBlock

Feedback Block of DIC.

FeedbackBlockCustom

Custom feedback block, will be used as the first feedback block.

GroupResBlock

ResBlock with Group Conv.

FeatureHeatmapFusingBlock

Fusing Feature and Heatmap.

FeedbackBlockHeatmapAttention

Feedback block with HeatmapAttention.

class mmagic.models.editors.dic.dic_net.DICNet(in_channels, out_channels, mid_channels, num_blocks=6, hg_mid_channels=256, hg_num_keypoints=68, num_steps=4, upscale_factor=8, detach_attention=False, prelu_init=0.2, num_heatmaps=5, num_fusion_blocks=7, init_cfg=None)[源代码]

Bases: mmengine.model.BaseModule

DIC network structure for face super-resolution.

Paper: Deep Face Super-Resolution with Iterative Collaboration between

Attentive Recovery and Landmark Estimation

参数
  • in_channels (int) – Number of channels in the input image

  • out_channels (int) – Number of channels in the output image

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

  • num_blocks (tuple[int]) – Block numbers in the trunk network. Default: 6

  • hg_mid_channels (int) – Channel number of intermediate features of HourGlass. Default: 256

  • hg_num_keypoints (int) – Keypoint number of HourGlass. Default: 68

  • num_steps (int) – Number of iterative steps. Default: 4

  • upscale_factor (int) – Upsampling factor. Default: 8

  • detach_attention (bool) – Detached from the current tensor for heatmap or not.

  • prelu_init (float) – init of PReLU. Default: 0.2

  • num_heatmaps (int) – Number of heatmaps. Default: 5

  • num_fusion_blocks (int) – Number of fusion blocks. Default: 7

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

forward(x)[源代码]

Forward function.

参数

x (Tensor) – Input tensor.

返回

Forward results. sr_outputs (list[Tensor]): forward sr results. heatmap_outputs (list[Tensor]): forward heatmap results.

返回类型

Tensor

class mmagic.models.editors.dic.dic_net.FeedbackBlock(mid_channels, num_blocks, upscale_factor, padding=2, prelu_init=0.2)[源代码]

Bases: torch.nn.Module

Feedback Block of DIC.

It has a style of:

----- Module ----->
  ^            |
  |____________|
参数
  • mid_channels (int) – Number of channels in the intermediate features.

  • num_blocks (int) – Number of blocks.

  • upscale_factor (int) – upscale factor.

  • padding (int) – Padding size. Default: 2.

  • prelu_init (float) – init of PReLU. Default: 0.2

forward(x)[源代码]

Forward function.

参数

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

返回

Forward results.

返回类型

Tensor

class mmagic.models.editors.dic.dic_net.FeedbackBlockCustom(in_channels, mid_channels, num_blocks, upscale_factor)[源代码]

Bases: FeedbackBlock

Custom feedback block, will be used as the first feedback block.

参数
  • in_channels (int) – Number of channels in the input features.

  • mid_channels (int) – Number of channels in the intermediate features.

  • num_blocks (int) – Number of blocks.

  • upscale_factor (int) – upscale factor.

forward(x)[源代码]

Forward function.

参数

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

返回

Forward results.

返回类型

Tensor

class mmagic.models.editors.dic.dic_net.GroupResBlock(in_channels, out_channels, mid_channels, groups, res_scale=1.0)[源代码]

Bases: torch.nn.Module

ResBlock with Group Conv.

参数
  • in_channels (int) – Channel number of input features.

  • out_channels (int) – Channel number of output features.

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

  • groups (int) – Number of blocked connections from input to output.

  • res_scale (float) – Used to scale the residual before addition. Default: 1.0.

forward(x)[源代码]

Forward function.

参数

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

返回

Forward results.

返回类型

Tensor

class mmagic.models.editors.dic.dic_net.FeatureHeatmapFusingBlock(in_channels, num_heatmaps, num_blocks, mid_channels=None)[源代码]

Bases: torch.nn.Module

Fusing Feature and Heatmap.

参数
  • in_channels (int) – Number of channels in the input features.

  • num_heatmaps (int) – Number of heatmap.

  • num_blocks (int) – Number of blocks.

  • mid_channels (int | None) – Number of channels in the intermediate features. Default: None

forward(feature, heatmap)[源代码]

Forward function.

参数
  • feature (Tensor) – Input feature tensor.

  • heatmap (Tensor) – Input heatmap tensor.

返回

Forward results.

返回类型

Tensor

class mmagic.models.editors.dic.dic_net.FeedbackBlockHeatmapAttention(mid_channels, num_blocks, upscale_factor, num_heatmaps, num_fusion_blocks, padding=2, prelu_init=0.2)[源代码]

Bases: FeedbackBlock

Feedback block with HeatmapAttention.

参数
  • in_channels (int) – Number of channels in the input features.

  • mid_channels (int) – Number of channels in the intermediate features.

  • num_blocks (int) – Number of blocks.

  • upscale_factor (int) – upscale factor.

  • padding (int) – Padding size. Default: 2.

  • prelu_init (float) – init of PReLU. Default: 0.2

forward(x, heatmap)[源代码]

Forward function.

参数
  • x (Tensor) – Input feature tensor.

  • heatmap (Tensor) – Input heatmap tensor.

返回

Forward results.

返回类型

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.