From 834fc47c455f13c6df772f8566f0490f316d419a Mon Sep 17 00:00:00 2001 From: Maxim Zhiltsov Date: Mon, 25 May 2020 16:52:30 +0300 Subject: [PATCH 1/2] Fix image size conversion --- datumaro/datumaro/components/dataset_filter.py | 7 ++++++- datumaro/datumaro/plugins/yolo_format/extractor.py | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/datumaro/datumaro/components/dataset_filter.py b/datumaro/datumaro/components/dataset_filter.py index e9f10febda9..351cc6c8d1a 100644 --- a/datumaro/datumaro/components/dataset_filter.py +++ b/datumaro/datumaro/components/dataset_filter.py @@ -32,7 +32,12 @@ def encode(cls, item, categories=None): def encode_image(cls, image): image_elem = ET.Element('image') - h, w = image.size + size = image.size + if size is not None: + h, w = size + else: + h = 'unknown' + w = h ET.SubElement(image_elem, 'width').text = str(w) ET.SubElement(image_elem, 'height').text = str(h) diff --git a/datumaro/datumaro/plugins/yolo_format/extractor.py b/datumaro/datumaro/plugins/yolo_format/extractor.py index 5e2c61b3df6..135f6f8f206 100644 --- a/datumaro/datumaro/plugins/yolo_format/extractor.py +++ b/datumaro/datumaro/plugins/yolo_format/extractor.py @@ -137,7 +137,8 @@ def _parse_annotations(anno_path, image): annotations = [] if lines: - image_height, image_width = image.size # use image info late + # use image info as late as possible + image_height, image_width = image.size for line in lines: label_id, xc, yc, w, h = line.split() label_id = int(label_id) From 0a60aa85a926a45ce16e40ebf864c40813b28e6e Mon Sep 17 00:00:00 2001 From: Maxim Zhiltsov Date: Wed, 3 Jun 2020 13:41:44 +0300 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 858ec855c72..7e87f64fa4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - ### Fixed -- +- Fixed dataset filter item representation for imageless dataset items (https://github.com/opencv/cvat/pull/1593) ### Security -