Memory Efficient Continual Learning for Edge-Based Visual Anomaly Detection

Manuel Barusco, Lorenzo D'Antoni, Davide Dalle Pezze, Francesco Borsatti, Gian Antonio SustoarXiv 2025 · DOI

Introduction

Visual Anomaly Detection (VAD) is a critical component in industrial quality control and medical diagnostics, focusing on the identification and localization of defects. Deploying these models on edge devices—such as factory-floor cameras or mobile sensors—presents significant challenges due to limited computational resources and the phenomenon of "catastrophic forgetting." When a model is sequentially trained on new data distributions (e.g., a new product line), it often loses the ability to detect anomalies in previously learned categories.

Overview of the Continual Learning for Visual Anomaly Detection (CLAD) framework across sequential tasks.

This paper introduces a framework designed for Continual Learning for Visual Anomaly Detection (CLAD) on edge hardware. The proposed approach combines an optimized architecture, PaSTe, with advanced Compressed Replay techniques to maintain high performance across multiple tasks while minimizing memory overhead.

Methodology

PaSTe Architecture

The core of the framework is the PaSTe (Paper-to-Architecture Student-Teacher) model, an evolution of the Student-Teacher Feature Pyramid Matching (STFPM) framework. In a typical Teacher-Student setup, a fixed, pre-trained "Teacher" network provides reference features, while a "Student" network is trained on normal samples to replicate those features. Anomalies are detected where the Student's output deviates significantly from the Teacher's.

Comparison between the standard STFPM architecture (a) and the proposed PaSTe model (b), highlighting shared frozen layers.

As shown in Figure 2, PaSTe optimizes this by freezing and sharing the initial layers of the backbone between the Teacher and the Student. This architectural choice serves two purposes: it reduces the number of trainable parameters, lowering the memory footprint, and it stabilizes feature representations across different tasks, which inherently mitigates catastrophic forgetting.

Compressed Replay

To further prevent forgetting without the massive storage requirements of saving raw images, the authors implement Compressed Replay. Instead of a standard image buffer, the system stores intermediate feature maps. Three levels of compression are explored:

  1. Feature Replay: Storing latent representations instead of raw pixels.
  2. Feature Quantization (FQ): Reducing precision from 32-bit floats to 8-bit integers.
  3. Product Quantization (PQ): An aggressive vector quantization technique that clusters subspaces to achieve extreme compression ratios.

Experimental Results

The framework was evaluated using the MVTec AD Dataset, simulating a 10-task continual learning environment.

Performance and Efficiency

The PaSTe architecture, when paired with Replay techniques, achieved a 10% improvement in pixel-level F1-score compared to the standard STFPM baseline. Beyond accuracy, the efficiency gains were substantial:

  • Memory Reduction: Utilizing Product Quantization (PQ) Replay reduced the memory required for the replay buffer by 91.5% compared to traditional image-based Replay.
  • Computational Speed: PaSTe reduced inference time by 25% and training time by 33%.
  • Resource Management: Peak RAM usage during training was slashed by 76%, making it highly suitable for microcontrollers like those supported by the MCUNet-IN3 backbone.

Stability and Forgetting

Analysis of "average forgetting" scores confirmed that the shared-layer design of PaSTe provides a more robust foundation for sequential learning. By maintaining consistent low-level features, the model avoids the aggressive weight shifts that typically degrade performance on older tasks.

Conclusion

This research demonstrates that effective continual learning for anomaly detection is feasible on resource-constrained edge devices. By optimizing the Teacher-Student architecture and employing aggressive feature compression, the proposed framework achieves superior detection accuracy with a fraction of the memory and computational cost of traditional methods. Future work will investigate distillation-based approaches to further reduce reliance on memory buffers and explore the limits of feature compression in complex, overlapping task environments.

Summary updated

BibTeX
@misc{barusco2025memory,
  author = {Manuel Barusco and Lorenzo D'Antoni and Davide Dalle Pezze and Francesco Borsatti and Gian Antonio Susto},
  title = {{Memory Efficient Continual Learning for Edge-Based Visual Anomaly Detection}},
  year = {2025},
  eprint = {2503.02691},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2503.02691},
}
Figure