TL;DR
REDiff-AD is a training-free framework that generates realistic and diverse industrial anomaly images by repurposing a frozen Multi-Modal Diffusion Transformer (MMDiT). By leveraging in-context learning and internal attention signals, it synthesizes high-fidelity defects and their corresponding pixel-level masks without requiring manual target annotations or product-specific fine-tuning.
What Problem Does This Paper Address?
Training robust industrial anomaly detection (AD) models is notoriously difficult due to the "scarcity of defects." In a real factory, you have millions of "normal" samples but very few examples of actual cracks, stains, or broken parts.
Existing solutions for data augmentation fall into two expensive camps:
- Training-based methods: These require fine-tuning generative models (like GANs or Diffusion models) for every specific product or defect type, which is computationally heavy and hard to scale.
- Mask-dependent methods: These require a "target mask"—a manually drawn area on a normal image where the defect should be placed. Creating these masks for thousands of images is a massive manual bottleneck.
REDiff-AD aims for the "most practical deployment setting": a system that needs no training and no manual target masks, yet produces realistic, diverse anomalies that can effectively train downstream inspection models.
Methods
The authors build their framework on FLUX.1 Fill, a state-of-the-art Rectified Flow MMDiT model designed for image inpainting. Their approach, REDiff-AD, introduces several novel components to adapt this general-purpose editor for industrial inspection:
- In-Context One-Shot Generation: Instead of using text prompts (which struggle to describe the fine texture of a specific metal scratch), the model uses a single "reference" anomaly image. It "learns" the defect's appearance in-context and transfers it to a "normal" target image.
- Diversity Orthogonal K (DOK): A common failure of in-context learning is "copy-pasting"—the model just reproduces the exact shape of the reference defect. DOK solves this by manipulating the attention mechanism. It suppresses the spatial shape component in the Key features (which govern geometry) while preserving the Value features (which carry appearance/texture). This allows the model to generate a defect that looks like the reference but has a completely new, diverse shape.
- Attention Adaptive Module (AAM): Small or subtle defects are often "washed out" during diffusion. AAM acts as a real-time monitor, checking internal attention signals to see if a defect is forming. If the signal is weak, it adaptively boosts the conditioning strength to ensure the anomaly is successfully generated.
- Target-Mask-Free Pipeline: To avoid manual masking, the system uses "Semantic Localization" to find the product in the image and then randomly places simple geometric shapes (primitives) within that area to act as a "planning region" for the defect.
- Internal Discovery for Pseudo-Masks: The model reuses its internal "Target-to-Reference" (T2R) attention maps to automatically localize where it placed the defect. These coarse maps are then refined using edge (Scharr gradients) and color cues to produce precise, pixel-level "pseudo-masks" for training downstream models.
Datasets
The authors evaluated REDiff-AD on the MVTec-AD dataset, the industry standard for anomaly detection. It contains 15 categories covering various textures (like carpet and leather) and objects (like bottles and transistors). They used the first third of real anomalies as a reference pool and generated 250 synthetic samples per defect type to create a balanced training set.
Key Insights and Ideas
- Attention as a "Free" Segmentor: One of the most elegant parts of the paper is the realization that a modern transformer-based diffusion model already "knows" where the defect is. By analyzing the 57 blocks of FLUX.1, the authors identified that "single-stream" blocks provide the cleanest localization signals.
- Decoupling Geometry from Texture: The DOK module demonstrates that in the attention operation ($A = \text{softmax}(QK^T/\sqrt{d})$), the Keys ($K$) and Values ($V$) serve distinct roles. By only relaxing the geometric constraints in the Key space, you can achieve diversity without losing the specific "look" of the reference defect.
- Rectified Flow Efficiency: By using a Rectified Flow backbone instead of traditional SDE-based diffusion, the model achieves high-quality results in just 20-30 steps, making it significantly faster than previous SOTA methods.
Key Results
- Realism and Diversity: REDiff-AD achieved the lowest average Kernel Inception Distance (KID) of 31.09 on MVTec-AD, indicating it produces the most realistic images among training-free methods.
- Downstream Utility: When used to train a standard U-Net for anomaly detection, the synthetic data from REDiff-AD led to a 99.4 AP-I (Image-level Average Precision) and competitive pixel-level localization scores, outperforming other training-free baselines like O2MAG.
- Efficiency: The model is highly efficient, requiring only 9GB of VRAM (fitting on consumer GPUs like an RTX 3060/4060) and taking roughly 10-16 seconds to generate an image-mask pair.
Limitations and Future Work
- Reference Bias: While DOK significantly improves diversity, the generated anomalies still inherit some characteristics from the single reference image. Exploring multi-reference or purely text-to-anomaly generation that maintains industrial-grade fidelity remains an open challenge.
- Small Defect Sensitivity: Although AAM helps, extremely tiny defects (just a few pixels) can still be difficult for the latent-based diffusion model to reconstruct perfectly.
- Zero-Shot Potential: The authors briefly showed that using a "daily life image" (like a random texture) as a reference can still generate plausible anomalies. Future work could further explore this "zero-reference" path to remove the need for even a single real defect sample.
Summary updated