A PCB defect detection method based on adaptive feature enhancement fusion
By using an adaptive feature enhancement fusion method, and combining the ResNext-101 network with NAM and AFF modules, the problems of large model parameter quantity and redundant information capture in PCB defect detection are solved, and high-precision defect detection is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- FUZHOU WEILIANDA MEDIA CO LTD
- Filing Date
- 2023-05-08
- Publication Date
- 2026-05-01
AI Technical Summary
Existing deep learning methods for PCB defect detection suffer from problems such as large model parameter count, redundant information capture affecting accuracy, and continuous upsampling leading to information loss, making it difficult to accurately locate and detect PCB defects.
An adaptive feature enhancement fusion method is adopted, which uses the ResNext-101 network combined with NAM and AFF modules to capture defect features through convolution at different scales, perform feature fusion and normalization to reduce redundant information, and improve detection accuracy by using three bottom-up deconvolution upsampling steps.
It significantly improves the accuracy of PCB defect identification and location, reduces network computation, enhances feature extraction capabilities, enriches global feature information, and improves detection accuracy.
Smart Images

Figure CN116543174B_ABST
Abstract
Description
An Adaptive Feature Enhancement Fusion Method for PCB Defect Detection Technical Field
[0001] This invention relates to the fields of deep learning and image processing technology, and in particular to an adaptive feature enhancement fusion method for PCB defect detection. Background Technology
[0002] With the introduction of the "Made in China 2025" development strategy, my country has accelerated the intelligent transformation of production equipment in its industrial manufacturing sector and increased support and encouragement for the Printed Circuit Board (PCB) industry. As a core component of intelligent, high-density, and miniaturized electronic products, the quality inspection of PCBs is crucial to ensuring the rapid intelligent development of the electronics manufacturing industry. However, due to the complex PCB production process, defects such as missing holes, open circuits, and short circuits are easily found in bare PCB boards.
[0003] Currently, there are three major challenges in PCB defect detection: (1) There are many types of PCBs, and the types and shapes of defects are complex and diverse. (2) PCBs have large areas, while defect targets are small, making it difficult to accurately locate defect areas. (3) The PCB background color is obvious, and the defect feature extraction process is easily interfered with by the background color. Due to the existence of the above problems, it is difficult to accurately detect defects in PCBs. Currently widely used deep learning methods, including SSD, YOLO series, CenterNet and other networks, cannot achieve accurate detection of PCB defects.
[0004] Disadvantages of existing technologies: (1) Using deep neural networks as the backbone feature extractor results in a large number of model parameters due to the continuous stacking of convolutional layers. (2) For deep neural networks, deeper network layers can improve the network's feature extraction capability, but inevitably some redundant information will be captured, thus affecting the accuracy of subsequent prediction results. (3) After performing deep feature extraction, continuous upsampling can reduce the computational load of the model, but some extracted feature information will be lost, affecting the final detection accuracy. Summary of the Invention
[0005] The purpose of this invention is to provide an adaptive feature enhancement fusion method for PCB defect detection, thereby significantly improving the accuracy of identification and location of the inspected target.
[0006] The technical solution adopted in this invention is:
[0007] An adaptive feature enhancement fusion method for PCB defect detection includes the following steps:
[0008] Step S1: Input the acquired PCB image into the ResNext-101 feature extractor with embedded NAM module to extract the initial PCB feature map of the defect area;
[0009] Step S2: Input the extracted initial PCB feature map into the AFF module. The AFF module captures different types and sizes of defect features under different receptive fields through convolution at different scales to obtain the corresponding multi-scale information feature map. Then, after channel normalization of the obtained multi-scale information feature map, the output feature K is obtained by removing redundant information and containing defect features with different weights.
[0010] Step S3: Perform three bottom-up deconvolution upsampling operations on the output feature K to obtain a high-resolution feature map;
[0011] Step S4: Perform two convolution operations, 3×3 and 1×1, on the obtained high-resolution feature map in sequence, and finally output the location and classification prediction of PCB defects.
[0012] Furthermore, the experimental dataset used in step S1 adopts the printed circuit board defect dataset from the Intelligent Robotics Open Laboratory of Peking University. Through data augmentation techniques such as cropping and rotation, 10,668 defect images were amplified. The defect types include six categories: missing holes, rodent bites, open circuits, short circuits, burrs, and excess copper. The effects of each type of defect are shown in Figure 2.
[0013] During training, the input image pixels were set to 512×512. First, the images were divided into a training set, a validation set, and a test set in a 9:1 ratio. Then, the training set and the validation set were divided in a 9:1 ratio, with 8641 images used as the training set, 960 images as the validation set, and 1067 images as the test set.
[0014] Furthermore, in step S1, a NAM module is embedded at the end of each residual structure of the feature extractor ResNext-101.
[0015] Furthermore, the NAM module includes a channel attention module (CAM) and a spatial attention module (SAM). The channel attention module (CAM) of the NAM module uses the scaling factor in batch normalization (BN) to reflect the importance of each channel. The channel attention module (CAM) first performs batch normalization on the input features to obtain the scaling factor for each channel. Then, it assigns high and low weights to the feature information of each channel according to the scaling factor to focus on the target features. Finally, it outputs the features through a sigmoid activation function. The spatial attention module (SAM) of the NAM module applies batch normalization (BN) to the spatial dimension and measures the importance of spatial features by normalizing pixels.
[0016] Furthermore, the expression for the NAM module is as follows:
[0017]
[0018]
[0019]
[0020]
[0021] Q r =sigmoid(w(y(P) c )))(5)
[0022] Q t =sigmoid(w(y(P) s )))(6)
[0023] In the formula, m represents the total number of feature input batches, and x i μ represents the feature input of the i-th batch. B Represents the batch feature mean. y represents the variance of the batch features. i The scaling factor for the i-th channel is represented by ∈, where ∈ is a number to prevent the denominator from being zero, and γ and β represent the parameters to be learned during training; w i P represents the weight of the i-th channel; c P represents the input features of the channel attention module (CAM). s The input features of the spatial attention module (SAM) are represented by Q. r Q represents the output features of the channel attention module (CAM); t This represents the output features of the Spatial Attention Module (SAM).
[0024] Furthermore, the AFF module utilizes 1×1 convolution, 3×3 convolution with different dilation rates (rate = 1, 3, 7), and global pooling to enhance feature extraction from the input feature map. Considering the complexity and diversity of PCB defects, their varying sizes, and the presence of color background interference, using convolutional kernels with a fixed receptive field for feature extraction can easily overlook the completeness of the features of interest. Therefore, to ensure the comprehensiveness and richness of the defect feature map information extraction, multi-scale convolutional kernels with different receptive fields are first used for feature capture. 1×1 convolution and global pooling are then used to perform global feature extraction on the feature map, yielding feature maps A1 and A3. Then, 3×3 convolutions with different dilation rates are used to expand the receptive field and extract features from defects of different sizes, resulting in feature map A2. Choosing convolutions with different dilation rates ensures a larger receptive field while maintaining sufficient detail about the PCB image boundaries, guaranteeing the completeness of feature information extraction. Finally, feature maps A2 with different dilation rates are fused to obtain feature map A3, enriching the PCB defect feature information under this convolutional kernel. Dimensionality reduction was performed on A1, A3, and A4 using 1×1 convolutions to obtain the weights Wθ. W g Because redundant information is inevitably obtained during feature extraction, affecting the accuracy of subsequent information filtering and detection, W... θ and W g Matrix multiplication is performed to aggregate information from different content segments, and attention features are obtained by normalization using the softmax function. Then With W g Matrix multiplication is performed to weight the defect features, eliminating redundant information and obtaining detailed output features K. By enabling cross-channel information interaction, the computational load of the network is reduced while strengthening the strong correlation between local features.
[0025] Furthermore, the specific steps of step S2 are as follows:
[0026] Step S2-1: Input the obtained initial PCB feature map into the AFF module. The AFF module uses 1×1 convolution and global pooling to perform global feature extraction on the feature map to obtain feature maps A1 and A3. Then, it uses 3×3 convolution with different hole rates (rate = 1, 3, 7) to expand the receptive field and extract features of defects of different sizes to obtain feature map A2. Choosing convolution with different hole rates can ensure that a larger receptive field is obtained while the feature map resolution does not lose too much detail information about the PCB image boundary, thus ensuring the integrity of feature information extraction.
[0027] Step S2-2: Feature map A3 is obtained by fusing the feature maps A2 under different void ratios to enrich the PCB defect feature information under the convolution kernel.
[0028] Step S2-3: Perform dimensionality reduction on A1, A3, and A4 using 1×1 convolutions to obtain the weights W. θ , W g This is used for subsequent cross-channel aggregation.
[0029] Step S2-4: Since redundant information is inevitably obtained during feature extraction, affecting the accuracy of subsequent defect information screening and detection, W... θ and Matrix multiplication is performed to aggregate information from different content segments, and attention features are obtained by normalization using the softmax function. Then With W g Matrix multiplication is performed to weight the defect features, eliminating redundant information and obtaining detailed output features K. By implementing cross-channel information interaction, the strong correlation between local features is strengthened while reducing network computation. The corresponding calculation expression is as follows:
[0030] W θ ∈f(θ(A1)) (7)
[0031]
[0032] W g ∈f(g(A3)) (9)
[0033]
[0034] In the formula, f() represents a 1×1 convolution, K∈R H×W×C The output features are represented by H, W, and C, which represent the height, width, and number of channels of the output feature map, respectively.
[0035] Furthermore, in step S2-1, the values of different void ratios (rate) are 1, 3, and 7.
[0036] Furthermore, in step S6, the output feature K is subjected to three bottom-up deconvolution upsampling operations using a 4×4 convolution kernel and a stride of 2.
[0037] This invention employs the above technical solutions, using ResNext-101 as the backbone feature extraction network. Based on aggregated transformations and grouped convolutions, it acquires richer information with fewer parameters. A normalized attention mechanism is embedded at the end of the residual blocks of ResNext-101 to suppress insignificant features, reduce redundant information acquisition, and improve the network's feature extraction capability. An adaptive feature enhancement fusion module is proposed, which captures defect features of different types and sizes under different receptive fields through convolutions at different scales, performs feature fusion, and then normalizes the obtained multi-scale information to reduce the semantic gap between different feature channel layers, further enhancing the feature expression capability of the detection network and capturing more complete deep semantic information. Three bottom-up deconvolutional upsampling operations are used to obtain high-resolution feature maps. To reduce the aliasing effect caused by continuous upsampling, two more convolutions (3×3 and 1×1) are performed to achieve defect localization and classification prediction.
[0038] This invention reduces the number of parameters in the backbone feature extraction network, improving the model's lightweightness; reduces the acquisition of redundant information, increasing the network's focus on the target and further enhancing the network's feature extraction capability; and enriches global feature information, strengthening the network's feature expression capability. Attached Figure Description
[0039] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments;
[0040] Figure 1 is a flowchart of the PCB defect detection method with adaptive feature enhancement fusion according to the present invention.
[0041] Figure 2 is a schematic diagram of each defect type;
[0042] Figure 3 is a schematic diagram of the RAFF-Net network structure;
[0043] Figure 4 is a schematic diagram of the NAM attention mechanism module;
[0044] Figure 5 is a schematic diagram of the AFF module. Detailed Implementation Methods
[0045] Figure 1 is a flowchart of an adaptive feature enhancement fusion PCB defect detection method proposed in this invention. To make the objectives, technical solutions and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings.
[0046] As shown in any one of Figures 2 to 5, this invention discloses an adaptive feature enhancement fusion method for PCB defect detection, which includes the following steps:
[0047] Step S1: Input the acquired PCB image into the ResNext-101 feature extractor embedded with the NAM module to extract the initial feature map of the PCB in the defect area;
[0048] Step S2: Input the extracted initial PCB feature map into the AFF module. The AFF module captures different types and sizes of defect features under different receptive fields through convolution at different scales to obtain the corresponding multi-scale information feature map. Then, after channel normalization of the obtained multi-scale information feature map, the output feature K is obtained by removing redundant information and containing defect features with different weights.
[0049] Step S3: Perform three bottom-up deconvolution upsampling operations on the output feature K to obtain a high-resolution feature map;
[0050] Step S4: Perform two convolution operations, 3×3 and 1×1, on the obtained high-resolution feature map in sequence, and finally output the location and classification prediction of PCB defects.
[0051] Furthermore, in step S1, a NAM module is embedded at the end of each residual structure of the feature extractor ResNext-101.
[0052] Furthermore, the NAM module includes a channel attention module (CAM) and a spatial attention module (SAM). The channel attention module (CAM) of the NAM module uses the scaling factor in batch normalization (BN) to reflect the importance of each channel. The channel attention module (CAM) first performs batch normalization on the input features to obtain the scaling factor for each channel. Then, it assigns high and low weights to the feature information of each channel according to the scaling factor to focus on the target features. Finally, it outputs the features through a sigmoid activation function. The spatial attention module (SAM) of the NAM module applies batch normalization (BN) to the spatial dimension and measures the importance of spatial features by normalizing pixels.
[0053] Furthermore, the expression for the NAM module is as follows:
[0054]
[0055]
[0056]
[0057]
[0058] Q r =sigmoid(w(y(P) c )))(5)
[0059] Q t =sigmoid(w(y(P) s )))(6)
[0060] In the formula, m represents the total number of feature input batches, and x i μ represents the feature input of the i-th batch. B Represents the batch feature mean. y represents the variance of the batch features. i The scaling factor for the i-th channel is represented by ∈, where ∈ is a number to prevent the denominator from being zero, and γ and β represent the parameters to be learned during training; w i P represents the weight of the i-th channel; c P represents the input features of the channel attention module (CAM). s The input features of the spatial attention module (SAM) are represented by Q. r Q represents the output features of the channel attention module (CAM); t This represents the output features of the Spatial Attention Module (SAM).
[0061] Furthermore, the AFF module utilizes 1×1 convolution, 3×3 convolution with different dilation rates (rate = 1, 3, 7), and global pooling to enhance feature extraction from the input feature map. Considering the complexity and diversity of PCB defects, their varying sizes, and the presence of color background interference, using convolutional kernels with a fixed receptive field for feature extraction can easily overlook the completeness of the features of interest. Therefore, to ensure the comprehensiveness and richness of the defect feature map information extraction, multi-scale convolutional kernels with different receptive fields are first used for feature capture. 1×1 convolution and global pooling are then used to perform global feature extraction on the feature map, yielding feature maps A1 and A3. Then, 3×3 convolutions with different dilation rates are used to expand the receptive field and extract features from defects of different sizes, resulting in feature map A2. Choosing convolutions with different dilation rates ensures a larger receptive field while maintaining sufficient detail about the PCB image boundaries, guaranteeing the completeness of feature information extraction. Finally, feature maps A2 with different dilation rates are fused to obtain feature map A3, enriching the PCB defect feature information under this convolutional kernel. The weights W are obtained by performing 1×1 convolution on A1, A3, and A4 respectively. θ , W g Because redundant information is inevitably obtained during feature extraction, affecting the accuracy of subsequent information filtering and detection, W... θ and W g Matrix multiplication is performed to aggregate information from different content segments, and attention features are obtained by normalization using the softmax function. Then With W gMatrix multiplication is performed to weight the defect features, eliminating redundant information and obtaining detailed output features K. By enabling cross-channel information interaction, the computational load of the network is reduced while strengthening the strong correlation between local features.
[0062] Furthermore, the specific steps of step S2 are as follows:
[0063] Step S2-1: Input the obtained initial PCB feature map into the AFF module. The AFF module uses 1×1 convolution and global pooling to perform global feature extraction on the feature map to obtain feature maps A1 and A3. Then, it uses 3×3 convolution with different hole rates (rate = 1, 3, 7) to expand the receptive field and extract features of defects of different sizes to obtain feature map A2. Choosing convolution with different hole rates can ensure that a larger receptive field is obtained while the feature map resolution does not lose too much detail information about the PCB image boundary, thus ensuring the integrity of feature information extraction.
[0064] Step S2-2: Feature map A3 is obtained by fusing the feature maps A2 under different void ratios to enrich the PCB defect feature information under the convolution kernel.
[0065] Step S2-3: Perform dimensionality reduction on A1, A3, and A4 using 1×1 convolutions to obtain the weights W. θ , W g This is used for subsequent cross-channel aggregation.
[0066] Step S2-4: Since redundant information is inevitably obtained during feature extraction, affecting the accuracy of subsequent defect information screening and detection, W... θ and Matrix multiplication is performed to aggregate information from different content segments, and attention features are obtained by normalization using the softmax function. Then With W g Matrix multiplication is performed to weight the defect features, eliminating redundant information and obtaining detailed output features K. By implementing cross-channel information interaction, the strong correlation between local features is strengthened while reducing network computation. The corresponding calculation expression is as follows:
[0067] W θ ∈f(θ(A1)) (7)
[0068]
[0069] W g ∈f(g(A3)) (9)
[0070]
[0071] In the formula, f() represents a 1×1 convolution, K∈R H×W×C The output features are represented by H, W, and C, which represent the height, width, and number of channels of the output feature map, respectively.
[0072] Furthermore, in step S2-1, the values of different void ratios (rate) are 1, 3, and 7.
[0073] Furthermore, in step S6, the output feature K is subjected to three bottom-up deconvolution upsampling operations using a 4×4 convolution kernel and a stride of 2.
[0074] The specific principles of this invention will be explained in detail below:
[0075] This invention proposes an attention-based adaptive feature-enhanced fusion network (ResNext101+NAM-Adaptive Feature-Eenhanced Fusion Network, RAFF-Net), which significantly improves the accuracy of target identification and localization. The RAFF-Net network consists of three parts: feature extraction, feature enhancement and fusion, and high-resolution feature maps.
[0076] 1) The ResNext-101 network is used as the backbone feature extraction network to extract richer semantic information through deep convolutional neural networks. To address the issue of small PCB target defects, a lightweight Normalization-Based Attention Module (NAM) is introduced. This module extracts salient features of PCB target defects in both channel and spatial dimensions and facilitates information interaction between features from different dimensions, thereby improving the ability to focus on small target defects.
[0077] 2) Considering the complexity and diversity of PCB defect types, an Adaptive Feature-Enhanced Fusion (AFF) module is proposed based on a self-attention mechanism to obtain rich global PCB defect information. This module captures defect features of different types and sizes within different receptive fields through convolutions at different scales, performs feature fusion, and then normalizes the resulting multi-scale information. This reduces the semantic gap between different feature channel layers, further enhancing the feature representation capability of the detection network and capturing more complete deep semantic information.
[0078] 3) High-resolution feature maps are obtained by using three bottom-up deconvolution upsampling operations. To reduce the aliasing effect caused by continuous upsampling, two more convolutions, 3×3 and 1×1, are performed to achieve defect localization and classification prediction. The network structure is shown in Figure 3.
[0079] Normalized Attention Module: Deep neural networks inevitably capture some redundant information while extracting features, thus affecting the reliability of subsequent prediction results. Therefore, this invention integrates an attention mechanism into CNNs to improve network accuracy by focusing on regions of interest. NAM is a lightweight and efficient attention mechanism, comprising two sub-modules: channel attention and spatial attention. This invention embeds a NAM module at the end of each residual structure of ResNext-101, using continuously learned weight contribution factors to allocate feature information, thereby helping the network focus on target features while suppressing insignificant features, thus improving the effect of target attention.
[0080] The Channel Attention Module (CAM) of NAM utilizes the scaling factor in Batch Normalization (BN) to reflect the importance of each channel. CAM first performs batch normalization on the input features to obtain the scaling factor for each channel. Then, it assigns high and low weights to the feature information of each channel based on the scaling factor to focus on the target features. Finally, it outputs the features after passing through the sigmoid activation function. The Spatial Attention Module (SAM) of NAM applies BN to the spatial dimension, measuring the importance of spatial features by normalizing pixels. Its structure is shown in Figure 4, and the specific formula is as follows.
[0081]
[0082]
[0083]
[0084]
[0085] Q r =sigmoid(w(y(P) c ))) (5)
[0086] Q t =sigmoid(w(y(P) s ))) (6)
[0087] In the formula, m represents the feature input batch, x i μ represents the feature input of the i-th batch. B Represents the batch feature mean. y represents the variance of the batch features. i Let w represent the scaling factor for the i-th channel, ∈ is a number to prevent the denominator from being zero, and γ and β represent the parameters to be learned during training. i P represents the weight of the i-th channel. c P s Represents the input features, Q r Q t This indicates the output features.
[0088] Adaptive Feature Enhancement Fusion Module: Due to the varying shapes and sizes of PCB defect targets, the backbone network with a fixed receptive field easily overlooks some regions during feature extraction, resulting in a loss of geometric information. Therefore, to address the issue of target scale variation and enrich global information, this invention designs an Adaptive Feature Enhancement Fusion (AFF) module. This module utilizes convolutions of different scales to capture multi-scale features under different receptive fields, and then performs information interaction on the captured features to further enhance the correlation of feature information between different channels.
[0089] First, the AFF module processes the input features X∈R H×W×C Multi-scale defect features A1, A2, and A3 are obtained using convolutional kernels with different receptive fields (1×1 and 3×3) and global average pooling. Features extracted with different hole rates (rate = 1, 3, 7) are then fused to obtain feature A4, enriching the global semantic information. Finally, feature layers A1, A3, and A4 are convolved with a 1×1 layer to obtain a weight matrix W containing feature information. θ , W g To aggregate information from different sources, W θ and Attention features are obtained by performing matrix multiplication and normalizing using the softmax function. Finally, With W g Matrix multiplication is performed to obtain the output feature K. By realizing cross-channel information interaction, the strong correlation between local features is strengthened while reducing the network's computational load, as shown in Figure 5.
[0090] This invention employs the above technical solutions, using ResNext-101 as the backbone feature extraction network. Based on aggregated transformations and grouped convolutions, it acquires richer information with fewer parameters. A normalized attention mechanism is embedded at the end of the residual blocks of ResNext-101 to suppress insignificant features, reduce redundant information acquisition, and improve the network's feature extraction capability. An adaptive feature enhancement fusion module is proposed, which captures defect features of different types and sizes under different receptive fields through convolutions at different scales, performs feature fusion, and then normalizes the obtained multi-scale information to reduce the semantic gap between different feature channel layers, further enhancing the feature expression capability of the detection network and capturing more complete deep semantic information. Three bottom-up deconvolutional upsampling operations are used to obtain high-resolution feature maps. To reduce the aliasing effect caused by continuous upsampling, two more convolutions (3×3 and 1×1) are performed to achieve defect localization and classification prediction. This invention reduces the number of parameters in the backbone feature extraction network, improving the model's lightweightness; reduces the acquisition of redundant information, increasing the network's focus on the target and further enhancing the network's feature extraction capability; and enriches global feature information, strengthening the network's feature expression capability.
[0091] Obviously, the described embodiments are only a part of the embodiments of this application, not all of them. Without conflict, the embodiments and features in the embodiments of this application can be combined with each other. The components of the embodiments of this application described and illustrated herein can generally be arranged and designed in various different configurations. Therefore, the detailed description of the embodiments of this application is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
Claims
1. A PCB defect detection method based on adaptive feature enhancement fusion, characterized in that: It includes the following steps: Step S1: Input the acquired PCB image into the ResNext-101 feature extractor embedded with a NAM module to extract the initial PCB feature map of the defect area; S2: Input the extracted initial PCB feature map into the AFF module. The AFF module captures different types and sizes of defect features under different receptive fields through convolutions at different scales to obtain corresponding multi-scale information feature maps. Then, after channel normalization of the obtained multi-scale information feature maps, the output feature K is obtained by removing redundant information and containing defect features with different weights; S3: Perform three bottom-up deconvolution upsampling operations on the output feature K to obtain a high-resolution feature map; S4: Perform two convolution operations of 3×3 and 1×1 on the obtained high-resolution feature map in sequence, and finally output the localization and classification prediction of PCB defects; In this step, a NAM module is embedded at the end of each residual structure of the feature extractor ResNext-101. The NAM module is used to assign high and low weights to the feature information of each channel to focus on the target features; The NAM module includes a channel attention module (CAM) and a spatial attention module. The force module SAM and the channel attention module CAM of the NAM module use the scaling factor in batch normalization (BN) to reflect the importance of each channel. The channel attention module CAM first performs batch normalization on the input features to obtain the scaling factor for each channel; then, it assigns high and low weights to the feature information of each channel according to the scaling factor to focus on the target features; finally, it outputs the features after passing through the sigmoid activation function. The spatial attention module SAM of the NAM module applies BN to the spatial dimension, measuring the importance of spatial features by normalizing pixels. The AFF module uses 1×1 convolution, 3×3 convolution with different dilation rates, and global pooling to enhance feature extraction from the input feature map. It uses 1×1 convolution and global pooling to perform global feature extraction to obtain feature maps A1 and A3, and uses 3×3 convolution with different dilation rates to expand the receptive field and extract features of defects of different sizes to obtain feature map A2. Feature maps A2 with different dilation rates are fused to obtain feature map A3. A1, A3, and A4 are dimensionality reduced using 1×1 convolution to obtain the weight W. θ W φ W g W θ and W g Matrix multiplication is performed to aggregate information from different content segments, and the attention feature W is obtained by normalization using the softmax function. θ W φ T W θ W φ T With W g Matrix multiplication is performed to assign weights to the defect features, resulting in detailed output features K.
2. The PCB defect detection method based on adaptive feature enhancement fusion according to claim 1, characterized in that: The expression for the NAM module is as follows: (1) (2) (3) (4) (5) In formula (6), Indicates the total number of feature input batches. Indicates the first A batch of feature inputs, Represents the batch feature mean. Represents the variance of batch features. Indicates the first The scaling factor for each channel, To prevent numbers with a denominator of 0, and This represents the parameters to be learned during the training process; Indicates the first Each channel weight; This represents the input features of the channel attention module (CAM). This represents the input features of the Spatial Attention Module (SAM). This indicates the integration of batch scaling factors. This indicates the integration of weights for batch channels. This represents the output characteristics of the channel attention module (CAM). This represents the output features of the Spatial Attention Module (SAM).
3. The PCB defect detection method based on adaptive feature enhancement fusion according to claim 1, characterized in that: The specific steps of step S2 are as follows: Step S2-1: The AFF module uses 1×1 convolution and global pooling operations to extract global features from the input PCB initial feature map to obtain feature maps A1 and A3. Then, it uses 3×3 convolution with different hole ratios to expand the receptive field and extract features of defects of different sizes to obtain feature map A2. Step S2-2: Feature maps A2 with different hole ratios are fused to obtain feature map A4 with rich PCB defect feature information. Step S2-3: Dimensionality reduction is performed on A1, A3, and A4 using 1×1 convolution to obtain weight W. θ W φ W g This is used for subsequent cross-channel aggregation; Step S2-4: Place W θ and W φ Matrix multiplication is performed to aggregate information from different content segments, and attention features W are obtained by normalization using the softmax function. θ W φ T Then W θ W φ T With W g Matrix multiplication is performed to weight the defect features, remove redundant information, and obtain detailed output features K. The corresponding calculation expression is as follows: (7) (8) (9) In equation (10), This represents a 1×1 convolution process, where θ(), φ(), and g() represent the 1×1 convolution kernel. The output features are represented by H, W, and C, which represent the height, width, and number of channels of the output feature map, respectively.
4. The PCB defect detection method based on adaptive feature enhancement fusion according to claim 3, characterized in that: In step S2-1, the different void ratios (rate) of the 3×3 convolution kernel are 1, 3, and 7.
5. The PCB defect detection method based on adaptive feature enhancement fusion according to claim 1, characterized in that: In step S6, the output feature K is subjected to three bottom-up deconvolution upsampling operations using a 4×4 kernel and a stride of 2.
Citation Information
Patent Citations
PCB surface defect real-time detection method and device and readable medium
CN113628179A
Multi-sound music human sound main melody extraction method based on deep learning
CN114627892A