HVQ-Trans
A Transformer that detects image anomalies by reconstructing inputs from codebooks of normal prototypes.
Segmentation · 1,621 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
At a glance
- Task
- Segmentation
- Parameters
- 37.4M
- Operations
- 1,621
- Framework
- PyTorch
- Recurrent
- No
- Published
- NeurIPS 2023
- Cited by
- 47 (as of 27 October 2026)
- Authors
- Ruiying Lu, YuJie Wu, Long Tian and others
- Source
- GitHub: RuiyingLu/HVQ-Trans
- Checked
- Passed: the trace was replayed operation by operation and matched the model's own output for this input.
Files
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
Details
- Stable ID
- m17288
- Graph hash
- e6dd280e6c45075d952f39a3600cdac58b43572070d68402a330b07b5c3b7f47
- Skeleton hash
- c780d6a0a1f1e9b0e13ecb625be8e9beaf9c58c891a1b69f15b0839fec8cad7c
- Architecture hash
- b36a9bb874b5875ba74fb01fd7f81f928bbcf1ece2f64a07c1c1bff589dc52ff
- Diagram SHA-256
- d2d73960f2485f3158ebfdbc86687efe99664ed4e0b098c0deae77eb3c141e9f
- TorchLens version
- 2.36.0
- Renderer
- graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
- Check
- Forward pass replayed in PyTorch
What it is
HVQ-Trans is one model for unsupervised anomaly detection across many object classes: it models normal data only and treats samples that deviate from it as anomalies. Reconstruction-based networks can suffer from what the paper calls the "identical shortcut" issue, where normal and abnormal samples are both recovered well and are difficult to distinguish.
HVQ-Trans responds with a discrete latent space. Typical normal patterns are kept as prototypes in codebooks, and during reconstruction the encoded features are replaced with the nearest prototypes and decoded by a VQ-based Transformer decoder. An abnormal data point is thereby flipped to a normal one, which induces a large feature discrepancy for anomalies. The quantization is hierarchical, merging fine-grained and abstract features to prevent codebook collapse. A switching mechanism classifies each input image into a single category and chooses the corresponding codebook and reconstruction expert.
Anomaly scores come from a prototype-oriented optimal transport (OT) method. The authors' repository provides the model with and without the OT strategy, and this model is the one with it. In the paper's MVTec-AD setup a pre-trained EfficientNet turns the image into 14 × 14 × 272 feature maps, which go through a 4-layer Transformer encoder and a 4-layer VQ Transformer decoder. On MVTec-AD the paper reports that HVQ-Trans surpasses PatchCore and UniAD by 1.6% and 1.5% on average.
Key idea. The paper builds a Transformer that reconstructs inputs from discrete prototypes of normal patterns, held in hierarchical vector-quantized codebooks, so that anomalies are rebuilt as normal.
- hvq-trans
- hvq trans
- hierarchical vector quantized transformer
- unsupervised anomaly detection
- multi-class anomaly detection
- anomaly localization
- industrial inspection
- vector quantization
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
Cite the paper
@misc{lu2023hierarchicalvectorquantizedtransformer,
title={Hierarchical Vector Quantized Transformer for Multi-class Unsupervised Anomaly Detection},
author={Ruiying Lu and YuJie Wu and Long Tian and Dongsheng Wang and Bo Chen and Xiyang Liu and Ruimin Hu},
year={2023},
eprint={2310.14228},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2310.14228},
}