RandomFlip¶
- class mmcv.transforms.RandomFlip(prob: Optional[Union[float, Iterable[float]]] = None, direction: Union[str, Sequence[Optional[str]]] = 'horizontal', swap_seg_labels: Optional[Sequence] = None)[源代码]¶
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 bedirection``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 bedirection[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: givenlen(prob) == len(direction)
, the image will bedirection[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)
- 参数
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 inprob
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.