A printed circuit board surface defect detection method and device based on deformable fusion channel position attention and multi-scale adaptive feature fusion

By introducing deformable fusion channel position attention and multi-scale adaptive feature fusion modules, the printed circuit board surface defect detection network is optimized, solving the problems of slow detection speed and low accuracy, and achieving fast, lightweight and efficient detection results.

CN120997178BActive Publication Date: 2026-04-10GUANGDONG UNIV OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GUANGDONG UNIV OF TECH
Filing Date
2025-08-11
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing target detectors are slow, not lightweight enough, and lack accuracy and robustness in detecting defects on printed circuit board surfaces, failing to meet the application needs of industrial sites or mobile devices.

Method used

A deformable fusion channel position attention and multi-scale adaptive feature fusion module is introduced. Through a deep learning network model, feature information is adaptively optimized and cross-scale feature fusion is performed. The network structure is optimized to improve detection accuracy and reduce complexity.

Benefits of technology

It enables rapid and lightweight detection of surface defects on printed circuit boards, improving the accuracy and robustness of detection, and is suitable for real-time applications and various scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120997178B_ABST
    Figure CN120997178B_ABST
Patent Text Reader

Abstract

The present application relates to a kind of printed circuit board surface defect detection method and device based on deformable fusion channel position attention and multi-scale adaptive feature fusion, method includes: the printed circuit board image to be detected is collected;The printed circuit board image to be detected is input into deep learning network model, and the surface defect detection result of the printed circuit board image to be detected is output, wherein the deep learning network model is obtained by printed circuit board surface defect data set training, the deep learning network model is fused by multi-scale feature fusion strategy different scale features, by channel feature and spatial feature focus on key feature area.The present application can effectively utilize the feature information in printed circuit board image, improve the detection accuracy and robustness of printed circuit board surface defect.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of printed circuit board quality detection, in particular to a printed circuit board surface defect detection method and device based on deformable fusion channel position attention and multi-scale adaptive feature fusion. BACKGROUND

[0002] Target detection technology, as a new and efficient high-precision detection method, has the potential to be widely used in the field of printed circuit board quality detection. Target detection systems rely on cameras and computers equipped with GPUs to run, making it possible to perform long-term high-precision and high-real-time detection. Target detection technology is light in size, easy to deploy, and has strong real-time performance, making it suitable for fields such as electronic manufacturing that require high real-time performance.

[0003] In recent years, the rapid development of deep learning technology has provided powerful tools for image recognition and detection. However, traditional target detectors have certain limitations in printed circuit board surface defect detection. Existing target detectors are not ideal in terms of speed and lightweight, and cannot meet the application requirements of edge devices such as industrial sites or mobile devices. In addition, printed circuit board surface defects often have diverse sizes and complex shapes, and are easily disturbed by the elements and circuits of the circuit board. Traditional detection methods face challenges in accuracy and robustness. Therefore, developing a faster, lighter, and more accurate target detection algorithm is of great significance for printed circuit board surface defect detection. SUMMARY

[0004] The purpose of the present application is to provide a printed circuit board surface defect detection method and device based on deformable fusion channel position attention and multi-scale adaptive feature fusion, which introduces deformable fusion channel position attention and multi-scale adaptive feature fusion modules. It can effectively utilize the feature information in the printed circuit board image, improve the detection accuracy and robustness of the printed circuit board surface defect. At the same time, the original YOLO11 network is lightened, reducing the complexity of the network and improving the computing efficiency.

[0005] To achieve the above purpose, the present application provides the following scheme:

[0006] A printed circuit board surface defect detection method based on deformable fusion channel position attention and multi-scale adaptive feature fusion, comprising:

[0007] Collecting printed circuit board images to be detected;

[0008] Input the printed circuit board image to be detected into a deep learning network model, and output a surface defect detection result of the printed circuit board image to be detected, wherein the deep learning network model is obtained by training a printed circuit board surface defect data set, and the deep learning network model fuses different scale features through a multi-scale feature fusion strategy and focuses on a key feature area through channel features and spatial features.

