datumaro.util.annotation_util#
Functions
|
Object Keypoint Similarity metric. |
|
Percentage of Detected Joints metric. |
|
Approximates a 2d line to the required number of segments. |
|
IoU computations for simple cases with bounding boxes |
|
|
|
|
|
Maps label ids from source to destination. |
|
Computes the maximum bbox for the set of spatial annotations and boxes. |
|
Computes the mean bbox for the set of spatial annotations and boxes. |
|
Non-maxima suppression algorithm. |
|
Generic IoU computation with masks, polygons, and boxes. |
|
- datumaro.util.annotation_util.max_bbox(annotations: Iterable[Tuple[float, float, float, float] | _Shape | Mask]) Tuple[float, float, float, float] [source]#
Computes the maximum bbox for the set of spatial annotations and boxes.
- Returns:
(x, y, w, h)
- Return type:
bbox (tuple)
- datumaro.util.annotation_util.mean_bbox(annotations: Iterable[Tuple[float, float, float, float] | _Shape | Mask]) Tuple[float, float, float, float] [source]#
Computes the mean bbox for the set of spatial annotations and boxes.
- Returns:
(x, y, w, h)
- Return type:
bbox (tuple)
- datumaro.util.annotation_util.nms(segments, iou_thresh=0.5)[source]#
Non-maxima suppression algorithm.
- datumaro.util.annotation_util.bbox_iou(a, b) Literal[-1] | float [source]#
IoU computations for simple cases with bounding boxes
- datumaro.util.annotation_util.segment_iou(a, b)[source]#
Generic IoU computation with masks, polygons, and boxes. Returns -1 if no intersection, [0; 1] otherwise
- datumaro.util.annotation_util.PDJ(a, b, eps=None, ratio=0.05, bbox=None)[source]#
Percentage of Detected Joints metric. Counts the number of matching points.
- datumaro.util.annotation_util.OKS(a, b, sigma=None, bbox=None, scale=None)[source]#
Object Keypoint Similarity metric. https://cocodataset.org/#keypoints-eval
- datumaro.util.annotation_util.approximate_line(points: Sequence[float], segments: int) ndarray [source]#
Approximates a 2d line to the required number of segments. The new points are distributed uniformly across the input line.
- Parameters:
points (Sequence) – an array of line point coordinates. The size is [points * 2], the layout is [x0, y0, x1, y1, …].
segments (int) – the required numebr of segments in the resulting line.
- Returns:
an array of new line point coordinates.
- Return type:
new_points (numpy.ndarray)
- Returns:
The size is [(segments + 1) * 2], the layout is [x0, y0, x1, y1, …].
- datumaro.util.annotation_util.make_label_id_mapping(src_labels: LabelCategories, dst_labels: LabelCategories, fallback: int = 0) Tuple[Callable[[int], int | None], Dict[int, int], Dict[int, str], Dict[int, str]] [source]#
Maps label ids from source to destination. Fallback id is used for missing labels.
Returns:
map_id (callable): src id -> dst idid_mapping (dict): src id -> dst isrc_labels (dict): src id -> src labeldst_labels (dict): dst id -> dst label