Shortcuts

FixInvalidPolygon

class mmocr.datasets.transforms.FixInvalidPolygon(mode='fix', min_poly_points=4, fix_from_bbox=True)[source]

Fix invalid polygons in the dataset.

Required Keys:

  • gt_polygons

  • gt_ignored (optional)

  • gt_bboxes (optional)

  • gt_bboxes_labels (optional)

  • gt_texts (optional)

Modified Keys:

  • gt_polygons

  • gt_ignored (optional)

  • gt_bboxes (optional)

  • gt_bboxes_labels (optional)

  • gt_texts (optional)

Parameters
  • mode (str) – The mode of fixing invalid polygons. Options are ‘fix’ and ‘ignore’. For the ‘fix’ mode, the transform will try to fix the invalid polygons to a valid one by eliminating the self-intersection or converting the bboxes to polygons. If it can’t be fixed by any means (e.g. the polygon contains less than 3 points or it’s actually a line/point), the annotation will be removed. For the ‘ignore’ mode, the invalid polygons will be set to “ignored” during training. Defaults to ‘fix’.

  • min_poly_points (int) – Minimum number of the coordinate points in a polygon. Defaults to 4.

  • fix_from_bbox (bool) – Whether to convert the bboxes to polygons when the polygon is invalid and not directly fixable. Defaults to True.

Return type

None

transform(results)[source]

Fix invalid polygons.

Parameters

results (dict) – Result dict containing the data to transform.

Returns

The transformed data. If all the polygons are unfixable, return None.

Return type

Optional[dict]

Read the Docs v: stable
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.