diff --git a/CHANGELOG.md b/CHANGELOG.md index 9781e527e8..5cc4b155ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Randomness of random split transform () - `Transform.subsets()` method () - Supported unknown image formats in TF Detection API converter () +- Supported empty attribute values in CVAT extractor () ### Security - diff --git a/datumaro/plugins/cvat_format/extractor.py b/datumaro/plugins/cvat_format/extractor.py index 35343ea07d..59a8f4ed94 100644 --- a/datumaro/plugins/cvat_format/extractor.py +++ b/datumaro/plugins/cvat_format/extractor.py @@ -86,7 +86,7 @@ def _parse(cls, path): } elif ev == 'end': if el.tag == 'attribute' and attributes is not None: - attr_value = el.text + attr_value = el.text or '' if el.text in ['true', 'false']: attr_value = attr_value == 'true' else: diff --git a/tests/test_cvat_format.py b/tests/test_cvat_format.py index fb8aea5513..99dc485c4a 100644 --- a/tests/test_cvat_format.py +++ b/tests/test_cvat_format.py @@ -150,7 +150,7 @@ def test_can_save_and_load(self): label_categories = LabelCategories() for i in range(10): label_categories.add(str(i)) - label_categories.items[2].attributes.update(['a1', 'a2']) + label_categories.items[2].attributes.update(['a1', 'a2', 'empty']) label_categories.attributes.update(['occluded']) source_dataset = Dataset.from_iterable([ @@ -158,10 +158,10 @@ def test_can_save_and_load(self): annotations=[ Polygon([0, 0, 4, 0, 4, 4], label=1, group=4, - attributes={ 'occluded': True }), + attributes={ 'occluded': True}), Points([1, 1, 3, 2, 2, 3], label=2, - attributes={ 'a1': 'x', 'a2': 42, + attributes={ 'a1': 'x', 'a2': 42, 'empty': '', 'unknown': 'bar' }), Label(1), Label(2, attributes={ 'a1': 'y', 'a2': 44 }), @@ -199,7 +199,7 @@ def test_can_save_and_load(self): attributes={ 'occluded': True }), Points([1, 1, 3, 2, 2, 3], label=2, - attributes={ 'occluded': False, + attributes={ 'occluded': False, 'empty': '', 'a1': 'x', 'a2': 42 }), Label(1), Label(2, attributes={ 'a1': 'y', 'a2': 44 }),