From b3eaf4a5035ad37c4cf591643b5d0f4b18f64992 Mon Sep 17 00:00:00 2001 From: Anastasia Yasakova Date: Wed, 14 Apr 2021 10:35:38 +0300 Subject: [PATCH] Adding "difficult", "truncated", "occluded" attributes when converting to Pascal VOC if they are not present (#216) * remove check for 'difficult' attribute * remove check for 'truncated' and 'occluded' attributes * update changelog --- CHANGELOG.md | 1 + datumaro/plugins/voc_format/converter.py | 20 ++++++-------------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef2dd699a1..f0e966c5fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Allowed explicit label removal in `remap_labels` transform () - Image extension in CVAT format export () - Added a label "face" for bounding boxes in Wider Face () +- Allowed adding "difficult", "truncated", "occluded" attributes when converting to Pascal VOC if these attributes are not present () ### Security - diff --git a/datumaro/plugins/voc_format/converter.py b/datumaro/plugins/voc_format/converter.py index abb109ff9a..4a5d36b9f6 100644 --- a/datumaro/plugins/voc_format/converter.py +++ b/datumaro/plugins/voc_format/converter.py @@ -236,20 +236,12 @@ def save_subsets(self): ET.SubElement(obj_elem, 'pose').text = \ str(attr['pose']) - if 'truncated' in attr: - truncated = _convert_attr('truncated', attr, int, 0) - ET.SubElement(obj_elem, 'truncated').text = \ - '%d' % truncated - - if 'difficult' in attr: - difficult = _convert_attr('difficult', attr, int, 0) - ET.SubElement(obj_elem, 'difficult').text = \ - '%d' % difficult - - if 'occluded' in attr: - occluded = _convert_attr('occluded', attr, int, 0) - ET.SubElement(obj_elem, 'occluded').text = \ - '%d' % occluded + ET.SubElement(obj_elem, 'truncated').text = \ + '%d' % _convert_attr('truncated', attr, int, 0) + ET.SubElement(obj_elem, 'occluded').text = \ + '%d' % _convert_attr('occluded', attr, int, 0) + ET.SubElement(obj_elem, 'difficult').text = \ + '%d' % _convert_attr('difficult', attr, int, 0) bbox = obj.get_bbox() if bbox is not None: