Abstract
Deep learning-based defect detection in industrial manufacturing is often hampered by the scarcity of high-quality training data. To address this "data hunger," we present DefectDiffu, a novel text-guided diffusion framework designed to generate diverse, high-fidelity industrial defect images from limited samples. By modeling intra-product and inter-product consistencies, DefectDiffu achieves state-of-the-art generation quality and enables zero-shot defect transfer across different product categories.
Introduction
In modern manufacturing, automated defect detection is critical for maintaining quality standards. However, defects are rare by design, making it difficult to collect the thousands of annotated images required to train robust deep learning models. Existing generative approaches, such as Generative Adversarial Networks (GANs), often fail in few-shot scenarios, leading to overfitting, lack of diversity, or inaccurate segmentation masks.
DefectDiffu addresses these challenges by leveraging a Diffusion Transformer (DiT) backbone optimized for industrial contexts. Unlike previous models that treat each product in isolation, DefectDiffu exploits the inherent consistencies in industrial imagery: backgrounds remain stable within a product line, and specific defect types (e.g., scratches or holes) exhibit similar morphological features across different materials.
Methodology
The DefectDiffu architecture incorporates several innovations to ensure high-quality, controllable generation:
Text-guided Disentangled Integrated Architecture (TDIA)
To separate the "normal" product features from the "anomalous" defects, TDIA utilizes three distinct components. A Background Block is conditioned on the product name, a Defect Block is conditioned on the defect type, and a Fusion Block integrates the two. This disentanglement allows the model to learn defect features independently of the background texture.
Double-free Strategy
Building upon classifier-free guidance, the Double-free strategy introduces two-stage perturbation. By adjusting the perturbation scales ($w_d$ for defects and $w_p$ for products), users can precisely control the intensity of the generated defect and the specific product type, enabling a smooth transition from minor imperfections to major structural failures.
Adaptive Attention-enhanced Loss (AAL)
Small defects often occupy a negligible fraction of the total pixels, causing standard loss functions to ignore them. AAL solves this by calculating an "attention ratio" from cross-attention maps. It dynamically increases the loss weight for defect regions, ensuring the model captures fine-grained details even for the smallest anomalies.
Automatic Mask Generation
One of the most practical features of DefectDiffu is its ability to generate accurate binary segmentation masks automatically. By extracting cross-attention maps from the Defect Block—which indicate exactly where the model is placing the anomaly—the system provides high-quality ground truth labels for downstream detector training without manual intervention.
Key Insights: The Power of Consistency
The success of DefectDiffu lies in its modeling of two types of consistency:
- Intra-product Consistency: The background of a defective item (e.g., a cable) is identical to its non-defective counterpart.
- Inter-product Consistency: The physical appearance of a "hole" or "scratch" is remarkably similar across different objects, such as hazelnuts or metal parts.
This insight enables "defect surgery," where a defect learned from one product can be applied to a completely different one in a zero-shot manner. For example, a scratch pattern learned from metal can be realistically projected onto a pill or a leather surface.
Experimental Results
The model was evaluated on the MVTec AD benchmark, using only half of the standard test set for training to simulate a few-shot environment.
- Image Quality: DefectDiffu achieved a Fréchet Inception Distance (FID) of 69.35, a significant improvement over previous benchmarks like StyleGAN2 (138.99) and Defect-Gen (233.70).
- Diversity: High LPIPS scores confirmed that the model generates a wide variety of defect instances rather than simply memorizing training data.
- Downstream Utility: When synthetic images from DefectDiffu were used to augment the training set for a standard UNet defect detector, the mean Intersection over Union (mIoU) rose from 60.3 to 67.1, demonstrating the practical value of the generated data for real-world inspection systems.
Conclusion
DefectDiffu represents a significant step forward in industrial defect generation. By disentangling defect and background features and leveraging consistency modeling, it provides a robust solution to the data scarcity problem. Future work will focus on reducing the computational overhead of the Diffusion Transformer backbone and testing the framework in more complex, cluttered industrial environments.
Summary updated