[0009] Optionally, inputting the printed circuit board image to be detected into a deep learning network model and outputting a surface defect detection result of the printed circuit board image to be detected comprises:

[0010] Input the printed circuit board image to be detected into a backbone feature extraction network, and output a feature map I b1 , I b2 , I b3 ;

[0011] The feature map I b1 , I b2 , I b3 is fused through a multi-scale adaptive feature fusion module in a cross-channel and cross-spatial manner to obtain fusion information.

[0012] Input the feature map I b1 , I b2 , I b3 into a neck feature extraction network to output a feature map I n1 , I n2 , input the feature map I n1 and the fusion information into a deformable fusion channel position attention module to perform deformable channel attention and enhanced position attention operation, and fuse the operation result.

[0013] Input the fused operation result and the feature map I n2 into a YoloHead detection head structure to output the surface defect detection result.

[0014] Optionally, the feature map I b1 , I b2 , I b3 is fused through the multi-scale adaptive feature fusion module in a cross-channel and cross-spatial manner.

[0015] Uniformize the channel number of the feature map I b1 , I b2 , I b3 through a convolution layer, and uniformize the scale of the feature map with uniformized channel number through bilinear interpolation.

[0016] The scale-unified feature map is spliced into a 3D feature body along the depth dimension, and the 3D feature body is processed through a 3D convolution and a self-attention module to obtain an enhanced feature and an average weight;

[0017] The enhanced feature and the average weight are matrix multiplied to obtain a weighted feature;

[0018] The weighted feature is summed along the depth dimension and fused with an input feature to obtain the fusion information.

[0019] Optionally, obtaining the enhanced feature and the average weight comprises:

[0020] F 3D =σ(BN(W 3D *F combine +b 3D ))⊙(W 3D *F combine +b 3D );

[0021] W=Softmax(Conv 1×1 (SiLU(Conv 1×1 (AvgPool 3d (F combine )))));

[0022] W=Softmax(W2*(σ(W1*E [d,h,w] [F combine ])));

[0023] W′=Mean(W,dim=1);

[0024] Wherein, F 3D represents the enhanced feature, sigma represents the Sigmoid function, BN is the BatchNorm operation; W 3D and b 3D represent the weight and bias of the layer; * represents the 3D convolution operation, E [d,h,w] represents the mean operation along the depth, height and width dimensions, W1∈R c ×c / 8×1×1×1 , W2∈R c / 8×3×1×1×1 , and represents the element-by-element multiplication operation of two matrices, F combine represents the spliced three-dimensional feature map, W represents the weight generated by the attention mechanism of the self-attention module, W' represents the average weight, Mean represents the weight average processing, and dim is the dimension number.

[0025] Optionally, the feature map I n1and the fusion information is input into the deformable fusion channel position attention module to perform deformable channel attention, enhanced position attention operation, and fusion of an operation result, and the fusion information is input into the enhanced channel attention module and the deformable spatial attention module respectively to obtain output features of two branches;

[0026] The feature map I n1 is input into the enhanced channel attention module and the deformable spatial attention module respectively to obtain output features of two branches.

[0027] The output features of the two branches are input into a dynamic weight fusion module to obtain the fused operation result.

[0028] Optionally, obtaining the output features of the two branches comprises:

[0029] The enhanced channel attention module extracts channel features of the feature map I n1 , performs channel relationship modeling, and obtains channel attention output features.

[0030] The fusion information is input into the deformable spatial attention module to generate spatial offsets, and deformable convolution operation is performed, and features processed by deformable convolution, the fusion information, and corresponding horizontal attention weights and vertical attention weights are multiplied to obtain spatial attention features.

[0031] Optionally, obtaining the fused operation result comprises:

[0032] F DFCPAM = lambda o F space_att + (1 - lambda) o F ch_att ;

[0033] wherein, F DFCPAM represents the fused operation result, lambda represents a fusion gate, F space_att represents channel attention features, and F ch_att represents spatial attention features.

[0034] Optionally, training the deep learning network model through the printed circuit board surface defect dataset comprises:

[0035] The deep learning network model is pre-trained through a public dataset, the skeleton features of the pre-trained deep learning network model are frozen, the weights of neck and head parts of the pre-trained deep learning network model are updated by training the pre-trained deep learning network model through the printed circuit board surface defect dataset, and then all the weights are unfrozen for training.

[0036] The application also provides a printed circuit board surface defect detection device based on deformable fusion channel position attention and multi-scale adaptive feature fusion, which comprises a computer 101, a camera 102 and a detected circuit board 103; the computer 101 is connected with the camera 102, acquires an image of the detected circuit board 103 and performs defect detection through a deep learning network model.

[0037] The deep learning network model is obtained through printed circuit board surface defect data set training, and the deep learning network model focuses on a key feature area through a multi-scale feature fusion strategy and fusion of channel features and spatial features.

[0038] The application has the following advantages: the application introduces a dynamic weight fusion mechanism, realizes adaptive optimization combination of channel features and spatial features, enables the network to focus on a key feature area more accurately, adopts an improved multi-scale feature fusion strategy, enhances the correlation between different scale features through 3D convolution operation, improves the utilization efficiency of multi-scale features, and finally, an optimized network structure design greatly reduces model complexity and computing resource consumption on the premise of ensuring detection performance. The method has the advantages of rapidity, light weight and accuracy, and is suitable for real-time application and various scenes of printed circuit board surface defect detection. The application has broad application prospects in printed circuit board production lines and printed circuit board quality inspection links. BRIEF DESCRIPTION OF DRAWINGS

[0039] In order to more clearly illustrate the technical solutions in the embodiments of the application or the prior art, the following will briefly introduce the drawings needed in the embodiments. Obviously, the drawings in the following description only constitute some embodiments of the application, and for those skilled in the art, other drawings can also be obtained without creative labor on the basis of these drawings.

[0040] Figure 1 The application provides a printed circuit board surface defect detection device based on deformable fusion channel position attention and multi-scale adaptive feature fusion, wherein the computer-101, the camera-102 and the detected circuit board-103.

[0041] Figure 2 The application provides a deep learning network model overall architecture schematic diagram.

[0042] Figure 3 The application provides a multi-scale adaptive feature fusion module network architecture schematic diagram.

[0043] Figure 4 The application provides a self-attention module network architecture schematic diagram.

[0044] Figure 5 A schematic diagram of a deformable fusion channel position attention module architecture for an embodiment of the application;

[0045] Figure 6 A schematic diagram of a deformable position attention module architecture for an embodiment of the application;

[0046] Figure 7 A schematic diagram of an enhanced channel attention module architecture for an embodiment of the application. DETAILED DESCRIPTION

[0047] The technical solutions in the embodiments of the application will be described clearly and completely below with reference to the drawings in the embodiments of the application. Obviously, the described embodiments are only some of the embodiments of the application, but not all the embodiments of the application. Based on the embodiments in the application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the application.

[0048] In order to make the above objectives, characteristics and advantages of the application more apparent, the application will be described in further detail below with reference to the drawings and specific embodiments.

[0049] Embodiment one:

[0050] In view of the problems of slow speed, low detection accuracy and low robustness of the printed circuit board surface defect detection algorithm, the embodiment provides a printed circuit board surface defect detection method based on deformable fusion channel position attention and multi-scale adaptive feature fusion, which comprises the following steps:

[0051] Collecting a printed circuit board image to be detected;

[0052] Inputting the printed circuit board image to be detected into a deep learning network model to output a surface defect detection result of the printed circuit board image to be detected, wherein the deep learning network model is obtained by training a printed circuit board surface defect data set, and the deep learning network model focuses on key feature regions by fusing different scale features through a multi-scale feature fusion strategy and by channel features and spatial features.

[0053] Specifically, the camera captures the printed circuit board image to be detected, and a printed circuit board surface defect data set I h =[I h1 , I h2 ,... I hK ], wherein the total number of elements in the data set I h is K, the image size is n ch ×h×w, and n chis the image channel, h is the image height, and w is the image width. Image labeling uses the open-source tool X-Anylabeling, and the labeled information is the defect category and the coordinates of the upper left corner and the lower right corner of the defect target. The format of the labeled information file is txt.

[0054] Further, the surface defect detection result of the printed circuit board image to be detected is output, including:

[0055] The printed circuit board image to be detected is input into the backbone feature extraction network, and a feature map I b1 is output. b2 b3 ;

[0056] The feature map I b1 is input into the neck feature extraction network, and a feature map I b2 is output. b3 The multi-scale adaptive feature fusion module is used for cross-channel and cross-space information fusion to obtain fusion information.

[0057] The feature map I b1 is input into the neck feature extraction network, and a feature map I b2 is output. b3 The feature map I n1 is input into the YoloHead detection head structure, and a surface defect detection result is output. n2 The feature map I n1 and the fusion information are input into the deformable fusion channel position attention module to perform deformable channel attention and enhanced position attention operations, and the operation results are fused.

[0058] The fused operation results and the feature map I n2 are input into the YoloHead detection head structure, and a surface defect detection result is output.

[0059] Specifically, a network model as shown in Figure 2 is built, and the deep learning network model includes a backbone feature extraction network, a neck feature extraction network, a deformable fusion channel position attention module, a multi-scale adaptive feature fusion module, and a YoloHead detection head structure.

[0060] An RGB image with a size of n ch ×h×w is used as input to enter the backbone of the network model, and is respectively processed through convolution, a C3k2 layer, an SPPF layer, and a C2PSA layer, and three feature maps I b1 , I b2 , and I b3 with different scales are output, and the scales are n c1 ×h / 8×w / 8, n c2 ×h / 16×w / 16, and n c3 ×h / 32×w / 32. The feature map I​b1 , I b2 , I b3 The feature transmission between the C3k2 layer in the backbone and the neck layer is connected through the multi-scale adaptive feature fusion module. The cross-channel and cross-space information fusion between the feature maps is realized by using the module. The output channel number of the multi-scale adaptive feature fusion module is the same as I b1 .

[0061] In the neck of the network model, fine adjustment of efficient fusion of feature maps and further reduction of parameter quantity are realized. In the overall structure of the neck, first, the large-scale detection head is removed to reduce the model complexity. The input of the neck feature extraction network is the output of the backbone feature extraction network, and two scale different feature maps I n1 , I n2 are output. The scales are n c1 ×h / 8×w / 8 and n c2 ×h / 16×w / 16 respectively. Then, a deformable fusion channel position attention module is designed, which receives the multi-scale adaptive feature fusion module and the feature maps I n1 and performs deformable channel attention and enhanced position attention operations, and fuses the operation results to output the feature map I CPAM with a scale of n c1 ×h / 8×w / 8, achieving the purpose of extracting channel information and position information at the same time. Finally, the feature maps I CPAM and I n2 are input into the YoloHead detection head structure, and the surface defect detection result of the printed circuit board image is output.

[0062] Further, the feature maps I b1 , I b2 , I b3 cross-channel and cross-space information fusion through the multi-scale adaptive feature fusion module includes:

[0063] The channel numbers of the feature maps I b1 , I b2 , I b3 are unified through the convolution layer, and the feature maps with unified channel numbers are unified in scale through bilinear interpolation;

[0064] The feature maps with unified scale are spliced into a 3D feature body along the depth dimension, and the 3D feature body is processed through a 3D convolution and a self-attention module to obtain enhanced features and average weights;

[0065] The enhanced features and the average weights are multiplied in matrix to obtain weighted features;

[0066] The weighted features are summed along the depth dimension and fused with the input features to obtain fusion information.

[0067] Specifically, the multi-scale adaptive feature fusion module is as shown in the figure Figure 3 As shown in the figure, assuming that the input feature maps are P2, P4, and P8, which come from features of different scales of the network. First, use a convolutional layer to unify the channel number of each feature map to 256 to obtain feature maps C2, C4, and C8. Then, C4 and C8 are unified to the scale of C2 through bilinear interpolation. Next, C2, C4, and C8 are spliced along the depth dimension into a 3D feature body. The specific operation is to add a depth dimension on the basis of each feature map in dimension 2, and splice in the depth dimension to form a feature tensor with a size of [B, C, D, H, W]. The mathematical description of this operation is:

[0068]

[0069] In the above formula, f unsqueeze (·) represents a dimension increasing function, ∑(·) represents a Concat operation, P i represents an input feature map, F combine represents a spliced three-dimensional feature map, C i represents a feature map with a unified channel number.

[0070] Next, group 3D convolution is performed on F combine to obtain enhanced features F 3D . Then, the attention mechanism of the self-attention module is used to generate weights W of each scale, and the weights are averaged to obtain average weights W'. The average weights and the enhanced features are multiplied to obtain weighted features F weighted . Finally, summing along the depth dimension and fusing with the original C2 feature, the final output F MSAF of the module is obtained. This process can be described as:

[0071] F 3D =σ(BN(W 3D *F combine +b 3D ))⊙(W 3D *F combine +b 3D );

[0072] W=Softmax(Conv 1×1 (SiLU(Conv 1×1 (AvgPool3d(F combine )))));

