Skip to main content
QUICK REVIEW

[Paper Review] Defect Transformer: An Efficient Hybrid Transformer Architecture for Surface Defect Detection

Junpu Wang, Guili Xu|arXiv (Cornell University)|Jul 17, 2022
Industrial Vision Systems and Defect DetectionEngineering11 citations
TL;DR

This paper proposes Defect Transformer (DefT), a hybrid CNN-Transformer architecture that combines convolutional neural networks for local feature extraction with a novel multi-scale self-attention mechanism to model long-range dependencies in surface defect detection. The method achieves state-of-the-art performance with improved accuracy, training efficiency, and data efficiency on three benchmark datasets, outperforming both CNN- and transformer-based models.

ABSTRACT

Surface defect detection is an extremely crucial step to ensure the quality of industrial products. Nowadays, convolutional neural networks (CNNs) based on encoder-decoder architecture have achieved tremendous success in various defect detection tasks. However, due to the intrinsic locality of convolution, they commonly exhibit a limitation in explicitly modeling long-range interactions, critical for pixel-wise defect detection in complex cases, e.g., cluttered background and illegible pseudo-defects. Recent transformers are especially skilled at learning global image dependencies but with limited local structural information necessary for detailed defect location. To overcome the above limitations, we propose an efficient hybrid transformer architecture, termed Defect Transformer (DefT), for surface defect detection, which incorporates CNN and transformer into a unified model to capture local and non-local relationships collaboratively. Specifically, in the encoder module, a convolutional stem block is firstly adopted to retain more detailed spatial information. Then, the patch aggregation blocks are used to generate multi-scale representation with four hierarchies, each of them is followed by a series of DefT blocks, which respectively include a locally position-aware block for local position encoding, a lightweight multi-pooling self-attention to model multi-scale global contextual relationships with good computational efficiency, and a convolutional feed-forward network for feature transformation and further location information learning. Finally, a simple but effective decoder module is proposed to gradually recover spatial details from the skip connections in the encoder. Extensive experiments on three datasets demonstrate the superiority and efficiency of our method compared with other CNN- and transformer-based networks.

Motivation & Objective

  • To address the limitations of CNNs in modeling long-range dependencies and transformers in capturing fine-grained local details for surface defect detection.
  • To develop a unified architecture that effectively fuses local spatial inductive bias from CNNs with global contextual modeling from transformers.
  • To improve detection performance on complex industrial images with cluttered backgrounds and pseudo-defects.
  • To enhance training and data efficiency by embedding inductive bias explicitly through convolutional components.

Proposed method

  • A convolutional stem block is used at the encoder input to preserve high-resolution spatial details.
  • Patch aggregation blocks generate multi-scale features across four hierarchical levels.
  • Each level is followed by a DefT block containing a locally position-aware block (LPB) for local position encoding.
  • A lightweight multi-pooling self-attention (LMPS) mechanism captures multi-scale global context with low computational cost.
  • A convolutional feed-forward network (CFFN) replaces standard FFN to enhance feature transformation and location learning.
  • A simple decoder with skip connections reconstructs dense segmentation maps from hierarchical features.

Experimental results

Research questions

  • RQ1Can a hybrid CNN-Transformer architecture outperform pure CNNs and transformers in surface defect detection?
  • RQ2How does explicit local position encoding via convolutional operations improve performance compared to absolute or relative position encoding?
  • RQ3To what extent does incorporating CNN inductive bias enhance training and data efficiency in defect detection?
  • RQ4What is the contribution of each component (LPB, LMPS, CFFN) to the overall detection performance?

Key findings

  • DefT achieves a 5.5% relative improvement in MAE over the baseline when replacing the standard FFN with the proposed CFFN.
  • The addition of the locally position-aware block (LPB) improves MAE by 5.2% with negligible computational cost.
  • The lightweight multi-pooling self-attention (LMPS) mechanism reduces computational overhead while improving performance, achieving an MAE of 0.0136.
  • DefT outperforms Swin-Unet in both training and data efficiency: it achieves 82.53% F1 after only 60 epochs, surpassing Swin-Unet trained for 700 epochs.
  • DefT trained on 30% of the data matches the performance of Swin-Unet* pre-trained on ImageNet, demonstrating strong data efficiency.
  • The model with no specialized position encoding (N/A) still performs competitively (97.12% accuracy), confirming that convolutional components implicitly provide spatial inductive bias.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.