Skip to content
Snippets Groups Projects
Unverified Commit b654f896 authored by Kamran Melikov's avatar Kamran Melikov Committed by GitHub
Browse files

Add class to wrap result fields into lists for evaluation (#2285)


* Add class to wrap result fields into lists for evaluation

On branch wrap_into_lists
Changes to be committed:
modified:   mmdet/datasets/pipelines/formating.py

* Add doctsring to WrapFieldsToLists

On branch wrap_into_lists
Changes to be committed:
modified:   mmdet/datasets/pipelines/formating.py

* update the example in docstring of WrapFieldsToLists

Co-authored-by: default avatarKai Chen <chenkaidev@gmail.com>
parent 6678a231
No related branches found
No related tags found
No related merge requests found
......@@ -190,3 +190,35 @@ class Collect(object):
def __repr__(self):
return self.__class__.__name__ + '(keys={}, meta_keys={})'.format(
self.keys, self.meta_keys)
@PIPELINES.register_module
class WrapFieldsToLists(object):
"""
Wrap fields of the data dictionary into lists for evaluation.
This class can be used as a last step of a test or validation
pipeline for single image evaluation or inference.
Example:
>>> test_pipeline = [
>>> dict(type='LoadImageFromFile'),
>>> dict(type='Normalize',
mean=[123.675, 116.28, 103.53],
std=[58.395, 57.12, 57.375],
to_rgb=True),
>>> dict(type='Pad', size_divisor=32),
>>> dict(type='ImageToTensor', keys=['img']),
>>> dict(type='Collect', keys=['img']),
>>> dict(type='WrapIntoLists')
>>> ]
"""
def __call__(self, results):
# Wrap dict fields into lists
for key, val in results.items():
results[key] = [val]
return results
def __repr__(self):
return '{}()'.format(self.__class__.__name__)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment