Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anomaly Heatmaps #5

Closed
SDJustus opened this issue Jun 8, 2021 · 4 comments
Closed

Anomaly Heatmaps #5

SDJustus opened this issue Jun 8, 2021 · 4 comments

Comments

@SDJustus
Copy link

SDJustus commented Jun 8, 2021

Hi,

is there a way to get the anomaly heatmaps from your code?

Best regards,
Justus

@Pangoraw
Copy link
Owner

Pangoraw commented Jun 8, 2021

padim.predict(..) returns the mahalanobis distances for each patch of the image. You can resize it to a square matrix to see the unormalized anomaly map. So you can do something like that:

import math
import matplotlib.pyplot
distances = padim.predict(img.unsqueeze(0))
w = int(math.sqrt(distances.numel()))
amap = distances.view(w, w)
plt.imshow(amap)
plt.show()

@Pangoraw
Copy link
Owner

Pangoraw commented Jun 8, 2021

image

Here is an example notebook where the input is 416x416 so the backbone outputs 104x104 anomaly maps

@Pangoraw Pangoraw pinned this issue Jun 8, 2021
@SDJustus
Copy link
Author

SDJustus commented Jun 9, 2021

Thank you again for your super fast work. I appreciate your effort very much!

@SDJustus SDJustus closed this as completed Jun 9, 2021
@rishabh-akridata
Copy link

rishabh-akridata commented Jul 30, 2024

@Pangoraw Why are we using Gaussian blurring as a preprocessing step for the amap? Is it just for visualization or is there any specific reason for doing that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants