Skip to content

Commit dcf0820

Browse files
authored
🐞 fix(data): update_augmentations when no model is attached (#2720)
* Make OpenVINO fully optional in Anomalib Signed-off-by: Samet Akcay <samet.akcay@intel.com> * Fix augmentation application when no model is attached Signed-off-by: Samet Akcay <samet.akcay@intel.com> --------- Signed-off-by: Samet Akcay <samet.akcay@intel.com>
1 parent 4a8117a commit dcf0820

File tree

1 file changed

+9
-3
lines changed
  • src/anomalib/data/datamodules/base

1 file changed

+9
-3
lines changed

src/anomalib/data/datamodules/base/image.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,15 @@ def _update_augmentations(self) -> None:
165165
for subset_name in ["train", "val", "test"]:
166166
subset = getattr(self, f"{subset_name}_data", None)
167167
augmentations = getattr(self, f"{subset_name}_augmentations", None)
168-
model_transform = get_nested_attr(self, "trainer.model.pre_processor.transform")
169-
if subset and model_transform:
170-
self._update_subset_augmentations(subset, augmentations, model_transform)
168+
model_transform = get_nested_attr(self, "trainer.model.pre_processor.transform", None)
169+
170+
if subset:
171+
if model_transform:
172+
# If model transform exists, update augmentations with model-specific transforms
173+
self._update_subset_augmentations(subset, augmentations, model_transform)
174+
else:
175+
# If no model transform, just apply the user-specified augmentations
176+
subset.augmentations = augmentations
171177

172178
@staticmethod
173179
def _update_subset_augmentations(

0 commit comments

Comments
 (0)