Improved YOLOv5 Network for Steel Surface Defect Detection

Bo Huang, Jian‐Hong Liu, Xiang Liu, Kang Liu, Xinyu Liao, Kun Li, Jian WangMetals 2023 · DOI

TL;DR

This paper tackles the challenge of accurately detecting defects on steel surfaces, a critical task for quality control. The researchers enhance the popular YOLOv5 object detection model by incorporating deformable convolutions, a CBAM attention mechanism, a Focal EIOU loss function, and optimized anchor boxes. This improved YOLOv5 achieves a notable 4.3% increase in detection probability on the NEU-DET dataset with only a minimal increase in inference time.

What Problem Does This Paper Address?

Ensuring the quality of steel is paramount, and surface defects like cracks, patches, and scratches can significantly compromise its structural integrity and service life. Traditional manual visual inspection is prone to fatigue and human error. While computer vision has advanced defect detection, achieving high accuracy, especially for subtle or irregularly shaped defects, remains a challenge. Existing deep learning models, even powerful ones like YOLOv5, can sometimes miss defects or struggle with variations in defect appearance and scale, leading to lower detection probabilities. This paper aims to bridge this gap by improving the robustness and accuracy of a YOLOv5-based system for steel surface defect detection.

Methods

The authors propose a multi-pronged approach to enhance the YOLOv5 architecture:

  • Deformable Convolution (DCnv2): Standard convolutional kernels sample features at fixed grid locations. For irregularly shaped defects, this can be inefficient. Deformable convolution introduces learnable offsets to the sampling locations, allowing the kernel to adapt its receptive field to better focus on the target defect region. This is integrated into the backbone network, replacing a standard convolutional module.
  • CBAM Attention Mechanism: To help the network focus on relevant features and suppress noise, a Convolutional Block Attention Module (CBAM) is incorporated. CBAM sequentially applies channel and spatial attention mechanisms, allowing the model to learn which features (across channels) and which spatial locations are most important for defect detection. It's added after several C3 modules in the backbone.
  • Focal EIOU Loss Function: The standard YOLOv5 uses the CIOU loss. This paper replaces it with Focal EIOU. EIOU addresses limitations of CIOU by directly considering the difference in width and height between predicted and ground truth boxes, leading to faster convergence. Focal loss is then integrated to address the imbalance between easy and hard-to-detect samples, further improving performance.
  • K-means for Anchor Box Optimization: YOLOv5 uses pre-defined anchor boxes. The authors found that these might not be optimal for the specific characteristics of steel defects. They use the K-means clustering algorithm with an IOU-based distance metric to re-cluster the anchor boxes based on the steel defect dataset, generating more suitable parameters for better feature extraction.

Datasets

The primary dataset used in this research is the NEU-DET dataset. This dataset contains 6000 images of steel surfaces with six types of defects: rolled-in-scale (RS), patches (PA), crazing (CR), inclusion (IN), pitted surface (PS), and scratches (SC). The paper utilizes a subset of 1800 images (300 per defect type) for training, validation, and testing, with a split of 8:1:1.

Key Insights and Ideas

  • Deformable convolutions are crucial for irregular shapes: The paper highlights how deformable convolutions can significantly improve feature extraction by allowing the network to adapt its sampling grid to the often non-uniform shapes of steel defects.
  • Attention mechanisms boost focus: The CBAM module demonstrably helps the network pinpoint defect regions more effectively, as visualized by the attention heatmaps. This is particularly important for subtle defects that might otherwise be overlooked.
  • Loss function matters for sample imbalance: The integration of Focal EIOU is key to handling datasets where some defects are much harder to detect than others. This prevents the model from becoming overly biased towards easily detectable samples.
  • Dataset-specific anchor boxes yield better results: Optimizing anchor boxes using K-means on the target dataset leads to a better initial configuration for the detector, improving its ability to capture the scale and aspect ratios of steel defects.

Key Results

The improved YOLOv5 network achieved a mean Average Precision (mAP) of 78.8% on the NEU-DET dataset. This represents a significant improvement of 4.3% compared to the original YOLOv5 network. Importantly, this enhancement came with only a marginal increase in inference time, just 1 ms per image. The paper also shows that individual defect detection rates improved, with RS and CR seeing the most substantial gains.

Limitations and Future Work

While the proposed method shows considerable improvement, the authors acknowledge that the detection probability for crazing defects remains relatively low. They suggest that future work should focus on further improving the detection of these specific defects and continuing to enhance the overall steel surface defect detection capabilities. The paper also notes that using multiple deformable convolution modules (DCnv2) could increase training time without proportional accuracy gains, leading them to use a single DCnv2 module strategically placed in the backbone.

Summary updated

Abstract

Steel surface defect detection is crucial for ensuring steel quality. The traditional detection algorithm has low detection probability. This paper proposes an improved algorithm based on the YOLOv5 model to enhance detection probability. Firstly, deformable convolution is introduced in the backbone network, and a traditional convolution module is replaced by deformable convolution; secondly, the CBAM attention mechanism is added to the backbone network; then, Focal EIOU is used instead of the CIOU loss function in YOLOv5; lastly, the K-means algorithm is used to cluster the Anchor box, and the Anchor box parameters that are more suitable for this paper are obtained. The experimental results show that using deformable convolution instead of traditional convolution can get more feature information, which is more conducive to the learning of the network. This paper uses the CBAM attention mechanism, and the heat map of the attention mechanism shows that the CBAM attention mechanism is beneficial for feature extraction. Focal EIOU is optimized in high and wide loss compared with the CIOU loss function, which accelerates the convergence of the model. The Anchor box is more favorable for feature extraction. The improved algorithm achieved a detection probability of 78.8% in the NEU-DET dataset, which is 4.3% better than the original YOLOv5 network, and the inference time of each image is only increased by 1 ms; therefore, the optimized algorithm proposed in this paper is effective.
BibTeX
@inproceedings{huang2023improved,
  author = {Bo Huang and Jian‐Hong Liu and Xiang Liu and Kang Liu and Xinyu Liao and Kun Li and Jian Wang},
  title = {{Improved YOLOv5 Network for Steel Surface Defect Detection}},
  booktitle = {Metals},
  year = {2023},
  doi = {10.3390/met13081439},
}
Figure