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

Apply PaDiM to another domain. #16

Open
sangkyuleeKOR opened this issue Mar 22, 2021 · 8 comments
Open

Apply PaDiM to another domain. #16

sangkyuleeKOR opened this issue Mar 22, 2021 · 8 comments

Comments

@sangkyuleeKOR
Copy link

Hi I'm sangkyu from south korea.

I am trying to apply PaDiM to another domain.

Several issues arose during application.

I want to do anomaly detection with an image of size 80x160x3.
The score distribution of the normal image tends to be higher than that of the abnormal image. I know that PaDiM is sensitive to the location, and the background was also erased with contours to minimize the background effect. However, the distribution of normal scores is still high. Can you leave any comments on this?

abnormal
normal

@DeepKnowledge1
Copy link

I applied on another domain, was fine,
can you increase the resolution: make your image size: 160 x160

@sangkyuleeKOR
Copy link
Author

sangkyuleeKOR commented Mar 23, 2021

I applied on another domain, was fine,
can you increase the resolution: make your image size: 160 x160

I've already tried to make image resolution as 160x160 by padding. but it didn't work properly.
Are you talking about to make images to 160x160 by resizing????

@sangkyuleeKOR
Copy link
Author

Heat maps are relative to the image data.
example)
nomal data = 0,0,0,1,2(red),1,1,4(red),2(red),1,...
anomaly data = 0,0,0,1,2,1,1,14(red),2,1,16(red),...
Are you check threshold? need gt mask

I'm taking about heatmap result. i think normal data has to be covered by blue but it has abnormal points which is colored by red. I don't need gt masks because I'm gonna shift threshold by circumstances.

@sangkyuleeKOR
Copy link
Author

sangkyuleeKOR commented Mar 23, 2021

In the case of normal image, even if there is little data deviation, it is expressed red in the heat map.
This is because heat maps make data normalize.
You'd better check it a score map.

Thanks for replying!
I modified the code a lot. heat map is in range 0 to 1, and score map 0 to 1 has proper value.. and I compared normal and abnormal image's distribution. I found nothing wrong with normalize.

@dhkdnduq
Copy link

dhkdnduq commented Mar 23, 2021

because of this code
norm = matplotlib.colors.Normalize(vmin=vmin, vmax=vmax)

if you change ax = ax_img[2].imshow(heat_map, cmap='jet', norm=None)

You will see the range of color bar range changing.

However, because heat maps are relative to the data, the high data will still look red.

easy to trick heatmap

heat_map = scores[i] * 255 <--below this code
heat_map[0] = vmax <-- write

@sangkyuleeKOR
Copy link
Author

sangkyuleeKOR commented Mar 25, 2021

because of this code
norm = matplotlib.colors.Normalize(vmin=vmin, vmax=vmax)

if you change ax = ax_img[2].imshow(heat_map, cmap='jet', norm=None)

You will see the range of color bar range changing.

However, because heat maps are relative to the data, the high data will still look red.

easy to trick heatmap

heat_map = scores[i] * 255 <--below this code
heat_map[0] = vmax <-- write

like I said, I checked score maps of normal and abnormal data, it was not heat map range problem. I fixed heat map range with static number

@dhkdnduq
Copy link

dhkdnduq commented Mar 25, 2021

It doesn't mean anything to fix the heat map range.

This is because when displaying image data in matplot, scale up to range.

The scale should be prevented by putting the max value into the image data.

Have you tested it like below?

  • heat_map[0] = vmax

I'm sorry if it wasn't the answer you wanted.

@SixK
Copy link

SixK commented Mar 27, 2021

Try to swap this lines:
mask[mask > threshold] = 1
mask[mask <= threshold] = 0
like this:
mask[mask <= threshold] = 0
mask[mask > threshold] = 1

If threshold is too high (>1), then some mask values become 1 then all mask values become 0 (as all values will be under threshold)

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

4 participants