arXiv:2609.02075cs.CVSep 2026

Manuscript Offprint

arXiv:2609.02075

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

Hang Yao, Yansheng Fu, Ming Liu, Zifei Yan, Yanli Ji, Hongzhi Zhang, Wangmeng Zuo

Figure

Fig. 1: Comparison of zero-shot anomaly generation setting with different anomaly source. (a) shows the real target-product anomalies. Texture pasting-based setting in (b) uses generic texture images as the anomaly source and often generate unrealistic anomaly patterns. Text description-based setting in (c) uses text descriptions as anomaly source. However, text cannot fully specify diverse anomaly appearances, and pre-trained anomaly concepts may diverge from real manufacturing anomalies. Our anomaly transfer-based setting in (d) instead learns a anomaly concept from real anomalies of other product and transfers it to a normal target image. This enables generating anomalies that closely resemble the real anomalies in (a).

Abstract—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 anomalous 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.

Index Terms—Anomaly detection, anomaly generation, zero-shot learning.

I. INTRODUCTION

INDUSTRIAL anomaly detection (IAD) [1]–[3], as a critical step of quality control, is drawing increasing attention in the intelligent industry era. Meanwhile, the rapid development of modern manufacturing has led to diversified demands and constant product iteration. When deploying IAD models [4]–[6] to these continuously introduced new products, both normal and anomalous samples are required for training is typically. In practice, however, while normal samples are readily obtainable, anomalous samples are extremely scarce. To alleviate this data scarcity, a straightforward and practical solution is to generate sufficient and diverse anomalous samples using only normal data, i.e., zero-shot anomaly generation.

Despite their diversity, zero-shot anomaly generation methods follow the same general formulation: an anomaly source is combined with a normal target image to produce a target anomalous image and its annotation. Within this formulation, the most critical element is the anomaly source, that is, the information that specifies what the anomaly should look like. The real target anomalies shown in Fig.1(a) represent the desired output and, ideally, the most reliable anomaly source. However, they are inaccessible under zero-shot setting. Early texture pasting-based methods [7]–[9] use external texture images as anomaly source and insert them into randomly sampled regions of normal images. Though efficient, they produce anomalies that are often unnatural and deviate significantly from real anomaly patterns, as illustrated in Fig.1(b). Recent, text description-base methods [10] use text descriptions as the source and prompt a pre-trained diffusion model (Fig.1(c)). However, text cannot fully specify the appearance of diverse industrial anomalies, and the anomaly concepts learned by the pre-trained generation model diverge from real manufacturing anomalies. Therefore, this anomaly source still lack authenticity, resulting in a substantial gap in visual appearance between generated anomalies and the expected target anomalies.

Although anomalous data are difficult to collect for a newly deployed product, factories often retain real anomaly samples from existing production. Many anomaly concepts, such as scratches, cracks, discoloration, and bent components, recur across related product families and exhibit similar visual patterns. This cross-product commonality makes existing anomalies a more faithful anomaly source than generic textures or text descriptions, while avoiding the costly collection of target-product anomalies. Motivated by this observation, we propose anomaly transfer-based zero-shot generation, illustrated in Fig.1(d). In this setting, anomaly concepts extracted from real anomalies of source products are transferred to unseen target products, with no real target anomaly samples required.

However, not every source anomaly is meaningful for the given target product. For example, a bent-lead anomaly is applicable only to products containing leads, whereas transferring it to a bottle would create semantically invalid training data. We therefore introduce a product-aware anomaly type filtering mechanism before transfer. For each target product, semantically incompatible source anomaly types are discarded, and only reasonable types are retained for generation. In practice, we use the vision-language model Qwen3-VL to make this compatibility decision before generation, after which the compatibility decision is cached and reused for all subsequent samples. Importantly, the vision-language model only decides whether an anomaly is suitable for the product. The anomaly concept itself is learned from the selected source anomaly.

A straightforward approach to achieve the transfer of selected anomaly types, is to use existing anomaly generation methods [11], [12] to extract anomaly representations from the source anomaly and apply it to a normal target-product image 1^{1}. However, such direct adaptation either fails to inject the anomaly into the target image or produces obvious artifacts, as shown in Fig.2(b) and (c). We attribute such failures to the impure anomaly representations extracted with these methods, where the vanilla feature extraction module inevitably couples anomaly representations with product representations.

Figure

Fig. 2: Results of direct cross-product anomaly transfer and the proposed DPA. (a) A source anomalous image contains both anomaly and source-product appearance. Directly applying existing anomaly generators to cross-product transfer, as illustrated by (b) AnomalyDiffusion [11] and (c) AnoGen [12], may transfer source-product information together with the anomaly and produce randomly located or misaligned masks. (d) DPA transfers a decoupled anomaly concept to a reasonable location of the target product and produces a mask aligned with the generated anomaly.

This entanglement motivates our Anomaly Concept Decoupling (ACD). First, ACD introduces two learnable embeddings: a product embedding shared across normal and anomalous samples to represent product appearance, and an anomaly embedding dedicated to anomaly semantics. And then, to assign complementary responsibilities to these embeddings, we construct three types of input-target pairs for embeddings training: masked anomaly →\rightarrow masked anomaly, anomaly →\rightarrow normal, and normal →\rightarrow anomaly. Guided by the corresponding embeddings, these pairs require the frozen diffusion model to perform three tasks: preserving, removing, and inserting anomalies, respectively. The preserve pair directly learns from the anomalous region to capture visual anomaly appearance, whereas the remove and insert pairs encourage the embedding to understand abstract anomaly concepts by erasing and adding anomalies. Together, these complementary tasks encourage it to decouple an abstract and transferable anomaly concept, rather than memorizing source-product appearance.

Another problem of these generation methods is the unreasonable mask, which is also shown in Fig.2(b) and (c). Existing methods typically use predefined masks as both generation constraints and ground-truth annotations. On the one hand, the masks are generated via random algorithms, which means that the mask regions may not be the place where a specific anomaly occurs. On the other hand, the generated anomalies are often unaligned with the masks (typically a circle or square), leading to imprecise annotations.

To address the mask issues, we propose an adaptive mask-guided pipeline comprising three modules: Initial Mask Generation (IMG), Mask Refinement(MR), and Anomaly Labeling(AL), which operate before, during, and after generation, respectively. Before generation, IMG determines the anomaly location via attention maps between anomaly embeddings and normal image features, and sets the size by sampling from the prior size distribution of existing anomalies, yielding a circular coarse mask as an initial estimate. During generation, MR dynamically refines this mask, aligning it with the evolving anomaly and guiding the anomaly shape toward more plausible forms. After generation, to further produce a high-resolution

1^{1}Although these methods are few-shot methods that require target anomaly data, replacing target anomalies with source anomalies makes them formally applicable to anomaly transfer.

mask, AL incorporates the refined masks, attention maps, and multi-scale VAE decoder features of normal and anomalous samples, to produce pixel-level precise annotations. These three modules jointly ensure the generated anomalies have reasonable spatial locations and shapes with accurate labels.

To verify the effectiveness of our anomaly transfer-based generation setting and generation pipeline, extensive experiments are conducted on two widely-used datasets (i.e., MVTec-AD [13] and VisA [14], where anomaly embeddings are extracted from one of these two datasets and evaluated on the other one. We also integrate a dedicated dataset for anomaly transfer, comprising both source data for extracting anomaly and target data for anomaly generation. Furthermore, we evaluate our model under the few-shot anomaly generation setting (where a small number of target anomaly samples are allowed), demonstrating the generality and effectiveness of our anomaly generation method. The contributions of this paper are summarized as follows.

  • We unify zero-shot anomaly generation as the composition of an anomaly source and a normal target image, and formulate anomaly transfer-based zero-shot generation setting, which uses real anomalies from existing products as a more faithful source.

  • A anomaly concept decoupling method is proposed, which decouples product appearance and anomaly concept to two learnable embeddings through complementary preserve, remove, and add tasks.

  • We introduce an adaptive mask-guided generation and labeling pipeline which considers location and shape of generated anomalies, and produces high-precision annotations aligned with the generated anomalies.

  • Experiments on three datasets, multiple downstream detection methods, and both zero-shot and few-shot settings consistently validate the proposed setting and method.