An Improved YOLOv5 Network for Detection of Printed Circuit Board Defects

Jie Niu,Hongyan Li,Xu Chen,Kun Qian
DOI: https://doi.org/10.1155/2023/7270093
IF: 2.336
2023-03-04
Journal of Sensors
Abstract:With the rapid development of China's printed circuit board industry, bare-board defect detection has high research and application values as an important factor in improving production quality. In this paper, a new detection method based on YOLOv5 is proposed to solve the balance problem of efficiency and performance in the task of circuit board defect detection. First, the k -means++ method is used to improve the location matching of the prior anchor boxes. Second, the Focal-EIOU loss function is used instead of GIOU to address the former's degeneration issue. Finally, the ECA-Net module is added to enhance the sensitivity of the model to channel features. Experiments were conducted on a public defect dataset, and superior performance was achieved. The proposed method achieves 99.1% mean average precision at 86 frames per second. Compared with other advanced methods, the proposed method achieves the highest mean average precision value, and the detection speed allows real-time applications.
engineering, electrical & electronic,instruments & instrumentation
What problem does this paper attempt to address?
The problem that this paper attempts to solve is the balance between efficiency and performance in printed circuit board (PCB) defect detection. With the rapid development of China's PCB industry, defect - free assembly detection has important research and application value for improving production quality. Specifically, this paper aims to achieve high - efficiency and high - precision PCB defect detection by improving the YOLOv5 network. ### Main improvement points 1. **Anchor box optimization**: - Use the k - means++ method to improve the position matching of prior anchor boxes to obtain more reasonable initial clustering centers, thereby improving the accuracy of the model in locating small - target defects. 2. **Loss function improvement**: - Replace the original GIOU loss function in YOLOv5 with the Focal - EIOU loss function, which solves the sample imbalance problem and accelerates the convergence speed. 3. **Attention mechanism introduction**: - Embed the ECA - Net module in the backbone network of YOLOv5 to enhance the model's sensitivity to channel features and improve the feature extraction ability. ### Experimental results The experiment was carried out on a public PCB defect data set, and the results show that the improved YOLOv5 model performs excellently in both detection speed and accuracy. Specific indicators are as follows: - **mAP@0.5**: Reaches 99.1%, which is significantly improved compared with other advanced methods. - **FPS**: Reaches 86 frames per second, meeting the requirements of real - time applications. ### Conclusion Through the above improvements, the optimized YOLOv5 model shows higher accuracy and faster detection speed in the PCB defect detection task and can be effectively applied in industrial scenarios. In addition, this method also shows potential application value in other fields such as fruit ripeness recognition and workpiece surface defect detection. ### Formula display - k - means++ center point selection probability formula: \[ P(x)=\frac{D(x)^{2}}{\sum_{x\in X}D(x)^{2}} \] where \(D(x)\) represents the squared Euclidean distance from the data point to the nearest selected center point. - Focal - EIOU loss function: \[ L_{\text{Focal - EIOU}}=\text{IOU}^{\gamma}\cdot L_{\text{EIOU}} \] \[ L_{\text{EIOU}}=L_{\text{IOU}}+L_{\text{dis}}+L_{\text{asp}} = 1-\text{IOU}+\frac{\rho^{2}(b, b')}{c^{2}}+\frac{\rho^{2}(w, w')}{C_{w}^{2}}+\frac{\rho^{2}(h, h')}{C_{h}^{2}} \] where \(\gamma\) is a parameter that controls the degree of outlier suppression, \(L_{\text{IOU}}\) is the IOU loss, \(L_{\text{dis}}\) is the distance loss, \(L_{\text{asp}}\) is the aspect ratio loss, and \(C_{w}\) and \(C_{h}\) represent the width and height of the minimum bounding box covering the predicted box and the ground - truth box respectively. These improvements make the model more robust and efficient in dealing with complex and diverse PCB defects.