Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Fix ndarray metainfo check in ConcatDataset #1333

Merged
merged 3 commits into from
Sep 1, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 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,16 @@ 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]:
first_type = type(self._metainfo[key])
cur_type = type(dataset.metainfo[key])
if first_type is cur_type: # type: ignore
raise TypeError(
f'The type of {key} in the {i}-th dataset should be '
'the same with the first dataset')
zhouzaida marked this conversation as resolved.
Show resolved Hide resolved
if (isinstance(self._metainfo[key], np.ndarray)
and not np.array_equal(self._metainfo[key],
dataset.metainfo[key])
or 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
Loading