SeaS: Few-shot Industrial Anomaly Image Generation with Separation and Sharing Fine-tuning

Zhewei Dai, Shilei Zeng, Haotian Liu, Xurui Li, Feng Xue, Yu ZhouSubmission to ICLR 2025 · Rejected

TL;DR

SeaS (Separation and Sharing Fine-tuning) is a unified diffusion-based framework designed for industrial visual inspection that generates diverse anomaly images, globally consistent normal product images, and sharp, pixel-accurate defect masks within a single model per product. By explicitly modeling the visual asymmetry between uniform normal surfaces and highly erratic defects, SeaS significantly boosts performance across downstream unsupervised, synthesis-based, and fully supervised anomaly detection models.

What Problem Does This Paper Address?

Training effective defect detection and segmentation models in industrial settings is notoriously difficult due to extreme data scarcity: real-world production yields millions of normal products but very few defective samples.

Existing synthetic data solutions suffer from key limitations:

  1. Isolated capability: Prior approaches either only generate defects (often blending them onto existing normal images using rigid masks, which yields boundary artifacts) or only generate normal images.
  2. Model sprawl: Methods like DFMGAN require training separate, dedicated generator networks for every single defect category and for normal samples.
  3. Imprecise mask generation: Standard diffusion-based segmentation tools upsample low-resolution cross-attention maps, resulting in fuzzy, unreliable defect masks that degrade supervised segmentation training.

Methods

SeaS fine-tunes a pre-trained Stable Diffusion (v1-4) backbone using a shared U-Net that decouples product-level and defect-level representations:

[Normal Images]   --> NA Loss (a <ob>) --------------------\
                                                            +--> Shared U-Net --> Discriminative Features
[Abnormal Images] --> DA Loss (a <ob> with <df1>..<dfN>) --/                            |
                                                                                        v
[High-Res VAE Decoder Features] ----------------------------------------------> Refined Mask Prediction (RMP)
                                                                                        |
                                                                                        v
                                                                             Pixel-Accurate Mask
  • Unbalanced Abnormal (UA) Text Prompt: Rather than generic prompts like "damaged bottle", SeaS uses an asymmetric prompt: a <ob> with <df1>, <df2>, ..., <dfN>. A single <ob> token models the globally uniform normal product, while multiple <dfn> tokens capture varied, localized defect attributes.
  • Decoupled Anomaly Alignment (DA) Loss: During defect training, DA loss aligns the cross-attention maps of <dfn> tokens to ground-truth defect regions while suppressing <ob> activation inside anomaly regions. Averaging token responses allows recombination into novel, unseen defect variations.
  • Normal-image Alignment (NA) Loss: To preserve background fidelity without overfitting to the small set of defect images, normal images are simultaneously fed using only the <ob> prompt.
  • Mixed Training: Batches uniformly mix normal and abnormal images across all defect types for a given product, training a single shared U-Net.
  • Refined Mask Prediction (RMP) Branch: Directly predicting masks from diffusion cross-attention produces coarse, blurry boundaries. RMP fuses discriminative, mid-level U-Net decoder features (up-2 and up-3) with high-resolution structural features from the VAE decoder across three progressive Mask Refinement Modules (MRMs), supervised with Focal Loss.

Datasets

The authors evaluate SeaS on three standard industrial anomaly benchmarks:

  • MVTec AD: 15 industrial product categories with up to 8 defect classes each.
  • VisA: 12 object categories spanning 3 industrial domains.
  • MVTec 3D AD (RGB images only): 10 product categories featuring complex geometric poses and varying illumination conditions.

Note: No new benchmark datasets are introduced.

Key Insights and Ideas

  • Symmetry in prompts harms generation: Industrial defect synthesis has an inherent structural asymmetry—products must remain globally identical and authentic, while defects need maximum shape, color, and texture diversity. Standard prompt tuning treats both equally; assigning $1$ token to the base product and $N$ tokens to the anomaly explicitly mirrors physical reality.
  • Attention decoupling unlocks combinatorial defects: Forcing individual defect tokens to latch onto separate visual attributes allows the model to mix features at inference time, synthesizing plausible anomalies never present in the few-shot training set.
  • U-Net semantics + VAE edges: U-Net latent features are semantically rich (they know what is a defect vs. background) but spatially coarse. VAE decoder skip features retain pixel-level edge details but lack semantic context. Merging them in a progressive refinement module produces crisp, pixel-aligned masks without manual post-processing.

