mmagic.datasets.transforms.generate_assistant
¶
Module Contents¶
Classes¶
Generate coordinate and cell. Generate coordinate from the desired size |
|
Generate heatmap from keypoint. |
Attributes¶
- 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:
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:
Generate coordinate from LQ and scale or target_size.
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:
results[‘gt’].shape[-2:]
results[‘lq’].shape[-2:] * scale
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
- 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])