Shortcuts

RandomFlip

class mmpretrain.datasets.transforms.RandomFlip(prob=None, direction='horizontal', swap_seg_labels=None)[source]

Flip the image & bbox & keypoints & segmentation map. Added or Updated keys: flip, flip_direction, img, gt_bboxes, gt_seg_map, and gt_keypoints. There are 3 flip modes:

  • prob is float, direction is string: the image will be direction``ly flipped with probability of ``prob . E.g., prob=0.5, direction='horizontal', then image will be horizontally flipped with probability of 0.5.

  • prob is float, direction is list of string: the image will be direction[i]``ly flipped with probability of ``prob/len(direction). E.g., prob=0.5, direction=['horizontal', 'vertical'], then image will be horizontally flipped with probability of 0.25, vertically with probability of 0.25.

  • prob is list of float, direction is list of string: given len(prob) == len(direction), the image will be direction[i]``ly flipped with probability of ``prob[i]. E.g., prob=[0.3, 0.5], direction=['horizontal', 'vertical'], then image will be horizontally flipped with probability of 0.3, vertically with probability of 0.5.

Required Keys:

  • img

  • gt_bboxes (optional)

  • gt_seg_map (optional)

  • gt_keypoints (optional)

Modified Keys:

  • img

  • gt_bboxes (optional)

  • gt_seg_map (optional)

  • gt_keypoints (optional)

Added Keys:

  • flip

  • flip_direction

  • swap_seg_labels (optional)

Parameters:
  • prob (float | list[float], optional) – The flipping probability. Defaults to None.

  • direction (str | list[str]) – The flipping direction. Options If input is a list, the length must equal prob. Each element in prob indicates the flip probability of corresponding direction. Defaults to ‘horizontal’.

  • swap_seg_labels (list, optional) – The label pair need to be swapped for ground truth, like ‘left arm’ and ‘right arm’ need to be swapped after horizontal flipping. For example, [(1, 5)], where 1/5 is the label of the left/right arm. Defaults to None.

transform(results)[source]

Transform function to flip images, bounding boxes, semantic segmentation map and keypoints.

Parameters:

results (dict) – Result dict from loading pipeline.

Returns:

Flipped results, ‘img’, ‘gt_bboxes’, ‘gt_seg_map’, ‘gt_keypoints’, ‘flip’, and ‘flip_direction’ keys are updated in result dict.

Return type:

dict

Read the Docs v: latest
Versions
latest
stable
mmcls-1.x
mmcls-0.x
dev
Downloads
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.