[Fix] Merge class lists when concatenating datasets with different types#12437
Open
crawfordxx wants to merge 1 commit intoopen-mmlab:mainfrom
Open
[Fix] Merge class lists when concatenating datasets with different types#12437crawfordxx wants to merge 1 commit intoopen-mmlab:mainfrom
crawfordxx wants to merge 1 commit intoopen-mmlab:mainfrom
Conversation
When concatenating datasets with different class sets (e.g. CocoDataset + VOCDataset), ConcatDataset previously stored metainfo as a list of dicts. This broke downstream evaluation code that expects metainfo to be a single dict with a 'classes' key, causing IndexError in _det2json when cat_ids[label] was accessed with out-of-range labels. This fix adds a _merge_metainfo method that merges class lists from all sub-datasets into a unified set, preserving palette colours from each dataset. The merged metainfo dict is used instead of the list fallback, so evaluation works correctly with heterogeneous dataset concatenation. Fixes open-mmlab#8890
|
majianhan seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Fixes #8890
When concatenating datasets with different class sets (e.g.
CocoDataset+VOCDataset),ConcatDatasetstored_metainfoas a list of dicts. This broke downstream evaluation code that expectsmetainfoto be a single dict with aclasseskey, causingIndexErrorin_det2jsonwhencat_ids[label]was accessed with out-of-range labels.Modification
Added a
_merge_metainfo()method toConcatDatasetthat:Also updated the
full_initmetainfo update logic to useisinstancecheck instead of the removedis_all_sameflag.BC-breaking (Yes/No)
No. When all datasets have the same classes, behaviour is unchanged. When datasets differ, the merged dict is a strict improvement over the previous list-of-dicts fallback which was unusable by downstream code.
Checklist
pre-commit run --all-files)tests/test_datasets/test_dataset_wrappers.py)