Shortcuts

FixInvalidPolygon

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

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)

参数
  • 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.

返回类型

None

transform(results)[源代码]

Fix invalid polygons.

参数

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

返回

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

返回类型

Optional[dict]

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

Free document hosting provided by Read the Docs.