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[source]
class mmagic.datasets.transforms.generate_assistant.GenerateCoordinateAndCell(sample_quantity=None, scale=None, target_size=None, reshape_gt=True)[source]

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.

Parameters
  • 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)[source]

Call function.

Parameters
  • 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) –

Returns

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’.

Return type

dict

__repr__()[source]

Return repr(self).

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

Bases: mmcv.transforms.base.BaseTransform

Generate heatmap from keypoint.

Parameters
  • 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)[source]

transform function.

Parameters

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

Returns

A dict containing the processed data and information.

Add ‘heatmap’.

Return type

dict

generate_heatmap_from_img(image)[source]

Generate heatmap from img.

Parameters

image (np.ndarray) – Face image.

results:

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

_face_alignment_detector(image)[source]

Generate face landmark by face_alignment.

Parameters

image (np.ndarray) – Face image.

Returns

Location of landmark.

Return type

landmark (Tuple[float])

_generate_one_heatmap(keypoint)[source]

Generate One Heatmap.

Parameters

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

results:

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

__repr__()[source]

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.