Introduction
In industrial manufacturing, automated defect inspection—encompassing detection, classification, and localization—is vital for quality control. However, deep learning models are data-hungry, and real-world defect images are notoriously scarce. Collecting these rare events is expensive and time-consuming. While Generative Adversarial Networks (GANs) are typically used for data augmentation, they often fail in "few-shot" scenarios—where only 10–20 images are available—leading to overfitting, blurry results, or mode collapse.
The authors introduce DFMGAN (Defect-aware Feature Manipulation GAN) to address these challenges. DFMGAN is designed to generate thousands of unique, high-fidelity defect images from a minimal set of real examples by leveraging structural priors from defect-free data.
Methodology: Defect-Aware Feature Manipulation
The core innovation of DFMGAN lies in its two-stage training strategy that decouples the generation of the base object from the generation of the defect. This approach recognizes that a defective object is essentially a "normal" object with localized changes.
Stage 1: Learning the "Normal" State
First, a data-efficient StyleGAN2 backbone is trained on a larger set of defect-free images. This stage allows the model to learn the complex structural and textural priors of the target object (e.g., a hazelnut) without the interference of anomalies. By using a frozen backbone for the object and residual blocks for the defect, the model doesn't have to "re-learn" the basic geometry of the object.
Stage 2: Localized Feature Manipulation
In the second stage, the backbone is frozen, and Defect-aware Residual Blocks are introduced. Instead of synthesizing a complete image from scratch, these blocks learn to modify the internal feature maps of the backbone at specific locations.
As shown in the architecture above, the process involves:
- Defect Mask Generation: The model produces a pixel-level map indicating the intended defect location.
- Feature Manipulation: The residual blocks modify features only within the masked region. This mask-guided manipulation prevents the "hallucination" of artifacts in the background or non-defective parts of the object.
- Defect Mapping: A separate network ($z_{defect}$) controls the specific style and variation of the added defects.
To maintain realism and diversity, the framework employs a Matching Discriminator to ensure defects align with their masks and a Mode Seeking Loss to prevent mode collapse by encouraging the model to produce different masks for different noise inputs.
Evaluation and Key Results
The model was primarily evaluated on the MVTec AD (Anomaly Detection) dataset, specifically the challenging "hazelnut" category. Hazelnuts are particularly difficult due to their complex textures and structural variations compared to simple surfaces like metal.
- Realism and Diversity: DFMGAN outperformed generic few-shot GANs (like DiffAug) and specialized generators (like SDGAN), achieving the lowest Kernel Inception Distance (KID) and the highest clustered LPIPS scores. This indicates that the generated images are both statistically similar to real defects and highly diverse.
- Downstream Performance: The ultimate test of generative augmentation is its impact on inspection tasks. Using DFMGAN-generated data to train a ResNet-34 classifier improved accuracy on the hazelnut dataset to approximately 81-83%, a significant leap from the 56-60% achieved by previous generative methods.
Conclusion
DFMGAN demonstrates that the key to few-shot defect generation is leveraging the "normal" state as a prior. By restricting generative changes to localized regions via mask-guided manipulation, the model avoids the common pitfalls of standard GANs in data-scarce environments. While the approach is currently dependent on the quality of the defect-free backbone and may struggle with defects that significantly alter an object's 3D silhouette, it provides a robust framework for high-fidelity industrial data augmentation.
Summary updated