Shortcuts

LoadAnnotations

class mmcv.transforms.LoadAnnotations(with_bbox: bool = True, with_label: bool = True, with_seg: bool = False, with_keypoints: bool = False, imdecode_backend: str = 'cv2', file_client_args: Optional[dict] = None, *, backend_args: Optional[dict] = None)[source]

Load and process the instances and seg_map annotation provided by dataset.

The annotation format is as the following:

{
    'instances':
    [
        {
        # List of 4 numbers representing the bounding box of the
        # instance, in (x1, y1, x2, y2) order.
        'bbox': [x1, y1, x2, y2],

        # Label of image classification.
        'bbox_label': 1,

        # Used in key point detection.
        # Can only load the format of [x1, y1, v1,…, xn, yn, vn]. v[i]
        # means the visibility of this keypoint. n must be equal to the
        # number of keypoint categories.
        'keypoints': [x1, y1, v1, ..., xn, yn, vn]
        }
    ]
    # Filename of semantic or panoptic segmentation ground truth file.
    'seg_map_path': 'a/b/c'
}

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 uint8 type.
    'gt_seg_map': np.ndarray (H, W)
     # with (x, y, v) order, in np.float32 type.
    'gt_keypoints': np.ndarray(N, NK, 3)
}

Required Keys:

  • instances

    • bbox (optional)

    • bbox_label

    • keypoints (optional)

  • seg_map_path (optional)

Added Keys:

  • gt_bboxes (np.float32)

  • gt_bboxes_labels (np.int64)

  • gt_seg_map (np.uint8)

  • gt_keypoints (np.float32)

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_seg (bool) – Whether to parse and load the semantic segmentation annotation. Defaults to False.

  • with_keypoints (bool) – Whether to parse and load the keypoints annotation. Defaults to False.

  • imdecode_backend (str) – The image decoding backend type. The backend argument for mmcv.imfrombytes(). See mmcv.imfrombytes() for details. Defaults to ‘cv2’.

  • file_client_args (dict, optional) – Arguments to instantiate a FileClient. See mmengine.fileio.FileClient for details. Defaults to None. It will be deprecated in future. Please use backend_args instead. Deprecated in version 2.0.0rc4.

  • backend_args (dict, optional) – Instantiates the corresponding file backend. It may contain backend key to specify the file backend. If it contains, the file backend corresponding to this value will be used and initialized with the remaining values, otherwise the corresponding file backend will be selected based on the prefix of the file path. Defaults to None. New in version 2.0.0rc4.

transform(results: dict)dict[source]

Function to load multiple types annotations.

Parameters

results (dict) – Result dict from mmengine.dataset.BaseDataset.

Returns

The dict contains loaded bounding box, label and semantic segmentation and keypoints annotations.

Return type

dict

Read the Docs v: 2.x
Versions
master
latest
2.x
1.x
v1.7.0
v1.6.2
v1.6.1
v1.6.0
v1.5.3
v1.5.2_a
v1.5.1
v1.5.0
v1.4.8
v1.4.7
v1.4.6
v1.4.5
v1.4.4
v1.4.3
v1.4.2
v1.4.1
v1.4.0
v1.3.18
v1.3.17
v1.3.16
v1.3.15
v1.3.14
v1.3.13
v1.3.12
v1.3.11
v1.3.10
v1.3.9
v1.3.8
v1.3.7
v1.3.6
v1.3.5
v1.3.4
v1.3.3
v1.3.2
v1.3.1
v1.3.0
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.