mmagic.models.editors.dic.feedback_hour_glass
¶
Module Contents¶
Classes¶
Feedback Hourglass model for face landmark. |
|
ResBlock for Hourglass. |
|
Hourglass model for face landmark. |
Functions¶
|
Reduce facial landmark heatmaps to 5 heatmaps. |
- class mmagic.models.editors.dic.feedback_hour_glass.FeedbackHourglass(mid_channels, num_keypoints)[source]¶
Bases:
mmengine.model.BaseModule
Feedback Hourglass model for face landmark.
It has a style of:
-- preprocessing ----- Hourglass -----> ^ | |_______________|
- Parameters
mid_channels (int) – Number of channels in the intermediate features.
num_keypoints (int) – Number of keypoints.
- forward(x, last_hidden=None)[source]¶
Forward function.
- Parameters
x (Tensor) – Input tensor with shape (n, c, h, w).
last_hidden (Tensor | None) – The feedback of FeedbackHourglass. In first step, last_hidden=None. Otherwise, last_hidden is the past output of FeedbackHourglass. Default: None.
- Returns
Heatmap of facial landmark. feedback (Tensor): Feedback Tensor.
- Return type
heatmap (Tensor)
- class mmagic.models.editors.dic.feedback_hour_glass.ResBlock(in_channels, out_channels)[source]¶
Bases:
torch.nn.Module
ResBlock for Hourglass.
It has a style of:
---Conv-ReLU-Conv-Conv-+- |_________Conv________| or ---Conv-ReLU-Conv-Conv-+- |_____________________|
- Parameters
in_channels (int) – Number of channels in the input features.
out_channels (int) – Number of channels in the output features.
- class mmagic.models.editors.dic.feedback_hour_glass.Hourglass(depth, mid_channels)[source]¶
Bases:
torch.nn.Module
Hourglass model for face landmark.
It is a recursive model.
- Parameters
depth (int) – Depth of Hourglass, the number of recursions.
mid_channels (int) – Number of channels in the intermediate features.
- mmagic.models.editors.dic.feedback_hour_glass.reduce_to_five_heatmaps(ori_heatmap, detach)[source]¶
Reduce facial landmark heatmaps to 5 heatmaps.
DIC realizes facial SR with the help of key points of the face. The number of key points in datasets are different from each other. This function reduces the input heatmaps into 5 heatmaps:
left eye right eye nose mouse face silhouette
- Parameters
ori_heatmap (Tensor) – Input heatmap tensor. (B, N, 32, 32).
detach (bool) – Detached from the current tensor or not.
- Returns
New heatmap tensor. (B, 5, 32, 32).
- Return type
Tensor