Abstract
Anomaly detection (AD) is a fundamental task in computer vision, aiming to identify image data patterns that deviate from normal distributions. Conventional methods often address AD by generating augmented negative samples to facilitate self-supervised learning. However, these techniques typically lack semantic awareness during augmentation, leading to unrealistic or invalid negative samples that can hinder feature extraction. In this study, we propose CutSwap, a novel augmentation strategy that leverages saliency guidance to incorporate semantic cues. By employing LayerCAM to extract multilevel features and applying K-means clustering to identify high-saliency regions, CutSwap selects patch pairs with dense semantic correlations and swaps their locations. This process generates subtle yet realistic negative samples. Extensive evaluations show that CutSwap achieves state-of-the-art performance on MVTec AD and VisA benchmarks.
Introduction
Industrial anomaly detection is characterized by a significant data imbalance: while "normal" samples are abundant, actual "anomalous" samples (defects like cracks or stains) are rare. To overcome this, Self-Supervised Learning (SSL) has become a standard approach, where models are trained to distinguish between original normal images and artificially generated anomalies.
A prominent existing method, CutPaste, creates anomalies by randomly cutting a patch and pasting it elsewhere. However, CutPaste is "semantics-blind." It may paste background textures onto other background areas—creating samples that appear normal—or place background patches onto foreground objects in physically impossible ways. Such low-quality negative samples introduce noise into the training process, preventing the neural network from learning the nuanced features required for real-world defect detection.
Methodology: The CutSwap Framework
To address the limitations of semantics-blind augmentation, we introduce CutSwap. This method ensures that synthetic defects are placed in semantically meaningful regions, forcing the model to focus on the object's core structure and texture.
The CutSwap workflow consists of three primary stages:
1. Multilevel Saliency Extraction
We utilize LayerCAM to generate saliency maps from multiple layers of a Convolutional Neural Network (CNN). Coarse layers provide a global view of the object area, while finer layers highlight intricate textures and edges. This multilevel approach allows the generation of a diverse range of anomalies, from structural shifts to minute textural glitches.
2. Saliency Map Clustering
Rather than simply selecting the highest intensity pixels, we apply K-means clustering to the saliency intensities. We identify the cluster with the highest average saliency to serve as the "anchor" region. This ensures that the augmentation occurs on the object of interest rather than the irrelevant background, maintaining semantic consistency.
3. The Swap Operation
Within the identified high-saliency cluster, two anchor points are randomly selected to form a patch pair. Unlike traditional "pasting," which duplicates information, "swapping" the locations of these two patches preserves the global statistics of the image while introducing a subtle local irregularity. This mimics the nature of real industrial defects more accurately than simple duplication.
For final detection, we integrate CutSwap into a PatchCore-based framework. A ResNet18 backbone is trained to classify images as normal, CutSwap-augmented, or "scar" (long, thin swapped patches). During inference, the model utilizes a memory bank of normal features to identify anomalous patches.
Experimental Results
The effectiveness of CutSwap was evaluated on two major industrial benchmarks: MVTec AD and VisA.
- MVTec AD: CutSwap achieved an average image-level Area Under the ROC Curve (AUC) of 0.955, a significant improvement over CutPaste's 0.928.
- VisA: On this more complex dataset, CutSwap reached an image-level AUC of 0.881, outperforming other self-supervised methods such as SPD (0.878).
Qualitative analysis reveals that CutSwap produces cleaner anomaly maps with fewer false positives, particularly in challenging categories like Grid or Toothbrush, where complex backgrounds often confuse simpler models.
Conclusion
CutSwap represents a significant advancement in self-supervised anomaly detection by introducing semantic awareness into the data augmentation process. By guiding patch swaps with multilevel saliency maps, the method generates realistic synthetic anomalies that facilitate superior feature learning. Future research will explore more sophisticated methods for fusing attention maps and refining saliency extraction to further enhance the realism of synthetic defects.
Summary updated