diff --git a/anomalib/models/patchcore/anomaly_map.py b/anomalib/models/patchcore/anomaly_map.py index 00e8eafbe0..086f44ff38 100644 --- a/anomalib/models/patchcore/anomaly_map.py +++ b/anomalib/models/patchcore/anomaly_map.py @@ -57,7 +57,7 @@ def compute_anomaly_score(patch_scores: torch.Tensor) -> torch.Tensor: """ max_scores = torch.argmax(patch_scores[:, 0]) confidence = torch.index_select(patch_scores, 0, max_scores) - weights = 1 - (torch.max(torch.exp(confidence)) / torch.sum(torch.exp(confidence))) + weights = 1 - torch.max(F.softmax(confidence, dim=-1)) score = weights * torch.max(patch_scores[:, 0]) return score