Papers › A Unified Model for Multi-class Anomaly Detection

A Unified Model for Multi-class Anomaly Detection

8 Jun 2022arXiv:2206.03687archive 2025-07-28

Zhiyuan You, Lei Cui, Yujun Shen, Kai Yang, Xin Lu, Yu Zheng, Xinyi Le

Despite the rapid advance of unsupervised anomaly detection, existing methods require to train separate models for different objects. In this work, we present UniAD that accomplishes anomaly detection for multiple classes with a unified framework. Under such a challenging setting, popular reconstruction networks may fall into an "identical shortcut", where both normal and anomalous samples can be well recovered, and hence fail to spot outliers. To tackle this obstacle, we make three improvements. First, we revisit the formulations of fully-connected layer, convolutional layer, as well as attention layer, and confirm the important role of query embedding (i.e., within attention layer) in preventing the network from learning the shortcut. We therefore come up with a layer-wise query decoder to help model the multi-class distribution. Second, we employ a neighbor masked attention module to further avoid the information leak from the input feature to the reconstructed output feature. Third, we propose a feature jittering strategy that urges the model to recover the correct message even with noisy inputs. We evaluate our algorithm on MVTec-AD and CIFAR-10 datasets, where we surpass the state-of-the-art alternatives by a sufficiently large margin. For example, when learning a unified model for 15 categories in MVTec-AD, we surpass the second competitor on the tasks of both anomaly detection (from 88.1% to 96.5%) and anomaly localization (from 89.5% to 96.8%). Code is available at https://github.com/zhiyuanyou/UniAD.

PaperPDFCodeCode Syntology ranMethod as code

In Syntology View this paper on Syntology, its page in Syntology's graph. That page adds which of its functions are also present in other papers' code Syntology holds, with dates, and its dated run record as JSON and a README badge. It also lists the repositories linked to the paper, the abstract and the calls for agents.

Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, on Syntology's MCP service (how to connect):

Code

