Shortcuts

mmagic.datasets.transforms.generate_assistant

Module Contents

Classes

GenerateCoordinateAndCell

Generate coordinate and cell. Generate coordinate from the desired size

GenerateFacialHeatmap

Generate heatmap from keypoint.

Attributes

has_face_alignment

mmagic.datasets.transforms.generate_assistant.has_face_alignment = True[源代码]
class mmagic.datasets.transforms.generate_assistant.GenerateCoordinateAndCell(sample_quantity=None, scale=None, target_size=None, reshape_gt=True)[源代码]

Bases: mmcv.transforms.base.BaseTransform

Generate coordinate and cell. Generate coordinate from the desired size of SR image.

Train or val:

  1. Generate coordinate from GT.

#. Reshape GT image to (HgWg, 3) and transpose to (3, HgWg). where Hg and Wg represent the height and width of GT.

Test:

  1. Generate coordinate from LQ and scale or target_size.

  2. Then generate cell from coordinate.

参数
  • sample_quantity (int | None) – The quantity of samples in coordinates. To ensure that the GT tensors in a batch have the same dimensions. Default: None.

  • scale (float) – Scale of upsampling. Default: None.

  • target_size (tuple[int]) – Size of target image. Default: None.

  • reshape_gt (bool) – Whether reshape gt to (-1, 3). Default: True If sample_quantity is not None, reshape_gt = True.

The priority of getting ‘size of target image’ is:

  1. results[‘gt’].shape[-2:]

  2. results[‘lq’].shape[-2:] * scale

  3. target_size

transform(results)[源代码]

Call function.

参数
  • results (Require either in) – A dict containing the necessary information

  • augmentation. (and data for) –

  • results

  • 'lq' (1.) –

  • 'gt' (2.) –

  • None (3.) –

  • and (the premise is self.target_size) –

  • len (self.target_size) –

返回

A dict containing the processed data and information. Reshape ‘gt’ to (-1, 3) and transpose to (3, -1) if ‘gt’ in results. Add ‘coord’ and ‘cell’.

返回类型

dict

__repr__()[源代码]

Return repr(self).

class mmagic.datasets.transforms.generate_assistant.GenerateFacialHeatmap(image_key, ori_size, target_size, sigma=1.0, use_cache=True)[源代码]

Bases: mmcv.transforms.base.BaseTransform

Generate heatmap from keypoint.

参数
  • image_key (str) – Key of facial image in dict.

  • ori_size (int | Tuple[int]) – Original image size of keypoint.

  • target_size (int | Tuple[int]) – Target size of heatmap.

  • sigma (float) – Sigma parameter of heatmap. Default: 1.0

  • use_cache (bool) – If True, load all heatmap at once. Default: True.

transform(results)[源代码]

transform function.

参数

results (dict) – A dict containing the necessary information and data for augmentation. Require keypoint.

返回

A dict containing the processed data and information.

Add ‘heatmap’.

返回类型

dict

generate_heatmap_from_img(image)[源代码]

Generate heatmap from img.

参数

image (np.ndarray) – Face image.

results:

heatmap (np.ndarray): Heatmap the face image.

_face_alignment_detector(image)[源代码]

Generate face landmark by face_alignment.

参数

image (np.ndarray) – Face image.

返回

Location of landmark.

返回类型

landmark (Tuple[float])

_generate_one_heatmap(keypoint)[源代码]

Generate One Heatmap.

参数

keypoint (Tuple[float]) – Location of a landmark.

results:

heatmap (np.ndarray): A heatmap of landmark.

__repr__()[源代码]

Return repr(self).

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.