From a01555e03ae2ba284d2d0cdc4e72985d90b608e6 Mon Sep 17 00:00:00 2001 From: Nikita Manovich Date: Wed, 17 Apr 2019 22:34:42 +0300 Subject: [PATCH] Slightly improve code for annotation.py --- cvat/apps/engine/annotation.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cvat/apps/engine/annotation.py b/cvat/apps/engine/annotation.py index 1ed3a31264ee..c2a13b1e292a 100644 --- a/cvat/apps/engine/annotation.py +++ b/cvat/apps/engine/annotation.py @@ -845,9 +845,9 @@ def merge(self, objects, start_frame, overlap): # Nothing to merge here. Just add all int_objects if any. if not old_objects_by_frame or not int_objects_by_frame: - for old_obj in [item for sublist in old_objects_by_frame.values() for item in sublist]: - self._modify_unmached_object(old_obj, - start_frame + overlap) + for frame in old_objects_by_frame: + for old_obj in old_objects_by_frame[frame]: + self._modify_unmached_object(old_obj, start_frame + overlap) self.objects.extend(int_objects) return @@ -952,7 +952,7 @@ def _calc_polygons_similarity(p0, p1): return overlap_area / (p0.area + p1.area - overlap_area) has_same_type = obj0["type"] == obj1["type"] - has_same_label = obj0["label_id"] == obj1["label_id"] if "label_id" in obj0 else True + has_same_label = obj0.get("label_id") == obj1.get("label_id") if has_same_type and has_same_label: if obj0["type"] == models.ShapeType.RECTANGLE: p0 = geometry.box(*obj0["points"])