PCB assembly X-Ray image identification method based on Mobile-YOLO
By adopting a lightweight network structure based on Mobile-YOLO in PCB defect detection, the problems of low efficiency, insufficient accuracy and high model complexity of traditional detection methods are solved, and efficient and real-time defect detection is achieved, which is suitable for industrial environments.
Patent Information
- Application Number
- CN202510070034.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-16
- Publication Date
- 2025-05-16
AI Technical Summary
Traditional PCB defect detection methods are inefficient, insufficient accuracy, and high model complexity, making it difficult to meet the requirements of real-time and equipment resource limitations in industrial scenarios.
Using a lightweight network structure based on Mobile-YOLO, including Mobile-YOLOl and Mobile-YOLOs models, the convolutional features are optimized through the SSA Mobile module, combined with data preprocessing and enhancement technology, to improve the robustness and efficiency of the detection model.
It has achieved high detection performance, 100% recall rate, and more than 98% accuracy. The complexity of model calculation is significantly reduced. It is suitable for industrial environments with limited resources and meets real-time detection needs.
Smart Images

Figure CN120013882A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer vision and electronic manufacturing, and in particular relates to a PCB component X-Ray image recognition method based on Mobile-YOLO. Background Art
[0002] With the continuous advancement of electronic technology, PCB (Printed Circuit Board) has become an indispensable and important part of modern electronic devices. In order to ensure the quality and performance of PCB, defect detection during the PCB manufacturing process is particularly important. PCB defects not only affect the normal function of the product, but may also cause equipment performance degradation or even failure, bringing safety hazards. Therefore, accurate and rapid detection of defects in PCB is a key step to ensure product quality.
[0003] Traditional PCB defect detection methods mostly rely on manual visual inspection or simple automated detection tools. Although these methods can work effectively in some scenarios with low precision requirements, they often fail to meet the needs of efficient and accurate detection in complex circuit board designs and production environments with high precision requirements. Manual inspection is inefficient and easily affected by factors such as operator fatigue and experience, and cannot guarantee consistency and high accuracy. Traditional machine vision inspection systems are usually based on preset rules and are difficult to cope with various deformations, noise and other changes in PCB images. Therefore, with the complexity of PCB manufacturing processes, traditional methods have gradually exposed various limitations, and more efficient and accurate defect detection technologies are urgently needed.
[0004] In recent years, deep learning technology has made significant progress in the field of image recognition, especially in target detection. Deep learning models can automatically learn feature expressions through training data without manually designing features, which provides a new solution for PCB defect detection. Among many deep learning frameworks, the YOLO (You Only Look Once) series of target detection algorithms have become a popular choice in the field of target detection due to their excellent performance in detection accuracy and speed. The YOLO algorithm realizes target recognition in images through a single neural network model, with high detection speed and low computational complexity, and is particularly suitable for industrial applications with high real-time requirements.
[0005] However, although the YOLO series of models have high detection speed and accuracy, they still face some challenges in industrial applications. First, the traditional YOLO model has a large amount of calculation. Especially in scenarios where high target detection accuracy is required, the model's parameter quantity and computational complexity are still high, making it difficult to adapt to devices with limited computing resources. Secondly, there are many types of PCB defects, with small defect sizes and complex shapes. Therefore, how to improve the robustness of the detection model under complex backgrounds and how to deal with low resolution and noise interference are still urgent issues to be resolved. In addition, due to their special imaging methods, X-ray images usually carry more noise and uncertainty. Therefore, how to improve the defect recognition rate of X-ray images is also a problem worthy of attention.
[0006] In recent years, lightweight neural networks and attention mechanisms have become important research directions in the field of deep learning. Lightweight networks aim to reduce the number of model parameters and computational complexity to achieve more efficient real-time reasoning. By designing efficient lightweight networks, it is possible to significantly reduce computing resource consumption while ensuring high accuracy, meeting the needs of environments with limited hardware resources such as embedded systems and mobile devices. Summary of the invention
[0007] The present invention provides a PCB assembly X-Ray image recognition method based on Mobile-YOLO, which aims to solve the problems of low detection efficiency, insufficient accuracy and high model complexity in traditional methods and meet the requirements of real-time and equipment resource limitations in industrial scenarios.
[0008] The technical solution adopted by the present invention is: a PCB component X-Ray image recognition method based on Mobile-YOLO, comprising the following steps:
[0009] S1, data acquisition and preprocessing: collect X-ray defect image data of PCB, mark the defect location, and expand the image through data enhancement to generate a data set; divide the data set into a training set and a validation set in a ratio of 8:2;
[0010] S2, build the Mobile-YOLO network: design a lightweight network structure based on the YOLOv8s model, including the Mobile-YOLOl model and the Mobile-YOLOs model; use the SSA Mobile module to optimize the convolutional features;
[0011] S3, model training and verification: use the pre-trained weight yolov8s.pt to initialize the model; use 200 training batches, turn off Mosaic enhancement for the last 10 batches, and save the model weight file with the best performance during training and the final weight file;
[0012] S4, performance evaluation: statistical model precision P, recall R, mAP, model weight size and computational complexity to verify model performance.
[0013] Furthermore, the data enhancement includes horizontal flipping, vertical flipping, Gaussian blurring, salt and pepper noise, brightness change and Mosaic enhancement.
[0014] Furthermore, the output channels of each Backbone layer of the Mobile-YOLOl model are 64, 128, 128, 256, 256, 512, 512, 1024, 1024 and 1024 respectively, the number of SSA Mobile modules is 8 layers, and the Neck and Head structures are consistent with YOLOv8s.
[0015] Furthermore, the output channels of each layer of the Backbone of the Mobile-YOLOs model are 64, 128, 128, 256, 256, 512 and 512 respectively, the number of SSA Mobile modules is 5 layers, and the output channels are halved; the weight of the Mobile-YOLOs model is one third of that of Mobile-YOLOl.
[0016] Further, the SSA Mobile module includes the following steps:
[0017] S21, extract the initial features through 1×1 convolution, and apply batch normalization and Hardswish activation function to process the initial features to generate S22 initial features;
[0018] S22, the initial features of S22 are reduced in dimension by two-dimensional average pooling, and then the fully connected layer is used to further reduce the dimension of the features, and the expressive power of the features is restored by ReLU and Hardsigmoid activation functions, and finally the initial features of S23 are generated by channel weighting operation;
[0019] S23, the initial features of S23 are passed through the spatial attention module to generate spatial attention features. The spatial attention features obtain two different feature maps through maximum pooling and average pooling operations respectively, and then they are spliced together and a 7×7 convolution is used to generate a spatial attention map; finally, the spatial attention map is element-wise multiplied with the input feature map to generate the initial features of S24;
[0020] S24, the initial features of S24 are added to the initial features of S22 and subjected to 1×1 convolution. The output features are added and fused with the initial features in S21 to form the optimized final features.
[0021] In summary, the method combines data preprocessing and enhancement technology through efficient lightweight design of the YOLOv8s model, and improves the ability to detect tiny defects in X-ray images of PCB components.
[0022] The beneficial effects of the present invention are:
[0023] 1. High detection performance: The Mobile-YOLO network achieved a recall rate of 100% and an accuracy rate of over 98% in PCB defect detection tasks. The comprehensive index mAP of Mobile-YOLO is better than other models;
[0024] 2. Lightweight design: The computational complexity of Mobile-YOLOl and Mobile-YOLOs is reduced by 26% and 73% respectively compared with the original YOLOv8s model. The model weight of Mobile-YOLOs is only 4.5MB, which is suitable for edge device deployment.
[0025] 3. Strong industrial applicability: It meets the needs of real-time industrial detection scenarios, especially in resource-constrained environments;
[0026] 4. Strengthen the learning of convolutional neural networks: The SSA Mobile module effectively improves the feature extraction efficiency and detection performance by combining channel attention with spatial attention.
[0027] The present invention provides an efficient and lightweight PCB assembly X-Ray image recognition method, which can be widely used in the quality inspection process in PCB manufacturing and provides important technical support for industrial automation inspection. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 is a flow chart of the method of the present invention;
[0029] Figure 2 This is the structure diagram of the SSA Mobile module used in the Mobile-YOLO backbone network;
[0030] Figure 3 This is a schematic diagram of the backbone network of Mobile-YOLO1 proposed in the present invention;
[0031] Figure 4 This is the structure diagram of the Mobile-YOLOs model proposed in the present invention;
[0032] Figure 5 The training and verification results of PCB X-ray data on Mobile-YOLOs;
[0033] Figure 6This is the comprehensive indicator result of PCB X-ray data on Mobile-YOLOs. DETAILED DESCRIPTION
[0034] The present invention will be further described below in conjunction with the accompanying drawings.
[0035] like Figure 1 As shown, the present invention is a PCB component X-Ray image recognition method based on Mobile-YOLO, comprising the following steps:
[0036] S1, data collection and preprocessing:
[0037] Data collection: The data set of the present invention is derived from X-ray images of PCBs, including three main types of defects: BGA bridges, redundant materials, and pin offsets. By collecting X-ray defect image data of PCBs, sample images of each type of defect are annotated, and corresponding labels are assigned to each defect area. The image resolution is 1536×864. During the data collection stage, special attention is paid to image quality and label accuracy to ensure accurate labeling of defect locations.
[0038] Labeling method: The defect area is calibrated using box labeling, and a label is assigned to each defect category. This process uses a special labeling tool, and the labeling results are saved in an XML file and then converted to the YOLO data format. Each defect area consists of the upper left corner and lower right corner coordinates and a category label.
[0039] Data enhancement: Use the following data enhancement methods to expand the image, generate data sets, and enrich training samples.
[0040] (1) Geometric transformation: horizontal flipping, vertical flipping, and horizontal and vertical flipping are used to increase sample diversity;
[0041] (2) Noise addition: Add Gaussian blur and salt and pepper noise to the original image to simulate image quality in different environments;
[0042] (3) Brightness change: simulate PCB images under different lighting conditions to enhance the model’s robustness to lighting changes;
[0043] (4) Mosaic enhancement: Improve the diversity of training data by stitching multiple images into one image.
[0044] Data partitioning: The data set is divided into a training set and a validation set in a ratio of 8:2 to ensure the diversity and data balance of the training set and the validation set. The validation set is used to evaluate the generalization ability of the model to avoid overfitting of the model.
[0045] S2, build Mobile-YOLO network: design a lightweight network structure based on the YOLOv8s model with high detection accuracy and speed, including Mobile-YOLOl model and Mobile-YOLOs model.
[0046] The present invention uses the SSA Mobile module to optimize the convolutional features; Figure 2 As shown in Figure 1, this module combines the channel attention module and the spatial attention module to optimize the convolutional features. The SSA Mobile module includes the following steps:
[0047] S21, extract the initial features through 1×1 convolution, and apply batch normalization and Hardswish activation function to process the initial features to generate S22 initial features;
[0048] S22, the initial features of S22 are reduced in dimension by two-dimensional average pooling, and then the fully connected layer is used to further reduce the dimension of the features, and the expressive power of the features is restored by ReLU and Hardsigmoid activation functions, and finally the initial features of S23 are generated by channel weighting operation;
[0049] S23, the initial features of S23 are passed through the spatial attention module to generate spatial attention features. The spatial attention features obtain two different feature maps through maximum pooling and average pooling operations respectively, and then they are spliced together and a 7×7 convolution is used to generate a spatial attention map; finally, the spatial attention map is element-wise multiplied with the input feature map to generate the initial features of S24;
[0050] S24, the initial features of S24 are added to the initial features of S22 and subjected to 1×1 convolution. The output features are added and fused with the initial features in S21 to form the optimized final features.
[0051] When generating channel attention features, the channel attention module introduces global information to enhance the focus on important channels, thereby suppressing the influence of redundant channels and improving feature expression capabilities. The spatial attention module helps the network pay more attention to the areas in the image that are important for defect recognition by weighting the features of the spatial dimension.
[0052] In the Mobile-YOLO network, the Neck and Head structures are consistent with YOLOv8s. The Backbone part is lightweight and improves the inference speed by optimizing the module structure, activation function and channel configuration.
[0053] like Figure 3As shown in the figure, the backbone network of Mobile-YOLOl retains the first convolution layer and the last SPPF module based on YOLOv8s. The convolution modules of other layers use SSA Mobile modules to optimize the computational efficiency.
[0054] The output channels of each layer of the Backbone of the Mobile-YOLOl model are 64, 128, 128, 256, 256, 512, 512, 1024, 1024, and 1024. This channel number configuration ensures a high feature extraction capability and avoids excessive computational overhead by introducing lightweight modules. The number of SSA Mobile modules is 8, and the Neck and Head structures are consistent with YOLOv8s.
[0055] like Figure 4 As shown in the figure, the Mobile-YOLOs model is further streamlined on the basis of Mobile-YOLOl, reducing the number of SSA Mobile modules and halving the number of output channels of some layers. In this way, the Mobile-YOLOs model further reduces the amount of calculation and model size, and is more suitable for real-time reasoning on low-power devices. The output channels of each Backbone layer of the Mobile-YOLOs model are 64, 128, 128, 256, 256, 512 and 512 respectively, and the number of SSA Mobile modules is 5 layers; the weight of the Mobile-YOLOs model is one-third of that of Mobile-YOLOl. Compared with Mobile-YOLOl, Mobile-YOLOs significantly reduces the computational complexity while maintaining high detection accuracy, and is suitable for edge computing devices.
[0056] The two models, Mobile-YOLOl and Mobile-YOLOs, have different structures and parameter configurations to meet the different needs of high performance and low computing resources respectively; Mobile-YOLOl is suitable for scenarios with sufficient computing resources and high precision requirements, while Mobile-YOLOs is a lightweight model that can achieve fast reasoning when hardware resources are limited.
[0057] In the Mobile-YOLOl model, the design of the Backbone part takes into account the characteristics of X-ray images, and the specific channel output configuration can capture the detailed features in the PCB image. By increasing the number of output channels in the subsequent layers, the model can effectively extract and fuse features of different scales to ensure high-precision identification of defects. The role of the SSA Mobile module in this model is to enhance the detection capability of small defects by strengthening the key information in the feature map.
[0058] Mobile-YOLOs achieves a lightweight effect by reducing the number of output channels of the Backbone part and the number of SSA Mobile modules. While maintaining high accuracy, it significantly reduces the computational complexity and is suitable for embedded devices or edge computing scenarios with limited hardware resources.
[0059] S3, model training and validation:
[0060] After the training data is enhanced, it is resized to 640×640 and input into the Mobile-YOLOl and Mobile-YOLOs models for training.
[0061] The pre-trained weights of YOLOv8s are used as the initialization weights, and the SGD (Stochastic Gradient Descent) optimizer is adopted. The cosine annealing strategy is used to adjust the learning rate to ensure the smoothness of the weight update during training.
[0062] During the training process, the training batch size was set to 200 times, and Mosaic enhancement was turned off for the last 10 batches. The model weight file with the best performance during the training process and the final weight file were saved.
[0063] like Figure 6 As shown, this is the verification result of the optimal model weight file.
[0064] S4, performance evaluation: Figure 5 As shown in the figure, during the training and verification process, the statistical model's precision P, recall R, mAP, model weight size, and computational complexity are used to measure the performance of the model in PCB component X-Ray image recognition.
[0065] Table 1 Verification results of PCB X-ray dataset on different models
[0066]
[0067] As shown in Table 1, the Mobile-YOLOl and Mobile-YOLOs models are superior to YOLOv8s in various performance indicators, especially in the recall rate R, which is 100%, effectively improving the model's ability to focus on features, and Mobile-YOLOs has lower weight and computational complexity, suitable for running on devices with limited resources. The model size and computational complexity are kept small, suitable for deployment in environments with limited hardware resources.
[0068] In practical applications, the model of the present invention can be deployed on edge computing devices such as NVIDIA Jetson Xavier to achieve real-time detection. The model exhibits low computational complexity and fast reasoning speed during both training and reasoning, and can detect and identify defects in PCB X-ray images in real time, meeting the requirements of industrial production lines for high efficiency and real-time performance.
[0069] The present invention can collect X-Ray images of PCB components in real time, use the trained Mobile-YOLO model for reasoning, identify and locate defects on X-Ray images of PCB components, and control the production process by feeding back defect information in real time to ensure the efficiency and quality of the production line.
[0070] Through the lightweight deep learning network design provided by the present invention, the Mobile-YOLO network architecture combined with the SSA Mobile module is used, which not only improves the accuracy of PCB defect detection, but also optimizes the model size and computational complexity, making the method more practical in industrial environments.
[0071] The present invention improves the detection capability of tiny defects in X-ray images of PCB components by performing efficient and lightweight design of the YOLOv8s model, combining data preprocessing and enhancement technology.
[0072] Although the present invention has been described in detail above with general description and specific embodiments, some modifications or improvements can be made on the basis of the present invention. The above description is only a preferred embodiment of the present invention and is not limited to the scope of the present invention. Other changes and modifications made by those skilled in the art without departing from the spirit and scope of protection of the present invention are still included in the scope of protection of the present invention.
Claims
1. A PCB component X-Ray image recognition method based on Mobile-YOLO, characterized in that: The following steps are involved: S1, data acquisition and preprocessing: collect X-ray defect image data of PCB, mark the defect location, and expand the image through data enhancement to generate a data set; divide the data set into a training set and a validation set in a ratio of 8:2; S2, build the Mobile-YOLO network: design a lightweight network structure based on the YOLOv8s model, including the Mobile-YOLOl model and the Mobile-YOLOs model; use the SSA Mobile module to optimize the convolutional features; S3, model training and verification: use the pre-trained weight yolov8s.pt to initialize the model; use 200 training batches, turn off Mosaic enhancement for the last 10 batches, and save the model weight file with the best performance during training and the final weight file; S4, performance evaluation: statistical model precision P, recall R, mAP, model weight size and computational complexity to verify model performance.
2. According to claim 1, a PCB assembly X-Ray image recognition method based on Mobile-YOLO is characterized in that: The data enhancement includes horizontal flipping, vertical flipping, Gaussian blurring, salt and pepper noise, brightness change, and Mosaic enhancement.
3. According to a Mobile-YOLO-based PCB assembly X-Ray image recognition method according to claim 1, it is characterized in that: The output channels of each Backbone layer of the Mobile-YOLOl model are 64, 128, 128, 256, 256, 512, 512, 1024, 1024 and 1024 respectively. The number of SSA Mobile modules is 8 layers, and the Neck and Head structures are consistent with YOLOv8s.
4. According to claim 1, a PCB assembly X-Ray image recognition method based on Mobile-YOLO is characterized in that: The output channels of each layer of Backbone of the Mobile-YOLOs model are 64, 128, 128, 256, 256, 512 and 512 respectively. The number of SSA Mobile modules is 5 layers, and the output channels are halved. The weight of the Mobile-YOLOs model is one third of that of Mobile-YOLOl.
5. According to a Mobile-YOLO-based PCB assembly X-Ray image recognition method according to claim 1, it is characterized in that: The SSA Mobile module includes the following steps: S21, extract the initial features through 1×1 convolution, and apply batch normalization and Hardswish activation function to process the initial features to generate S22 initial features; S22, the initial features of S22 are reduced in dimension by two-dimensional average pooling, and then the fully connected layer is used to further reduce the dimension of the features, and the expressive power of the features is restored by ReLU and Hardsigmoid activation functions, and finally the initial features of S23 are generated by channel weighting operation; S23, the initial features of S23 are passed through the spatial attention module to generate spatial attention features. The spatial attention features obtain two different feature maps through maximum pooling and average pooling operations respectively, and then they are spliced together and a 7×7 convolution is used to generate a spatial attention map; finally, the spatial attention map is element-wise multiplied with the input feature map to generate the initial features of S24; S24, the initial features of S24 are added to the initial features of S22 and subjected to 1×1 convolution. The output features are added and fused with the initial features in S21 to form the optimized final features.