anomalib icon indicating copy to clipboard operation
anomalib copied to clipboard

Is the PatchCore image-level anomaly score correctly calculated?

Open StefanoSamele-PoliMi opened this issue 3 years ago • 3 comments

We have found a significant difference between the implementation proposed and the one described in the paper, for the PatchCore image-level anomaly score calculation.

For a test image , they first calculate the maximum distance score as:

Screenshot 2022-04-26 at 16 36 19

where is the set of patches of image and the memory bank.

They then apply a re-weighting factor to take into account if the patch is far from neighboring samples and thereby an already rare nominal occurrence.

Screenshot 2022-04-26 at 16 17 38

We underline that are the nearest neighbors of in the memory bank. In your implementation instead, you weigh according to the nearest neighbors of , choosing the distance from the furthest element as numerator, and the distances from the others as denominator.

We have tested the two scoring methods (the original one and the one proposed in this repository) on a custom dataset and no differences were registered in terms of AUCROC score. We are currently testing on some MVTEC classes.

StefanoSamele-PoliMi avatar Apr 27 '22 09:04 StefanoSamele-PoliMi

Thanks @StefanoSamele-PoliMi! We'll check it out

samet-akcay avatar Apr 27 '22 10:04 samet-akcay

Adding to the discussion, if you aren't aware patchcore authors updated their paper on arxiv and upload the official implementation of the algorithm, apparently it performs even better than the result reported by you (99.2 compared to 98.0 avg) with the wide resnet 50. If you have time might be worth checking it out! https://github.com/amazon-research/patchcore-inspection

lorenzomammana avatar May 11 '22 07:05 lorenzomammana

In official patchcore work, the performance is Patchcore(99.1,98.1). But your work get (98.0,98.0),which is lower than official. Why is that ? Is there any problem about the score calculation?

cyj95 avatar Aug 23 '22 09:08 cyj95