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)[源代码]¶
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])
- 参数
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.
- 返回类型