Skip to content

Commit

Permalink
use clamp instead of min/max
Browse files Browse the repository at this point in the history
  • Loading branch information
djdameln committed Jan 14, 2025
1 parent 785679a commit 1feebc0
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/anomalib/post_processing/one_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,7 @@ def _normalize(
if preds is None:
return None
preds = ((preds - threshold) / (norm_max - norm_min)) + 0.5
preds = torch.minimum(preds, torch.tensor(1))
return torch.maximum(preds, torch.tensor(0))
return preds.clamp(min=0, max=1)

@property
def normalized_image_threshold(self) -> float:
Expand Down

0 comments on commit 1feebc0

Please sign in to comment.