Target before Shooting: Accurate Anomaly Detection and Localization under One Millisecond via Cascade Patch Retrieval

Hanxi Li, Jianfei Hu, Bo Li, Hao Chen, Yongbin Zheng +1 more
8/13/2023
cs.CV

Official code: flyinghu123/CPR (119 stars, MIT, last commit 2024-10-28).

Abstract

In this work, by re-examining the "matching" nature of Anomaly Detection (AD), we propose a new AD framework that simultaneously enjoys new records of AD accuracy and dramatically high running speed. In this framework, the anomaly detection problem is solved via a cascade patch retrieval procedure that retrieves the nearest neighbors for each test image patch in a coarse-to-fine fashion. Given a test sample, the top-K most similar training images are first selected based on a robust histogram matching process. Secondly, the nearest neighbor of each test patch is retrieved over the similar geometrical locations on those "global nearest neighbors", by using a carefully trained local metric. Finally, the anomaly score of each test image patch is calculated based on the distance to its "local nearest neighbor" and the "non-background" probability. The proposed method is termed "Cascade Patch Retrieval" (CPR) in this work. Different from the conventional patch-matching-based AD algorithms, CPR selects proper "targets" (reference images and locations) before "shooting" (patch-matching). On the well-acknowledged MVTec AD, BTAD and MVTec-3D AD datasets, the proposed algorithm consistently outperforms all the comparing SOTA methods by remarkable margins, measured by various AD metrics. Furthermore, CPR is extremely efficient. It runs at the speed of 113 FPS with the standard setting while its simplified version only requires less than 1 ms to process an image at the cost of a trivial accuracy drop. The code of CPR is available at https://github.com/flyinghu123/CPR.

View on arXivView PDF

Code Implementations(1)

flyinghu123/CPROfficial100%
MIT

This is an official implementation of the paper : "Target before Shooting: Accurate Anomaly Detection and Localization under One Millisecond via Cascade Patch Retrieval" (Accepted by IEEE TIP)

11913Shell, PythonJun 18, 20231 years agoMIT
anomaly-detectioncontrastive-loss

Similar Papers

Cite this paper

@article{li2023target,
  title  = {Target before Shooting: Accurate Anomaly Detection and Localization under One Millisecond via Cascade Patch Retrieval},
  author = {Hanxi Li and Jianfei Hu and Bo Li and Hao Chen and Yongbin Zheng and Chunhua Shen},
  year   = {2023},
  eprint = {2308.06748},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2308.06748v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2308.06748.svg)](https://codeofpaper.com/paper/2308.06748)

Discussion