From bd659246e9db106fdad12d70a47a86f17e2ccc57 Mon Sep 17 00:00:00 2001 From: zhiltsov-max Date: Sun, 12 Apr 2020 18:52:25 +0300 Subject: [PATCH] [Datumaro] Fix COCO keypoint export bug (#1388) --- CHANGELOG.md | 1 + datumaro/datumaro/plugins/coco_format/converter.py | 6 +++--- datumaro/tests/test_coco_format.py | 3 +++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e99a221..997b3c93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Merge is allowed for points, but clicks on points conflict with frame dragging logic - Removed objects are visible for search - Add missed task_id and job_id fields into exception logs for the new UI (https://github.com/opencv/cvat/pull/1372) +- Fixed polygon exporting bug in COCO dataset (https://github.com/opencv/cvat/issues/1387) - Task creation from remote files (https://github.com/opencv/cvat/pull/1392) ### Security diff --git a/datumaro/datumaro/plugins/coco_format/converter.py b/datumaro/datumaro/plugins/coco_format/converter.py index a618c227..2fe0ee38 100644 --- a/datumaro/datumaro/plugins/coco_format/converter.py +++ b/datumaro/datumaro/plugins/coco_format/converter.py @@ -1,5 +1,5 @@ -# Copyright (C) 2019 Intel Corporation +# Copyright (C) 2020 Intel Corporation # # SPDX-License-Identifier: MIT @@ -364,9 +364,9 @@ class _KeypointsConverter(_InstancesConverter): solitary_points = [] for g_id, group in groupby(annotations, lambda a: a.group): - if g_id and not cls.find_instance_anns(group): + if not g_id or g_id and not cls.find_instance_anns(group): group = [a for a in group if a.type == AnnotationType.points] - solitary_points.extend(group) + solitary_points.extend(group) return solitary_points diff --git a/datumaro/tests/test_coco_format.py b/datumaro/tests/test_coco_format.py index f9340b65..a0339abc 100644 --- a/datumaro/tests/test_coco_format.py +++ b/datumaro/tests/test_coco_format.py @@ -560,6 +560,9 @@ class CocoConverterTest(TestCase): annotations=[ # Solitary keypoints Points([1, 2, 0, 2, 4, 1], label=5, id=3), + + # Some other solitary annotations (bug #1387) + Polygon([0, 0, 4, 0, 4, 4], label=3, id=4), ]), DatasetItem(id=3, subset='val',