IADGPT: Unified LVLM for Few-Shot Industrial Anomaly Detection, Localization, and Reasoning via In-Context Learning

Mengyang Zhao, Teng Fu, Haiyang Yu, Ke Niu, Bin LiarXiv 2025

Abstract

Few-Shot Industrial Anomaly Detection (FS-IAD) has important applications in automating industrial quality inspection. Recently, some FS-IAD methods based on Large Vision-Language Models (LVLMs) have been proposed with some achievements through prompt learning or fine-tuning. However, existing LVLMs focus on general tasks but lack basic industrial knowledge and reasoning capabilities related to FS-IAD, making these methods far from specialized human quality inspectors. To address these challenges, we propose a unified framework, IADGPT, designed to perform FS-IAD in a human-like manner, while also handling associated localization and reasoning tasks, even for diverse and novel industrial products. To this end, we introduce a three-stage progressive training strategy inspired by humans. Specifically, the first two stages gradually guide IADGPT in acquiring fundamental industrial knowledge and discrepancy awareness. In the third stage, we design an in-context learning-based training paradigm, enabling IADGPT to leverage a few-shot image as the exemplars for improved generalization to novel products. In addition, we design a strategy that enables IADGPT to output image-level and pixel-level anomaly scores using the logits output and the attention map, respectively, in conjunction with the language output to accomplish anomaly reasoning. To support our training, we present a new dataset comprising 100K images across 400 diverse industrial product categories with extensive attribute-level textual annotations. Experiments indicate IADGPT achieves considerable performance gains in anomaly detection and demonstrates competitiveness in anomaly localization and reasoning.

Introduction

Industrial Anomaly Detection (IAD) is a critical component of modern manufacturing, traditionally requiring the identification of defects such as scratches, dents, or missing components. Historically, this has necessitated a "one-for-one" approach, where a specific model is trained for every unique product type. While Large Vision-Language Models (LVLMs) have shown promise in general visual tasks, they often lack the specialized domain knowledge and reasoning capabilities required to act as effective quality inspectors.

Figure 1: The IADGPT framework provides a unified output for anomaly detection, localization, and reasoning using a reference-query image pair.

IADGPT addresses these limitations by introducing a "one-for-all" framework. By leveraging in-context learning (ICL), the model can inspect novel products by comparing them to a few "normal" reference images, mimicking the behavior of a human inspector who understands both the visual discrepancy and the underlying cause of a defect.

Methodology

IADGPT is built upon the Qwen2.5-VL-7B architecture and utilizes a novel three-stage progressive training strategy:

  1. Basic Knowledge Acquisition: The model is first trained to describe industrial products—their shapes, materials, and surface qualities—using a massive image-text dataset.
  2. Discrepancy-Aware Learning: The model engages in proxy tasks, such as identifying outliers in groups and locating differences between paired images, to sharpen its sensitivity to anomalies.
  3. In-Context Learning (ICL): The final stage enables the model to use exemplars (normal images) as context to judge a query image. This allows IADGPT to generalize to unseen products without further weight updates.

To optimize performance, the framework incorporates Multi-Layer Visual Embedding to fuse features from different encoder layers, capturing both fine-grained scratches and coarse-grained missing parts. Additionally, a Visual Token Compression strategy identifies and discards up to 80% of redundant tokens from reference images, maintaining accuracy while significantly reducing computational overhead.

Datasets and Evaluation

A core contribution of this work is the IADGPT Dataset, a large-scale collection of 100,000 images across 400 diverse industrial product categories. Each image features detailed, attribute-level textual annotations. For benchmarking, the authors utilized standard datasets including MVTec-AD and VisA for detection and localization, and VisA-D&R for evaluating anomaly reasoning (causes and solutions).

Results and Key Insights

IADGPT demonstrates state-of-the-art performance across multiple metrics:

  • Detection: On MVTec and VisA, IADGPT outperformed the previous leading "one-for-all" model (IIPAD) by an average of 1.5% to 5.5% in image-level AUC.
  • Reasoning: The model's specialized training allows it to outperform general-purpose models like GPT-4V in explaining defects. It can precisely describe anomalies (e.g., "the second pin is bent") and suggest preventative measures.
  • Localization: The model achieves a competitive pixel-level AUC of approximately 96.7%, effectively generating heatmaps that highlight defect locations directly from internal attention maps.

Conclusion

IADGPT represents a significant step toward a unified, human-like industrial inspector. By combining in-context learning with a specialized three-stage training regimen, it overcomes the "one-for-one" limitation of traditional IAD. While the model achieves high accuracy, future work will focus on tighter integration with dedicated segmentation architectures to push the ceiling of pixel-level localization and the public release of the 100K image dataset to foster further community research.

Summary updated

BibTeX
@misc{zhao2025iadgpt,
  author = {Mengyang Zhao and Teng Fu and Haiyang Yu and Ke Niu and Bin Li},
  title = {{IADGPT: Unified LVLM for Few-Shot Industrial Anomaly Detection, Localization, and Reasoning via In-Context Learning}},
  year = {2025},
  eprint = {2508.10681},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2508.10681},
}
Figure