Add pipeline transform order validation#12438
Open
crawfordxx wants to merge 1 commit intoopen-mmlab:mainfrom
Open
Add pipeline transform order validation#12438crawfordxx wants to merge 1 commit intoopen-mmlab:mainfrom
crawfordxx wants to merge 1 commit intoopen-mmlab:mainfrom
Conversation
Add validate_pipeline_order() that warns when data augmentation transforms appear in a suspicious order. For example, placing Normalize before RandomFlip or Pad before Resize can silently produce bad training results, as reported in open-mmlab#6106. The validation is called automatically in BaseDetDataset.__init__ and emits UserWarning messages without raising exceptions, so existing configs continue to work. Covered rules: - Loading transforms must come first - Spatial augmentation before pixel augmentation - Pad after Resize and RandomFlip - Normalize after all augmentations and Pad - Formatting / packing last
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.
Summary
Fixes #6106
As reported in the issue, the ordering of data augmentation transforms in training pipelines is error-prone and can silently produce incorrect results (e.g., zero evaluation metrics). This PR adds a
validate_pipeline_order()utility that:NormalizebeforeRandomFlip,PadbeforeResize)BaseDetDataset.__init__before the dataset is builtUserWarningmessages — never raises exceptions — so existing configs continue to workChanges
mmdet/datasets/utils.py: Addedvalidate_pipeline_order()with transform category definitions and pair-wise ordering rulesmmdet/datasets/base_det_dataset.py: Callsvalidate_pipeline_order()during dataset initializationmmdet/datasets/__init__.py: Exports the new functiontests/test_datasets/test_utils.py: Unit tests covering correct pipelines, the exact problematic pipeline from Training pipeline transformation order? #6106, and various misordering scenariosExample warning
When using the problematic pipeline from #6106 (Normalize before Pad):
Test plan