Syntology 15 code samples harvested from 1 repository linked to this paper: 8 ran (of which 0 constructed an object rather than computing a result; 6 with no instrument failure: 0 honoured, 0 violated, 6 with no contract checked; 2 where Syntology's instrument failed) · 7 unverified. Where Syntology's instrument failed: 2 where the contract check could not run; failures of Syntology's instrument, not of the code.

By repository: official repository: 15 samples from 1 repository, 8 ran (6 with no instrument failure; 2 where Syntology's instrument failed). The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

Levels written between 2026-09-22 and 2026-09-24 (UTC): the dates Syntology's graph wrote each sample's verification level, not when the code executed. 1 of the 8 samples that ran has no recorded date.

zhiyuanyou/uniad officialmentioned in papermentioned on GitHubpytorchSyntology: 15 samples, 8 ran (2 instrument-failed) · 7 unverified report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

15 samples harvested: 8 ran (of which 0 constructed an object rather than computing a result; 6 with no instrument failure: 0 honoured, 0 violated, 6 with no contract checked; 2 where Syntology's instrument failed) · 7 unverified. “Where Syntology's instrument failed” counts failures of Syntology's instrument, not of the code. Syntology's record for this page has not changed since , the first build that kept a record date for it; when this build read Syntology's graph is in the build record. That date is not when the samples ran.

2ran; the contract check could not run
6ran
7unverified

Licence: 0 of the 15 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from zhiyuanyou/uniad. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. A line beginning “fixture:” under a sample that ran gives the arguments Syntology's fixture called the sample with, each as name:type/rank/element kind (? where none was recorded), and the type of what the fixture's run returned, exactly as the harness recorded them; the arguments and the returned type were recorded by two separate runs of the same fixture. No output value is shown, and a returned type says nothing about whether the output was right. “Level recorded” gives the UTC date when Syntology's graph wrote the sample's verification level, not when the code executed; where the level was written before Syntology's graph kept that date, the row says “level recorded, date not recorded”. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself. “Our draft was wrong” and “the contract check could not run” are failures of Syntology's instrument, not of the code: the sample ran on Syntology's synthesized input, and then the drafted contract did not describe it, or the check itself raised an error (RAISES), lacked a dependency (DEP_MISSING) or ran out of time (TIMEOUT); hover the label for which. A metamorphic tier, where shown, is evidence of the output's shape, not that the sample implements the method.

Each sample ends with its code_sha256. A sample's code_sha256 is Syntology's identity for that exact code. It is printed in full (16 hexadecimal characters for every sample in this build), and get_code(code_sha256="…") takes it exactly as printed. An agent calls it on Syntology's MCP service (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples are grouped by repository: a repository marked official first, then by how directly the repository is tied to the paper, then in the archive's order; never by how many ran. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of six reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar); this paper's copy was not located, so its licence is not recorded; or this paper's copy is cleared, but the stored copy of the same code that Syntology serves is not. Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

A function or class name links to its page when the name occurs in the harvested code of at least 5 papers; the name is a string, not an identity. A census tag appears when Syntology's census ran implementations with that name on one shared input per bucket: it gives how many were compared, from how many papers, and how many distinct outputs they produced, and names this sample's bucket when this sample was one of them.

zhiyuanyou/uniad official repository 15 samples, 8 ran (2 instrument-failed) · 7 unverified
PositionEmbeddingLearned in 12 papers models/reconstructions/uniad.py ran · metamorphic tier: invariant fingerprinted Apache-2.0 (permissive) · 09b9c17fbe0d29e4 · report fixture: signature tensor:Tensor/2/float · returned Tensor · level recorded 2026-09-22
PositionEmbeddingSine in 21 papers
census: 6 implementations from 6 papers, 3 distinct outputs across 3 buckets, one shared input per bucket this sample: bucket 2 of 3, arg 1: rank 2, kind float, dtype float32
models/reconstructions/uniad.py ran · metamorphic tier: invariant fingerprinted Apache-2.0 (permissive) · c74afaad75da67ca · report fixture: signature tensor:Tensor/2/float · returned Tensor · level recorded 2026-09-22
TransformerDecoder in 49 papers models/reconstructions/uniad.py ran · metamorphic tier: invariant fingerprinted Apache-2.0 (permissive) · 2e15a94ae3c582d9 · report fixture: signature memory:Tensor/3/float, tgt_mask:NoneType/0/?, memory_mask:NoneType/0/?, tgt_key_padding_mask:NoneType/0/?, memory_key_padding_mask:NoneType/0/?, pos:NoneType/0/? · returned Tensor · level recorded 2026-09-22
TransformerDecoderLayer in 45 papers models/reconstructions/uniad.py ran fingerprinted Apache-2.0 (permissive) · d32327f0af382e01 · report fixture: signature out:Tensor/3/float, memory:Tensor/3/float, tgt_mask:NoneType/0/?, memory_mask:NoneType/0/?, tgt_key_padding_mask:NoneType/0/?, memory_key_padding_mask:NoneType/0/?, pos:NoneType/0/? · returned Tensor · level recorded 2026-09-24
TransformerEncoder in 96 papers models/reconstructions/uniad.py ran · metamorphic tier: invariant fingerprinted Apache-2.0 (permissive) · ff5b931728384843 · report fixture: signature src:Tensor/3/float, mask:NoneType/0/?, src_key_padding_mask:NoneType/0/?, pos:NoneType/0/? · returned Tensor · level recorded 2026-09-22
TransformerEncoderLayer in 90 papers models/reconstructions/uniad.py ran · metamorphic tier: invariant fingerprinted Apache-2.0 (permissive) · 4b270121cf640133 · report fixture: signature src:Tensor/3/float, src_mask:NoneType/0/?, src_key_padding_mask:NoneType/0/?, pos:NoneType/0/? · returned Tensor · level recorded 2026-09-22
build_position_embedding in 5 papers models/reconstructions/uniad.py ran; the contract check could not run (RAISES) · metamorphic tier: deterministic Apache-2.0 (permissive) · d5b20d47c0675398 · report fixture: signature pos_embed_type:str/0/str, feature_size:tuple/1/int, hidden_dim:int/0/int · returned PositionEmbeddingSine · level recorded, date not recorded
build_position_embedding in 5 papers models/reconstructions/uniad.py ran; the contract check could not run (RAISES) Apache-2.0 (permissive) · 0c617154b24e553f · report fixture: signature pos_embed_type:str/0/str, feature_size:tuple/1/int, hidden_dim:int/0/int · returned PositionEmbeddingSine · level recorded 2026-09-22
Transformer in 173 papers models/reconstructions/uniad.py unverified Apache-2.0 (permissive) · d93d5baaaf4faa9b · report
UniAD models/reconstructions/uniad.py unverified Apache-2.0 (permissive) · b78aca6c49077d11 · report
init_weights_msra models/reconstructions/uniad.py unverified Apache-2.0 (permissive) · 5b5f3715b5e5582a · report
init_weights_normal in 5 papers models/reconstructions/uniad.py unverified Apache-2.0 (permissive) · 05bee06c0fc81a84 · report
init_weights_xavier in 5 papers models/reconstructions/uniad.py unverified Apache-2.0 (permissive) · 240526ea95ba0d0c · report
initialize in 15 papers models/reconstructions/uniad.py unverified Apache-2.0 (permissive) · 9599fed324e3b1f2 · report
initialize_from_cfg models/reconstructions/uniad.py unverified Apache-2.0 (permissive) · 0d7628c3c2441737 · report

Method as code Syntology

What Syntology's graph records as this paper's claimed method, lifted into code: each assembly names its bricks (functions and classes), each with its own role and its own verification level. An assembly is not a check that the code implements the method correctly or reproduces the paper's results. Levels are each brick's own verification level in Syntology's graph (level 0: no recorded run), listed brick by brick and never combined into one level; “ran” means the brick executed on a synthesized input, not that its output is correct, and the instrument figure counts failures of Syntology's instrument, not of the code. Where a model read the code against the paper's claim, each assembly's label verdict is one model's judgement, kept in this page's JSON twin; it is not calibrated, so no card prints it.

1 assembly on this paper: 1 harvested, 0 generated.

harvested Assembly for UniAD (graph method: UniAD). 16 bricks; individually on a fixture: 9 ran (of which 0 constructed an object rather than computing a result; 6 with no instrument failure: 0 honoured, 0 violated, 6 with no contract checked; 3 where Syntology's instrument failed) · 7 unverified. The assembly has not been run end-to-end.

  1. UniAD entry · level 0 · unverified · b78aca6c49077d11
  2. Transformer model · level 0 · unverified · d93d5baaaf4faa9b
  3. build_position_embedding helper · level 1 · ran; the contract check could not run (RAISES) · 0c617154b24e553f
  4. initialize_from_cfg helper · level 0 · unverified · 0d7628c3c2441737
  5. TransformerDecoder model · level 1 · ran · 2e15a94ae3c582d9
  6. TransformerDecoderLayer model · level 1 · ran · d32327f0af382e01
  7. TransformerEncoder model · level 1 · ran · ff5b931728384843
  8. TransformerEncoderLayer model · level 1 · ran · 4b270121cf640133
  9. PositionEmbeddingLearned helper · level 1 · ran · 09b9c17fbe0d29e4
  10. PositionEmbeddingSine helper · level 1 · ran · c74afaad75da67ca
  11. initialize helper · level 0 · unverified · 9599fed324e3b1f2
  12. _get_clones helper · level 1 · ran · our draft was wrong · c03e17b75656115f
  13. _get_activation_fn helper · level 1 · ran · our draft was wrong · 0bb264f52e707e08
  14. init_weights_msra helper · level 0 · unverified · 5b5f3715b5e5582a
  15. init_weights_normal helper · level 0 · unverified · 05bee06c0fc81a84
  16. init_weights_xavier helper · level 0 · unverified · 240526ea95ba0d0c

Each brick ends with its code_sha256, Syntology's identity for that exact code; click one to copy the get_code call that returns it. For agents, on Syntology's MCP service: assembly(arxiv_id="2206.03687") returns these assemblies with each brick's role and wiring (how to connect).

Tasks

Anomaly DetectionAnomaly LocalizationMulti-class Anomaly DetectionUnsupervised Anomaly Detectionmodel

Results from the paper archive 2025-07-28

TaskDatasetModelMetricValueRank at snapshotLeaderboardReport
Multi-class Anomaly Detection MVTec AD UniAD Detection AUROC 96.5 #13 of 13 Archive leaderboard report
Multi-class Anomaly Detection MVTec AD UniAD Segmentation AUROC 96.8 #13 of 13 Archive leaderboard report

Ranks are positions in the archive's leaderboards as they stood at the 2025-07-28 snapshot. Results published since then are not among these rows, so a rank here is not a current standing.

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections