datumaro.components.annotations.merger#

Classes

AnnotationMerger(*[, context])

Method generated by attrs for class AnnotationMerger.

BboxMerger(*, context[, pairwise_dist, ...])

Method generated by attrs for class BboxMerger.

CaptionsMerger(*[, context])

Method generated by attrs for class CaptionsMerger.

Cuboid2DMerger(*, context[, pairwise_dist, ...])

Method generated by attrs for class Cuboid2DMerger.

Cuboid3dMerger(*, context[, pairwise_dist, ...])

Method generated by attrs for class Cuboid3dMerger.

EllipseMerger(*, context[, pairwise_dist, ...])

Method generated by attrs for class EllipseMerger.

FeatureVectorMerger(*[, context])

Method generated by attrs for class FeatureVectorMerger.

HashKeyMerger(*[, context])

Method generated by attrs for class HashKeyMerger.

ImageAnnotationMerger(*[, context])

Method generated by attrs for class ImageAnnotationMerger.

LabelMerger(*[, context, quorum])

Method generated by attrs for class LabelMerger.

LineMerger(*, context[, pairwise_dist, ...])

Method generated by attrs for class LineMerger.

MaskMerger(*, context[, pairwise_dist, ...])

Method generated by attrs for class MaskMerger.

PointsMerger(*, context[, pairwise_dist, ...])

Method generated by attrs for class PointsMerger.

PolygonMerger(*, context[, pairwise_dist, ...])

Method generated by attrs for class PolygonMerger.

RotatedBboxMerger(sigma, *, context[, ...])

Method generated by attrs for class RotatedBboxMerger.

TabularMerger(*[, context])

Method generated by attrs for class TabularMerger.

class datumaro.components.annotations.merger.AnnotationMerger(*, context: IMatcherContext | IMergerContext | None = None)[source]#

Bases: AnnotationMatcher

Method generated by attrs for class AnnotationMerger.

merge_clusters(clusters)[source]#
class datumaro.components.annotations.merger.LabelMerger(*, context: IMatcherContext | IMergerContext | None = None, quorum=0)[source]#

Bases: AnnotationMerger, LabelMatcher

Method generated by attrs for class LabelMerger.

merge_clusters(clusters)[source]#
class datumaro.components.annotations.merger.BboxMerger(*, context: ~datumaro.components.abstracts.merger.IMatcherContext | ~datumaro.components.abstracts.merger.IMergerContext | None = None, pairwise_dist=0.9, cluster_dist=-1.0, match_segments=<function match_segments_pair>, quorum=0)[source]#

Bases: _ShapeMerger, BboxMatcher

Method generated by attrs for class BboxMerger.

class datumaro.components.annotations.merger.RotatedBboxMerger(sigma: list | None = None, *, context: ~datumaro.components.abstracts.merger.IMatcherContext | ~datumaro.components.abstracts.merger.IMergerContext | None = None, pairwise_dist=0.9, cluster_dist=-1.0, match_segments=<function match_segments_pair>, quorum=0)[source]#

Bases: _ShapeMerger, RotatedBboxMatcher

Method generated by attrs for class RotatedBboxMerger.

class datumaro.components.annotations.merger.PolygonMerger(*, context: ~datumaro.components.abstracts.merger.IMatcherContext | ~datumaro.components.abstracts.merger.IMergerContext | None = None, pairwise_dist=0.9, cluster_dist=-1.0, match_segments=<function match_segments_pair>, quorum=0)[source]#

Bases: _ShapeMerger, PolygonMatcher

Method generated by attrs for class PolygonMerger.

class datumaro.components.annotations.merger.MaskMerger(*, context: ~datumaro.components.abstracts.merger.IMatcherContext | ~datumaro.components.abstracts.merger.IMergerContext | None = None, pairwise_dist=0.9, cluster_dist=-1.0, match_segments=<function match_segments_pair>, quorum=0)[source]#

Bases: _ShapeMerger, MaskMatcher

Method generated by attrs for class MaskMerger.

class datumaro.components.annotations.merger.PointsMerger(*, context: ~datumaro.components.abstracts.merger.IMatcherContext | ~datumaro.components.abstracts.merger.IMergerContext | None = None, pairwise_dist=0.9, cluster_dist=-1.0, match_segments=<function match_segments_pair>, quorum=0, sigma: list | None = None, instance_map)[source]#

