Transformer-Based Multiscale Reconstruction Network for Defect Detection of Infrared Images

Changyun Wei, Hui Han, Zhichao Wu, Yu Xia, Ze JiIEEE Trans. Instrumentation & Measurement 2024

Abstract

Bottle packaging is extensively used in manufacturing, and inspecting aluminum foil sealing during filling is crucial for ensuring product quality. Traditional machine vision methods based on supervised learning require extensive annotated data, but the scarcity of defective samples hampers the effectiveness of these methods. To address this challenge, unsupervised learning methods have emerged. Despite their potential, these methods often struggle to accurately learn the distribution of normal samples, resulting in higher rates of false positives and negatives. This article proposes an unsupervised learning-based approach for anomaly detection in infrared images. Specifically, we construct a transformer-based multiscale image reconstruction network (TMIRN) that includes a feature extraction module, a feature fusion module, a reconstruction module, a discriminator network, and an anomaly scoring module. By effectively combining Transformer and convolutional neural network (CNN) techniques, the proposed network excels at capturing both global and local semantic information. Its multiscale structure accurately localizes defects of varying sizes and combines image-level and feature-level anomaly scores to mitigate the impact of nonuniform distribution and noise. Experimental results on the infrared image dataset for aluminum foil sealing demonstrate high accuracy in anomaly detection and localization. Furthermore, on the industrial MVTec AD dataset, our TMIRN exhibits superior generalization and detection compared to state-of-the-art reconstruction networks.

The Challenge of Infrared Defect Detection

In high-speed bottling lines, ensuring a perfect aluminum foil seal is critical for product safety. Manufacturers often use infrared (IR) imaging because it can "see" the heat signature of a seal through a plastic cap. However, detecting defects in these images is surprisingly difficult.

Traditional "supervised" AI requires thousands of labeled examples of every possible defect—such as nicks, folds, or loose caps—which are rare in a well-run factory. "Unsupervised" methods, which learn what a normal seal looks like and flag anything else as an anomaly, often struggle with the noisy, non-uniform backgrounds typical of IR images. Current models either miss small defects or are distracted by harmless thermal noise, leading to high false-alarm rates.

Figure 4: Comparison of normal and defective seals. Top row shows visible light images, bottom row shows corresponding infrared thermal signatures for (a) normal, (b) no foil, (c) reversed foil, (d) nicked, (e) over-sealed, (f) loose cap, and (g) tilted cap.

Proposed Methodology: TMIRN

The authors propose the Transformer-based Multiscale Reconstruction Network (TMIRN), an unsupervised architecture based on a Generative Adversarial Network (GAN) framework. The core innovation lies in its hybrid, multiscale approach to feature extraction.

Hybrid Architecture and Multiscale Extraction

TMIRN integrates Convolutional Neural Networks (CNNs) to handle local details like edges and textures with Vision Transformers (ViTs) to understand the global structure of the seal. Instead of looking at the image at just one resolution, the Multiscale Transformer Feature Extraction (MTFE) module processes it at three different scales simultaneously. This allows the network to catch both tiny pinhole leaks and large-scale misalignments.

Figure 6: The architecture of the Multi-scale Transformer feature extraction module, showing the integration of ResNet and Vision Transformer blocks across multiple image scales.

Key Technical Innovations

  • Efficient Channel Attention (ECA): Within the feature fusion module, the system uses "attention" to suppress noise and focus on the most informative parts of the thermal signal.
  • Dual-Level Anomaly Scoring: Most models only look at pixel-level differences between the original and reconstructed image. TMIRN combines image-level residuals (pixel differences) with feature-level residuals (differences in deep semantic patterns), making it much more robust to the "grainy" noise found in IR data.
  • The "Inductive Bias" Balance: By nesting CNN-based residual blocks inside the Transformer modules, the authors provide the model with a "head start" in understanding local image structures, allowing it to perform well even with the relatively small datasets typical of specialized industrial tasks.

Experimental Results

The study utilized two primary datasets to validate the model: a proprietary infrared foil sealing dataset collected from a real production line and the standard industrial MVTec AD benchmark.

Performance Metrics

The TMIRN model set a new bar for performance in this domain:

  • Accuracy: On the infrared dataset, it achieved an Image-AUROC of 99.25%, outperforming other leading models like DRAEM (98.40%) and PatchCore (91.83%).
  • Localization: For pinpointing exactly where a defect is located, it achieved a Pixel-AUROC of 96.41%.
  • Speed: The inference time is approximately 0.029 seconds per image, meeting the requirements for real-time monitoring on high-speed mass production lines.
  • Generalization: On the MVTec AD benchmark, it maintained a high average AUROC of 94.20%, proving its effectiveness beyond just infrared data.

Conclusion and Future Work

TMIRN demonstrates that combining the local feature-capturing power of CNNs with the global context of Vision Transformers can significantly improve anomaly detection in noisy industrial environments. While highly effective, the authors noted that the model still faces challenges with highly irregular complex textures. Future research will focus on model compression to allow these powerful Transformer components to run on lower-power edge computing hardware directly on the factory floor.

Summary updated

Abstract

Bottle packaging is extensively used in manufacturing, and inspecting aluminum foil sealing during filling is crucial for ensuring product quality. Traditional machine vision methods based on supervised learning require extensive annotated data, but the scarcity of defective samples hampers the effectiveness of these methods. To address this challenge, unsupervised learning methods have emerged. Despite their potential, these methods often struggle to accurately learn the distribution of normal samples, resulting in higher rates of false positives and negatives. This article proposes an unsupervised learning-based approach for anomaly detection in infrared images. Specifically, we construct a transformer-based multiscale image reconstruction network (TMIRN) that includes a feature extraction module, a feature fusion module, a reconstruction module, a discriminator network, and an anomaly scoring module. By effectively combining Transformer and convolutional neural network (CNN) techniques, the proposed network excels at capturing both global and local semantic information. Its multiscale structure accurately localizes defects of varying sizes and combines image-level and feature-level anomaly scores to mitigate the impact of nonuniform distribution and noise. Experimental results on the infrared image dataset for aluminum foil sealing demonstrate high accuracy in anomaly detection and localization. Furthermore, on the industrial MVTec AD dataset, our TMIRN exhibits superior generalization and detection compared to state-of-the-art reconstruction networks.
BibTeX
@article{wei2024transformer,
  author = {Changyun Wei and Hui Han and Zhichao Wu and Yu Xia and Ze Ji},
  title = {{Transformer-Based Multiscale Reconstruction Network for Defect Detection of Infrared Images}},
  journal = {IEEE Trans. Instrumentation \& Measurement},
  year = {2024},
  url = {https://openreview.net/forum?id=0fJwO9b1ax},
}
Figure