[0073] W=Softmax(W2*(σ(W1*E [d,h,w] [Fcombine )));

[0074] W' = Mean(W, dim = 1);

[0075] F weighted = F 3D ⊙ W';

[0076] F MSAF = F weighted + C2

[0077] wherein, σ represents a Sigmoid function, BN is a BatchNorm operation; W 3D and b 3D represent the weights and bias of the layer; * represents a 3D convolution operation, E [d,h,w] represents a mean operation along the depth, height and width dimensions, W1∈R c×c / 8×1×1×1 and W2∈R c / 8×3×1×1×1 are weight coefficients, W is the weight generated by the attention mechanism of the self-attention module for each scale, Mean represents weight average processing, dim is the dimension number, and ⊙ represents the element-by-element multiplication operation of two matrices.

[0078] Figure 4 The structure of the self-attention module in the multi-scale adaptive feature fusion module is shown, including the complete processing flow of the adaptive mean 3D pooling layer, the SiLu activation function, the 3D convolution layer and the SoftMax normalization layer. The self-attention module first performs global information extraction on the input multi-scale feature map in the spatial dimension through the adaptive mean 3D pooling operation to generate a compact feature representation, then performs nonlinear transformation through the SiLu activation function to enhance the expression ability of the feature, then performs depth feature learning and cross-scale information interaction on the pooled feature through the 3D convolution layer, and finally calculates the adaptive weight coefficients of each scale feature through the SoftMax normalization layer.

[0079] Further, the feature map I n1 and the fusion information are input into the deformable fusion channel position attention module to perform deformable channel attention and enhanced position attention operation, and the operation results are fused, including:

[0080] The feature map I n1 and the fusion information are input into the enhanced channel attention module and the deformable spatial attention module respectively to obtain the output features of the two branches.

[0081] The output features of the two branches are input into the dynamic weight fusion module to obtain the fused operation results.

[0082] Further, obtaining the output features of the two branches includes:

[0083] The enhanced channel attention module extracts channel features of the feature map I n1 , and models channel relationships to obtain channel attention output features;

[0084] The fusion information is input into the deformable spatial attention module to generate a spatial offset, and a deformable convolution operation is performed. The features processed by the deformable convolution, the fusion information, and the corresponding horizontal attention weight and vertical attention weight are multiplied to obtain spatial attention output features.

[0085] Specifically, the deformable fusion channel position attention module receives the outputs of the multi-scale adaptive feature fusion module and the neck feature extraction network, and has a structure as shown in Figure 5 . First, given the input feature map I n1 and the output feature F MSAF of the multi-scale adaptive feature fusion module, the two branches are processed by the enhanced channel attention module and the deformable spatial attention module respectively to obtain the outputs of the two branches. As shown in Figure 7 , for the channel attention part, first, the global channel features z c of the input feature map are extracted by a 2D average pooling operation, which compresses the spatial dimension to 1x1 and retains the channel dimension information; then the extracted channel features are dimensionally transformed by squeeze and transpose operations to a format suitable for 1D convolution processing; then a multi-scale parallel processing strategy is adopted, and three 1D convolution layers Conv S, Conv M, and Conv L with different kernel sizes are used to model the channel features, wherein the small-scale convolution kernel captures local channel relationships, the medium-scale convolution kernel models medium-range channel dependencies, and the large-scale convolution kernel learns long-range channel interaction patterns; the output features of the three parallel branches are adjusted in dimension to ensure the compatibility of subsequent fusion operations; then the channel features of the three scales are spliced in the channel dimension, and feature fusion is performed by a 1x1 convolution to learn the weight distribution of different scale features; finally, the channel attention weight is generated by a Sigmoid activation function, and is multiplied element by element with the original input feature to realize adaptive feature enhancement in the channel dimension, and a feature representation F ch_att modeled by channel relationships is obtained. As shown in Figure 6 , for the spatial attention part, the input feature map is first processed by the offset generation network, which generates offset parameters Δp using a 3x3 convolution layer; then the generated spatial offset Δp is input into the deformable convolution module, which adaptively adjusts the sampling grid of the standard convolution according to the offset, so that the convolution kernel can sample features at irregular spatial positions, thereby capturing the geometric deformation information of the target, and obtaining a feature representation F def_convSimultaneously, to further enhance the spatial attention mechanism, the system also implements a positional attention branch. Global contextual information in the horizontal and vertical directions of the feature map is extracted through horizontal and vertical pooling operations, respectively. After dimensionality compression via 1×1 convolution, batch normalization and ReLU activation functions are applied for non-linear transformation. Then, dedicated convolutional layers are used to restore the original number of channels, and a Sigmoid activation function is applied to generate horizontal and vertical attention weights. Finally, the original input features, the Sigmoid activation results of the deformable convolutional features, and the horizontal and vertical attention weights are multiplied element-wise to obtain the positional attention output. The above process can be represented as:

[0086] z c =GAP(I n1 );

[0087] F ch_att =σ(W up (δ(W down z c )));

[0088] Δp=f offset (F MSAF );

[0089]

[0090] F space_att =F MSAF ⊙σF def_conv ⊙F h ⊙F w Where GAP(·) represents the global average pooling operation, δ is the ReLU activation function, and W down W up These are the dimension reduction and dimension increase matrices, respectively; f offset (·) is the function that generates the offset. k Let p represent the fixed weight parameter at the k-th position of the deformable convolution kernel, and p represent the coordinates of the current center position of the convolution kernel. k Δp represents the preset relative offset of the convolution kernel at the k-th position. k This indicates that the convolution kernel passes through f offset (·) The learned dynamic offset, F h F represents the horizontal attention weight. w This represents the vertical attention weight.

[0091] The output F of these two branches space_att F ch_att The features used as input to the dynamic weight fusion module are fused to obtain the final output of the deformable fusion channel position attention module. This process can be described as follows:

[0092] F DFCPAM = λ ⊙ F space_att + (1 - λ) ⊙ F ch_att

[0093] wherein F DFCPAM represents the fusion operation result, λ represents the fusion gate, F space_att represents the spatial attention feature, F ch_att represents the channel attention feature.

[0094] Further, the deep learning network model is trained by the printed circuit board surface defect dataset, including:

[0095] The deep learning network model is pre-trained by a public dataset, the skeleton features of the pre-trained deep learning network model are frozen, the pre-trained deep learning network model is trained by the printed circuit board surface defect dataset to update the weights of the neck and head parts, and then all the weights are unfrozen for training.

[0096] Specifically, the training method includes training a pre-training model on a large public dataset first, then loading the pre-training model, using the specific dataset required by the current task, i.e. constructing the printed circuit board surface defect dataset I h , freezing the skeleton features, and only updating the weights of the neck and head parts, and training multiple epochs. Then, all the weights are unfrozen, and multiple epochs are trained; the loss function used is consistent with the loss function in the original yolov8. The network training parameters are set: learning rate lr0, lr f , batch size, training set validation set division, optimizer and training period.

[0097] In the network inference stage, a prediction mechanism based on multi-scale feature fusion is adopted. After preprocessing, the input image is uniformly adjusted to 640x640 resolution, multi-level features are extracted through the backbone network, and feature enhancement and fusion are performed through the neck network containing the deformable fusion channel position attention module. The detection head outputs three scales of feature maps of 80x80, 40x40 and 20x20, which correspond to different sizes of defect detection requirements. In the post-processing stage, an improved weighted non-maximum suppression strategy is adopted. First, the prediction results of the three scales are spliced along the channel dimension to form a prediction tensor with dimensions (b, 8400, 84), where the 84 dimensions include 4-dimensional bounding box coordinates, 1-dimensional object confidence and 80-dimensional classification probability. After preliminary screening based on the confidence threshold, a dynamic intersection over union threshold is used for prediction box deduplication. Finally, the optimized prediction results that do not exceed the preset maximum number of detection boxes are output.

[0098] The normalized position coordinates (X, Y, W, H) corresponding to the coordinate positions (x, y, w, h) of the described detection frame are obtained and plotted in the test image. If the detection frame is output from the test image, it means that the printed circuit board being tested has defects, otherwise, the printed circuit board being tested does not have defects.

[0099] The method of the embodiment introduces deformable fusion channel position attention and a multi-scale adaptive feature fusion module. The feature information in the printed circuit board image can be effectively utilized to improve the detection accuracy and robustness of the surface defects of the printed circuit board. At the same time, the original YOLO11 network is lightened to reduce the complexity of the network and improve the computing efficiency. With the continuous development and wide application of target detection technology, the printed circuit board surface defect detection algorithm combined with deep learning can be widely applied in factory assembly lines, product quality inspection and other fields to improve the production efficiency and quality of electronic products.

[0100] Embodiment two:

[0101] As shown in Figure 1 The embodiment provides a printed circuit board surface defect detection device based on deformable fusion channel position attention and multi-scale adaptive feature fusion, which comprises a computer 101, a camera 102 and a circuit board 103 to be tested. The computer 101 is connected to the camera 102, acquires the image of the circuit board 103 to be tested and performs defect detection through a deep learning network model.

[0102] The deep learning network model is obtained by training a printed circuit board surface defect data set, and the deep learning network model focuses on key feature regions through multi-scale feature fusion strategy and channel features and spatial features.

[0103] The above-described embodiments are only descriptions of the preferred modes of the present application and do not limit the scope of the present application. Without departing from the design spirit of the present application, various modifications and improvements to the technical solutions of the present application made by those skilled in the art shall fall within the protection scope determined by the claims of the present application.

Claims

1. A method for detecting surface defects on printed circuit boards based on deformable fusion channel position attention and multi-scale adaptive feature fusion, characterized in that, include: Acquire images of the printed circuit board to be inspected; The printed circuit board image to be detected is input into a deep learning network model, and the surface defect detection result of the printed circuit board image to be detected is output. The deep learning network model is trained on a printed circuit board surface defect dataset. The deep learning network model fuses features of different scales through a multi-scale feature fusion strategy and focuses on key feature regions through channel features and spatial features. The image of the printed circuit board to be inspected is input into a deep learning network model, and the surface defect detection results of the image of the printed circuit board to be inspected are output, including: The image of the printed circuit board to be inspected is input into the backbone feature extraction network, which outputs a feature map. , , ; The feature map , , A multi-scale adaptive feature fusion module is used to perform cross-channel and cross-spatial information fusion to obtain fused information. The feature map , , Input the neck feature extraction network and output the feature map , The feature map The fused information is input to the deformable fusion channel position attention module to perform variable channel attention and enhanced position attention operations, and the operation results are fused. The fusion result and the feature map Input the YOLOHead detection head structure and output the surface defect detection results; The feature map , , The cross-channel and cross-spatial information fusion through the multi-scale adaptive feature fusion module includes: The feature map is processed by a convolutional layer. , , The number of channels is unified, and the feature maps with unified channel numbers are scaled using bilinear interpolation. The feature maps with uniform scale are stitched together along the depth dimension to form a 3D feature volume. The 3D feature volume is then processed by a 3D convolution and self-attention module to obtain enhanced features and average weights. The enhanced features and the average weights are multiplied by a matrix to obtain the weighted features; The weighted features are summed along the depth dimension and fused with the input features to obtain the fused information.

2. The method according to claim 1, characterized in that, Obtaining enhanced features and average weights includes: ; ; ; ; in, Indicates enhanced features, express function, for operate; and This indicates the weights and biases of the layer; This represents a 3D convolution operation. This indicates the mean calculation along the depth, height, and width dimensions. and These are the weighting coefficients. This represents the term-by-term multiplication operation between two matrices. This represents the stitched 3D feature map. This indicates that weights at each scale are generated through the attention mechanism of the self-attention module. Indicates average weight. This indicates weighted averaging, where dim is the number of dimensions and SiLU is the activation function. For adaptive average 3D pooling.

3. The method according to claim 2, characterized in that, The feature map The process of inputting the fusion information into the deformable fusion channel position attention module for variable channel attention and enhanced position attention calculations, and then fusing the calculation results, includes: The feature map The fused information is input into the enhanced channel attention module and the deformable space attention module respectively for processing to obtain the output features of the two branches; The output features of the two branches are input into the dynamic weight fusion module to obtain the fusion result.

4. The method according to claim 3, characterized in that, Obtaining the output features of the two branches includes: The enhanced channel attention module extracts the feature map. The channel features are identified, and channel relationship modeling is performed to obtain channel attention features; The fused information is input into the deformable spatial attention module to generate a spatial offset, and deformable convolution is performed. The features processed by deformable convolution, the fused information, and the corresponding horizontal and vertical attention weights are multiplied together to obtain spatial attention features.

5. The method according to claim 3, characterized in that, Obtaining the fusion result includes: ; in, This represents the result of the fusion operation. Indicates fusion gating, Representing spatial attention characteristics, This represents the channel attention feature.

6. The method according to claim 1, characterized in that, Training the deep learning network model using a dataset of surface defects on printed circuit boards includes: The deep learning network model is pre-trained using a public dataset, the skeleton features of the pre-trained deep learning network model are frozen, and the weights of the neck and head parts are updated by training the pre-trained deep learning network model using a printed circuit board surface defect dataset. Then all weights are unfrozen and trained again.

7. A printed circuit board surface defect detection device based on deformable fusion channel position attention and multi-scale adaptive feature fusion, implemented according to any one of claims 1-6, characterized in that, include: Computer (101), camera (102), and circuit board under inspection (103). The computer (101) is connected to the camera (102) to acquire images of the circuit board under inspection (103) and perform defect detection through a deep learning network model. The deep learning network model is trained using a printed circuit board surface defect dataset. The deep learning network model fuses features of different scales through a multi-scale feature fusion strategy and focuses on key feature regions through channel features and spatial features.

Citation Information

Patent Citations

  • Surface defect salient target detection method based on adaptive multi-scale feature fusion

    CN119478354A

  • Circuit board defect detection method and equipment based on improved YOLOv8

    CN120235837A