
Abstract
Printed Circuit Boards (PCBs) play a crucial role in electronic devices, and defect detection during their manufacturing process is a key step in ensuring product quality. In recent years, deep learning technologies have made significant progress in object detection tasks, particularly with the YOLO (You Only Look Once) series of algorithms, which excel in real-time detection. This paper employs two object detection models, YOLOv8 and YOLOv5, to detect defects in PCBs and conducts comparative experiments on their detection performance. The experimental results indicate that YOLOv8 outperforms YOLOv5 in both detection accuracy and inference speed, enabling more efficient identification of common PCB defects such as pad missing, solder bridging, and fractures.
Theory
The object detection algorithms in deep learning mainly include two-stage detection (such as Faster R-CNN) and single-stage detection (such as YOLO and SSD). The YOLO series algorithms directly predict the class and location of objects through a regression method, thus achieving high detection speeds.
1. YOLOv5
- YOLOv5 is an improved version of the YOLO series, utilizing CSPDarknet53 as the backbone network to enhance feature extraction capabilities.
- It employs Mosaic data augmentation, FPN+PAN feature pyramid structure, and GIoU loss function to improve small object detection capabilities.
- It is suitable for real-time industrial detection tasks.
2. YOLOv8
- YOLOv8 is the latest version in the YOLO family, further optimizing the network structure and using a more efficient model architecture, significantly enhancing detection accuracy and speed.
- It adopts an Anchor-Free design, reducing the need for hyperparameter tuning and improving detection flexibility.
- Through deeper feature fusion and a new loss function, it achieves more accurate detection of small defects.
Experimental Results
This experiment utilized a dataset containing various types of PCB defects, including pad missing, pad misalignment, solder bridging, fractures, and holes. We trained both YOLOv5 and YOLOv8 on the same training and testing sets and compared their detection results.
The experimental results show that YOLOv8 outperforms YOLOv5 in terms of mAP (mean Average Precision) and inference speed, making it suitable for high-precision and high-real-time PCB defect detection tasks.

Sample Code
clc; clear; close all;
% Read the detected image
image = imread('pcb_detected.jpg');
% Read detection box data (assumed to be in CSV format: [x, y, width, height, confidence, class])
data = readmatrix('detection_results.csv');
% Display the image
imshow(image);
hold on;
% Draw detection boxes
for i = 1:size(data,1)
x = data(i,1);
y = data(i,2);
w = data(i,3);
h = data(i,4);
conf = data(i,5);
class_id = data(i,6);
% Random color
color = rand(1,3);
% Draw box
rectangle('Position', [x, y, w, h], 'EdgeColor', color, 'LineWidth', 2);
% Display class and confidence
text(x, y-5, sprintf('Class: %d, Conf: %.2f', class_id, conf), ...
'Color', 'red', 'FontSize', 12, 'FontWeight', 'bold');
end
hold off;
Related Technologies
❝
- Redmon, J., & Farhadi, A. (2018). YOLOv3: An Incremental Improvement. arXiv preprint arXiv:1804.02767.
- Bochkovskiy, A., Wang, C. Y., & Liao, H. Y. M. (2020). YOLOv4: Optimal Speed and Accuracy of Object Detection. arXiv preprint arXiv:2004.10934.
- Jocher, G., Chaurasia, A., & Qiu, J. (2021). YOLOv5. GitHub repository.
- Ultralytics. (2023). YOLOv8: Newest Version of YOLO Object Detection. GitHub repository.
(The content of this article is for reference only; specific results are subject to the images.)
