Shortcuts

RandomFlip

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

Flip the image & bbox polygon.

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_polygons (optional)

Modified Keys:
  • img

  • gt_bboxes (optional)

  • gt_polygons (optional)

Added Keys:
  • flip

  • flip_direction

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 (Optional[Sequence]) –

Return type

None

flip_polygons(polygons, img_shape, direction)[source]

Flip polygons horizontally, vertically or diagonally.

Parameters
  • polygons (list[numpy.ndarray) – polygons.

  • img_shape (tuple[int]) – Image shape (height, width)

  • direction (str) – Flip direction. Options are ‘horizontal’, ‘vertical’ and ‘diagonal’.

Returns

Flipped polygons.

Return type

list[numpy.ndarray]

Read the Docs v: dev-1.x
Versions
latest
stable
v1.0.1
v1.0.0
0.x
v0.6.3
v0.6.2
v0.6.1
v0.6.0
v0.5.0
v0.4.1
v0.4.0
v0.3.0
v0.2.1
v0.2.0
v0.1.0
dev-1.x
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.