Bases: _ShapeMerger, PointsMatcher

Method generated by attrs for class PointsMerger.

class datumaro.components.annotations.merger.LineMerger(*, context: ~datumaro.components.abstracts.merger.IMatcherContext | ~datumaro.components.abstracts.merger.IMergerContext | None = None, pairwise_dist=0.9, cluster_dist=-1.0, match_segments=<function match_segments_pair>, quorum=0)[source]#

Bases: _ShapeMerger, LineMatcher

Method generated by attrs for class LineMerger.

class datumaro.components.annotations.merger.CaptionsMerger(*, context: IMatcherContext | IMergerContext | None = None)[source]#

Bases: AnnotationMerger, CaptionsMatcher

Method generated by attrs for class CaptionsMerger.

class datumaro.components.annotations.merger.Cuboid3dMerger(*, context: ~datumaro.components.abstracts.merger.IMatcherContext | ~datumaro.components.abstracts.merger.IMergerContext | None = None, pairwise_dist=0.9, cluster_dist=-1.0, match_segments=<function match_segments_pair>, quorum=0)[source]#

Bases: _ShapeMerger, Cuboid3dMatcher

Method generated by attrs for class Cuboid3dMerger.

merge_cluster(cluster)[source]#
class datumaro.components.annotations.merger.ImageAnnotationMerger(*, context: IMatcherContext | IMergerContext | None = None)[source]#

Bases: AnnotationMerger, ImageAnnotationMatcher

Method generated by attrs for class ImageAnnotationMerger.

class datumaro.components.annotations.merger.EllipseMerger(*, context: ~datumaro.components.abstracts.merger.IMatcherContext | ~datumaro.components.abstracts.merger.IMergerContext | None = None, pairwise_dist=0.9, cluster_dist=-1.0, match_segments=<function match_segments_pair>, quorum=0)[source]#

Bases: _ShapeMerger, ShapeMatcher

Method generated by attrs for class EllipseMerger.

class datumaro.components.annotations.merger.HashKeyMerger(*, context: IMatcherContext | IMergerContext | None = None)[source]#

Bases: AnnotationMerger, HashKeyMatcher

Method generated by attrs for class HashKeyMerger.

class datumaro.components.annotations.merger.FeatureVectorMerger(*, context: IMatcherContext | IMergerContext | None = None)[source]#

Bases: AnnotationMerger, FeatureVectorMatcher

Method generated by attrs for class FeatureVectorMerger.

class datumaro.components.annotations.merger.AnnotationMatcher(*, context: IMatcherContext | IMergerContext | None = None)[source]#

Bases: object

Method generated by attrs for class AnnotationMatcher.

match_annotations(sources)[source]#
class datumaro.components.annotations.merger.Bbox(x, y, w, h, *args, **kwargs)[source]#

Bases: Shape

Bbox annotation class. This class represents a bounding box defined by its top-left corner (x, y) and its width and height (w, h).

_type#

The type of annotation, set to AnnotationType.bbox.

Type:

AnnotationType

__init__()[source]#

Initializes the Bbox with its coordinates and dimensions.

x()#

Property to get the x-coordinate of the bounding box.

y()#

Property to get the y-coordinate of the bounding box.

w()#

Property to get the width of the bounding box.

h()#

Property to get the height of the bounding box.

get_area()[source]#

Calculates the area of the bounding box.

get_bbox()[source]#

Returns the bounding box coordinates and dimensions.

as_polygon()[source]#

Returns the bounding box as a list of points forming a polygon.

iou()[source]#

Calculates the Intersection over Union (IoU) with another shape.

wrap()[source]#

Creates a new Bbox instance with updated attributes.

Initialize the Bbox with its top-left corner (x, y) and its width and height (w, h).

Parameters:
  • x (float) – The x-coordinate of the top-left corner.

  • y (float) – The y-coordinate of the top-left corner.

  • w (float) – The width of the bounding box.

  • h (float) – The height of the bounding box.

property x#

Get the x-coordinate of the top-left corner of the bounding box.

Returns:

The x-coordinate of the bounding box.

Return type:

float

property y#

Get the y-coordinate of the top-left corner of the bounding box.

