Abstract
Unsupervised anomaly detection (AD) often relies on Knowledge Distillation (KD), where a student network learns to mimic a pre-trained teacher. However, powerful student networks frequently suffer from "normality forgetting," where they inadvertently learn to reconstruct anomalous features, reducing the discrepancy used for detection. This paper proposes MemKD (Memory-guided Knowledge Distillation), which introduces a Normality Recall (NR) Memory module. By forcing the student to recall stored normal patterns, MemKD effectively constrains the student's representational power to normal data only. Evaluated across five major benchmarks, MemKD achieves state-of-the-art results while maintaining a significantly smaller memory footprint than existing memory-bank methods.
Introduction: The Challenge of Normality Forgetting
In the field of unsupervised anomaly detection, models are typically trained exclusively on normal data. A prevalent strategy is Knowledge Distillation (KD), which employs a fixed "teacher" network—usually pre-trained on a large dataset like ImageNet—and a "student" network. During inference, both networks process an image; a significant discrepancy between their outputs indicates a potential anomaly.
Despite its popularity, standard KD faces a critical bottleneck known as "normality forgetting." Because modern student networks are highly capable function approximators, they often generalize too well. They may successfully reconstruct anomalous features they have never encountered during training, or conversely, fail to capture the intricate details of normal patterns. When a student accurately mimics the teacher on an anomalous input, the detection signal (the discrepancy) vanishes, leading to false negatives.
The MemKD Framework
To address these issues, the authors introduce MemKD, a framework that integrates a "normality anchor" directly into the distillation process. Unlike traditional KD, where the student operates independently, MemKD constrains the student's output using a specialized memory module.
Core Components
- Normality Recall Memory (NR Memory): The student network does not predict features in isolation. Instead, it generates a "query" to look up relevant normal patterns stored in a key-value memory module. This ensures that the student's features are always modulated by explicit representations of normality.
- Normality Embedding Learning (NEL): The memory is populated through a specific training strategy using a "normal exemplar set." The module is forced to learn compact representations that can accurately reconstruct these normal exemplars.
- Coordinate Optimization: The framework is optimized using three distinct losses:
- $L_{KD}$: The standard distillation loss to align the student with the teacher.
- $L_{NM}$: Normality Memorization loss ensures the memory effectively stores and recalls normal information.
- $L_{Orth}$: Orthogonal Loss encourages diversity among stored memory items, maximizing the "vocabulary" of normal patterns.
Memory as a Constraint
The fundamental innovation of MemKD is using memory as a physical constraint. By requiring the student to "consult" a bank of normal features, it becomes architecturally difficult for the network to represent an anomaly. This adaptive modulation allows the model to handle complex textures and fine-grained details more effectively than standard reconstruction-based approaches.
Experimental Evaluation
The robustness of MemKD was validated across five diverse benchmarks: MVTec AD, VisA, MPDD, MVTec 3D-AD (RGB), and Eyecandies.
Key Results
MemKD demonstrated state-of-the-art (SOTA) performance across several metrics:
- Superior Accuracy: On MVTec AD, the model achieved a 99.6% Image-AUC, surpassing both standard KD and heavy memory-bank methods like PatchCore.
- Enhanced Localization: The framework significantly improved the detection of "tiny" anomalies, such as single missing wires, which are often overlooked by traditional methods.
- Efficiency and Compactness: MemKD is remarkably efficient. For the MPDD dataset, while PatchCore requires 48.4 MB to store its feature bank, MemKD requires only 0.3 MB.
- Generalization: The NR Memory module is highly versatile and can be integrated into various distillation architectures (both forward and reverse) to consistently boost performance.
Conclusion and Future Directions
MemKD successfully mitigates the "normality forgetting" problem by anchoring the distillation process in a learned memory of normal patterns. While the current implementation primarily utilizes RGB data, future work could extend this memory-guided approach to multi-modal data, such as point clouds or depth maps, to detect geometric anomalies. Additionally, research into compressing the dual-network (teacher-student) setup could further enhance inference speeds for real-time applications.
Summary updated