Fix augmentation application when no model is attached #2720
+9
−3
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.
📝 Description
This PR fixes an issue where user-specified augmentations weren't being applied to datasets when no model was attached to the datamodule. The fix ensures augmentations work in all scenarios, improving the user experience especially during testing and development.
Problem
Currently, when users set augmentations on a datamodule but don't attach a model, those augmentations aren't applied during dataset setup. This causes confusion since users naturally expect their specified transforms to be applied regardless of whether a model is present.
The issue occurs in the
_update_augmentations
method which only applies user augmentations when both:trainer.model.pre_processor.transform
This behavior forces users to implement workarounds like directly setting augmentations on datasets or attaching dummy models.
Solution
The fix updates the
_update_augmentations
method to properly handle scenarios where no model transform exists, ensuring user-specified augmentations are always applied.Code Changes
Before Fix
After Fix
Previous Workarounds (No Longer Needed)
Before this fix, users had to use one of these workarounds:
Select what type of change your PR is:
✅ Checklist
Before you submit your pull request, please make sure you have completed the following steps:
For more information about code review checklists, see the Code Review Checklist.