[Paper Review] AnomalyDiffusion: Few-Shot Anomaly Image Generation with Diffusion Model
AnomalyDiffusion is a diffusion-based framework for few-shot anomaly image generation that disentangles anomaly appearance and location with Spatial Anomaly Embedding and uses Adaptive Attention Re-weighting to produce authentic, mask-aligned anomaly image-mask pairs, boosting downstream anomaly inspection tasks.
Anomaly inspection plays an important role in industrial manufacture. Existing anomaly inspection methods are limited in their performance due to insufficient anomaly data. Although anomaly generation methods have been proposed to augment the anomaly data, they either suffer from poor generation authenticity or inaccurate alignment between the generated anomalies and masks. To address the above problems, we propose AnomalyDiffusion, a novel diffusion-based few-shot anomaly generation model, which utilizes the strong prior information of latent diffusion model learned from large-scale dataset to enhance the generation authenticity under few-shot training data. Firstly, we propose Spatial Anomaly Embedding, which consists of a learnable anomaly embedding and a spatial embedding encoded from an anomaly mask, disentangling the anomaly information into anomaly appearance and location information. Moreover, to improve the alignment between the generated anomalies and the anomaly masks, we introduce a novel Adaptive Attention Re-weighting Mechanism. Based on the disparities between the generated anomaly image and normal sample, it dynamically guides the model to focus more on the areas with less noticeable generated anomalies, enabling generation of accurately-matched anomalous image-mask pairs. Extensive experiments demonstrate that our model significantly outperforms the state-of-the-art methods in generation authenticity and diversity, and effectively improves the performance of downstream anomaly inspection tasks. The code and data are available in https://github.com/sjtuplayer/anomalydiffusion.
Motivation & Objective
- Motivate improved anomaly inspection under scarce anomaly data in manufacturing.
- Propose a diffusion-based method that generates authentic and diverse anomaly samples from few examples.
- Disentangle anomaly appearance and location to control type and placement of anomalies.
- Improve alignment between generated anomalies and masks to support localization and classification tasks.
Proposed method
- Utilize a pre-trained Latent Diffusion Model (LDM) to transfer prior knowledge from large-scale data for few-shot anomaly generation.
- Introduce Spatial Anomaly Embedding that combines an anomaly embedding (appearance) with a spatial embedding (location) to condition the generation.
- Apply masked textual inversion to learn anomaly appearance tokens while focusing on anomaly regions.
- Encode anomaly masks into a spatial embedding via a dedicated spatial encoder shared across categories.
- Incorporate Adaptive Attention Re-weighting to dynamically emphasize regions with less noticeable anomalies during denoising, improving mask alignment.
- Generate anomalies on input normal samples using a blended diffusion process that blends the anomalous regions with normal content according to the mask.
- Optionally generate anomaly masks via learned mask embeddings to augment training data for downstream tasks.
Experimental results
Research questions
- RQ1Can few anomaly examples be used to generate authentic and diverse anomaly images that align well with given masks?
- RQ2Does disentangling anomaly appearance from location improve controllability over generated anomalies?
- RQ3Can adaptive attention re-weighting improve the alignment between generated anomalies and anomaly masks during diffusion synthesis?
- RQ4Do generated anomaly samples improve downstream anomaly inspection tasks such as detection, localization, and classification?
- RQ5How effective is mask generation via learned embeddings in expanding training data for anomaly tasks?
Key findings
- AnomalyDiffusion outperforms state-of-the-art anomaly generation models in generation authenticity and diversity on the MVTec dataset.
- The approach achieves high-quality, densely aligned anomaly images that match input masks, aided by the Adaptive Attention Re-weighting mechanism.
- Generated anomaly data substantially improves downstream anomaly inspection performance, including pixel-level localization.
- On MVTec, the method yields a pixel-level localization AUROC of 99.1% and an AP of 81.4% when evaluated with a simple U-Net trained on the generated data.
- The model enables generating extensive anomaly image-mask pairs (e.g., 1000 per anomaly type) from only a few real anomaly samples, and the spatial anomaly embedding provides controllable placement and appearance of anomalies.
- Generated anomalies achieve strong categorical classification performance when used to train a classifier, surpassing several baselines.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.