RandomFlip¶
- class mmocr.datasets.transforms.RandomFlip(prob=None, direction='horizontal', swap_seg_labels=None)[源代码]¶
Flip the image & bbox polygon.
There are 3 flip modes:
probis float,directionis 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.
probis float,directionis list of string: the image willbe
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.
probis list of float,directionis list of string:given
len(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_polygons (optional)
- Modified Keys:
img
gt_bboxes (optional)
gt_polygons (optional)
- Added Keys:
flip
flip_direction
- 参数
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 inprobindicates the flip probability of corresponding direction. Defaults to ‘horizontal’.swap_seg_labels (Optional[Sequence]) –
- 返回类型
- flip_polygons(polygons, img_shape, direction)[源代码]¶
Flip polygons horizontally, vertically or diagonally.
- 参数
polygons (list[numpy.ndarray) – polygons.
direction (str) – Flip direction. Options are ‘horizontal’, ‘vertical’ and ‘diagonal’.
- 返回
Flipped polygons.
- 返回类型