From cdf1fda401d6a20ed21e14679ad64e7e9eaeab32 Mon Sep 17 00:00:00 2001 From: NrealLzx Date: Fri, 1 Sep 2023 06:53:46 +0000 Subject: [PATCH] [Fix]: fix ndarray metainfo check in ConcatDataset --- mmengine/dataset/dataset_wrapper.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mmengine/dataset/dataset_wrapper.py b/mmengine/dataset/dataset_wrapper.py index 49b630d8f0..6cbf1f0a08 100644 --- a/mmengine/dataset/dataset_wrapper.py +++ b/mmengine/dataset/dataset_wrapper.py @@ -6,6 +6,7 @@ from collections import defaultdict from typing import List, Sequence, Tuple, Union +import numpy as np from torch.utils.data.dataset import ConcatDataset as _ConcatDataset from mmengine.logging import print_log @@ -73,7 +74,14 @@ def __init__(self, raise ValueError( f'{key} does not in the meta information of ' f'the {i}-th dataset') - if self._metainfo[key] != dataset.metainfo[key]: + if isinstance(self._metainfo[key], np.ndarray) and isinstance( + dataset.metainfo[key], np.ndarray): + if not np.array_equal(self._metainfo[key], + dataset.metainfo[key]): + raise ValueError( + f'The meta information of the {i}-th dataset does' + 'not match meta information of the first dataset') + elif self._metainfo[key] != dataset.metainfo[key]: raise ValueError( f'The meta information of the {i}-th dataset does not ' 'match meta information of the first dataset')