datumaro.util.annotation_util#

Functions

OKS(a, b[, sigma, bbox, scale])

Object Keypoint Similarity metric.

PDJ(a, b[, eps, ratio, bbox])

Percentage of Detected Joints metric.

approximate_line(points, segments)

Approximates a 2d line to the required number of segments.

bbox_iou(a, b)

IoU computations for simple cases with bounding boxes

find_group_leader(group)

find_instances(instance_anns)

make_label_id_mapping(src_labels, dst_labels)

Maps label ids from source to destination.

max_bbox(annotations)

Computes the maximum bbox for the set of spatial annotations and boxes.

mean_bbox(annotations)

Computes the mean bbox for the set of spatial annotations and boxes.

nms(segments[, iou_thresh])

Non-maxima suppression algorithm.

segment_iou(a, b)

Generic IoU computation with masks, polygons, and boxes.

softmax(x)

datumaro.util.annotation_util.find_instances(instance_anns)[source]#
datumaro.util.annotation_util.find_group_leader(group)[source]#
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.softmax(x)[source]#
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 id
id_mapping (dict): src id -> dst i
src_labels (dict): src id -> src label
dst_labels (dict): dst id -> dst label