Abstract
AnoStyler is a lightweight framework that generates realistic, localized anomaly images from a single normal image using text-guided style transfer. By framing anomaly generation as a "stylization" task rather than a "from-scratch" generation task, it produces high-quality synthetic data that significantly improves the performance of anomaly detection models without requiring any real-world defect examples for training.
Introduction
In industrial inspection, anomalies such as cracks, holes, or stains are rare, making it difficult to train robust machine learning models. Existing solutions generally fall into two categories: heuristic methods (e.g., cut-and-paste), which often lack realism, and generative methods (e.g., GANs or Diffusion), which are computationally intensive and often fail to preserve the exact structure of the original object. AnoStyler addresses these challenges by offering a lightweight, text-driven approach that is sophisticated enough for high-quality generation yet efficient enough for practical deployment.
Methodology
AnoStyler treats anomaly generation as a text-driven localized style transfer task. The architecture consists of three primary components:
- Shape-Guided Mask Generation: The system utilizes "meta-shape priors" (Line, Dot, and Freeform shapes) to create plausible defect geometries. It integrates the Segment Anything Model (SAM) to ensure these masks are accurately placed on the foreground object.
- Two-Class Prompt Generation: Natural language guides the stylization. The model generates pairs of text prompts: a "normal" prompt (e.g., "a photo of a flawless hazelnut") and an "anomaly" prompt (e.g., "a photo of a hazelnut with a hole defect").
- Lightweight Stylization Network: A compact U-Net serves as the core generator. It is optimized using CLIP-based losses, specifically the Mask-Weighted Co-Directional Loss ($L_{mwcd}$) and Masked CLIP Loss ($L_{mclip}$). These losses ensure that visual modifications are confined to the mask and align with the textual description of the defect.
Experimental Evaluation
The authors evaluated AnoStyler on two benchmark datasets:
- MVTec-AD: 15 categories (10 objects, 5 textures) with over 5,000 high-resolution images.
- VisA: 12 categories with over 10,000 images, featuring complex scenes and multiple objects.
Results and Discussion
AnoStyler demonstrates superior performance in both visual quality and detection accuracy. It achieved the highest Inception Score (IS) on both benchmarks, indicating that its generated anomalies are more realistic and diverse than existing zero-shot methods.
Key Performance Metrics:
- Detection Accuracy: When synthetic images were used to train a standard U-Net anomaly detector, it achieved a state-of-the-art image-level AUC of 98.0% on MVTec-AD.
- Efficiency: Generating an anomaly image requires only 9.5 TFLOPs, significantly lower than the 22.8 TFLOPs required by leading diffusion-based competitors like AnomalyAny.
- Zero-Shot Capability: By leveraging pre-trained CLIP encoders, the model effectively generates defects like "rotten" or "burnt" without ever seeing a real-world example of such damage.
Conclusion
AnoStyler represents a significant advancement in synthetic data generation for industrial inspection. By prioritizing style transfer over full image generation, it maintains structural integrity while producing realistic defects. Future work will focus on improving prompt dependency for harder-to-describe defects and exploring more diverse shape priors to cover a broader range of real-world failure cases.
Summary updated