Skip to content

🐞 fix(data): update_augmentations when no model is attached #2720

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

Merged
Merged
Changes from all 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: 9 additions & 3 deletions src/anomalib/data/datamodules/base/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,15 @@ def _update_augmentations(self) -> None:
for subset_name in ["train", "val", "test"]:
subset = getattr(self, f"{subset_name}_data", None)
augmentations = getattr(self, f"{subset_name}_augmentations", None)
model_transform = get_nested_attr(self, "trainer.model.pre_processor.transform")
if subset and model_transform:
self._update_subset_augmentations(subset, augmentations, model_transform)
model_transform = get_nested_attr(self, "trainer.model.pre_processor.transform", None)

if subset:
if model_transform:
# If model transform exists, update augmentations with model-specific transforms
self._update_subset_augmentations(subset, augmentations, model_transform)
else:
# If no model transform, just apply the user-specified augmentations
subset.augmentations = augmentations

@staticmethod
def _update_subset_augmentations(
Expand Down
Loading