Skip to content
Open
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
4 changes: 2 additions & 2 deletions src/anomalib/post_processing/post_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ def on_validation_epoch_end(self, trainer: Trainer, pl_module: LightningModule)
del trainer, pl_module
if self.enable_thresholding:
# compute threshold values
if self._image_threshold_metric.update_called:
if getattr(self._image_threshold_metric, "_update_called", False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am personally not in favour of using getattrs if possible. If the image threshold metric isn't set, it will be None. In that case we can just compare it against null value.

self._image_threshold.copy_(self._image_threshold_metric.compute())
self._image_threshold_metric.reset()
if self._pixel_threshold_metric.update_called:
self._pixel_threshold.copy_(self._pixel_threshold_metric.compute())
self._pixel_threshold_metric.reset()
if self.enable_normalization:
# compute normalization values
if self._image_min_max_metric.update_called:
if getattr(self._image_min_max_metric, "_update_called", False):
image_min, image_max = self._image_min_max_metric.compute()
self.image_min.copy_(image_min)
self.image_max.copy_(image_max)
Expand Down
Loading