Skip to content

Commit

Permalink
đŸ›  NaN fix for PaDim. With custom dataset and backbone distances somet…
Browse files Browse the repository at this point in the history
…imes contains small negative numbers, possible due to imperfect pseudo inverse calculation. (#392)
  • Loading branch information
VdLMV committed Jul 1, 2022
1 parent f204aae commit 92e243f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion anomalib/models/padim/anomaly_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def compute_distance(embedding: Tensor, stats: List[Tensor]) -> Tensor:

distances = (torch.matmul(delta, inv_covariance) * delta).sum(2).permute(1, 0)
distances = distances.reshape(batch, height, width)
distances = torch.sqrt(distances)
distances = distances.clamp(0).sqrt()

return distances

Expand Down

0 comments on commit 92e243f

Please sign in to comment.