Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable coco format to import bbox annotations #1360

Merged
merged 4 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
(<https://github.com/openvinotoolkit/datumaro/pull/1262>)
- Fix explore command without project
(<https://github.com/openvinotoolkit/datumaro/pull/1271>)
- Fix enable COCO to import only bboxes
(<https://github.com/openvinotoolkit/datumaro/pull/1360>)

## Jan. 2024 Release 1.5.2
### Enhancements
Expand Down
9 changes: 7 additions & 2 deletions src/datumaro/plugins/data_formats/coco/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2019-2022 Intel Corporation
# Copyright (C) 2019-2024 Intel Corporation
#
# SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -505,7 +505,12 @@
)
)

segmentation = self._parse_field(ann, "segmentation", (list, dict))
try:
segmentation = self._parse_field(ann, "segmentation", (list, dict))
except MissingFieldError as e:
log.warn(str(e))
segmentation = None

Check warning on line 512 in src/datumaro/plugins/data_formats/coco/base.py

View check run for this annotation

Codecov / codecov/patch

src/datumaro/plugins/data_formats/coco/base.py#L511-L512

Added lines #L511 - L512 were not covered by tests

if segmentation and segmentation != [[]]:
rle = None

Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_coco_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,8 @@ def test_can_report_missing_item_field(self):

@mark_requirement(Requirements.DATUM_ERROR_REPORTING)
def test_can_report_missing_ann_field(self):
for field in ["id", "image_id", "segmentation", "iscrowd", "category_id", "bbox"]:
# https://github.com/openvinotoolkit/datumaro/issues/1344 requires to make "segmentation" optional
for field in ["id", "image_id", "iscrowd", "category_id", "bbox"]:
with self.subTest(field=field):
with TestDir() as test_dir:
ann_path = self._get_dummy_annotation_path(test_dir)
Expand Down
Loading