Printed circuit board defect detection method and system based on improved YOLO network
By improving the YOLO network and combining it with a green filter and an adaptive anchor frame generation algorithm, the accuracy and efficiency issues in printed circuit board defect detection were resolved, achieving efficient and real-time defect detection.
Patent Information
- Application Number
- CN202511047105.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-29
- Publication Date
- 2025-11-07
AI Technical Summary
Existing technologies for defect detection on printed circuit boards suffer from insufficient detection accuracy, inadequate feature representation capabilities, computational redundancy, and mismatch in anchor frame dimensions, making it difficult to meet the requirements for real-time performance and high efficiency.
An improved YOLO network is adopted, combined with a green filter to filter background light interference, and an attention mechanism and adaptive anchor box generation algorithm are introduced. A multi-scale training strategy and soft NMS optimization are used to integrate traditional image processing and deep learning.
It improves detection accuracy and efficiency, enhances model generalization ability, meets the real-time requirements of online detection, and is suitable for large-scale PCB production.
Smart Images

Figure CN120912552A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to a printed circuit board defect detection method and system, in particular to a printed circuit board defect detection method and system based on an improved YOLO network. BACKGROUND
[0002] With the rapid development of electronic manufacturing technology, as the key component of electronic equipment, the quality of printed circuit board (PCB) directly affects the reliability and performance of the product.
[0003] In the PCB production process, defect detection is an important link to ensure product quality. Traditional detection methods rely on manual visual inspection or simple optical instruments, which are inefficient and easily affected by subjective factors. Machine vision technology has been widely used in PCB defect detection due to its advantages of high efficiency, accuracy and stability.
[0004] At the same time, as a real-time target detection algorithm, YOLO network has the characteristics of fast detection speed and high accuracy, but it still has some limitations in the special requirements of PCB defect detection, such as insufficient detection accuracy for small defects and insufficient feature expression ability.
[0005] In combination with the prior art, CN115272346A discloses a circuit board defect positioning method based on edge-preserving filtering. It uses a bilateral filtering algorithm to preserve edge information, but it does not cooperate with a deep learning detection module. The edge positioning result needs to be manually screened and then input into the detection network, which increases the calculation redundancy and cannot meet the real-time requirements of the production line
[0006] In addition, the prior art CN111723737B discloses a non-maximum suppression optimization method in target detection. It reduces the deletion of overlapping frames by improving the NMS algorithm, but it does not solve the problem of anchor frame size mismatch with PCB defects. Since PCB defects are mostly irregular microstructures (such as solder bubble and broken lines), standard YOLO anchor frames are difficult to cover their geometric characteristics, which may lead to missed detection.
[0007] In view of the above defects, the present design person actively studies and innovates to create a printed circuit board defect detection method and system based on an improved YOLO network, which can effectively filter green background light interference. Second, it combines traditional image processing and deep learning, improves the YOLO network, introduces an attention mechanism to enhance feature learning ability, uses an adaptive anchor frame generation algorithm to improve matching degree, and uses a multi-scale training strategy and soft NMS optimization post-processing. SUMMARY
[0008] To solve the above technical problems, the purpose of the present application is to provide a printed circuit board defect detection method and system based on an improved YOLO network.
[0009] The improved YOLO network-based printed circuit board defect detection method of the present application comprises the following steps:
[0010] Step one, using an industrial camera equipped with a green filter to collect printed circuit board images, filtering green background light interference;
[0011] Step two, pre-processing the collected images, including grayscale processing and Gaussian filter denoising;
[0012] Step three, using an edge detection algorithm to locate potential defect areas, reducing the detection range;
[0013] Step four, extracting the statistical feature vector of the pre-processed image, including pixel mean variance and histogram distribution;
[0014] Step five, inputting the processed image into the improved YOLO network, the improvements to the YOLO network include introducing channel attention mechanism and spatial attention mechanism in the backbone network, generating channel weights through global average pooling and fully connected layers through the channel attention module, and generating a spatial weight map through the spatial attention module through the convolution layer; using an adaptive anchor box generation algorithm to dynamically generate anchor box sizes; applying a multi-scale training strategy to randomly adjust the input image resolution; using soft non-maximum suppression to participate in optimization processing;
[0015] Step six, outputting defect class position and confidence information.
[0016] Further, the improved YOLO network-based printed circuit board defect detection method, wherein in step one, the center wavelength of the green filter is 525-545 nm, and the transmittance is ≥ 90%. The center wavelength and transmittance parameters are optimized and selected based on the spectral reflection characteristics of the green solder mask ink on the surface of the printed circuit board (PCB) and the spectral reflection / absorption differences of common defects (such as copper foil exposure, solder abnormality, foreign matter residue). The specific deduction process is as follows: By measuring the reflection spectrum of typical FR4 substrate green solder mask ink in the visible light band (400-700 nm), it is found that there is a significant reflection peak near 540-560 nm; At the same time, analyze the optical response of common PCB defect areas (such as bare copper showing yellow / gold, solder showing silver white, foreign matter may show different colors) in the corresponding band. Deduce that selecting a band-pass filter with a center wavelength of 525-545 nm and a peak transmittance of ≥ 90% can effectively suppress the reflection intensity of the green solder mask ink background at the 540-560 nm peak, while relatively enhancing the reflection signal of the defect area (especially non-green defects such as copper, tin, and foreign matter) in this band, thereby maximizing the imaging contrast between the defect area and the background.
[0017] Further, the PCB defect detection method based on the improved YOLO network, wherein in step two, the preprocessing further includes retaining edge information by using a bilateral filtering algorithm.
[0018] Further, the PCB defect detection method based on the improved YOLO network, wherein in step five, the adaptive anchor box generation algorithm comprises the following steps:
[0019] (a) collecting defect annotation boxes of PCBs obtained in the training data set, and extracting width (W) and height (H) data thereof;
[0020] (b) based on the characteristics that PCB defects are generally small and irregular in shape, calculating a weight factor for each annotation box, the weight factor being inversely proportional to the area of the annotation box or corresponding to the minimum dimension (min(W, H)), for improving the influence of small size and irregular shape defects in clustering;
[0021] (c) using a weighted K-means++ clustering algorithm to cluster the width and height data points of the weighted annotation boxes in a specific space;
[0022] (d) generating a corresponding number (k) of initial anchor box sizes according to a preset anchor box number (k);
[0023] (e) according to the actual requirements of PCB defect detection, performing post-processing optimization on the initial anchor box size set generated by clustering to generate an anchor box size set, including removing anchor boxes with an area less than a set threshold and merging redundant anchor boxes with a too close width-height ratio;
[0024] (f) using the optimized anchor box size set as the initial anchor box parameter of the improved YOLO network.
[0025] Further, the PCB defect detection method based on the improved YOLO network, wherein in step five, the scale adjustment mechanism of the multi-scale training strategy is that the size distribution of the training set defects is counted, when the proportion of small defects (<20 pixels) is >30%, the scaling range is automatically adjusted to 80%-150% (step size 16 pixels); when the proportion of large defects (>50 pixels) is >20%, the scaling range is automatically adjusted to 50%-120% (step size 24 pixels); through a defect density heat map, 100%-150% large-scale training is enabled for high-density areas (>0.5 per 100 pixels2), and a cross-scale feature consistency loss is introduced, with a cosine similarity weight of 0.1, so that the defect representation at different scales is consistent, and the multi-scale detection robustness of complex PCB scenes is improved.
[0026] Further, the PCB defect detection method based on the improved YOLO network, wherein in step five, the soft non-maximum suppression adopts a Gaussian weighting function, the overlap threshold is set to 0.5-0.7, the decay coefficient σ is 0.5, and the overlap threshold is dynamically adjusted according to the defect type (soldering point / line / via) corresponding to the detection frame.
[0027] A PCB defect detection system based on an improved YOLO network, comprising: an image acquisition module, an industrial camera equipped with a green filter and a light source control system; a preprocessing module for performing grayscale noise removal and edge detection; a feature statistics module for calculating image mean variance and histogram features; an improved YOLO network module integrating the improved YOLO network of claim 1; and a result output module for generating a defect position and type visualization report.
[0028] Further, the PCB defect detection system based on the improved YOLO network, wherein the improved YOLO network module adopts deformable group convolution instead of standard convolution for the backbone network, and the number of convolution groups is 4.
[0029] Further, the PCB defect detection system based on the improved YOLO network, wherein the neck of the improved YOLO network module is embedded with a cross-attention feature fusion module, which fuses multi-scale features by the following steps: constructing a high-level feature map (size HxWxC1, typical value 128x128x512), bilinearly upsampling to a low-level resolution (2Hx2W), and then generating a Query matrix (Q) through 1x1 convolution, expanding the channel to a fusion dimension D, D=256, and expanding coefficient 0.5; a low-level feature map (size 2Hx2WxC2, typical value 256x256x64) generates a Key matrix (K) and a Value matrix (V) through 1x1 convolution, and the channels are aligned to the fusion dimension D; the similarity weight is calculated through the cross-attention mechanism; the features are fused by weighting; and the residual is enhanced for output.
[0030] By the above scheme, the present application has at least the following advantages:
[0031] 1. Improved detection accuracy. By introducing the attention mechanism and optimizing the anchor box generation algorithm, various defects on the PCB can be more accurately located and recognized, especially for small defects and defects in complex backgrounds, and the detection accuracy is significantly improved.
[0032] 2. Enhanced model generalization ability. The multi-scale training strategy makes the model adapt to different sizes of input images, has better detection effect on PCB defects of different sizes in actual production, and improves the practicability and stability of the model.
[0033] 3. It can improve the detection efficiency. The improved YOLO network can still maintain a faster detection speed under the premise of ensuring the detection accuracy. Thus, it meets the real-time requirement of online detection and is suitable for defect detection in large-scale PCB production process.
[0034] 4. It can realize the fusion of traditional and deep learning. The improved traditional image processing method can be combined with deep learning to fully utilize the advantages of both, reduce the detection area and calculation amount, and provide more rich feature information for the deep learning model, further improving the detection effect.
[0035] 5. It can optimize the image acquisition quality. The use of green filter for image acquisition effectively reduces the interference of the green background of the circuit board and improves the quality and contrast of the image, providing a better data basis for subsequent image processing and feature extraction.
[0036] The above description is only a summary of the technical scheme of the present application. In order to more clearly understand the technical means of the present application and can be implemented according to the content of the specification, the following will be described in detail with the preferred embodiments of the present application and with the help of the accompanying drawings. BRIEF DESCRIPTION OF DRAWINGS
[0037] Figure 1 is the overall architecture diagram of the improved YOLO network used in the present application.
[0038] Figure 2 is the construction diagram of the cross-attention feature fusion module.
[0039] Figure 3 is the flowchart of the adaptive anchor box generation algorithm.
[0040] Figure 4 is the implementation diagram of the multi-scale training strategy.
[0041] The meanings of the various reference signs in the drawings are as follows. DETAILED DESCRIPTION
[0042] The specific embodiments of the present application will be further described in detail below in combination with the drawings and examples. The following examples are used to illustrate the present application, but not to limit the scope of the present application.
[0043] As Figures 1 to 4 A printed circuit board defect detection method based on an improved YOLO network, characterized in that it comprises the following steps:
[0044] Step one, use the industrial camera equipped with green filter to collect printed circuit board image, filter green background light interference. During the implementation, the center wavelength of the green filter is 525nm to 545nm, and the transmittance is ≥90%. The center wavelength and transmittance parameters are optimized based on the spectral reflection characteristics of the green solder mask ink on the surface of the printed circuit board (PCB) and the spectral reflection / absorption differences of common defects such as copper foil exposure, solder abnormality, foreign matter residue, etc. The specific deduction process is as follows: by measuring the reflection spectrum of typical FR4 substrate green solder mask ink in the visible light band (400-700nm), it is found that there is a significant reflection peak near 540-560nm. At the same time, analyze the common PCB defect areas, such as exposed copper showing yellow or gold color, solder showing silver white color, and foreign matter may show different colors, and respond to the corresponding waveband light. Deduce that selecting a band-pass filter with a center wavelength of 525-545nm and a peak transmittance of ≥90% can effectively suppress the reflection intensity of the green solder mask ink background at the 540-560nm peak. And, relative to the enhanced defect area, especially non-green defects such as copper, tin, and foreign matter, the reflection signal in this waveband, thereby maximizing the imaging contrast between the defect area and the background.
[0045] Step two, pre-process the collected image, including grayscale processing and Gaussian filter denoising. And the pre-processing in actual processing also includes retaining edge information by using bilateral filtering algorithm.
[0046] Step three, use edge detection algorithm to locate potential defect area and narrow down the detection range.
[0047] Step four, extract the statistical feature vector of the pre-processed image, including pixel mean variance and histogram distribution.
[0048] Step five, input the processed image into the improved YOLO network. The improvements to the YOLO network include introducing channel attention mechanism and spatial attention mechanism in the backbone network. Specifically, the channel attention module generates channel weights through global average pooling and fully connected layer, and the spatial attention module generates spatial weight map through convolution layer. At the same time, use adaptive anchor box generation algorithm to dynamically generate anchor box size; apply multi-scale training strategy to randomly adjust input image resolution. And, soft non-maximum suppression (Soft NMS) can be used for optimization processing.
[0049] During implementation, the steps of the adaptive anchor box generation algorithm used are as follows: first, collect the defect annotation boxes of the PCB obtained in the training data set, and extract the width (W) and height (H) data. Then, based on the characteristics of the PCB defects, which are generally small and irregular in shape, a weight factor is calculated for each annotation box. The weight factor is inversely proportional to the area of the annotation box or corresponds to the minimum dimension (min(W, H)), which is used to enhance the influence of small size and irregular shape defects in clustering. Then, the weighted K-means++ clustering algorithm is used to cluster the width and height data points of the weighted annotation boxes in a specific space. Subsequently, according to the preset anchor box number (k), the corresponding number (k) of initial anchor box sizes is generated. Then, according to the actual needs of PCB defect detection, the initial anchor box size set generated by clustering is post-processed and optimized to generate an anchor box size set. During implementation, it can include removing anchor boxes with an area less than a set threshold and merging redundant anchor boxes with a width-to-height ratio that is too close. Finally, the optimized anchor box size set is used as the initial anchor box parameter of the improved YOLO network.
[0050] In addition, in order to meet the optimization of multi-scale training, the scale adjustment mechanism of the multi-scale training strategy used by the present application is as follows: the defect size distribution of the training set is counted, when the proportion of micro defects (<20 pixels) is >30%, the scaling range is automatically adjusted to 80%-150% (step size 16 pixels). When the proportion of large defects (>50 pixels) is >20%, the scaling range is automatically adjusted to 50%-120% (step size 24 pixels). Through the defect density heat map, the 100%-150% large-scale training is enabled for high-density areas (>0.5 / 100 pixels2). At the same time, cross-scale feature consistency loss is introduced, with a cosine similarity weight of 0.1, to make the defect representations consistent at different scales and improve the multi-scale detection robustness of complex PCB scenes.
[0051] For the processing of soft non-maximum suppression, a Gaussian weighting function is used, and the overlap threshold is set to 0.5-0.7, and the decay coefficient σ=0.5. During implementation, the overlap threshold is dynamically adjusted according to the defect type corresponding to the detection box, such as solder joints, lines, and vias. The reason is that when detecting defects such as solder joint bubbles and tin bead adhesion, an overlap threshold lower than 0.5 can easily lead to the deletion of adjacent defect boxes, and an overlap threshold higher than 0.7 can miss some overlapping defects. Therefore, the second method can balance false detection suppression and overlapping defect recall.
[0052] It should be noted that the channel attention module (Channel Attention Module) and the spatial attention module (Spatial Attention Module) involved in the present application are commonly used modules in the industry, and will not be described here.
[0053] Step six, output the defect category position and confidence information.
[0054] Further, in order to better implement the present application, a printed circuit board defect detection system based on an improved YOLO network is provided, which comprises an image acquisition module, an industrial camera equipped with a green filter and a light source control system. It also includes a preprocessing module that performs grayscale noise removal and edge detection. At the same time, it also includes a feature statistics module that calculates the image mean variance and histogram features. And it also includes an improved YOLO network module for integrating the improved YOLO network. Furthermore, a result output module can be added to generate a defect position and type visualization report.
[0055] In combination with actual implementation, the improved YOLO network module adopted uses a deformable group convolution (DGConv) instead of a standard convolution for the backbone network, with 4 groups of convolution.
[0056] Specifically, a high-level feature map is constructed, with a size of HxWxC1 (long), and a typical value of 128x128x512. It is bilinearly upsampled to a low-level resolution (2Hx2W). Then, a 1x1 convolution is used to generate a Query matrix (Q). Next, the channel is expanded to a fusion dimension D, D=256, with an expansion coefficient of 0.5. At the same time, the low-level feature map, with a size of 2Hx2WxC2 (long, typical value 256x256x64), is convolved by 1x1 to generate a Key matrix (K) and a Value matrix (V), with the channels aligned to the fusion dimension D. Finally, the similarity weight is calculated by the cross-attention mechanism, the features are weighted and fused, and the residual enhancement output result is obtained.
[0057] During implementation, the following steps can be implemented by the cross-attention feature fusion module to fuse multi-scale features: upsample the high-level feature map, channel splice with the low-level feature map; calculate the similarity weight between features by the cross-attention mechanism; and output the enhanced feature map after weighted fusion.
[0058] The working principle of the present application is as follows, and the following detailed implementation steps can be included:
[0059] 1. Image acquisition and preprocessing.
[0060] Image acquisition: use a camera equipped with a green filter to take pictures of the PCB. The green filter can effectively filter out the green background light of the circuit board, reduce background interference, improve the contrast and clarity of the defect features in the image, and is beneficial to subsequent image processing and feature extraction.
[0061] Image preprocessing: The collected PCB image is preprocessed, including grayscale, noise removal and other operations to improve image quality and lay a foundation for subsequent processing.
[0062] 2. Integration of traditional image processing and deep learning. Before using deep learning for judgment, an improved traditional image processing method is used to reduce the detection area or count image features to facilitate the judgment of deep learning. During this period, edge detection and region positioning are involved. Through edge detection algorithms such as Canny edge detection and Sobel operator, the edge information in the PCB image is accurately detected, and the possible defect area is located according to the edge features, reducing the detection range and reducing the calculation amount. Then, image feature statistics are performed. The preprocessed image is statistically analyzed, such as calculating the mean, variance, and histogram of pixel values, to extract statistical features that can reflect the overall characteristics of the image, provide supplementary information for the deep learning model, and enhance the model's understanding and judgment ability of the image.
[0063] 3. Improvement of YOLO network. Based on the YOLOv8 network, new technologies such as attention mechanism are added, and new algorithms or structures are integrated to improve network performance. Specifically, it contains the main part, which replaces Conv with DGConv. DGConv is a deformable grouped convolution that combines deformable convolution and grouped convolution, which can adapt to the geometric deformation of the target and reduce the calculation amount.
[0064] As a result, the following advantages are achieved: (1) Enhanced detection ability for irregular targets. Deformable convolution can adapt to the geometric deformation of the target, improving the model's detection ability for irregular targets. (2) Reduced calculation amount. Grouped convolution divides the input channels into several groups, each of which performs convolution operations independently, significantly reducing the calculation amount. (3) Improved model efficiency. Deformable grouped convolution reduces the computational complexity while maintaining high performance, making it suitable for real-time target detection tasks.
[0065] Meanwhile, it also contains a neck, which is introduced into the cross-attention feature fusion module (CAFM for short). Specifically, CAFM is a feature fusion module based on cross-attention mechanism, which can effectively fuse multi-scale features and improve the detection ability of small targets and occlusions. During implementation, CAFM includes the following functions: (1) Multi-scale feature fusion can be achieved. In the target detection task, the model needs to process targets of different scales. Low-level features usually contain rich detailed information (such as edges, textures), while high-level features contain more semantic information (such as target categories). CAFM effectively fuses low-level and high-level features through cross-attention mechanism, so that the model can utilize both detailed information and semantic information. (2) Cross-attention mechanism is realized. Cross-attention mechanism dynamically adjusts the weight of feature fusion by calculating the correlation between different feature maps. For example, low-level features and high-level features can complement each other through cross-attention mechanism. Low-level features can enhance the detailed information of high-level features, while high-level features can provide semantic guidance for low-level features.
[0066] Therefore, relying on the selection of cross-attention feature fusion module, the following advantages can be achieved: (1) Multi-scale feature fusion can be achieved. CAFM can effectively fuse features from different levels to improve the detection ability of the model for multi-scale targets. (2) Dynamic weight adjustment can be met. Through cross-attention mechanism, CAFM can dynamically adjust the fusion weight according to the input features, making the model more flexible. (3) The feature expression ability can be enhanced: CAFM enhances the representation ability of features through cross-attention mechanism, so that the model can better capture the details and semantic information of the target.
[0067] For the convenience of actual operation, the actual operation can be carried out in the following manner:
[0068] First, feature input is performed. During this period, feature maps from different levels or different branches are input, such as FPN feature maps in YOLO.
[0069] Then, cross-attention calculation is performed. The correlation between different feature maps is calculated through cross-attention mechanism. Linear transformation is performed on the input feature maps to generate query (Query), key (Key) and value (Value); the similarity between Query and Key is calculated to obtain attention weight; the Value is weighted and summed using the attention weight to obtain the fused feature.
[0070] Next, feature fusion is performed. During this period, the feature output by the cross-attention mechanism is fused with the original feature. For the convenience of implementation, the fusion method can be selected by adding or splicing.
[0071] Then, output processing is performed, and the fused feature map is output for subsequent target detection or segmentation tasks.
[0072] Finally, the loss function is processed, and the uncertainty-aware loss (UAL) can be utilized. An uncertainty-aware mechanism is introduced into the loss function of YOLO. By modeling the uncertainty of model prediction, the weights of classification loss, bounding box regression loss and target confidence loss are dynamically adjusted, thereby improving the robustness and detection accuracy of the model.
[0073] The implementation principle and use flow of the printed circuit board defect detection system based on the improved YOLO network are as follows:
[0074] First, data preparation is performed during system architecture. A large number of PCB image datasets with defect annotations are collected, and image preprocessing is performed, including normalization, data enhancement and other operations, to expand the dataset scale and improve the robustness of the model.
[0075] Then, a camera equipped with a green filter is used to capture the PCB to obtain high-quality image data. The reason is that the green filter can effectively filter out the green background light of the circuit board, reduce background interference, and improve the contrast and clarity of the defect features in the image. At the same time, the collected PCB image can be subjected to grayscale processing to convert the color image into a grayscale image, reducing the data volume and computational complexity. Furthermore, Gaussian filtering and other methods can be used to remove noise from the grayscale image, improving image quality and reducing noise interference on subsequent processing.
[0076] Next, edge detection and region positioning are performed. The Canny edge detection algorithm is used to detect edge information in the image, and the possible defect region is located according to the edge features to narrow the detection range. The system can perform feature statistics on the preprocessed image, calculate statistical features such as mean and variance of pixel values, and extract feature vectors that can reflect the overall characteristics of the image to provide supplementary information for the deep learning model.
[0077] Subsequently, network construction is performed in the system. As shown in Figure 2 A cross-attention feature fusion module can be added to the backbone of the YOLO network. The normal value is the parameter in the figure, where H (Height) represents the height of the feature map, W (Width) represents the width of the feature map, and C (Channels) represents the number of feature channels. By dynamically fusing the low-level detail information and high-level semantic information of multi-scale feature maps, the feature expression ability of the model for PCB defects is enhanced. At the same time, as shown in Figure 3As shown, according to the PCB defect dataset, run the adaptive anchor box generation algorithm to obtain anchor box parameters matching the defect size distribution, and replace the default anchor box in the original YOLO network. Then, set the scale range and step of multi-scale training. As shown, randomly select the size from imgsz*0.5, imgsz*1.5+gs to train the network at different scales and learn more robust feature representations. Figure 4 As shown, randomly select the size from imgsz*0.5, imgsz*1.5+gs to train the network at different scales and learn more robust feature representations.
[0078] Then, model training is performed. The preprocessed dataset is divided into a training set and a validation set. The improved YOLO network is trained using the training set. By adjusting the learning rate, batch size and other hyperparameters, the model performance is evaluated by the validation set to prevent overfitting, until the model achieves satisfactory detection results on both the training set and the validation set.
[0079] Finally, model testing and application are performed. The trained model is applied to actual PCB defect detection to detect real-time PCB images collected, output detection results including defect location, category and confidence, etc. to assist production personnel in quality control.
[0080] In addition, the indicated orientation or positional relationship described in the present application is based on the orientation or positional relationship shown in the drawings, and is only for the convenience of describing the present application and simplifying the description, and does not indicate or imply that the device or structure referred to must have a specific orientation or be operated in a specific orientation, and therefore cannot be understood as a limitation on the present application.
[0081] The above description is only the preferred embodiments of the present application and is not intended to limit the present application. It should be noted that for ordinary skilled persons in the art, without departing from the technical principles of the present application, a number of improvements and modifications can be made, and these improvements and modifications should be considered as the protection scope of the present application.
Claims
1. A printed circuit board defect detection method based on an improved YOLO network, characterized by The method comprises the following steps: Step one, using an industrial camera equipped with a green filter to collect printed circuit board images, filtering green background light interference; Step two, preprocessing the collected images, including grayscale processing and Gaussian filter denoising; Step three, using edge detection algorithm to locate potential defect area, narrowing the detection range; Step four, extracting the statistical feature vector of the preprocessed image, including pixel mean variance and histogram distribution; Step five, input the processed image into the improved YOLO network, the improvement of YOLO network includes introducing channel attention mechanism and spatial attention mechanism in the backbone network, generating channel weight through global average pooling and fully connected layer through channel attention module, generating spatial weight map through convolution layer through spatial attention module; using adaptive anchor box generation algorithm to dynamically generate anchor box size; applying multi-scale training strategy to randomly adjust the resolution of the input image; using soft non-maximum suppression to participate in optimization processing; Step six, output the defect category position and confidence information.
2. The printed circuit board defect detection method based on the improved YOLO network according to claim 1, characterized in that: In step one, the center wavelength of the green filter is 525-545 nm, and the transmittance is ≥90%.
3. The printed circuit board defect detection method based on the improved YOLO network according to claim 1, characterized in that: In step two, the preprocessing further includes using bilateral filter algorithm to retain edge information.
4. The printed circuit board defect detection method based on the improved YOLO network according to claim 1, characterized in that: In step five, the steps of the adaptive anchor box generation algorithm are: (a) Collect the labeled boxes of PCB defects obtained in the training data set, and extract the width and height data; (b) Based on the characteristics of PCB defects being generally small and irregular in shape, a weight factor is calculated for each labeled box, which is inversely proportional to the area of the labeled box or corresponds to the minimum dimension, for enhancing the influence of small size and irregular shape defects in clustering; (c) Using weighted K-means++ clustering algorithm, the width and height data points of the labeled boxes with weights are clustered; (d) According to the preset number of anchor boxes, the corresponding number of initial anchor box sizes is generated; (e) According to the actual needs of PCB defect detection, the initial anchor box size set generated by clustering is post-processed and optimized to generate an anchor box size set, including removing anchor boxes with an area less than a set threshold and merging redundant anchor boxes with a similar width-height ratio; (f) The optimized anchor box size set is used as the initial anchor box parameter of the improved YOLO network.
5. The printed circuit board defect detection method based on the improved YOLO network according to claim 1, characterized in that: In step five, the scale adjustment mechanism of the multi-scale training strategy is to count the defect size distribution of the training set, when the proportion of small defects is >30%, the scaling range is automatically adjusted to 80%-150%; when the proportion of large defects is >20%, the scaling range is automatically adjusted to 50%-120%; Through the defect density heat map, 100%-150% large scale training is enabled in high density area, and cross-scale feature consistency loss is introduced, with cosine similarity weight 0.1, and the consistency of defect representation under different scales is ensured.
6. The printed circuit board defect detection method based on the improved YOLO network according to claim 1, characterized in that: In step five, the soft non-maximum suppression uses a Gaussian weighting function, the overlap threshold is set to 0.5-0.7, the decay coefficient σ=0.5, and the overlap threshold is dynamically adjusted according to the defect type corresponding to the detection box.
7. A printed circuit board defect detection system based on an improved YOLO network, characterized by It comprises: An image acquisition module, an industrial camera equipped with a green filter and a light source control system; The preprocessing module performs grayscale noise removal and edge detection. The feature statistics module calculates image mean variance and histogram features. The improved YOLO network module integrates the improved YOLO network of claim 1. The result output module generates a defect position and type visualization report.
8. The printed circuit board defect detection system based on the improved YOLO network according to claim 7, characterized in that: The improved YOLO network module uses deformable group convolution instead of standard convolution for the backbone network, and the number of convolution groups is 4 groups. (Refer to lightweight design, CN115272346A deformable convolution application) 9. The printed circuit board defect detection system based on the improved YOLO network according to claim 7, characterized in that: The neck of the improved YOLO network module is embedded with a cross-attention feature fusion module. The cross-attention feature fusion module fuses multi-scale features by the following steps: constructing a high-level feature map, bilinearly upsampling to a low-level resolution, generating a Query matrix through 1×1 convolution, expanding the channel to a fusion dimension D, D=256, and the expansion coefficient is 0.5; the low-level feature map generates a Key matrix and a Value matrix through 1×1 convolution, and the channels are aligned to the fusion dimension D; and calculating the similarity weight through the cross-attention mechanism. Weighted fusion features Residual enhancement output
Citation Information
Patent Citations
A target detection method based on deep feature learning of multi-scale matching strategy
CN111723737B
Cited By
Processing method and system for micro defect image recognition data of sealing surface of ferrule joint
CN121616818A
A method and system for identifying and processing image data of minor defects on sealing surfaces of ferrule connectors
CN121616818B