From 082b75a24731ad2b1e5f2012667875cbb393540f Mon Sep 17 00:00:00 2001 From: Maxim Zhiltsov Date: Tue, 1 Jun 2021 14:34:13 +0300 Subject: [PATCH] Fix warnings --- datumaro/cli/commands/explain.py | 2 +- datumaro/components/operations.py | 4 ++-- datumaro/plugins/cifar_format.py | 2 +- datumaro/plugins/coco_format/converter.py | 2 +- datumaro/plugins/coco_format/importer.py | 4 ++-- datumaro/plugins/ndr.py | 18 ++++++++++-------- datumaro/plugins/yolo_format/converter.py | 2 +- 7 files changed, 18 insertions(+), 16 deletions(-) diff --git a/datumaro/cli/commands/explain.py b/datumaro/cli/commands/explain.py index 9c3e1d147a..c47ae011fb 100644 --- a/datumaro/cli/commands/explain.py +++ b/datumaro/cli/commands/explain.py @@ -152,7 +152,7 @@ def explain_command(args): for item in dataset: image = item.image.data if image is None: - log.warn( + log.warning( "Dataset item %s does not have image data. Skipping." % \ (item.id)) continue diff --git a/datumaro/components/operations.py b/datumaro/components/operations.py index bfe26aec99..002e76f623 100644 --- a/datumaro/components/operations.py +++ b/datumaro/components/operations.py @@ -1032,8 +1032,8 @@ def _extractor_stats(extractor): for item in extractor: if not (item.has_image and item.image.has_data): available = False - log.warn("Item %s has no image. Image stats won't be computed", - item.id) + log.warning("Item %s has no image, it will be excluded from " + "image stats", item.id) break stats = { diff --git a/datumaro/plugins/cifar_format.py b/datumaro/plugins/cifar_format.py index e2a2bec12b..b6f3a01a23 100644 --- a/datumaro/plugins/cifar_format.py +++ b/datumaro/plugins/cifar_format.py @@ -158,7 +158,7 @@ def apply(self): annotation_dict = {} annotation_dict['filenames'] = filenames annotation_dict['labels'] = labels - annotation_dict['data'] = np.array(data) + annotation_dict['data'] = np.array(data, dtype=object) if len(image_sizes): size = (CifarPath.IMAGE_SIZE, CifarPath.IMAGE_SIZE) # 'image_sizes' isn't included in the standard format, diff --git a/datumaro/plugins/coco_format/converter.py b/datumaro/plugins/coco_format/converter.py index 36781a0396..f7caa56b96 100644 --- a/datumaro/plugins/coco_format/converter.py +++ b/datumaro/plugins/coco_format/converter.py @@ -265,7 +265,7 @@ def save_annotations(self, item): return if not item.has_image: - log.warn("Item '%s': skipping writing instances " + log.warning("Item '%s': skipping writing instances " "since no image info available" % item.id) return h, w = item.image.size diff --git a/datumaro/plugins/coco_format/importer.py b/datumaro/plugins/coco_format/importer.py index 2e8f8a2ac8..8d41376ea8 100644 --- a/datumaro/plugins/coco_format/importer.py +++ b/datumaro/plugins/coco_format/importer.py @@ -88,10 +88,10 @@ def find_sources(path): try: ann_type = CocoTask[ann_type] except KeyError: - log.warn("Skipping '%s': unknown subset " + log.warning("Skipping '%s': unknown subset " "type '%s', the only known are: %s" % \ (subset_path, ann_type, - ', '.join([e.name for e in CocoTask]))) + ', '.join(e.name for e in CocoTask))) continue subset_name = name_parts[1] subsets[subset_name][ann_type] = subset_path diff --git a/datumaro/plugins/ndr.py b/datumaro/plugins/ndr.py index b92945bbad..060cd8047e 100644 --- a/datumaro/plugins/ndr.py +++ b/datumaro/plugins/ndr.py @@ -22,14 +22,16 @@ class NDR(Transform, CliPlugin): """ - Near-duplicated image removal |n - Removes near-duplicated images in subset |n - Example: control number of outputs to 100 after NDR |n - |s|s%(prog)s \ |n - |s|s|s|s--working_subset train \ |n - |s|s|s|s--algorithm gradient \ |n - |s|s|s|s--num_cut 100 \ |n - |s|s|s|s--over_sample random \ |n + Near-duplicated image removal.|n + |n + Removes near-duplicated images in subset|n + |n + Example: apply NDR, return no more than 100 images|n + |s|s%(prog)s|n + |s|s|s|s--working_subset train|n + |s|s|s|s--algorithm gradient|n + |s|s|s|s--num_cut 100|n + |s|s|s|s--over_sample random|n |s|s|s|s--under_sample uniform """ diff --git a/datumaro/plugins/yolo_format/converter.py b/datumaro/plugins/yolo_format/converter.py index fb71b8f172..71f021f0e6 100644 --- a/datumaro/plugins/yolo_format/converter.py +++ b/datumaro/plugins/yolo_format/converter.py @@ -49,7 +49,7 @@ def apply(self): if not subset_name or subset_name == DEFAULT_SUBSET_NAME: subset_name = YoloPath.DEFAULT_SUBSET_NAME elif subset_name not in YoloPath.SUBSET_NAMES: - log.warn("Skipping subset export '%s'. " + log.warning("Skipping subset export '%s'. " "If specified, the only valid names are %s" % \ (subset_name, ', '.join( "'%s'" % s for s in YoloPath.SUBSET_NAMES)))