FAPM: Fast Adaptive Patch Memory for Real-Time Industrial Anomaly Detection

Donghyeong Kim, Chaewon Park, Suhwan Cho, Sangyoun Lee

TL;DR

FAPM (Fast Adaptive Patch Memory) is a new framework that brings real-time speeds to high-accuracy industrial anomaly detection. By organizing memory banks spatially and using an adaptive sampling strategy that prioritizes complex image regions, FAPM achieves 44.1 FPS—nearly an 8x speedup over previous state-of-the-art methods—without sacrificing detection accuracy.

What Problem Does This Paper Address?

In industrial quality control, detecting tiny defects (anomalies) in products like transistors, tiles, or cables is a high-stakes task. Recent "feature-matching" methods have set records for accuracy by comparing features of a test image against a "memory bank" of normal features.

However, these methods face a major hurdle: speed. Most high-performing models, like PatchCore, are computationally heavy because they compare every part of a new image against a massive, global library of normal examples. In a real-world factory line, you can't wait half a second for a model to process one frame. Furthermore, these models often treat every part of an image the same way, even though some regions (like the complex center of a chip) might need more "memory" to describe than a plain background.

Methods

The authors introduce Fast Adaptive Patch Memory (FAPM), which optimizes the process through three main innovations:

  1. Patch-wise Memory: Most industrial images are "aligned" (the object is always in the same spot). FAPM exploits this by only comparing a patch at a specific location in the test image to the memory of patches at that exact same location from the training set. This drastically reduces the search space.
  2. Layer-wise Memory: Standard models often "concatenate" (stack) features from different layers of a neural network. This requires expensive upsampling. FAPM keeps these layers separate, calculates anomaly scores for each independently, and then combines them. This avoids redundant calculations.
  3. Patch-wise Adaptive Coreset Sampling: This is the "Adaptive" part of FAPM. Not all patches are equally complex. FAPM uses a distance-based score to measure the "spread" of features in a patch. If a patch is highly variable, the model keeps more "key vectors" in memory. If it's simple, it keeps fewer. This ensures the memory bank is lean but effective.

Datasets

The researchers evaluated FAPM on the MVTec Anomaly Detection (MVTec AD) benchmark. This is the gold standard for the field, containing 15 categories of industrial objects and textures (e.g., leather, wood, screws, and transistors) with over 5,000 high-resolution images.

Key Insights and Ideas

  • Spatial Context is a Speed Hack: By assuming industrial parts are roughly aligned, the authors turned a global search problem into a local one. This is the primary driver behind the massive jump in FPS.
  • Efficiency through Independence: The decision to process network layers separately rather than concatenating them proves that you can achieve the same "multi-scale" benefits of deep learning with much lower computational overhead.
  • Dynamic Resource Allocation: The adaptive sampling reflects a more "human-like" approach to memory—paying more attention to complex areas and less to repetitive ones. The ablation study showed that this adaptive approach improved accuracy by 0.6 percentage points compared to uniform sampling.

Key Results

  • Inference Speed: FAPM reached 44.1 FPS on an NVIDIA Titan RTX. For comparison, the authors' implementation of the popular PatchCore model ran at only 5.9 FPS on the same hardware.
  • Accuracy: Despite the speedup, FAPM remains highly competitive. It achieved an average Image-level AUROC of 99.0% and a Pixel-level AUROC (for localization) of 98.0% across the MVTec AD dataset.
  • SOTA Performance: In specific categories like "transistor" and "zipper," FAPM outperformed all other compared methods in both detection and localization.

Limitations and Future Work

The biggest limitation of FAPM is its reliance on the assumption that images are roughly aligned. In many industrial settings, parts are held in jigs, making this a safe assumption. However, in "in-the-wild" scenarios where objects might be rotated or shifted significantly, the patch-wise memory approach might struggle.

Future work could involve making the patch-matching process more robust to translation and rotation (perhaps through spatial transformers or more flexible alignment preprocessing) while maintaining the real-time performance that makes FAPM so practical for the factory floor.

Summary updated

BibTeX
@inproceedings{kim2023fapm,
  author = {Donghyeong Kim and Chaewon Park and Suhwan Cho and Sangyoun Lee},
  title = {{FAPM: Fast Adaptive Patch Memory for Real-Time Industrial Anomaly Detection}},
  booktitle = {IEEE International Conference on Acoustics, Speech and Signal Processing},
  year = {2023},
  url = {https://openreview.net/forum?id=zPgPdXXguLI},
}

Loading related content...

Figure