Returns:

The y-coordinate of the bounding box.

Return type:

float

property w#

Get the width of the bounding box.

Returns:

The width of the bounding box.

Return type:

float

property h#

Get the height of the bounding box.

Returns:

The height of the bounding box.

Return type:

float

get_area()[source]#

Calculate the area of the bounding box.

Returns:

The area of the bounding box.

Return type:

float

get_bbox()[source]#

Get the bounding box coordinates and dimensions.

Returns:

The bounding box as [x, y, w, h].

Return type:

List[float]

as_polygon() List[float][source]#

Convert the bounding box into a polygon representation.

Returns:

The bounding box as a polygon.

Return type:

List[float]

iou(other: Shape) float | ~typing.Literal[-1][source]#

Calculate the Intersection over Union (IoU) with another shape.

Parameters:

other (Shape) – The other shape to compare with.

Returns:

The IoU value or -1 if not applicable.

Return type:

Union[float, Literal[-1]]

wrap(**kwargs)[source]#

Create a new Bbox instance with updated attributes.

Parameters:
  • item (Bbox) – The original Bbox instance.

  • kwargs – Additional attributes to update.

Returns:

A new Bbox instance with updated attributes.

Return type:

Bbox

class datumaro.components.annotations.merger.BboxMatcher(*, context: ~datumaro.components.abstracts.merger.IMatcherContext | ~datumaro.components.abstracts.merger.IMergerContext | None = None, pairwise_dist=0.9, cluster_dist=-1.0, match_segments=<function match_segments_pair>)[source]#

Bases: ShapeMatcher

Method generated by attrs for class BboxMatcher.

class datumaro.components.annotations.merger.CaptionsMatcher(*, context: IMatcherContext | IMergerContext | None = None)[source]#

Bases: AnnotationMatcher

Method generated by attrs for class CaptionsMatcher.

match_annotations(sources)[source]#
class datumaro.components.annotations.merger.Cuboid2DMatcher(*, context: ~datumaro.components.abstracts.merger.IMatcherContext | ~datumaro.components.abstracts.merger.IMergerContext | None = None, pairwise_dist=0.9, cluster_dist=-1.0, match_segments=<function match_segments_pair>)[source]#

Bases: ShapeMatcher

Method generated by attrs for class Cuboid2DMatcher.

class datumaro.components.annotations.merger.Cuboid2DMerger(*, context: ~datumaro.components.abstracts.merger.IMatcherContext | ~datumaro.components.abstracts.merger.IMergerContext | None = None, pairwise_dist=0.9, cluster_dist=-1.0, match_segments=<function match_segments_pair>, quorum=0)[source]#

Bases: _ShapeMerger, Cuboid2DMatcher

Method generated by attrs for class Cuboid2DMerger.

class datumaro.components.annotations.merger.Cuboid3dMatcher(*, context: ~datumaro.components.abstracts.merger.IMatcherContext | ~datumaro.components.abstracts.merger.IMergerContext | None = None, pairwise_dist=0.9, cluster_dist=-1.0, match_segments=<function match_segments_pair>)[source]#

Bases: ShapeMatcher

Method generated by attrs for class Cuboid3dMatcher.

distance(a, b)[source]#
exception datumaro.components.annotations.merger.FailedLabelVotingError(item_id, votes, ann=None, *, sources=_Nothing.NOTHING)[source]#

Bases: DatasetMergeError

Method generated by attrs for class FailedLabelVotingError.

item_id#
votes#
ann#
class datumaro.components.annotations.merger.FeatureVectorMatcher(*, context: IMatcherContext | IMergerContext | None = None)[source]#

Bases: AnnotationMatcher

Method generated by attrs for class FeatureVectorMatcher.

match_annotations(sources)[source]#
class datumaro.components.annotations.merger.HashKeyMatcher(*, context: IMatcherContext | IMergerContext | None = None)[source]#

Bases: AnnotationMatcher

Method generated by attrs for class HashKeyMatcher.

match_annotations(sources)[source]#
class datumaro.components.annotations.merger.ImageAnnotationMatcher(*, context: IMatcherContext | IMergerContext | None = None)[source]#

Bases: AnnotationMatcher

Method generated by attrs for class ImageAnnotationMatcher.

