Shortcuts

LoadKIEAnnotations

class mmocr.datasets.transforms.LoadKIEAnnotations(with_bbox=True, with_label=True, with_text=True, directed=False, key_node_idx=None, value_node_idx=None, **kwargs)[source]

Load and process the instances annotation provided by dataset.

The annotation format is as the following:

{
    # A nested list of 4 numbers representing the bounding box of the
    # instance, in (x1, y1, x2, y2) order.
    'bbox': np.array([[x1, y1, x2, y2], [x1, y1, x2, y2], ...],
                     dtype=np.int32),

    # Labels of boxes. Shape is (N,).
    'bbox_labels': np.array([0, 2, ...], dtype=np.int32),

    # Labels of edges. Shape (N, N).
    'edge_labels': np.array([0, 2, ...], dtype=np.int32),

    # List of texts.
    "texts": ['text1', 'text2', ...],
}

After this module, the annotation has been changed to the format below:

{
    # In (x1, y1, x2, y2) order, float type. N is the number of bboxes
    # in np.float32
    'gt_bboxes': np.ndarray(N, 4),
    # In np.int64 type.
    'gt_bboxes_labels': np.ndarray(N, ),
    # In np.int32 type.
    'gt_edges_labels': np.ndarray(N, N),
    # In list[str]
    'gt_texts': list[str],
    # tuple(int)
    'ori_shape': (H, W)
}

Required Keys:

  • bboxes

  • bbox_labels

  • edge_labels

  • texts

Added Keys:

  • gt_bboxes (np.float32)

  • gt_bboxes_labels (np.int64)

  • gt_edges_labels (np.int64)

  • gt_texts (list[str])

  • ori_shape (tuple[int])

Parameters
  • with_bbox (bool) – Whether to parse and load the bbox annotation. Defaults to True.

  • with_label (bool) – Whether to parse and load the label annotation. Defaults to True.

  • with_text (bool) – Whether to parse and load the text annotation. Defaults to True.

  • directed (bool) – Whether build edges as a directed graph. Defaults to False.

  • key_node_idx (int, optional) – Key node label, used to mask out edges that are not connected from key nodes to value nodes. It has to be specified together with value_node_idx. Defaults to None.

  • value_node_idx (int, optional) – Value node label, used to mask out edges that are not connected from key nodes to value nodes. It has to be specified together with key_node_idx. Defaults to None.

Return type

None

transform(results)[source]

Function to load multiple types annotations.

Parameters

results (dict) – Result dict from :obj:OCRDataset.

Returns

The dict contains loaded bounding box, label polygon and text annotations.

Return type

dict

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.