Skip to content

Commit

Permalink
[Datumaro] Fix duplicating keypoints in COCO export (#1435)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiltsov-max authored Apr 22, 2020
1 parent 9344b06 commit c78db45
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Auto annotation, TF annotation and Auto segmentation apps (https://github.com/opencv/cvat/pull/1409)
- Import works with truncated images now: "OSError:broken data stream" on corrupt images (https://github.com/opencv/cvat/pull/1430)
- Duplicating keypoints in COCO export (https://github.com/opencv/cvat/pull/1435)

### Security
-
Expand Down
6 changes: 3 additions & 3 deletions datumaro/datumaro/plugins/coco_format/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,7 @@ def save_annotations(self, item):
instance = [points, [], None, points.get_bbox()]
elem = super().convert_instance(instance, item)
elem.update(self.convert_points_object(points))
if elem:
self.annotations.append(elem)
self.annotations.append(elem)

# Create annotations for complete instance + keypoints annotations
super().save_annotations(item)
Expand Down Expand Up @@ -390,7 +389,8 @@ def convert_points_object(ann):

def convert_instance(self, instance, item):
points_ann = find(item.annotations, lambda x: \
x.type == AnnotationType.points and x.group == instance[0].group)
x.type == AnnotationType.points and \
instance[0].group and x.group == instance[0].group)
if not points_ann:
return None

Expand Down
2 changes: 1 addition & 1 deletion datumaro/tests/test_coco_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ def __iter__(self):
Points([1, 2, 3, 4, 2, 3], group=2, id=2),
Bbox(1, 2, 2, 2, group=2, id=2),
]),
DatasetItem(id=2, subset='train',
DatasetItem(id=2, subset='train', image=np.zeros((5, 4, 3)),
annotations=[
# Solitary keypoints
Points([1, 2, 0, 2, 4, 1], label=5, id=3),
Expand Down

0 comments on commit c78db45

Please sign in to comment.