Skip to content

Commit

Permalink
Enable coco format to import bbox annotations (#1360)
Browse files Browse the repository at this point in the history
<!-- Contributing guide:
https://github.com/openvinotoolkit/datumaro/blob/develop/CONTRIBUTING.md
-->

### Summary

<!--
Resolves #111 and #222.
Depends on #1000 (for series of dependent commits).

This PR introduces this capability to make the project better in this
and that.

- Added this feature
- Removed that feature
- Fixed the problem #1234
-->

### How to test
<!-- Describe the testing procedure for reviewers, if changes are
not fully covered by unit tests or manual testing can be complicated.
-->

### Checklist
<!-- Put an 'x' in all the boxes that apply -->
- [ ] I have added unit tests to cover my changes.​
- [ ] I have added integration tests to cover my changes.​
- [x] I have added the description of my changes into
[CHANGELOG](https://github.com/openvinotoolkit/datumaro/blob/develop/CHANGELOG.md).​
- [ ] I have updated the
[documentation](https://github.com/openvinotoolkit/datumaro/tree/develop/docs)
accordingly

### License

- [ ] I submit _my code changes_ under the same [MIT
License](https://github.com/openvinotoolkit/datumaro/blob/develop/LICENSE)
that covers the project.
  Feel free to contact the maintainers if that's a concern.
- [ ] I have updated the license header for each file (see an example
below).

```python
# Copyright (C) 2024 Intel Corporation
#
# SPDX-License-Identifier: MIT
```
  • Loading branch information
wonjuleee authored Mar 20, 2024
1 parent 97a83d7 commit 2436d90
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
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 @@ def _load_annotations(self, ann, image_info=None, parsed_annotations=None):
)
)

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

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

0 comments on commit 2436d90

Please sign in to comment.