Key Results

  • Generation Quality & Diversity: SeaS achieves leading Inception Scores (1.88 on MVTec AD, 1.95 on MVTec 3D AD) and intra-cluster diversity (IC-LPIPS of 0.34 and 0.30), outperforming GAN baselines (DFMGAN) and diffusion alternatives (AnomalyDiffusion) in both defect variation (IC-LPIPS(a)) and normal fidelity (KID).
  • Downstream Synthesis-Based AD: Replacing synthetic pseudo-defects in DRAEM and GLASS with SeaS-generated anomalies improves average pixel-level Average Precision (AP) by +8.66%.
  • Downstream Unsupervised AD: Augmenting normal training splits for PatchCore, HVQ-Trans, and MambaAD yields an average +1.10% gain in image-level AP by eliminating false positives.
  • Supervised Segmentation: Training off-the-shelf segmentation models (BiSeNet V2, UPerNet, LFD) using 1,000 SeaS-generated image–mask pairs per defect type yields massive improvements, outperforming previous generative approaches by an average +12.79% IoU (+11.17% on MVTec AD, +11.71% on VisA, and +15.49% on MVTec 3D AD).

Limitations and Future Work

  • Per-Product Fine-Tuning: While SeaS unifies all defect types and normal generation into one network, it still trains a separate model per product category rather than a single universal model for all industrial domains.
  • Reliance on Masked Seeds: The pipeline operates in a few-shot setting (requiring roughly one-third of available anomaly samples with manual masks), making it dependent on having at least a handful of labeled real defects.
  • Inference Latency: Relying on multi-step iterative latent diffusion sampling during data synthesis is computationally heavier than one-pass GAN-based generation methods.

Summary updated

Abstract

Current segmentation methods typically require many training images and precise masks, while insufficient anomaly images hinder their application in industrial scenarios. To address such an issue, we explore producing diverse anomalies and accurate pixel-wise annotations. By observing the real production lines, we find that anomalies vary randomly in shape and appearance, whereas products hold globally consistent patterns with slight local variations. Such a characteristic inspires us to develop a Separation and Sharing Fine-tuning (SeaS) approach using only a few abnormal and some normal images. Firstly, we propose the Unbalanced Abnormal (UA) Text Prompt tailored to industrial anomaly generation, consisting of one product token and several anomaly tokens. Then, for anomaly images, we propose a Decoupled Anomaly Alignment (DA) loss to bind the attributes of the anomalies to different anomaly tokens. Re-blending such attributes may produce never-seen anomalies, achieving a high diversity of anomalies. For normal images, we propose a Normal-image Alignment (NA) loss to learn the products' key features that are used to synthesize products with both global consistency and local variations. The two training processes are separated but conducted on a shared U-Net. Finally, SeaS produces high-fidelity annotations for the generated anomalies by fusing discriminative features of U-Net and high-resolution VAE features. The extensive evaluations on the challenging MVTec AD and MVTec 3D AD dataset (RGB images) demonstrate the effectiveness of our approach. For anomaly image generation, on MVTec AD dataset, we achieve 1.88 on IS and 0.34 on IC-LPIPS, while on the MVTec 3D AD dataset, we obtain 1.95 on IS and 0.30 on IC-LPIPS. For the downstream task, by using our generated anomaly image-mask pairs, three common segmentation methods achieve an average 11.17\% improvement on IoU on MVTec AD dataset, and a 15.49\% enhancement in IoU on the MVTec 3D AD dataset. The source code will be released publicly available.
BibTeX
@misc{dai2024seas,
  author = {Zhewei Dai and Shilei Zeng and Haotian Liu and Xurui Li and Feng Xue and Yu Zhou},
  title = {{SeaS: Few-shot Industrial Anomaly Image Generation with Separation and Sharing Fine-tuning}},
  year = {2024},
  eprint = {2410.14987},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.14987},
}
Figure