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

Fix empty attributes in CVAT extractor #45

Merged
merged 2 commits into from
Oct 26, 2020
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Randomness of random split transform (<https://github.com/openvinotoolkit/datumaro/pull/38>)
- `Transform.subsets()` method (<https://github.com/openvinotoolkit/datumaro/pull/38>)
- Supported unknown image formats in TF Detection API converter (<https://github.com/openvinotoolkit/datumaro/pull/40>)
- Supported empty attribute values in CVAT extractor (<https://github.com/openvinotoolkit/datumaro/pull/45>)

### Security
-
Expand Down
2 changes: 1 addition & 1 deletion datumaro/plugins/cvat_format/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions tests/test_cvat_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,18 @@ 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([
DatasetItem(id=0, subset='s1', image=np.zeros((5, 10, 3)),
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 }),
Expand Down Expand Up @@ -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 }),
Expand Down