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 saving attribute in WiderFace extractor #251

Merged
merged 3 commits into from
May 26, 2021
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 @@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Allowed adding "difficult", "truncated", "occluded" attributes when converting to Pascal VOC if these attributes are not present (<https://github.com/openvinotoolkit/datumaro/pull/216>)
- Empty lines in YOLO annotations are ignored (<https://github.com/openvinotoolkit/datumaro/pull/221>)
- Export in VOC format when no image info is available (<https://github.com/openvinotoolkit/datumaro/pull/239>)
- Fixed saving attribute in WiderFace extractor (<https://github.com/openvinotoolkit/datumaro/pull/251>)

### Security
-
Expand Down
6 changes: 5 additions & 1 deletion datumaro/plugins/widerface_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from datumaro.components.converter import Converter
from datumaro.components.extractor import (AnnotationType, Bbox, DatasetItem,
Importer, Label, LabelCategories, SourceExtractor)
from datumaro.util import str_to_bool


class WiderFacePath:
Expand Down Expand Up @@ -119,7 +120,10 @@ def _load_items(self, path):
i = 4
for attr in WiderFacePath.BBOX_ATTRIBUTES:
if bbox_list[i] != '-':
attributes[attr] = bbox_list[i]
if bbox_list[i] in ['True', 'False']:
attributes[attr] = str_to_bool(bbox_list[i])
else:
attributes[attr] = bbox_list[i]
i += 1

annotations.append(Bbox(
Expand Down
4 changes: 3 additions & 1 deletion tests/test_widerface_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ def test_can_save_and_load(self):
'blur': '2', 'expression': '1', 'illumination': '0',
'occluded': '0', 'pose': '1', 'invalid': '0'}),
Bbox(0, 2, 3, 2, label=0, attributes={
'occluded': 'False'}),
'occluded': False}),
Bbox(0, 3, 4, 2, label=0, attributes={
'occluded': True}),
Bbox(0, 2, 4, 2, label=0),
Bbox(0, 7, 3, 2, label=0, attributes={
'blur': '2', 'expression': '1', 'illumination': '0',
Expand Down