match_annotations(sources)[source]#
class datumaro.components.annotations.merger.Label(label, *, id: int = 0, attributes: Dict[str, Any] = _Nothing.NOTHING, group: int = 0, object_id: int = -1)[source]#

Bases: Annotation

Method generated by attrs for class Label.

label: int#
class datumaro.components.annotations.merger.LabelMatcher(*, context: IMatcherContext | IMergerContext | None = None)[source]#

Bases: AnnotationMatcher

Method generated by attrs for class LabelMatcher.

distance(a, b)[source]#
match_annotations(sources)[source]#
class datumaro.components.annotations.merger.LineMatcher(*, context: ~datumaro.components.abstracts.merger.IMatcherContext | ~datumaro.components.abstracts.merger.IMergerContext | None = None, pairwise_dist=0.9, cluster_dist=-1.0, match_segments=<function match_segments_pair>)[source]#

Bases: ShapeMatcher

Method generated by attrs for class LineMatcher.

distance(a, b)[source]#
class datumaro.components.annotations.merger.MaskMatcher(*, context: ~datumaro.components.abstracts.merger.IMatcherContext | ~datumaro.components.abstracts.merger.IMergerContext | None = None, pairwise_dist=0.9, cluster_dist=-1.0, match_segments=<function match_segments_pair>)[source]#

Bases: ShapeMatcher

Method generated by attrs for class MaskMatcher.

class datumaro.components.annotations.merger.PointsMatcher(*, context: ~datumaro.components.abstracts.merger.IMatcherContext | ~datumaro.components.abstracts.merger.IMergerContext | None = None, pairwise_dist=0.9, cluster_dist=-1.0, match_segments=<function match_segments_pair>, sigma: list | None = None, instance_map)[source]#

Bases: ShapeMatcher

Method generated by attrs for class PointsMatcher.

sigma: list | None#
distance(a, b)[source]#
class datumaro.components.annotations.merger.PolygonMatcher(*, context: ~datumaro.components.abstracts.merger.IMatcherContext | ~datumaro.components.abstracts.merger.IMergerContext | None = None, pairwise_dist=0.9, cluster_dist=-1.0, match_segments=<function match_segments_pair>)[source]#

Bases: ShapeMatcher

Method generated by attrs for class PolygonMatcher.

class datumaro.components.annotations.merger.RotatedBboxMatcher(sigma: list | None = None, *, context: ~datumaro.components.abstracts.merger.IMatcherContext | ~datumaro.components.abstracts.merger.IMergerContext | None = None, pairwise_dist=0.9, cluster_dist=-1.0, match_segments=<function match_segments_pair>)[source]#

Bases: ShapeMatcher

Method generated by attrs for class RotatedBboxMatcher.

sigma: list | None#
distance(a, b)[source]#
class datumaro.components.annotations.merger.ShapeMatcher(*, context: ~datumaro.components.abstracts.merger.IMatcherContext | ~datumaro.components.abstracts.merger.IMergerContext | None = None, pairwise_dist=0.9, cluster_dist=-1.0, match_segments=<function match_segments_pair>)[source]#

Bases: AnnotationMatcher

Method generated by attrs for class ShapeMatcher.

match_annotations(sources: List[List[Annotation]]) List[List[Annotation]][source]#
distance(a, b)[source]#
label_matcher(a, b)[source]#
class datumaro.components.annotations.merger.TabularMatcher(*, context: IMatcherContext | IMergerContext | None = None)[source]#

Bases: AnnotationMatcher

Method generated by attrs for class TabularMatcher.

match_annotations(sources)[source]#
class datumaro.components.annotations.merger.TabularMerger(*, context: IMatcherContext | IMergerContext | None = None)[source]#

Bases: AnnotationMerger, TabularMatcher

Method generated by attrs for class TabularMerger.

datumaro.components.annotations.merger.attrib(default=_Nothing.NOTHING, validator=None, repr=True, cmp=None, hash=None, init=True, metadata=None, type=None, converter=None, factory=None, kw_only=False, eq=None, order=None, on_setattr=None, alias=None)[source]#

Create a new field / attribute on a class.

Identical to attrs.field, except it’s not keyword-only.

Consider using attrs.field in new code (attr.ib will never go away, though).

Warning

Does nothing unless the class is also decorated with attr.s (or similar)!

New in version 15.2.0: convert

New in version 16.3.0: metadata

Changed in version 17.1.0: validator can be a list now.

Changed in version 17.1.0: hash is None and therefore mirrors eq by default.

New in version 17.3.0: type

Deprecated since version 17.4.0: convert

New in version 17.4.0: converter as a replacement for the deprecated convert to achieve consistency with other noun-based arguments.

New in version 18.1.0: factory=f is syntactic sugar for default=attr.Factory(f).

New in version 18.2.0: kw_only

Changed in version 19.2.0: convert keyword argument removed.

Changed in version 19.2.0: repr also accepts a custom callable.

Deprecated since version 19.2.0: cmp Removal on or after 2021-06-01.

New in version 19.2.0: eq and order

New in version 20.1.0: on_setattr

Changed in version 20.3.0: kw_only backported to Python 2

Changed in version 21.1.0: eq, order, and cmp also accept a custom callable

Changed in version 21.1.0: cmp undeprecated

New in version 22.2.0: alias

datumaro.components.annotations.merger.attrs(maybe_cls=None, these=None, repr_ns=None, repr=None, cmp=None, hash=None, init=None, slots=False, frozen=False, weakref_slot=True, str=False, auto_attribs=False, kw_only=False, cache_hash=False, auto_exc=False, eq=None, order=None, auto_detect=False, collect_by_mro=False, getstate_setstate=None, on_setattr=None, field_transformer=None, match_args=True, unsafe_hash=None)[source]#

A class decorator that adds dunder methods according to the specified attributes using attr.ib or the these argument.

Consider using attrs.define / attrs.frozen in new code (attr.s will never go away, though).

Parameters:

repr_ns (str) – When using nested classes, there was no way in Python 2 to automatically detect that. This argument allows to set a custom name for a more meaningful repr output. This argument is pointless in Python 3 and is therefore deprecated.

Caution

Refer to attrs.define for the rest of the parameters, but note that they can have different defaults.

Notably, leaving on_setattr as None will not add any hooks.

New in version 16.0.0: slots

New in version 16.1.0: frozen

New in version 16.3.0: str

New in version 16.3.0: Support for __attrs_post_init__.

Changed in version 17.1.0: hash supports None as value which is also the default now.

New in version 17.3.0: auto_attribs

Changed in version 18.1.0: If these is passed, no attributes are deleted from the class body.

Changed in version 18.1.0: If these is ordered, the order is retained.

New in version 18.2.0: weakref_slot

Deprecated since version 18.2.0: __lt__, __le__, __gt__, and __ge__ now raise a DeprecationWarning if the classes compared are subclasses of each other. __eq and __ne__ never tried to compared subclasses to each other.

Changed in version 19.2.0: __lt__, __le__, __gt__, and __ge__ now do not consider subclasses comparable anymore.

New in version 18.2.0: kw_only

New in version 18.2.0: cache_hash

New in version 19.1.0: auto_exc

Deprecated since version 19.2.0: cmp Removal on or after 2021-06-01.

New in version 19.2.0: eq and order

New in version 20.1.0: auto_detect

New in version 20.1.0: collect_by_mro

New in version 20.1.0: getstate_setstate

New in version 20.1.0: on_setattr

New in version 20.3.0: field_transformer

Changed in version 21.1.0: init=False injects __attrs_init__

Changed in version 21.1.0: Support for __attrs_pre_init__

Changed in version 21.1.0: cmp undeprecated

New in version 21.3.0: match_args

New in version 22.2.0: unsafe_hash as an alias for hash (for PEP 681 compliance).

Deprecated since version 24.1.0: repr_ns

Changed in version 24.1.0: Instances are not compared as tuples of attributes anymore, but using a big and condition. This is faster and has more correct behavior for uncomparable values like math.nan.

New in version 24.1.0: If a class has an inherited classmethod called __attrs_init_subclass__, it is executed after the class is created.

Deprecated since version 24.1.0: hash is deprecated in favor of unsafe_hash.

datumaro.components.annotations.merger.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.components.annotations.merger.segment_iou(a, b)[source]#

Generic IoU computation with masks, polygons, and boxes. Returns -1 if no intersection, [0; 1] otherwise