Large-Scale Universal Defect Generation: Foundation Models and Datasets

Yuanting Fan, Jun Liu, Bin-Bin Gao, Xiaochen Chen, Yuhuan Lin, Zhewei Dai, Jiawei Zhan, Chengjie WangarXiv 2026

TL;DR

The authors introduce UDG, a massive dataset of 300K normal-abnormal-mask-caption quadruplets, and UniDG, a 12B-parameter universal defect generation foundation model. By leveraging a two-stage training strategy combining supervised fine-tuning and reinforcement learning, UniDG seamlessly transfers defects across completely different object categories without requiring per-category fine-tuning. This approach significantly alleviates the data bottleneck for downstream industrial anomaly detection and localization tasks.

What Problem Does This Paper Address?

Supervised anomaly detection models in industrial inspection, medical imaging, and safety-critical applications are notoriously hard to train due to the inherent scarcity of real-world abnormal samples. While generative models can synthesize synthetic defects to patch this data bottleneck, existing methods fall into two limited paradigms:

  1. Few-shot approaches that overfit to specific defect categories and generalize poorly to unseen objects.
  2. Zero-shot text-to-image models that lack defect-specific prior knowledge, failing to accurately capture complex defect scales, textures, and morphologies.

Furthermore, existing anomaly detection datasets provide image-mask pairs but lack high-quality normal counterparts and descriptive captions, which prevents generative foundation models from learning a unified, cross-domain defect distribution.

Methods

The authors propose UniDG, a universal defect generation model built on a Multimodal Diffusion Transformer (MM-DiT) backbone. It introduces several key mechanisms to ensure realistic and context-aware defect synthesis:

  • Defect-Context Editing: To avoid background reconstruction artifacts, the task is framed as local image inpainting. An Adaptive Defect Crop strategy isolates the reference defect and scales the surrounding context based on the defect's size. This cropped defect is concatenated with a partially masked target image to form a structured diptych input.
  • Multimodal Fusion: The MM-DiT backbone jointly processes the VAE-latent of the diptych input alongside semantic features extracted from the reference defect (via a SigLIP image encoder) and textual instructions.
  • Two-Stage Training Strategy:
    1. Diversity-SFT (Supervised Fine-Tuning): The model is trained on three distinct data sampling distributions (defect-fill, intra-defect cross-sampling, and multi-object cross-sampling) to maximize defect diversity and teach cross-object defect transfer.
  • Consistency-RFT (Reinforcement Fine-Tuning): To correct color, texture, or illumination shifts introduced during SFT, the authors employ Flow-GRPO (Group Relative Policy Optimization). This online reinforcement learning process optimizes the model using two custom reward functions: Defect-Und-Reward (an MLLM-based judge evaluating reference adherence and visual quality) and Defect-Recog-Reward (task-aware classification and segmentation models).
Figure 3. Overall framework of UniDG. UniDG leverages MM-DiT with a Defect-Context Editing strategy to integrate reference defects into target regions. Diversity-SFT and Consistency-RFT further improve synthesis quality.

Datasets

The paper introduces the Universal Defect Generation (UDG) dataset, which aggregates and enhances samples from 50 publicly available anomaly detection datasets.

  • Scale & Variety: It contains 300K samples covering 269 original defect types mapped into 28 standardized categories (e.g., scratch, discoloration, deformation, hole).
  • Structure: Each sample is structured as a quadruplet: Normal Image, Abnormal Image, Defect Mask, and Fine-Grained Caption.
  • Curation Pipeline: Curated using a multi-agent framework consisting of an Inpainting Agent (to reconstruct perfectly matched normal counterparts), a Captioner Agent (to generate multi-level descriptions), and a Verifier Agent (to filter out low-quality pairs).

For evaluation, the authors benchmark downstream task performance on the standard MVTec-AD and VisA datasets.

Figure 2. Overview of UDG Dataset. (a) The construction pipeline for generating normal-abnormal-mask-caption quadruplets. (b) The distribution across scenarios and the frequency of mapped defect categories.

Key Insights and Ideas

  • Local Inpainting Over Global Generation: Rather than generating an entire image from scratch—which often introduces background distortions—focusing generative capacity entirely on a masked target region preserves the structural integrity of the original scene.
  • The Diversity vs. Consistency Trade-Off: Supervised fine-tuning (SFT) excels at expanding the variety of generated defects but can cause stability issues like color bleeding or lighting mismatches. Reinforcement learning via GRPO acts as a crucial alignment step, enforcing strict reference consistency without collapsing generation diversity.
  • Cross-Object Transfer Priors: By training on a standardized multi-domain dataset, the model develops an abstract understanding of defect physics. It can successfully take a "scratch" from a piece of metal and realistically render it onto a completely different material, like wood or a fruit surface.

Key Results

UniDG was evaluated by using its generated images to train downstream anomaly detection and localization models. It consistently outperformed prior few-shot anomaly generation (e.g., SeaS, AnomalyDiffusion) and image-editing baselines (e.g., AnyDoor, InsertAnything):

  • Downstream Binary Segmentation (MVTec-AD): Object-specific U-Net models trained on UniDG-RFT data achieved state-of-the-art localization performance, reaching an image-level AUROC of 98.4% and a pixel-level AUROC of 98.8%.
  • Anomaly Classification: Object-specific ResNet-34 classifiers trained on UniDG data improved classification accuracy by ~10% over previous leading methods.
  • Unified Multi-Class Segmentation: When training a single, unified multi-class U-Net to recognize and localize all 73 defect classes simultaneously, UniDG-RFT outperformed baselines by a massive margin, boosting the foreground mean Intersection over Union (FG-mIoU) by 20.5% over prior methods.

Limitations and Future Work

  • Computational Footprint: At 12 billion parameters, the baseline MM-DiT model demands substantial memory and computational overhead during inference. The authors plan to explore lighter, distilled DiT backbones (like Z-Image-Turbo) to improve efficiency.
  • Metrics Alignment: Standard generative metrics (like LPIPS or Inception Score) correlate poorly with human perception and downstream detector performance in defect scenarios. While the authors introduced MLLM-based evaluation frameworks to mitigate this, they emphasize that dedicated Image Quality Assessment (IQA) metrics tailored specifically for industrial defects are still urgently required.

Summary updated

BibTeX
@misc{fan2026large,
  author = {Yuanting Fan and Jun Liu and Bin-Bin Gao and Xiaochen Chen and Yuhuan Lin and Zhewei Dai and Jiawei Zhan and Chengjie Wang},
  title = {{Large-Scale Universal Defect Generation: Foundation Models and Datasets}},
  year = {2026},
  eprint = {2604.08915},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2604.08915},
}
Figure