One-for-More: Continual Diffusion Model for Anomaly Detection

Xiaofan Li, Xin Tan, Zhuo Chen, Zhizhong Zhang, Ruixin Zhang, Rizen Guo, Guannan Jiang, Yulong Chen, Yanyun Qu, Lizhuang Ma, Yuan Xie

Abstract

Diffusion models have demonstrated exceptional capabilities in anomaly detection by reconstructing images to their normal states. However, existing models typically follow "one-for-one" or "one-for-all" paradigms, which are impractical for real-world scenarios where new products and patterns emerge sequentially. This paper presents CDAD (Continual Diffusion model for Anomaly Detection), a framework designed for the "one-for-more" paradigm. CDAD addresses catastrophic forgetting and faithfulness hallucinations through memory-efficient gradient projection and a novel anomaly-masking network. Experimental results on MVTec and VisA datasets show that CDAD achieves state-of-the-art performance, maintaining high accuracy across sequential tasks.

Introduction: The Challenge of Continual Learning

In industrial settings, anomaly detection systems must adapt to new categories over time. Standard diffusion models struggle with continual learning due to two primary issues:

  1. Catastrophic Forgetting: Training on a new task (e.g., cables) often degrades the model's ability to detect anomalies in previously learned tasks (e.g., bottles).
  2. Faithfulness Hallucination: Models may incorrectly map features from previous classes onto new inputs, leading to structural inconsistencies in reconstructions.
Performance comparison and the faithfulness hallucination problem where standard models fail to maintain consistency across tasks compared to CDAD.

As illustrated above, while baseline methods like ControlNet suffer significant performance drops and visual hallucinations as more tasks are added, CDAD maintains stable AUROC scores and high-fidelity reconstructions.

Methodology

The CDAD framework introduces three key innovations to stabilize the continual learning process:

Continual Diffusion Model (CDM) with Gradient Projection

To prevent new training from overwriting established knowledge, the CDM modifies update gradients. It projects the gradient of a new task onto a subspace orthogonal to the "significant representation" of previous tasks. This ensures that updates for new categories do not perturb the feature space of earlier ones.

Iterative Singular Value Decomposition (iSVD)

Gradient projection typically requires computing SVD on massive feature matrices, which is computationally prohibitive for diffusion models. The authors propose iSVD, which processes feature matrices in small, iterative blocks. This reduces memory requirements from an estimated 157 GB to approximately 17 GB, making the approach feasible for standard hardware.

Anomaly-Masked Network (AMN)

Diffusion models can sometimes "over-fit" to anomalies, reconstructing the defect instead of the normal state. The AMN employs a local CNN and a non-local Transformer encoder with neighbor-masked self-attention. By masking out anomalous features during the conditioning phase, the model is forced to rely on surrounding normal regions to reconstruct the missing parts accurately.

The overall architecture of CDAD, including the CDM framework, iSVD process, and AMN structure.

Experimental Results

CDAD was evaluated on the MVTec-AD and VisA benchmarks using various continual learning protocols. The model achieved first place in 17 out of 18 experimental settings.

  • Anti-Forgetting: On MVTec, CDAD maintained an image-level AUROC of 96.4% after 14 sequential tasks, significantly outperforming baselines.
  • Localization: Pixel-level anomaly detection remained highly accurate, avoiding the localization collapse seen in other diffusion-based methods.
  • Efficiency: The iSVD technique allowed for scaling complex regularization to heavy generative models without sacrificing performance.

Conclusion

CDAD provides a robust solution for sequential anomaly detection in industrial environments. By combining gradient projection with efficient iterative computation and targeted feature masking, it overcomes the traditional pitfalls of continual learning in generative models. Future work may address the slight information loss inherent in k-rank approximations for extremely long task sequences.

Summary updated

BibTeX
@inproceedings{li2025one,
  author = {Xiaofan Li and Xin Tan and Zhuo Chen and Zhizhong Zhang and Ruixin Zhang and Rizen Guo and Guannan Jiang and Yulong Chen and Yanyun Qu and Lizhuang Ma and Yuan Xie},
  title = {{One-for-More: Continual Diffusion Model for Anomaly Detection}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2025},
  doi = {10.1109/cvpr52734.2025.00449},
}
Figure