Printed circuit board surface defect detection method and system
Patent Information
- Application Number
- CN202611006158.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-07
- Publication Date
- 2026-10-09
AI Technical Summary
[0006]本发明的主要目的在于提供了一种印刷电路板表面缺陷检测方法及系统,旨在解决现有技术在复杂场景下印刷电路板表面缺陷的检测精度不足的技术问题
[0019]本发明公开了获取待检测印刷电路板的表面图像;利用改进后的YOLOv11网络模型对所述表面图像进行缺陷检测,获得缺陷检测结果,所述改进后的YOLOv11网络模型是在YOLOv11网络模型中引入自适应校准卷积模块、上下文与空间特征校准网络和自增强注意力检测头后获得的网络模型;根据所述缺陷检测结果,确定所述表面图像中缺陷的类别信息和位置信息。由于本发明通过引入自适应校准卷积模块、上下文与空间特征校准网络和自增强注意力检测头对YOLOv11网络模型进行改进,然后利用改进后的YOLOv11网络模型对待检测印刷电路板的表面图像进行缺陷检测,相比于现有技术,相比于现有技术,本发明提升了复杂场景下印刷电路板表面缺陷的检测精度。
Smart Images

Figure CN122887799A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image data processing technology, and in particular to a method and system for detecting surface defects on printed circuit boards. Background Technology
[0002] As the core component of electronic devices, the surface defect detection of printed circuit boards (PCBs) is a crucial step in ensuring product reliability. With the development of electronic manufacturing towards higher density and precision, PCB circuits are becoming increasingly intricate, and defect morphologies are becoming more complex and diverse, placing higher demands on defect detection technology.
[0003] Currently, PCB surface defect detection methods are mainly divided into three categories. Traditional detection methods include manual visual inspection, electrical testing, and automated optical inspection (AOI). Manual visual inspection is inefficient and highly subjective, and is easily affected by fatigue factors, leading to missed defects. Electrical testing, such as flying probe testing, can determine continuity, but may cause secondary damage to precision PCBs and cannot identify non-electrical surface defects such as scratches and oxidation. Although AOI equipment has achieved automation, its recognition rate for minute defects is often insufficient when dealing with PCBs with extremely small linewidths and complex background textures, making it difficult to meet the needs of actual production lines.
[0004] With the development of deep learning technology, convolutional neural network-based target detection algorithms, especially the YOLO series models, have been widely studied and applied to PCB defect detection due to their end-to-end detection characteristics and speed advantages. Existing research has improved detection performance to some extent by introducing attention mechanisms and improving feature pyramid structures. However, PCB surface images in real-world industrial scenarios often present the following challenges: First, defect scales vary drastically, ranging from micrometer-level scratches to millimeter-level foreign objects, making multi-scale feature extraction difficult; second, complex background textures interfere with defect features, leading to a decrease in feature representation ability; and third, some defects are easily occluded by surrounding components, resulting in missing feature information. Therefore, in these complex scenarios, existing solutions still suffer from insufficient accuracy in detecting surface defects on printed circuit boards.
[0005] Therefore, there is an urgent need for a method to detect surface defects on printed circuit boards that can improve the detection accuracy of surface defects on printed circuit boards in complex scenarios. Summary of the Invention
[0006] The main objective of this invention is to provide a method and system for detecting surface defects on printed circuit boards, aiming to solve the technical problem of insufficient detection accuracy of surface defects on printed circuit boards in complex scenarios using existing technologies.
[0007] To achieve the above objectives, the present invention provides a method for detecting surface defects on printed circuit boards, the method comprising the following steps: Acquire a surface image of the printed circuit board to be inspected; The surface image was used to perform defect detection using an improved YOLOv11 network model to obtain defect detection results. The improved YOLOv11 network model is a network model obtained by introducing an adaptive calibration convolution module, a context and spatial feature calibration network, and a self-enhancing attention detection head into the YOLOv11 network model. Based on the defect detection results, the category and location information of the defects in the surface image are determined.
[0008] Optionally, the step of using the improved YOLOv11 network model to perform defect detection on the surface image and obtain defect detection results includes: The surface image is used to extract features by introducing the adaptive calibration convolution module into the backbone network of the improved YOLOv11 network model, generating a multi-scale feature map. The multi-scale feature map is fused using the context and spatial feature calibration network to generate a fused feature map. The self-enhancing attention detection head is used to perform target classification and bounding box regression on the fused feature map to obtain defect detection results.
[0009] Optionally, the step of extracting features from the surface image and generating multi-scale feature maps by introducing the adaptive calibration convolution module into the backbone network of the improved YOLOv11 network model includes: Perform a splitting operation on the surface image to obtain a first sub-feature map and a second sub-feature map; The first sub-feature map is adaptively enhanced by the adaptive module to obtain the first intermediate feature map; Perform a first convolution transformation on the second sub-feature map to obtain a second intermediate feature map; The first intermediate feature map and the second intermediate feature map are concatenated to obtain a multi-scale feature map.
[0010] Optionally, the step of adaptively enhancing the first sub-feature map using an adaptive module to obtain the first intermediate feature map includes: The first sub-feature map is subjected to downsampling, second convolution transformation and upsampling operations in sequence to generate a reference feature map; The reference feature map is fused with the first sub-feature map, and calibration weights are generated using an activation function. The first sub-feature map is subjected to a third convolutional transformation to generate an initial convolutional feature map; The initial convolutional feature map is multiplied element-wise with the calibration weights to obtain the calibration feature map; The calibration feature map is subjected to a fourth convolutional transformation to obtain a first intermediate feature map.
[0011] Optionally, the context and spatial feature calibration network includes a context feature calibration sub-network and a spatial feature calibration sub-network; The step of fusing features from the multi-scale feature map using the context and spatial feature calibration network to generate a fused feature map includes: The multi-scale feature map is cascaded into pyramid pooling through the context feature calibration sub-network to obtain multi-scale context features. The correlation between the multi-scale feature map and the multi-scale context features is determined based on the attention mechanism, and the feature representation of the multi-scale feature map is adaptively adjusted according to the correlation to obtain the context calibration feature map. The spatial feature calibration sub-network divides the context calibration feature map into multiple feature groups along the channel dimension; For each feature group, a corresponding two-dimensional offset map is learned, and the channel features of the corresponding feature group are spatially resampled using the two-dimensional offset map; multiple resampled feature groups are obtained. The multiple resampled feature groups are fused to generate a fused feature map.
[0012] Optionally, the self-enhancing attention detection head includes depth-separable convolutional units, channel-spatial hybrid units, and fully connected networks; The step of performing target classification and bounding box regression on the fused feature map using the self-enhancing attention detection head to obtain defect detection results includes: The fused feature map is convolved channel-wise by the depthwise separable convolutional unit to generate channel-separated features. The channel separation features are extracted using the channel and spatial mixing unit to generate mixed features at multiple scales. The fully connected network is used to fuse inter-channel information of the hybrid features to generate attention weights. The attention weights are weighted together with the fused feature map to obtain a weighted feature map; Based on the weighted feature map, target classification and bounding box regression are performed to obtain defect detection results.
[0013] Optionally, before the step of acquiring the surface image of the printed circuit board to be inspected, the method further includes: Obtain a printed circuit board surface defect dataset, which includes sample images of printed circuit board surfaces labeled with defect categories; The YOLOv11 network model is improved to obtain an initial YOLOv11 network model, which includes an adaptive calibration convolutional module, a context and spatial feature calibration network, and a self-enhancing attention detection head. The initial YOLOv11 network model was trained based on the printed circuit board surface defect dataset to obtain the training results; Based on the training results, the model parameters of the initial YOLOv11 network model are optimized to obtain an improved YOLOv11 network model.
[0014] Optionally, the step of improving the YOLOv11 network model to obtain an initial YOLOv11 network model includes: The original convolutional module in the C3K2 module of the backbone network of the YOLOv11 network model is replaced with an adaptive calibration convolutional module to obtain the first intermediate network model. In the neck network of the first intermediate network model, the original feature pyramid network is replaced with a context and spatial feature calibration network to obtain the second intermediate network model. The original detector head of the second intermediate network model is replaced with a self-enhancing attention detector head to obtain the initial YOLOv11 network model.
[0015] Optionally, the step of training the initial YOLOv11 network model based on the printed circuit board surface defect dataset to obtain the training results includes: The initial YOLOv11 network model is trained based on a preset loss function and the printed circuit board surface defect dataset to obtain training results. The preset loss function includes bounding box regression loss, confidence loss, and class loss.
[0016] Furthermore, to achieve the above objectives, the present invention also proposes a printed circuit board surface defect detection system, the system comprising: The image acquisition module is used to acquire surface images of the printed circuit board to be inspected. The defect detection module is used to perform defect detection on the surface image using the improved YOLOv11 network model and obtain the defect detection result. The improved YOLOv11 network model is a network model obtained by introducing an adaptive calibration convolution module, a context and spatial feature calibration network and a self-enhancing attention detection head into the YOLOv11 network model. The result output module is used to determine the category and location information of defects in the surface image based on the defect detection results.
[0017] Furthermore, to achieve the above objectives, the present invention also proposes a printed circuit board surface defect detection device, the device comprising: a memory, a processor, and a printed circuit board surface defect detection program stored in the memory and executable on the processor, the printed circuit board surface defect detection program being configured to implement the steps of the printed circuit board surface defect detection method as described above.
[0018] In addition, to achieve the above objectives, the present invention also proposes a storage medium storing a printed circuit board surface defect detection program, wherein when the printed circuit board surface defect detection program is executed by a processor, it implements the steps of the printed circuit board surface defect detection method as described above.
[0019] This invention discloses a method for acquiring a surface image of a printed circuit board (PCB) to be inspected; performing defect detection on the surface image using an improved YOLOv11 network model to obtain defect detection results. The improved YOLOv11 network model is obtained by introducing an adaptive calibration convolution module, a context and spatial feature calibration network, and a self-enhancing attention detection head into the YOLOv11 network model. Based on the defect detection results, the category and location information of defects in the surface image are determined. Because this invention improves the YOLOv11 network model by introducing an adaptive calibration convolution module, a context and spatial feature calibration network, and a self-enhancing attention detection head, and then uses the improved YOLOv11 network model to perform defect detection on the surface image of the PCB to be inspected, compared with existing technologies, this invention improves the detection accuracy of PCB surface defects in complex scenarios. Attached Figure Description
[0020] Figure 1 This is a flowchart illustrating the first embodiment of the printed circuit board surface defect detection method of the present invention; Figure 2 This is a schematic diagram of the overall structure of the model in the printed circuit board surface defect detection method of the present invention; Figure 3 This is a schematic diagram of the adaptive calibration convolution structure and adaptive module structure in the printed circuit board surface defect detection method of the present invention. Figure 4 This is a schematic diagram of the context feature calibration subnetwork and cascaded pyramid pooling module in the printed circuit board surface defect detection method of the present invention. Figure 5 This is a flowchart illustrating the second embodiment of the printed circuit board surface defect detection method of the present invention; Figure 6 This is a flowchart illustrating the third embodiment of the printed circuit board surface defect detection method of the present invention; Figure 7This is a structural block diagram of the first embodiment of the printed circuit board surface defect detection system of the present invention; Figure 8 This is a schematic diagram of the structure of a printed circuit board surface defect detection device in the hardware operating environment involved in the embodiments of the present invention.
[0021] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0022] It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.
[0023] This invention provides a method for detecting surface defects on printed circuit boards, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the printed circuit board surface defect detection method of the present invention.
[0024] In this embodiment, the printed circuit board surface defect detection method includes steps S10~S30: Step S10: Obtain a surface image of the printed circuit board to be inspected.
[0025] It should be noted that the executing entity in this embodiment can be a computer server device with data processing, network communication, and program execution functions applied in the scenario of printed circuit board defect detection, such as a server, tablet computer, personal computer, etc., or an electronic device capable of realizing the above functions (such as a printed circuit board surface defect detection device). The following uses a system including a printed circuit board surface defect detection device (hereinafter referred to as the system) as an example to illustrate this embodiment and the following embodiments.
[0026] It should be understood that the aforementioned printed circuit boards to be inspected can refer to finished or semi-finished printed circuit boards that require surface defect quality inspection, such as motherboards used in communication equipment, circuit boards in automotive electronic control units, and high-speed multilayer boards in AI servers.
[0027] It is understood that the aforementioned surface image may refer to a digital image obtained by taking a picture of the surface of a printed circuit board through an image acquisition device, such as a grayscale image or a color image acquired by a high-resolution industrial camera in an automated optical inspection device.
[0028] In its implementation, the system actively or passively acquires surface images of the printed circuit board (PCB) to obtain the raw image data required for surface defect detection. Specifically, the system can directly control an industrial camera to photograph the PCB delivered to the inspection station via an internal or external image acquisition interface, and receive the image data returned by the camera after the photographing is completed. Alternatively, the system can read image files from a local database or network storage location that pre-stores PCB images, such as JPEG, PNG, or BMP image files. After acquiring the surface image, the system can temporarily store it in its internal memory for use in subsequent defect detection processing steps.
[0029] Step S20: Use the improved YOLOv11 network model to perform defect detection on the surface image and obtain the defect detection result. The improved YOLOv11 network model is a network model obtained by introducing an adaptive calibration convolution module, a context and spatial feature calibration network, and a self-enhancing attention detection head into the YOLOv11 network model.
[0030] It should be noted that the aforementioned adaptive calibration convolution module can refer to a convolutional structure with a self-calibration mechanism, which can perform convolutional feature transformations at different scales and learn local features and global contextual information, thereby enhancing the discriminative ability of the feature map.
[0031] The aforementioned context and spatial feature calibration network can refer to a network structure for optimizing feature fusion, which includes a context feature calibration subnetwork and a spatial feature calibration subnetwork, capable of extracting multi-scale context information and resampling and calibrating spatial features.
[0032] The aforementioned self-enhancing attention detection head can refer to an improved target detection head structure that integrates depthwise separable convolution, channel and spatial hybrid modules, and fully connected networks to enhance the model's sensitivity to occluded regions and small-sized defects.
[0033] For example, refer to Figure 2 , Figure 2This is a schematic diagram of the overall model structure in the printed circuit board surface defect detection method of the present invention. In the figure, the improved YOLOv11 network model is based on the YOLOv11 model architecture, with the C3K2 module reconstructed using an adaptive calibration convolutional module (SACConv module) to obtain the C3K2_SACConv module. Furthermore, the traditional FPN structure is optimized through CSFCN (Context and Spatial Feature Calibration Network), which includes two core modules—Contextual Feature Calibration (CFC) and Spatial Feature Calibration (SFC)—effectively improving feature fusion efficiency and the model's expressive power. Based on this, the detection head introduces SEAM (Adaptive Enhancement Module), constructing a self-enhancing attention detection head (SEAM-Head detection head), effectively improving the model's feature extraction capabilities in handling complex backgrounds, small defects, and occlusion conditions.
[0034] It should be understood that the aforementioned defect detection results may refer to the data set output by the improved YOLOv11 network model, which describes whether there are defects in the surface image and related defect information.
[0035] In its implementation, after acquiring the surface image of the printed circuit board to be inspected, the system inputs this image into a pre-built and trained improved YOLOv11 network model. Internally, the model processes the input surface image, enhancing feature extraction capabilities through an introduced adaptive calibration convolutional module, optimizing the fusion of multi-scale features through a context and spatial feature calibration network, and improving sensitivity to occlusion and small-sized defects through a self-enhancing attention detection head. After forward computation, the model outputs the defect detection result. The system receives this defect detection result and temporarily stores it in memory for subsequent processing.
[0036] It should be noted that the step of using the improved YOLOv11 network model to perform defect detection on the surface image and obtain defect detection results may include: extracting features from the surface image through the backbone network of the improved YOLOv11 network model that incorporates the adaptive calibration convolution module to generate a multi-scale feature map; fusing the multi-scale feature map through the context and spatial feature calibration network to generate a fused feature map; and performing target classification and bounding box regression on the fused feature map through the self-enhancing attention detection head to obtain defect detection results.
[0037] It should be understood that the aforementioned backbone network can refer to the basic network structure in the improved YOLOv11 network model responsible for extracting features from the input image, used to convert raw pixels into high-dimensional feature representations. The aforementioned multi-scale feature maps can refer to a set of feature maps with different spatial resolutions and channel numbers output at different levels of the backbone network. For example, lower-level feature maps retain more spatial detail information for detecting small defects, while higher-level feature maps contain stronger semantic information for detecting large defects.
[0038] It should be noted that the aforementioned context and spatial feature calibration network can refer to a network structure used to optimize feature fusion. This network includes a context feature calibration sub-network and a spatial feature calibration sub-network, capable of extracting multi-scale contextual information and resampling and calibrating spatial features. The aforementioned fused feature map can refer to the feature map output after processing by the context and spatial feature calibration network.
[0039] The aforementioned self-enhancing attention detection head can refer to an improved target detection head structure that integrates depthwise separable convolution, channel and spatial hybrid modules, and fully connected networks to enhance the model's sensitivity to occluded regions and small-sized defects.
[0040] Understandably, the aforementioned target classification can refer to the operation of predicting the defect category of each candidate region in the fused feature map, such as identifying whether the region belongs to the categories of "open circuit," "short circuit," or "scratch." The aforementioned bounding box regression can refer to the operation of predicting the precise bounding box coordinates of each candidate region in the fused feature map, such as predicting the coordinates of the center point, width, and height of the smallest rectangle surrounding the defect.
[0041] It should be noted that the step of extracting features from the surface image and generating multi-scale feature maps by introducing the adaptive calibration convolution module into the backbone network of the improved YOLOv11 network model may include: performing a splitting operation on the surface image to obtain a first sub-feature map and a second sub-feature map; adaptively enhancing the first sub-feature map through the adaptive module to obtain a first intermediate feature map; performing a first convolution transformation on the second sub-feature map to obtain a second intermediate feature map; and concatenating the first intermediate feature map and the second intermediate feature map to obtain a multi-scale feature map.
[0042] Further, the step of adaptively enhancing the first sub-feature map using an adaptive module to obtain a first intermediate feature map includes: sequentially performing downsampling, a second convolutional transformation, and an upsampling operation on the first sub-feature map to generate a reference feature map; fusing the reference feature map with the first sub-feature map and generating calibration weights through an activation function; performing a third convolutional transformation on the first sub-feature map to generate an initial convolutional feature map; performing element-wise multiplication of the initial convolutional feature map with the calibration weights to obtain a calibration feature map; and performing a fourth convolutional transformation on the calibration feature map to obtain the first intermediate feature map.
[0043] For example, refer to Figure 3 , Figure 3 This is a schematic diagram of the adaptive calibration convolution structure and adaptive module structure in the printed circuit board surface defect detection method of the present invention. Figure 3 (a) in the diagram is a schematic diagram of the adaptive calibration convolution module. This module receives a surface image (input feature X) (with dimensions C×H×W, where C is the number of channels, H is the height, and W is the width). X is split into two sub-feature maps X1 and X2 through a Split operation. X1 is input to the Self-Adaptive module and outputs the first intermediate feature map Z1 after processing. X2 is processed by Conv1 (first convolution transformation) to obtain the second intermediate feature map Zz. Then, the first intermediate feature map Z1 and the second intermediate feature map Zz are concatenated through a Concat operation to finally output the multi-scale feature map Z (with dimensions C×H×W).
[0044] Further, refer to Figure 3 (b) Figure 3 Figure (b) shows the structural diagram of the adaptive module. The adaptive module has two branches. In one branch, X1 undergoes a Downsample operation, a Conv2 operation, and an Upsample operation to generate a reference feature map. The reference feature map is then fused with X1 element-wise, and a calibration weight is generated using the Sigmoid activation function. The other branch performs a Conv3 operation on X1 to generate an initial convolutional feature map; the initial convolutional feature map is then multiplied element-wise with the calibration weights to obtain a calibration feature map; and a Conv4 operation is performed on the calibration feature map to obtain Z1.
[0045] It should be added that, Figure 3 P1, P2, P3, and P4 in the diagram represent different convolution kernels or transformation matrices corresponding to Conv1, Conv2, Conv3, and Conv4, respectively.
[0046] It should be noted that the step of fusing features of the multi-scale feature map through the context and spatial feature calibration network to generate a fused feature map includes: performing cascaded pyramid pooling on the multi-scale feature map through the context feature calibration sub-network to obtain multi-scale context features; determining the correlation between the multi-scale feature map and the multi-scale context features based on an attention mechanism, and adaptively adjusting the feature representation of the multi-scale feature map according to the correlation to obtain a context calibration feature map; dividing the context calibration feature map into multiple feature groups along the channel dimension through the spatial feature calibration sub-network; learning a corresponding two-dimensional offset map for each feature group, and using the two-dimensional offset map to spatially resample the channel features of the corresponding feature group; obtaining multiple resampled feature groups; and fusing the multiple resampled feature groups to generate a fused feature map.
[0047] For example, refer to Figure 4 , Figure 4 This is a schematic diagram of the context feature calibration subnetwork and cascaded pyramid pooling module in the printed circuit board surface defect detection method of the present invention. Figure 4 (a) in the diagram is a schematic diagram of the structure of the context feature calibration subnetwork and Figure 4 Image (b) shows the structural diagram of the Cascade Pyramid Pooling module. The Context Feature Calibration Subnetwork (CFC) uses Cascade Pyramid Pooling (CPP) to extract multi-scale contextual information and calculates the correlation between pixels and context through an attention mechanism, adaptively adjusting feature representation to improve the model's perception of target regions and enhance its adaptability to complex backgrounds. Compared with traditional methods, CFC optimizes the context matching process, enabling the model to utilize global information more accurately and avoiding over-smoothing of small targets due to improper context fusion.
[0048] Specifically, CFC performs pooling at multiple scales to extract contextual information from local to global, and dynamically adjusts the receptive field in conjunction with an attention mechanism.
[0049] For larger defect areas, CFC focuses on capturing the overall structure, while for minor defects, it emphasizes local details. The Spatial Feature Calibration Subnetwork (SFC) successfully addresses the problem of spatial feature misalignment by grouping feature maps along the channel dimension and calibrating each group independently. Specifically, SFC uses a learning-based 2D offset map to spatially resample features, thereby selecting the most relevant features for calibration at each location. This process preserves more spatial detail, especially when dealing with small objects and detailed features.
[0050] By integrating these two networks (CFC and SFC), CSFCN enhances the YOLOv11 network model's ability to detect PCB surface defects in the improved model (SCS-YOLO model for short), performing particularly well when handling small objects and complex details. The model's detection accuracy has been improved, especially in multi-scale defect detection, achieving an excellent balance between accuracy and performance.
[0051] It should be noted that the self-enhancing attention detection head (SEAM-Head) includes depthwise separable convolutional units, channel-spatial blending units, and a fully connected network. The adaptive enhancement module (SEAM module) in the self-enhancing attention detection head enhances the model's sensitivity to difficult-to-detect regions, especially occluded defect regions, by combining depthwise separable convolutional units, channel-spatial blending units, and a fully connected network.
[0052] In a specific implementation, the step of performing target classification and bounding box regression on the fused feature map using the self-enhancing attention detection head to obtain defect detection results may include: performing channel-wise convolution on the fused feature map using the depthwise separable convolutional unit to generate channel-separated features; performing multi-scale feature extraction on the channel-separated features using the channel and spatial blending unit to generate mixed features; fusing inter-channel information of the mixed features using the fully connected network to generate attention weights; weighting the attention weights with the fused feature map to obtain a weighted feature map; and performing target classification and bounding box regression based on the weighted feature map to obtain defect detection results.
[0053] The first part of the SEAM module introduces depth-separable convolution, which operates on each channel individually. This not only effectively reduces computational complexity but also enhances the importance of features from different channels. However, depth-separable convolution cannot capture the relationships between channels. To address this issue, the SEAM module fuses the outputs of convolutions at different depths using 1x1 convolutions, thereby restoring the correlation between channels.
[0054] The Channel and Spatial Hybridization Unit (CSMM) in the SEAM module performs multi-scale feature extraction on the channel separation features generated by the depthwise separable convolutional units and utilizes the depthwise separable convolutions to learn the correlation between spatial dimension and channels. The CSMM module not only strengthens the fusion of spatial and channel information but also helps the network better learn local and global features, thereby improving its ability to identify complex defects. Subsequently, the SEAM module uses two fully connected layers to fuse information from each channel, aiming to strengthen the interrelationships between channels and enabling the network to learn the relationship between occluded and unoccluded regions, thus compensating for feature loss caused by occlusion. To improve the model's tolerance to positional errors, the SEAM module exponentially normalizes the logits output of the fully connected layers (logits specifically refer to the unprobably normalized raw values output by the fully connected network in the SEAM module), expanding the value range from [0,1] to [1,e]. This normalization provides a monotonic mapping relationship, making the model more resistant to positional errors and thus enhancing the robustness of detection.
[0055] Finally, the output of the SEAM module is used as attention weights and weighted with the fused feature map, enabling the model to focus more on key areas, especially partially occluded defect areas. This weighting method improves the model's accuracy in PCB surface defect detection, particularly in complex occlusion scenarios.
[0056] Step S30: Based on the defect detection results, determine the category and location information of the defects in the surface image.
[0057] It should be noted that the aforementioned defect detection results may refer to the dataset output by the improved YOLOv11 network model, which describes whether there are defects in the surface image and related defect information. For example, it may include a list of multiple prediction boxes and their corresponding category labels, confidence scores, and bounding box coordinates.
[0058] Understandably, the aforementioned category information can refer to data describing the specific type of defect, such as defect category identifiers like "open circuit," "short circuit," "scratch," or "foreign object." The aforementioned location information can refer to data describing the spatial location of the defect in the surface image, typically including the coordinates of the center point, width, and height of the predicted bounding box, or the coordinates of the top-left and bottom-right corners of the bounding box.
[0059] In its implementation, after obtaining the defect detection results output by the improved YOLOv11 network model, the system parses and processes these results. The system extracts the category label corresponding to each detected defect from the defect detection results and determines this category label as the defect's category information. Simultaneously, the system extracts the bounding box coordinate data corresponding to each detected defect from the defect detection results and determines this bounding box coordinate data as the defect's location information in the surface image. Subsequently, the system can store the determined category and location information in the form of structured data, such as JSON or XML format data records, or overlay this information onto the original surface image to generate a visualized detection result image.
[0060] This embodiment discloses acquiring a surface image of a printed circuit board (PCB) to be inspected; performing defect detection on the surface image using an improved YOLOv11 network model to obtain defect detection results. The improved YOLOv11 network model is obtained by introducing an adaptive calibration convolution module, a context and spatial feature calibration network, and a self-enhancing attention detection head into the YOLOv11 network model. Based on the defect detection results, the category and location information of defects in the surface image are determined. Because this embodiment improves the YOLOv11 network model by introducing an adaptive calibration convolution module, a context and spatial feature calibration network, and a self-enhancing attention detection head, and then uses the improved YOLOv11 network model to perform defect detection on the surface image of the PCB to be inspected, compared to existing technologies, this embodiment improves the detection accuracy of PCB surface defects in complex scenarios.
[0061] refer to Figure 5 , Figure 5 This is a flowchart illustrating the second embodiment of the printed circuit board surface defect detection method of the present invention.
[0062] Based on the first embodiment described above, in this embodiment, before step S10, steps S01 to S04 are further included: Step S01: Obtain a printed circuit board surface defect dataset, which includes printed circuit board surface sample images with labeled defect categories.
[0063] Step S02: Improve the YOLOv11 network model to obtain an initial YOLOv11 network model, which includes an adaptive calibration convolution module, a context and spatial feature calibration network, and a self-enhancing attention detection head.
[0064] Step S03: Train the initial YOLOv11 network model based on the printed circuit board surface defect dataset to obtain the training results.
[0065] Step S04: Optimize the model parameters of the initial YOLOv11 network model based on the training results to obtain an improved YOLOv11 network model.
[0066] It should be explained that the aforementioned printed circuit board surface defect dataset can refer to an image dataset used to train or evaluate defect detection models. This dataset contains multiple images of printed circuit board surfaces and corresponding annotation information for each image. For example, the dataset could be the DsPCBSD+ dataset, containing 10,259 PCB surface images covering nine types of defects: short circuits, spikes, virtual copper, open circuits, rat bite marks, hole breakthroughs, conductor scratches, conductor foreign objects, and substrate foreign objects. The aforementioned printed circuit board surface sample images with labeled defect categories can refer to each printed circuit board surface image in the dataset that has been manually or automatically labeled with the category to which the defect belongs. The annotation information is usually stored in association with the image file in the form of bounding boxes or pixel masks. For example, each sample image corresponds to an XML or JSON format annotation file, which records the category name and location coordinates of each defect in the image.
[0067] In its implementation, the system needs to acquire the raw data for training the improved YOLOv11 network model before training the model. The system reads the printed circuit board surface defect dataset from local storage, external databases, or network resources. Specifically, the system can access a pre-defined dataset storage path and read all the printed circuit board surface sample image files and their corresponding annotation files contained in the dataset. During the reading process, the system parses each annotation file, obtains the category and location information of all defects in each sample image, and establishes a correlation between the image data and the corresponding annotation data. After completing the data reading, the system divides the printed circuit board surface defect dataset into a training set, a validation set, and a test set according to a preset ratio, for example, an 8:1:1 ratio, and caches the divided dataset in memory or stores it in a temporary folder for use in subsequent training steps.
[0068] It should be noted that the step of improving the YOLOv11 network model to obtain an initial YOLOv11 network model may include: replacing the original convolutional module in the C3K2 module of the backbone network of the YOLOv11 network model with an adaptive calibration convolutional module to obtain a first intermediate network model; replacing the original feature pyramid network with a context and spatial feature calibration network in the neck network of the first intermediate network model to obtain a second intermediate network model; and replacing the original detection head of the second intermediate network model with a self-enhancing attention detection head to obtain the initial YOLOv11 network model.
[0069] It should be added that, in the step of training the initial YOLOv11 network model based on the printed circuit board surface defect dataset, a stochastic gradient descent (SGD) optimizer can be used to optimize the model parameters of the initial YOLOv11 network model.
[0070] This embodiment discloses a method for acquiring a printed circuit board (PCB) surface defect dataset, which includes PCB surface sample images labeled with defect categories. An initial YOLOv11 network model is obtained by improving the YOLOv11 network model, which includes an adaptive calibration convolutional module, a context and spatial feature calibration network, and a self-enhancing attention detection head. The initial YOLOv11 network model is trained based on the PCB surface defect dataset to obtain training results. Based on the training results, the model parameters of the initial YOLOv11 network model are optimized to obtain an improved YOLOv11 network model. Compared to existing technologies, this embodiment improves the model's detection performance and generalization ability for PCB surface defects.
[0071] refer to Figure 6 , Figure 6 This is a flowchart illustrating the third embodiment of the printed circuit board surface defect detection method of the present invention.
[0072] Based on the above embodiments, in this embodiment, step S03 includes step S031: Step S031: Train the initial YOLOv11 network model based on the preset loss function and the printed circuit board surface defect dataset to obtain the training results. The preset loss function includes bounding box regression loss, confidence loss and category loss.
[0073] It should be explained that the aforementioned pre-defined loss function can refer to a mathematical function predefined before model training to measure the degree of difference between the model's prediction results and the ground truth labels. The aforementioned bounding box regression loss can refer to a loss component that measures the difference between the coordinates of the bounding boxes predicted by the model and the coordinates of the ground truth bounding boxes. For example, it can be calculated using the complete intersection-union loss function, which considers the overlap area between the predicted and ground truth boxes, the distance between their center points, and the consistency of their aspect ratios. The aforementioned confidence loss can refer to a loss component that measures the difference between the confidence score of each bounding box predicted by the model and the true confidence score. The true confidence score is usually determined based on the overlap between the predicted and ground truth boxes. The aforementioned category loss can refer to a loss component that measures the difference between the probability distribution of the defect categories predicted by the model and the true category labels, typically calculated using the cross-entropy loss function. The aforementioned training results can refer to the dataset of model parameter updates and loss value changes obtained through forward and backpropagation calculations after one or more rounds of model training.
[0074] In its implementation, after obtaining the initial YOLOv11 network model and the printed circuit board surface defect dataset, the system trains the initial YOLOv11 network model based on a preset loss function. Specifically, the system inputs training sample images from the printed circuit board surface defect dataset batch by batch into the initial YOLOv11 network model. The model performs forward propagation calculations on each image, outputting the predicted bounding box coordinates, confidence scores, and class probability distributions. Subsequently, the system calculates the loss value between the model output and the true annotations of the samples according to the preset loss function. The system first calculates the bounding box regression loss, measuring the positional deviation between the predicted bounding box and the true bounding box; then it calculates the confidence loss, measuring the accuracy of the model's judgment on whether each predicted box contains the target; and finally, it calculates the class loss, measuring the accuracy of the model's prediction of the defect category. The system adds these three loss components to obtain the total loss value. Based on the total loss value, the system calculates the gradients of each parameter in the model using the backpropagation algorithm and updates the model parameters using an optimizer (e.g., a stochastic gradient descent optimizer). The system repeats the above process, traversing the entire training dataset multiple times, recording the changes in the loss value in each round, and finally obtaining the set of model parameters after training as the training result.
[0075] To facilitate understanding, the following explanation uses examples, but does not impose specific limitations on this embodiment. For instance, assume that the above system is trained using 8208 training images from the DsPCBSD+ dataset. The preset loss function uses CIoU loss for bounding box regression, binary cross-entropy loss for confidence loss, and multi-class cross-entropy loss for class loss. The system sets the batch size to 32 and the training epochs to 300. In each epoch, the system inputs images batch by batch, calculates the values of the three loss components, and sums them. After 300 epochs of training, the system obtains the training results, which include the final weight parameters of each layer of the model and the loss value curves recorded during each epoch, for subsequent model optimization and evaluation.
[0076] The bounding box regression loss is calculated using the complete intersection-union ratio (CloU). CloU considers not only the intersection-union ratio (IoU) but also the consistency of the center point distance and aspect ratio. The formula for calculating CloU is: ; in, represents the square of the Euclidean distance between the center points of the predicted bounding box and the ground truth bounding box; c is the diagonal length of the smallest bounding rectangle containing both the predicted and ground truth bounding boxes; a is a weighting factor for the width and height terms; v measures the consistency of the aspect ratio between the predicted and ground truth bounding boxes, defined as: ; The final bounding box regression loss is given by the following formula: .
[0077] Secondly, the confidence loss is used to measure whether each predicted box contains the target and is adjusted according to the overlap between the box and the ground truth box.
[0078] The confidence loss formula is as follows: ; Where s² represents the number of grid divisions, and B is the number of prior boxes per grid. This indicates whether the i-th or j-th prior box is responsible for predicting the target (1 indicates yes, 0 indicates no). is the confidence value of the i-th box, representing the overlap between the predicted box and the ground truth box.
[0079] In addition, non-target confidence loss can be included to prevent the model from making incorrect predictions in areas without a target. The calculation formula is as follows: ; in, It is a weighting factor used to adjust the non-target confidence loss.
[0080] Finally, the category loss measures the difference between the predicted bounding box and the true category, and is calculated using the cross-entropy loss definition: ; in, It represents the predicted probability of bounding box i,j in category c. A flag indicating whether there is a goal (1 indicates a goal, 0 indicates no goal).
[0081] Ultimately, the preset loss function can be a weighted sum of the bounding box regression loss, confidence loss, and class loss described above: ; in, , and These represent the weights for the bounding box regression loss, confidence loss, and category loss, respectively. By optimizing these preset loss functions, the model can achieve better predictions in multiple aspects, including regression, confidence, and category, thereby improving the accuracy and robustness of object detection.
[0082] This embodiment discloses a method for acquiring a printed circuit board (PCB) surface defect dataset, which includes PCB surface sample images labeled with defect categories. An initial YOLOv11 network model is obtained by improving the YOLOv11 network model, which includes an adaptive calibration convolutional module, a context and spatial feature calibration network, and a self-enhancing attention detection head. The initial YOLOv11 network model is trained based on a preset loss function and the PCB surface defect dataset to obtain training results. The model parameters of the initial YOLOv11 network model are optimized based on the training results to obtain an improved YOLOv11 network model. Compared to existing technologies, this embodiment further improves the accuracy and robustness of PCB surface defects in complex scenarios.
[0083] Furthermore, embodiments of the present invention also propose a storage medium storing a printed circuit board surface defect detection program, wherein when the printed circuit board surface defect detection program is executed by a processor, it implements the steps of the printed circuit board surface defect detection method described above.
[0084] Reference Figure 7 , Figure 7 This is a structural block diagram of the first embodiment of the printed circuit board surface defect detection system of the present invention.
[0085] like Figure 7 As shown, the printed circuit board surface defect detection system proposed in this embodiment of the invention includes: an image acquisition module 801, a defect detection module 802, and a result output module 803.
[0086] The image acquisition module 801 is used to acquire a surface image of the printed circuit board to be inspected.
[0087] The defect detection module 802 is used to perform defect detection on the surface image using an improved YOLOv11 network model to obtain defect detection results. The improved YOLOv11 network model is a network model obtained by introducing an adaptive calibration convolution module, a context and spatial feature calibration network, and a self-enhancing attention detection head into the YOLOv11 network model.
[0088] The result output module 803 is used to determine the category and location information of defects in the surface image based on the defect detection results.
[0089] The defect detection module 802 is further configured to extract features from the surface image through the backbone network of the improved YOLOv11 network model, which incorporates the adaptive calibration convolution module, to generate a multi-scale feature map; to fuse the multi-scale feature map through the context and spatial feature calibration network to generate a fused feature map; and to perform target classification and bounding box regression on the fused feature map through the self-enhancing attention detection head to obtain the defect detection result.
[0090] The defect detection module 802 is further configured to perform a splitting operation on the surface image to obtain a first sub-feature map and a second sub-feature map; to perform adaptive enhancement on the first sub-feature map through an adaptive module to obtain a first intermediate feature map; to perform a first convolution transformation on the second sub-feature map to obtain a second intermediate feature map; and to perform a stitching process on the first intermediate feature map and the second intermediate feature map to obtain a multi-scale feature map.
[0091] The defect detection module 802 is further configured to perform downsampling, a second convolution transformation, and upsampling operations sequentially on the first sub-feature map to generate a reference feature map; fuse the reference feature map with the first sub-feature map and generate calibration weights through an activation function; perform a third convolution transformation on the first sub-feature map to generate an initial convolution feature map; perform element-wise multiplication of the initial convolution feature map with the calibration weights to obtain a calibration feature map; and perform a fourth convolution transformation on the calibration feature map to obtain a first intermediate feature map.
[0092] The context and spatial feature calibration network includes a context feature calibration subnetwork and a spatial feature calibration subnetwork.
[0093] The defect detection module 802 is further configured to perform cascaded pyramid pooling on the multi-scale feature map through the context feature calibration sub-network to obtain multi-scale context features; determine the correlation between the multi-scale feature map and the multi-scale context features based on an attention mechanism, and adaptively adjust the feature representation of the multi-scale feature map according to the correlation to obtain a context calibration feature map; divide the context calibration feature map into multiple feature groups along the channel dimension through the spatial feature calibration sub-network; learn a corresponding two-dimensional offset map for each feature group, and use the two-dimensional offset map to spatially resample the channel features of the corresponding feature group; obtain multiple resampled feature groups; and fuse the multiple resampled feature groups to generate a fused feature map.
[0094] The self-enhancing attention detection head includes depth-separable convolutional units, channel-spatial hybrid units, and a fully connected network.
[0095] The defect detection module 802 is further configured to perform channel-wise convolution on the fused feature map using the depthwise separable convolutional unit to generate channel-separated features; perform multi-scale feature extraction on the channel-separated features using the channel and spatial mixing unit to generate mixed features; perform inter-channel information fusion on the mixed features using the fully connected network to generate attention weights; weight the attention weights with the fused feature map to obtain a weighted feature map; and perform target classification and bounding box regression based on the weighted feature map to obtain defect detection results.
[0096] This system embodiment discloses acquiring a surface image of a printed circuit board (PCB) to be inspected; performing defect detection on the surface image using an improved YOLOv11 network model to obtain defect detection results. The improved YOLOv11 network model is obtained by introducing an adaptive calibration convolution module, a context and spatial feature calibration network, and a self-enhancing attention detection head into the YOLOv11 network model. Based on the defect detection results, the category and location information of defects in the surface image are determined. Because this system embodiment improves the YOLOv11 network model by introducing an adaptive calibration convolution module, a context and spatial feature calibration network, and a self-enhancing attention detection head, and then uses the improved YOLOv11 network model to perform defect detection on the surface image of the PCB to be inspected, compared to existing technologies, this system embodiment improves the detection accuracy of PCB surface defects in complex scenarios.
[0097] Based on the first embodiment of the printed circuit board surface defect detection system of the present invention, a second embodiment of the printed circuit board surface defect detection system of the present invention is proposed.
[0098] In this embodiment, the image acquisition module 801 is further configured to acquire a printed circuit board surface defect dataset, which includes printed circuit board surface sample images labeled with defect categories; improve the YOLOv11 network model to obtain an initial YOLOv11 network model, which includes an adaptive calibration convolution module, a context and spatial feature calibration network, and a self-enhancing attention detection head; train the initial YOLOv11 network model based on the printed circuit board surface defect dataset to obtain training results; and optimize the model parameters of the initial YOLOv11 network model according to the training results to obtain an improved YOLOv11 network model.
[0099] Other embodiments or specific implementations of the printed circuit board surface defect detection system of the present invention can be referred to the above-described method embodiments, and will not be repeated here.
[0100] This application provides a printed circuit board surface defect detection device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the printed circuit board surface defect detection method in the above embodiment 1.
[0101] The following is for reference. Figure 8 This document illustrates a structural schematic diagram of a printed circuit board surface defect detection device suitable for implementing embodiments of this application. The printed circuit board surface defect detection device in this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), and in-vehicle terminals (e.g., in-vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. Figure 8 The printed circuit board surface defect detection device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0102] like Figure 8As shown, the printed circuit board surface defect detection device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory 1002 or a program loaded from a storage device 1003 into a random access memory 1004. The random access memory 1004 also stores various programs and data required for the operation of the printed circuit board surface defect detection device. The processing unit 1001, the read-only memory 1002, and the random access memory 1004 are interconnected via a bus 1005. An input / output interface 1006 is also connected to the bus. Typically, the following systems can be connected to the input / output interface 1006: input devices 1007 including, for example, a touch screen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 1003 including, for example, magnetic tape, hard disk, etc.; and communication devices 1009. Communication device 1009 allows the printed circuit board surface defect detection equipment to communicate wirelessly or wiredly with other devices to exchange data. Although the figures show printed circuit board surface defect detection equipment with various systems, it should be understood that implementation or possession of all the systems shown is not required. More or fewer systems may be implemented alternatively.
[0103] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from read-only memory 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0104] The printed circuit board surface defect detection device provided in this application, employing the printed circuit board surface defect detection method in the above embodiments, can solve the technical problem of insufficient detection accuracy of printed circuit board surface defects in complex scenarios in the prior art. Compared with the prior art, the beneficial effects of the printed circuit board surface defect detection device provided in this application are the same as those of the printed circuit board surface defect detection method provided in the above embodiments, and other technical features in this printed circuit board surface defect detection device are the same as those disclosed in the method of the previous embodiment, and will not be repeated here.
[0105] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0106] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0107] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0108] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0109] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as read-only memory / random access memory, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0110] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.
Claims
1. A method for detecting surface defects on a printed circuit board, characterized in that, The method includes: Acquire a surface image of the printed circuit board to be inspected; The surface image was used to perform defect detection using an improved YOLOv11 network model to obtain defect detection results. The improved YOLOv11 network model is a network model obtained by introducing an adaptive calibration convolution module, a context and spatial feature calibration network, and a self-enhancing attention detection head into the YOLOv11 network model. Based on the defect detection results, the category and location information of the defects in the surface image are determined.
2. The method for detecting surface defects on printed circuit boards as described in claim 1, characterized in that, The step of using the improved YOLOv11 network model to perform defect detection on the surface image and obtain defect detection results includes: The surface image is used to extract features by introducing the adaptive calibration convolution module into the backbone network of the improved YOLOv11 network model, generating a multi-scale feature map. The multi-scale feature map is fused using the context and spatial feature calibration network to generate a fused feature map. The self-enhancing attention detection head is used to perform target classification and bounding box regression on the fused feature map to obtain defect detection results.
3. The method for detecting surface defects on printed circuit boards as described in claim 2, characterized in that, The step of extracting features from the surface image and generating multi-scale feature maps by introducing the adaptive calibration convolution module into the improved YOLOv11 network model includes: Perform a splitting operation on the surface image to obtain a first sub-feature map and a second sub-feature map; The first sub-feature map is adaptively enhanced by the adaptive module to obtain the first intermediate feature map; Perform a first convolution transformation on the second sub-feature map to obtain a second intermediate feature map; The first intermediate feature map and the second intermediate feature map are concatenated to obtain a multi-scale feature map.
4. The method for detecting surface defects on printed circuit boards as described in claim 3, characterized in that, The step of adaptively enhancing the first sub-feature map using an adaptive module to obtain the first intermediate feature map includes: The first sub-feature map is subjected to downsampling, second convolution transformation and upsampling operations in sequence to generate a reference feature map; The reference feature map is fused with the first sub-feature map, and calibration weights are generated using an activation function. The first sub-feature map is subjected to a third convolutional transformation to generate an initial convolutional feature map; The initial convolutional feature map is multiplied element-wise with the calibration weights to obtain the calibration feature map; The calibration feature map is subjected to a fourth convolutional transformation to obtain a first intermediate feature map.
5. The method for detecting surface defects on a printed circuit board as described in claim 2, characterized in that, The context and spatial feature calibration network includes a context feature calibration sub-network and a spatial feature calibration sub-network; The step of fusing features from the multi-scale feature map using the context and spatial feature calibration network to generate a fused feature map includes: The multi-scale feature map is cascaded into pyramid pooling through the context feature calibration sub-network to obtain multi-scale context features. The correlation between the multi-scale feature map and the multi-scale context features is determined based on the attention mechanism, and the feature representation of the multi-scale feature map is adaptively adjusted according to the correlation to obtain the context calibration feature map. The spatial feature calibration sub-network divides the context calibration feature map into multiple feature groups along the channel dimension; For each feature group, a corresponding two-dimensional offset map is learned, and the channel features of the corresponding feature group are spatially resampled using the two-dimensional offset map; multiple resampled feature groups are obtained. The multiple resampled feature groups are fused to generate a fused feature map.
6. The method for detecting surface defects on a printed circuit board as described in claim 2, characterized in that, The self-enhancing attention detection head includes depth-separable convolutional units, channel-spatial hybrid units, and a fully connected network; The step of performing target classification and bounding box regression on the fused feature map using the self-enhancing attention detection head to obtain defect detection results includes: The fused feature map is convolved channel-wise by the depthwise separable convolutional unit to generate channel-separated features. The channel separation features are extracted using the channel and spatial mixing unit to generate mixed features at multiple scales. The fully connected network is used to fuse inter-channel information of the hybrid features to generate attention weights. The attention weights are weighted together with the fused feature map to obtain a weighted feature map; Based on the weighted feature map, target classification and bounding box regression are performed to obtain defect detection results.
7. The method for detecting surface defects on a printed circuit board as described in claim 1, characterized in that, Before the step of acquiring the surface image of the printed circuit board to be inspected, the method further includes: Obtain a printed circuit board surface defect dataset, which includes sample images of printed circuit board surfaces labeled with defect categories; The YOLOv11 network model is improved to obtain an initial YOLOv11 network model, which includes an adaptive calibration convolutional module, a context and spatial feature calibration network, and a self-enhancing attention detection head. The initial YOLOv11 network model was trained based on the printed circuit board surface defect dataset to obtain the training results; Based on the training results, the model parameters of the initial YOLOv11 network model are optimized to obtain an improved YOLOv11 network model.
8. The method for detecting surface defects on a printed circuit board as described in claim 7, characterized in that, The steps for improving the YOLOv11 network model to obtain an initial YOLOv11 network model include: The original convolutional module in the C3K2 module of the backbone network of the YOLOv11 network model is replaced with an adaptive calibration convolutional module to obtain the first intermediate network model. In the neck network of the first intermediate network model, the original feature pyramid network is replaced with a context and spatial feature calibration network to obtain the second intermediate network model. The original detector head of the second intermediate network model is replaced with a self-enhancing attention detector head to obtain the initial YOLOv11 network model.
9. The method for detecting surface defects on a printed circuit board as described in claim 7, characterized in that, The step of training the initial YOLOv11 network model based on the printed circuit board surface defect dataset to obtain the training results includes: The initial YOLOv11 network model is trained based on a preset loss function and the printed circuit board surface defect dataset to obtain training results. The preset loss function includes bounding box regression loss, confidence loss, and class loss.
10. A printed circuit board surface defect detection system, characterized in that, The system includes: The image acquisition module is used to acquire surface images of the printed circuit board to be inspected. The defect detection module is used to perform defect detection on the surface image using the improved YOLOv11 network model and obtain the defect detection result. The improved YOLOv11 network model is a network model obtained by introducing an adaptive calibration convolution module, a context and spatial feature calibration network and a self-enhancing attention detection head into the YOLOv11 network model. The result output module is used to determine the category and location information of defects in the surface image based on the defect detection results.