Source-linked AI summary
DPA: Decoupling Product-Agnostic Anomaly Representations for Zero-shot Anomaly Generation
Hang Yao, Yansheng Fu, Ming Liu, Zifei Yan, Yanli Ji, Hongzhi Zhang, Wangmeng Zuo
TL;DR
New products often lack anomalous training images, while texture- and text-based zero-shot sources can produce unrealistic anomalies. The paper transfers real anomalies across products using DPA, which decouples anomaly concepts, filters incompatible types, and guides masks and labels; across three datasets and settings, it reports stronger generation and downstream detection performance.
Problem
Newly deployed products typically provide normal images but lack sufficient anomalous samples, while texture and text anomaly sources often produce unrealistic results.
Method
DPA transfers filtered real source anomalies using decoupled product-irrelevant anomaly embeddings and an adaptive mask-guided generation and labeling pipeline.
Results
DPA achieves an overall mean of 84.91 versus 81.44 for AnomalyAny and improves overall means across DRAEM, CPR, and GLASS detection pipelines.
Takeaways & Limitations
Real anomalies from existing products can support realistic zero-shot transfer to unseen products without requiring target-product anomaly samples.
Abstract
from arXiv · showhide
Industrial anomaly detection benefits from anomaly samples, yet newly deployed products typically provide only normal images, making anomaly samples difficult to collect. Zero-shot anomaly generation offers a promising solution which avoids collection of target-product anomalies. However, existing methods mainly rely on texture images or text descriptions as anomaly sources, which often produce unrealistic anomalies. Observing that similar anomalies can recur across different products, we propose anomaly transfer-based zero-shot generation, which reuses real anomalies from existing source products, making target-product anomalies no longer necessary to generate realistic anomalious samples for unseen target products. Since not every anomaly type suits the target product, an anomaly type filtering mechanism first selects plausible source types. To transfer selected anomaly, we propose DPA, a diffusion-based framework that decouples product-agnostic anomaly representations. Instead of directly extracting anomaly representations, DPA learns product-irrelevant anomaly embeddings through training with the mismatched data pair, enabling transferable anomaly concept learning across products. Furthermore, we design an adaptive mask-guided pipeline that leverages adaptive masks to control the positional and geometric plausibility of generated anomalies during generation. A training-free anomaly labeling module is further introduced to produce pixel-level annotations aligned with generated anomalies. Extensive experiments on MVTec-AD, VisA, and a dedicated anomaly-transfer benchmark demonstrate that the proposed setting and DPA generate more realistic anomalies and significantly improve downstream anomaly detection performance under both zero-shot and few-shot settings. Source code and models will be released.
I. INTRODUCTION
The paper frames anomaly transfer from existing products as a zero-shot alternative to collecting target-product anomalies, while addressing source-product entanglement and implausible masks. DPA combines anomaly concept decoupling with adaptive mask-guided generation and labeling, and experiments evaluate the setting across datasets and downstream detection conditions.
- Motivation: Existing zero-shot methods use textures or text as anomaly sources, but their generated anomalies often lack realism compared with real manufacturing anomalies.Textures are inserted into random regions, while text descriptions incompletely specify diverse industrial anomalies.
- Motivation: Real anomalies from existing products provide a more faithful source because related products can share recurring scratches, cracks, discoloration, and bent-component patterns.The proposed setting transfers anomaly concepts to unseen target products without real target anomaly samples.
- Method: Product-aware filtering discards source anomaly types that are semantically incompatible with the target product before transfer.The paper gives bent leads transferred to a bottle as an example of an invalid pairing.
- Method: DPA learns separate product and anomaly embeddings through preserve, remove, and add tasks to transfer anomaly concepts without memorizing source-product appearance.Direct adaptation can fail because conventional anomaly representations couple anomaly and product information.
- Method: Its adaptive mask-guided pipeline controls anomaly location and shape during generation and produces pixel-level labels aligned with the generated anomalies.Initial Mask Generation, Mask Refinement, and Anomaly Labeling operate before, during, and after generation.
- Evaluation: Experiments on MVTec-AD, VisA, and a dedicated transfer dataset evaluate generation and downstream detection under zero-shot and few-shot settings.The study also considers multiple downstream detection methods.
B. Diffusion model
The paper places DPA within a common zero-shot generation formulation that combines an anomaly source with a normal target image to produce a target anomaly and label. Unlike texture- and text-based sources, DPA uses real source anomalies as a more faithful prior.
- Common formulation: Zero-shot anomaly generation combines an anomaly source with a normal target image to produce a target anomalous image and its annotation.The anomaly source specifies what the generated anomaly should look like.
- Existing sources: Texture-pasting methods use generic texture images, while text-guided methods use anomaly descriptions to condition generation.The formulation is expressed with texture, description, and source-anomaly variants.
- DPA formulation: DPA uses source anomalies S as the anomaly prior and combines them with normal images from target product p.The generated output is a target anomalous image and its label.
- Pipeline: The training-to-inference pipeline first learns decoupled anomaly embeddings, then filters compatible source types before generating target-product anomalies.The pipeline subsequently uses adaptive masks and derives labels from generated anomalies.
A. Anomaly Concept Decoupling
Anomaly Concept Decoupling separates source-product appearance from anomaly semantics using product and anomaly embeddings trained with intentionally mismatched pairs. The strategy assigns complementary responsibilities through preserve, remove, and add tasks supported by an anomaly-oriented diffusion loss.
- Embedding design: ACD introduces a product embedding shared by normal and anomalous samples and a dedicated anomaly embedding for anomaly semantics.The two embeddings are intended to separate product appearance from the anomaly concept.
- Training tasks: The training strategy uses mismatched pairs that preserve an anomaly, remove it, or add it to a normal sample.These tasks extend anomaly representation beyond pixel-level reconstruction.
- Training tasks: The add and remove tasks share the product embedding, encouraging product information to reside in ep and anomaly concepts to reside in ea.The preserve task operates under the anomaly embedding, while removal uses the product embedding.
- Diffusion objective: The ACD objective uses the Anomaly-oriented Training Paradigm loss because standard diffusion assumes identical input and target features.ATP supports reconstruction toward different targets for the add and remove pairs.
- Design rationale: ACD’s novelty is the training strategy that constructs three input–target pairs to give the embeddings complementary, decoupled semantic concepts.The contribution is not a new diffusion loss.
B. Adaptive Mask-Guided Generation
DPA generates target-product anomalies through product-aware type filtering and a staged adaptive mask-guided diffusion process. The masks constrain plausible location, size, content removal, insertion, and final shape while verification rejects failed outputs.
- Product-Aware Anomaly Type Filtering: Product-aware filtering retains only source anomaly types semantically compatible with each target product before transfer.Qwen3-VL makes the compatibility decision offline, and accepted source-anomaly–target-product pairs proceed to transfer.
- Mask Refinement: The initial circular mask provides coarse spatial constraints, while refinement derives removal and shape-aware masks for later generation stages.The removal mask clears conflicting normal structure within the intended region; the refined mask follows the emerging anomaly response for final shape control.
- Initial Mask Generation: Initial Mask Generation identifies a semantically plausible anomaly region and samples location and size priors from target and source-anomaly information.The initial mask uses a potential anomaly region for location and source circumcircle-radius statistics for size, retaining sample diversity.
- Generation with Adaptive Masks: DPA switches masks across remove–insert–refine stages to remove residual normal content, generate the anomaly under its learned embedding, and refine its shape.The active mask is respectively mrm, minit, or mref as diffusion progresses.
- Generated-Sample Verification: Generated-Sample Verification rejects outputs whose anomaly saliency score falls below threshold τ and can stop generation for a source–target pair when failures exceed one third of a batch.This output-level safeguard is distinct from the earlier semantic compatibility decision.
C. Anomaly Labeling
DPA derives pixel-level anomaly labels from the generated image’s actual multi-scale changes rather than using the low-resolution generation mask alone. It combines feature differences with refined masks and attention to recover anomaly semantics and boundaries.
- Label Construction: The generation masks control diffusion but are spatial constraints, so they are not directly suitable as pixel-accurate segmentation labels.The refined mask is 64 × 64 and does not precisely describe the generated appearance.
- Multi-Scale Feature Differences: Multi-scale VAE decoder feature differences between normal and anomalous outputs reveal changes concentrated within the generated anomaly regions.The comparison spans latent and progressively higher-resolution decoder features, complementing semantic attention masks.
- Final Label Fusion: The final ground-truth mask mgt fuses refined-mask constraints, final attention maps, and multi-scale feature distances to align labels with the generated anomaly.The refined mask suppresses irrelevant changes, attention preserves anomaly semantics, and feature distances recover boundaries.
A. Datasets
The evaluation uses cross-dataset and dedicated anomaly-transfer benchmarks under zero-shot and few-shot settings, with common detection protocols isolating generation quality. DPA is compared against multiple zero-shot generators and combined with different detection frameworks.
- MVTec-AD and VisA serve as reciprocal source-target datasets, with no target anomalous images used for generation training.
- ATAD contains 13 source and 16 target product categories, with semantically corresponding anomaly types across differing products.
- Zero-shot evaluation reserves the complete target test set for downstream assessment, while few-shot training uses one third of target anomalies.
- DPA and baselines provide generated image-mask pairs to the same DRAEM detector under identical training protocols, isolating generation quality.
- 84.91 is DPA’s overall zero-shot mean, exceeding AnomalyAny’s 81.44 by 3.47 points.
- Replacing native synthesized data with DPA data raises overall means for DRAEM from 81.17 to 84.91, CPR from 86.93 to 87.66, and GLASS from 84.24 to 84.89.
F. Results of few-shot Anomaly Generation
In few-shot evaluation, DPA achieves the strongest reported benchmark means and produces physically plausible anomalies with aligned annotations. Ablations and transfer analyses examine spatial control, labeling, decoupling, anomaly compatibility, and source coverage.
- Performance Against Anomaly Generation Methods: 85.29 is DPA’s overall few-shot mean, ranking first on ATAD, MVTec-AD, and VisA and exceeding AnomalyDiffusion by 1.16 points.
- Qualitative Evaluation: DPA produces physically plausible few-shot anomalies with well-aligned annotations, whereas competing methods place masks on backgrounds or semantically invalid product locations.
- Effectiveness of Each Proposed Module: The complete model reaches a 90.88 mean, 2.90 points above native DRAEM generation; removing any module reduces anomaly-detection performance.
- Qualitative Analysis of Anomaly Concept Decoupling: With ACD, transferred bent-lead embeddings attend to lead regions across target products; without ACD, attention follows source-like structures.
- Impact of Transferring Unreasonable Anomalies: Transferring reasonable anomaly types outperforms unreasonable types, while occasional selection errors do not cause catastrophic sensitivity; unreasonable transfers produce physically unrealistic outputs.
- Impact of Target Anomaly Coverage: Broader source coverage improves detection, but DPA remains competitive without a one-to-one source counterpart; few-shot training can extend coverage for essential uncovered types.
H. Computational Cost
DPA requires less total runtime than several diffusion-based baselines while operating at higher resolution than AnoGen. The paper also reports broad downstream gains across datasets and settings.
- 76.4 hours are required to generate 2,000 images per MVTec-AD product with DPA, versus 205.4 hours for AnomalyDiffusion, 124 hours for TF-IDG, and 291.5 hours for AnomalyAny.
- DPA operates at 512 × 512 resolution, whereas the faster AnoGen generates only 256 × 256 images.
- DPA outperforms AnoGen in inference speed when numerous generated samples are required.
- Across MVTec-AD, VisA, and ATAD, DPA-generated data outperform existing zero-shot generation methods and improve multiple downstream detectors in zero-shot and few-shot settings.
I. APPENDIX
The appendix provides supplementary visualizations, implementation details, metrics, dataset information, ablations, and additional generation and detection results. It also documents DPA’s learned embeddings, generation process, and evaluation measures.
- Appendix contents: The supplementary material includes additional visualizations, implementation details, metrics, dataset information, ablations, inpainting-quality discussion, filtering results, and extra generation and detection results.
- Implementation details: DPA represents anomaly types and product categories with learnable textual embeddings trained through Textual Inversion.
- Implementation details: The decoupling phase trains embeddings for 3,000 steps per anomaly type, while few-shot generation directly reuses the trained decoupled product embeddings.
- Implementation details: During generation, DPA combines selected anomaly and target-product embeddings, then performs ten diffusion denoising steps with progressively switched adaptive masks.
- Evaluation: DRAEM evaluation additionally reports Accuracy and Intersection over Union for binary segmentation outputs.
- Evaluation: Generation quality is evaluated with IS in zero-shot settings and IC-LPIPS and KID in few-shot settings.
IV. ATAD DATASET
ATAD is a dedicated anomaly-transfer benchmark with source products for reference anomalies and target products for generation and detection. Its protocol includes compatibility filtering and analyses of masks, inpainting, and sample verification.
- Dataset construction: ATAD integrates product categories and anomaly types from MVTec-AD, VisA, Real-IAD, and MANTA.
- Dataset construction: The benchmark separates a source subset providing reference anomalies from a target subset used for generation and detection, with semantic correspondences between target and source anomaly categories.
- Dataset statistics: The source subset contains 13 product categories, while the target subset contains 16 product categories with separate normal-training, normal-test, and anomalous-test counts.
- Ablations: A threshold of 0.55 yields the best overall detection performance during mask binarization.
- Ablations: Normal Region Removal and Generated-Sample Verification consistently improve all reported evaluation metrics by removing interfering normal content and mislabeled samples.
- Anomaly type filtering: Qwen3-VL makes a one-time offline compatibility decision for each source-anomaly-type–target-product candidate, and the cached result is reused during generation and detection.
VIII. ADDITIONAL RESULTS OF ANOMALY GENERATION
DPA achieves the strongest reported generation-quality means in both zero-shot and few-shot evaluation and improves deterministic downstream detection. Comparisons use protocol-specific metrics and fixed DRAEM localization models.
- Generation quality: DPA obtains the best mean generation-quality result in both zero-shot and few-shot tables.
- Generation quality: Zero-shot generation is evaluated with IS because target anomaly types are unavailable for same-type pairing, while few-shot generation uses IC-LPIPS and KID.
- Detection performance: Under both zero-shot and few-shot settings, DPA significantly improves deterministic detection metrics.
- Detection performance: DPA-generated training data remain competitive with SimpleNet, Dinomaly, and INP-Former in comparisons against unsupervised industrial anomaly detection methods.
- Detailed results: Detailed category-level detection and segmentation results are reported on MVTec-AD, VisA, and ATAD for DRAEM, AnomalyAny, and DPA.
- Localization: Figures 3 and 4 compare zero-shot and few-shot localization using the same DRAEM model, so differences reflect the generated images and labels.