AnoStyler: Text-Driven Localized Anomaly Generation via Lightweight Style Transfer

Seokho Kang, Yulim So, Seokho Kang 0001arXiv 2025 · DOI

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:

  1. 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.
  2. 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").
  3. 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.
The AnoStyler framework overview, illustrating the mask generation, prompt generation, and stylization network pipeline.

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.

Examples of normal images and corresponding anomalies generated by AnoStyler across various categories like carpet, pill, cashew, and candle.

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

BibTeX
@misc{kang2025anostyler,
  author = {Seokho Kang and Yulim So and Seokho Kang},
  title = {{AnoStyler: Text-Driven Localized Anomaly Generation via Lightweight Style Transfer}},
  year = {2025},
  eprint = {2511.06687},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2511.06687},
}
Figure