Hierarchical Gaussian Mixture Normalizing Flow Modeling for Unified Anomaly Detection

Xincheng Yao, Ruoqi Li, Zefeng Qian, Lu Wang, Chongyang Zhang · DOI

In industrial inspection, anomaly detection (AD) is critical for quality control. Traditionally, this has required "one-for-one" models—training a specific AI for every product category. While effective, this approach is difficult to scale. The goal is Unified Anomaly Detection: a single model capable of detecting defects across a wide variety of product types.

A recent paper, Hierarchical Gaussian Mixture Normalizing Flow Modeling for Unified Anomaly Detection, introduces HGAD, a framework that overcomes the limitations of previous unified models by rethinking the underlying probability distributions used in Normalizing Flows.

The Homogeneous Mapping Problem

Most current AD models are specialists. Unified AD attempts to train a single model on normal samples from many different classes (e.g., bottles, cables, and tiles). However, popular Normalizing Flow (NF) models struggle in this setting. NFs typically map complex data to a single, "uni-modal" Gaussian distribution.

When forced to map multiple distinct classes into one standard bell curve, the model often focuses on coarse, shared features, ignoring the fine-grained details that distinguish one class from another. This leads to "homogeneous mapping," where both normal and abnormal features receive high likelihood scores, making it nearly impossible to distinguish defects.

Conceptual comparison between standard unified AD and the proposed HGAD approach showing the shift from a single class center to hierarchical mixture modeling.

As shown in the figure above, HGAD replaces the single class center with a hierarchical mixture of Gaussians, allowing for better separation of distinct product categories in the latent space.

The HGAD Framework

HGAD introduces three key architectural shifts to solve the homogeneous mapping issue:

  1. Inter-class Gaussian Mixture Modeling: Instead of mapping every class to the same origin, HGAD assigns each class its own learnable center. This preserves the unique identity of different products.
  2. Mutual Information Maximization (MIM): To prevent these class centers from collapsing toward each other, an MIM loss acts as a "repulsion" force, ensuring different class distributions remain distinguishable.
  3. Intra-class Mixed Class Centers: Real-world products have internal diversity. HGAD models this by allowing each class to have multiple "sub-centers," capturing complex patterns within a single category.

The model uses a dual Anomaly Scoring mechanism, evaluating both the log-likelihood (fit to the assigned class) and inter-class entropy (model confusion between classes) to flag defects.

Key Results

HGAD sets a new high-water mark for unified anomaly detection across several benchmarks, including MVTecAD, BTAD, and VisA.

Comparison of training dynamics and log-likelihood distributions between many-to-one and unified NF-based AD.

On the MVTecAD benchmark, HGAD achieved a 98.4% image-level AUROC, significantly outperforming previous state-of-the-art methods like UniAD (96.5%) and standard NF-based baselines like CFLOW-AD (91.8%). Furthermore, it achieves these results with greater training efficiency, requiring only 100 epochs compared to the 1,000 epochs often needed by competing architectures.

The separation between normal and abnormal samples is much clearer in HGAD, as evidenced by the log-likelihood histograms in the figure above. This leads to highly accurate defect localization, reaching 97.9% pixel-level AUROC on MVTecAD.

Conclusion

HGAD demonstrates that the failure of Normalizing Flows in unified AD is not due to a lack of model capacity, but rather a prior bias toward single-Gaussian distributions. By adopting a hierarchical mixture prior, HGAD enables a single model to maintain high precision across diverse product lines. Future work will look toward making these models "class-agnostic," allowing them to generalize to entirely new product categories without retraining.

Summary updated

BibTeX
@inproceedings{yao2024hierarchical,
  author = {Xincheng Yao and Ruoqi Li and Zefeng Qian and Lu Wang and Chongyang Zhang},
  title = {{Hierarchical Gaussian Mixture Normalizing Flow Modeling for Unified Anomaly Detection}},
  booktitle = {European Conference on Computer Vision},
  year = {2024},
  doi = {10.1007/978-3-031-73411-3\_6},
}
Figure