Skip to content

Commit 879d05e

Browse files
committed
Reduce code duplication
1 parent bcbe859 commit 879d05e

File tree

1 file changed

+3
-26
lines changed

1 file changed

+3
-26
lines changed

cvat/apps/consensus/intersect_merge.py

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import itertools
88
from abc import ABCMeta, abstractmethod
99
from collections.abc import Collection
10-
from typing import Iterable, Optional, Sequence
10+
from typing import Iterable, Sequence
1111

1212
import attrs
1313

@@ -17,7 +17,7 @@
1717
import datumaro.components.merge.intersect_merge
1818
import numpy as np
1919
from datumaro.components.errors import FailedLabelVotingError
20-
from datumaro.util.annotation_util import find_instances, max_bbox, mean_bbox
20+
from datumaro.util.annotation_util import mean_bbox
2121
from datumaro.util.attrs_util import ensure_cls
2222

2323
from cvat.apps.engine.models import Label
@@ -121,27 +121,8 @@ def _for_type(t: dm.AnnotationType, **kwargs) -> AnnotationMatcher:
121121
else:
122122
raise AssertionError(f"Annotation type {t} is not supported")
123123

124-
instance_map = {}
125-
for s in sources:
126-
s_instances = find_instances(s)
127-
for inst in s_instances:
128-
inst_bbox = max_bbox(
129-
[
130-
a
131-
for a in inst
132-
if a.type
133-
in {
134-
dm.AnnotationType.polygon,
135-
dm.AnnotationType.mask,
136-
dm.AnnotationType.bbox,
137-
}
138-
]
139-
)
140-
for ann in inst:
141-
instance_map[id(ann)] = [inst, inst_bbox]
142-
143124
self._mergers = {
144-
t: _for_type(t, instance_map=instance_map, categories=self._categories)
125+
t: _for_type(t, categories=self._categories)
145126
for t in self.conf.included_annotation_types
146127
}
147128

@@ -357,17 +338,13 @@ class MaskMatcher(PolygonMatcher):
357338

358339
@attrs.define(kw_only=True, slots=False)
359340
class PointsMatcher(ShapeMatcher):
360-
sigma: Optional[list] = attrs.field(default=None)
361-
362341
def match_annotations_between_two_items(self, item_a, item_b):
363342
matches, _, _, _, distances = self._comparator.match_points(item_a, item_b)
364343
return matches, distances
365344

366345

367346
@attrs.define(kw_only=True, slots=False)
368347
class SkeletonMatcher(ShapeMatcher):
369-
sigma: float = 0.1
370-
371348
def match_annotations_between_two_items(self, item_a, item_b):
372349
matches, _, _, _, distances = self._comparator.match_skeletons(item_a, item_b)
373350
return matches, distances

0 commit comments

Comments
 (0)