Skip to content

Commit

Permalink
[Fix]: fix ndarray metainfo check in ConcatDataset
Browse files Browse the repository at this point in the history
  • Loading branch information
NrealLzx committed Sep 1, 2023
1 parent 8a7e80e commit cdf1fda
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion mmengine/dataset/dataset_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit cdf1fda

Please sign in to comment.