Training-Free Anomaly Generation via Dual-Attention Enhancement in Diffusion Model

  • 2025-08-15 15:52:02
  • Zuo Zuo, Jiahao Dong, Yanyun Qu, Zongze Wu
  • 0

Abstract

Industrial anomaly detection (AD) plays a significant role in manufacturingwhere a long-standing challenge is data scarcity. A growing body of works haveemerged to address insufficient anomaly data via anomaly generation. However,these anomaly generation methods suffer from lack of fidelity or need to betrained with extra data. To this end, we propose a training-free anomalygeneration framework dubbed AAG, which is based on Stable Diffusion (SD)'sstrong generation ability for effective anomaly image generation. Given anormal image, mask and a simple text prompt, AAG can generate realistic andnatural anomalies in the specific regions and simultaneously keep contents inother regions unchanged. In particular, we propose Cross-Attention Enhancement(CAE) to re-engineer the cross-attention mechanism within Stable Diffusionbased on the given mask. CAE increases the similarity between visual tokens inspecific regions and text embeddings, which guides these generated visualtokens in accordance with the text description. Besides, generated anomaliesneed to be more natural and plausible with object in given image. We proposeSelf-Attention Enhancement (SAE) which improves similarity between each normalvisual token and anomaly visual tokens. SAE ensures that generated anomaliesare coherent with original pattern. Extensive experiments on MVTec AD and VisAdatasets demonstrate effectiveness of AAG in anomaly generation and itsutility. Furthermore, anomaly images generated by AAG can bolster performanceof various downstream anomaly inspection tasks.

 

Quick Read (beta)

loading the full paper ...