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
andseg_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()
. Seemmcv.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 usebackend_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.