BGA defect detection method based on lightweight cross-scale feature fusion
By introducing an adaptive downsampling module and a lightweight cross-scale feature fusion network, the YOLO-APGC model is designed, which solves the problem of accuracy and efficiency imbalance in BGA defect detection, and realizes efficient and lightweight BGA defect detection.
Patent Information
- Application Number
- CN202510632637.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-16
- Publication Date
- 2025-08-08
AI Technical Summary
The existing BGA defect detection methods have imbalance in accuracy and efficiency in terms of detection accuracy and detection efficiency, and it is difficult to meet the needs of industrial real-time and edge deployment.
The YOLO-APGC model is designed using the adaptive downsampling module (ADown) and the lightweight cross-scale feature fusion network (PG-CCFN). The ADown module retains macroscopic and tiny feature information, and combines the cross-scale feature fusion module CCFM to optimize the feature extraction and fusion process to reduce the calculation cost.
While enhancing the detection capability of small-target defects, significantly reducing calculation costs, improving the level of model lightweighting and detection efficiency, achieving a balance between high accuracy and high efficiency, it is suitable for BGA defect detection.
Smart Images

Figure CN120451677A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer vision technology, and in particular relates to a BGA defect detection method based on lightweight cross-scale feature fusion. Background Art
[0002] As electronic packaging technology evolves toward higher density and miniaturization, ball grid array (BGA) packaging has become a mainstream form of integrated circuit packaging due to its excellent electrical performance and space efficiency. However, during the manufacturing process, BGA solder balls are susceptible to fluctuations in process parameters, material properties, and environmental factors, leading to defects such as damage, burrs, oxidation, and bridging. These microscopic defects can significantly reduce BGA solder ball reliability and even cause circuit board failure. Therefore, implementing high-precision and efficient solder ball defect detection methods during production is crucial to improving product quality.
[0003] BGA solder ball surface defect detection methods can be divided into traditional defect detection methods, machine learning-based detection methods, and new detection methods driven by deep learning. Traditional defect detection methods are mainly based on image processing (such as edge detection and template matching) and geometric analysis to achieve detection. This method has low computational complexity and does not require a large amount of labeled data. However, this method relies on manual parameter adjustment, which is computationally intensive when processing high-resolution images, easily leading to delays and slowing down overall production progress. Because traditional defect detection methods cannot meet the needs of industrial production line inspection, machine learning-based methods are gradually being applied to the defect detection field.
[0004] Machine learning methods, combining feature engineering with classification algorithms, offer a high-precision, low-cost solution for BGA solder ball defect detection. However, traditional machine learning methods require manual geometric feature extraction, which can lead to loss of defect information. Furthermore, clustering parameters must be adjusted for different scenarios, lacking adaptability. To overcome the limitations of manual feature extraction, deep learning has achieved a technological breakthrough through automated feature learning and end-to-end optimization.
[0005] The application of deep learning in defect detection has undergone a remarkable evolution, evolving from traditional image processing to multimodal fusion. This has resulted in a technological ecosystem centered around two-stage and single-stage detection models. Two-stage object detection models first generate candidate frames for a region and extract features from each candidate frame. Ultimately, they generate a location frame and predict the corresponding category. These models offer high detection accuracy and are suitable for scenes with complex backgrounds, but their high computational complexity makes them difficult to meet real-time requirements. Single-stage detection models directly predict category and location on the entire image using an end-to-end approach. While these models achieve high inference speed thanks to their end-to-end architecture, their dense prediction mechanism is susceptible to background interference, resulting in high false positive rates. Recently proposed object detection models based on the Transformer architecture effectively model global context, making them suitable for tasks such as object detection and machine translation. They can also be easily scaled to large models by adjusting the number of layers. However, these models suffer from slow training convergence, require extensive training with large amounts of data, and exhibit low accuracy for small object recognition.
[0006] As the accuracy of object detection models continues to improve, their structures become increasingly complex, leading to a sharp increase in computational costs and making them difficult to apply in real-world industrial detection scenarios. Consequently, researchers have been proposing lightweighting strategies. Initially, researchers focused on model compression, effectively reducing computational costs through techniques such as quantization and pruning (structured and unstructured pruning). However, pruning can compromise network integrity, leading to the loss of key features and a significant decrease in detection accuracy for small objects. Subsequently, knowledge distillation emerged. This transfers knowledge from a teacher model (a complex network) to a student model (a lightweight network), improving the performance of the smaller student model. However, this design is highly dependent on the teacher model. If the teacher model itself performs poorly, the performance of the student model after transfer can deteriorate, not improve, and deployment requirements are relatively stringent. Currently, researchers are optimizing model parameters from the source, proposing lightweight network designs that reduce computational costs and improve detection efficiency while maintaining model accuracy. These networks include MobileNet, ShuffleNet, and GhostNet. MobileNet suffers from semantic loss due to increased channels and reduced spatial dimensions. While it significantly improves efficiency in resource-constrained scenarios, its accuracy is slightly lower than that of fully convolutional models, and its performance is relatively limited in complex tasks. ShuffleNet's reduced input channels for a single convolution kernel reduces its information extraction capabilities. GhostNet excels in balancing efficiency and accuracy, but the fixed size of linear operations within the module limits the potential for diverse feature transformations. Furthermore, accuracy decreases significantly when the width factor is too large.
[0007] Overall, existing BGA defect detection methods have achieved significant progress in accuracy and efficiency, but an imbalance between accuracy and efficiency still exists. Industrial BGA defect detection deployment must meet the demands of both high precision and real-time performance. To address this balancing act, a lightweight and high-precision BGA defect detection solution is urgently needed. Summary of the Invention
[0008] In order to solve the problems of large number of parameters, high computational complexity, and difficulty in meeting industrial real-time and edge deployment requirements in BGA surface defect detection, the present invention provides a BGA defect detection method based on lightweight cross-scale feature fusion.
[0009] A BGA defect detection method based on lightweight cross-scale feature fusion of the present invention comprises the following steps:
[0010] Step 1: Obtain a BGA defect image and mark the defect image.
[0011] Step 2: Introduce ADown (Adaptive Downsampling) into the backbone network, design a lightweight cross-scale feature fusion network PG-CCFN (Partial Group-shuffle Cross-scale Feature Fusion Network), and propose a YOLO-APGC model based on YOLOv8.
[0012] Step 3: Use the BGA defect image training set to train the improved algorithm model.
[0013] Step 4: Pass the defect image test set into the trained model, record the detection results and evaluate the model performance.
[0014] Furthermore, step 1 is specifically as follows: obtaining a BGA solder ball defect dataset, using the Labelimg tool to annotate the dataset images, and generating a label file in TXT format.
[0015] Furthermore, the YOLO-APGC model in step 2 is specifically:
[0016] The dataset is input into the backbone network and passes through a four-level ADown downsampling module, each followed by a PP-Block (DoublePartial-Block) module. The ADown downsampling module retains both macro and micro feature information through a dual-path heterogeneous design and feature retention mechanism. The PP-Block module reduces the amount of computation by splitting the channel through partial convolution PartialConv and optimizes the gradient flow through residual connection to prevent information loss. The output result is then transmitted to the neck network after the spatial pyramid pooling SPPF operation.
[0017] In the neck network, a lightweight cross-scale dynamic feature fusion network PG-CCFN with the cross-scale feature fusion module CCFM as the core is designed; first, the multi-scale feature map output by the backbone network is subjected to 1×1 convolution, with the unified channel number being 256 to eliminate redundant information; then, cross-scale dual-path fusion is performed: high-level features are upsampled, spliced with middle-level features, and fused with the PP-Block module; upsampling is continued, spliced with shallow-level features, and optimized through the PP-Block module to generate high-resolution features and retain tiny defect details; shallow-level features are downsampled through grouped shuffled convolution GSConv, spliced with middle-level features, and fused with the PP-Block module to enhance global semantic expression; the fused feature map is grouped by channels, local features are extracted through depthwise separable convolution within the group, and global interaction is achieved through channel shuffling across groups. Finally, three groups of feature maps of different scales are output to the detection head, and the defect classification and location information in the detection image are output in the detection head.
[0018] Furthermore, the ADown downsampling module first achieves feature smoothing by performing an average pooling operation on the input feature map; after average pooling, the channel dimension of the feature map is divided into two parts: one part undergoes a 3×3 convolution operation; the other part first undergoes a maximum pooling operation and then undergoes a 1×1 convolution operation to extract high-frequency features; finally, the two processed parts are connected to output a feature map with both low-frequency and high-frequency features.
[0019] Furthermore, the CCFM module achieves efficient interaction of multi-scale features through dual-path fusion of top-down and bottom-up. The input high-level, middle-level, and shallow-level feature maps are first unified to 256 channels through 1×1 convolution, and then enter dual-path fusion: the high-level features are upsampled to 40×40 through bilinear interpolation, spliced with the compressed middle-level features, fused through the C2f module, and further upsampled to 80×80, spliced with the shallow-level features, and high-resolution features are generated through the C2f module; the shallow-level features are downsampled to 40×40 through 3×3 convolution, spliced with the middle-level features, and fused with the C2f module; they are further downsampled to 20×20, spliced and fused with the high-level features.
[0020] Furthermore, in the PP-Block module, the input feature map first undergoes 1×1 convolution processing, and then the channel is divided into two parts, one of which is directly retained as a skip connection, and the other is used for subsequent multi-level feature processing; the incoming feature map separates the channel again, one part of which is directly passed, and the other part undergoes two partial convolutions PartialConv to extract local features; after the processed features are spliced with other branches, they are processed by 1×1 convolution to fuse the information of all channels and integrate the semantics of different paths.
[0021] PartialConv performs convolution calculations on only a subset of the input channels, where 75% of the channels are retained and only 25% are involved in the calculation.
[0022] Furthermore, in the grouped shuffled convolution GSConv, the input features are first subjected to a 1×1 standard convolution to compress the number of input channels to half, and the compressed features are subjected to a depth-wise convolution DWConv operation. The depth-wise convolution is split into multiple independent single-channel feature maps according to the channel dimension. Each group performs a 3×3 convolution operation, and each convolution kernel only completes the convolution of a single input channel to obtain a feature map. Then, multiple feature maps are stacked to obtain an output with the same input depth; the output is spliced with the output of the previous 1×1 convolution along the channel dimension to restore the target number of channels.
[0023] Furthermore, step 3 is as follows: after improving the YOLOv8 model, the YOLO-APGC model is trained: the size of the input image is set to 640×640 pixels, the initial learning rate and the final learning rate are both set to 0.01, the number of iterations is 300 cycles, and the batch size is set to 16.
[0024] Furthermore, the model performance index in step 4 is:
[0025] In terms of detection accuracy, the mean average precision (mAP) is used as the evaluation indicator, which is defined as follows:
[0026]
[0027] Among them, Precision refers to the proportion of actual samples among all targets detected as positive samples; Recall refers to the proportion of targets detected as positive samples among all actual positive samples; TP represents the number of correctly detected defects, that is, defects that actually exist and are correctly predicted by the model; FP represents the number of falsely detected defects, that is, areas without defects that are incorrectly predicted as defects by the model; FN represents the number of missed defects, that is, defects that actually exist but are not detected by the model; P(R) represents the PR curve of the model, N class is the number of defect categories; AP i It represents the average classification accuracy of the i-th category.
[0028] In terms of computing efficiency, parameters, GFLOPs, and inference speed (FPS) are used as evaluation indicators. Parameters represents the total number of trainable model parameters and measures the model storage and transmission costs. Calculation represents the floating-point operations required for forward reasoning and reflects the model's computational complexity. Inference speed represents the number of image frames processed per second and determines the real-time performance of production line inspections. Specific definitions are as follows:
[0029] FLOPs = 2 × H out ×Wout ×K 2 ×C in ×C out
[0030] GFLOPs = 10 9 FLOPs
[0031]
[0032] Among them, H out , W out Represent the height and width of the output feature map respectively; K represents the size of the convolution kernel; C in ,C out They represent the number of input and output channels respectively; pre is the preprocessing time of the model, including the time consumed by image scaling, padding and channel conversion; inference is the inference time of the model, that is, the forward calculation time of the model; post refers to the time occupied by the model decoding output, non-maximum suppression NMS, and result visualization operations.
[0033] The beneficial technical effects of the present invention are:
[0034] The YOLO-APGC algorithm for BGA surface solder ball defect detection proposed in this invention significantly reduces computational costs while enhancing small target defect detection capabilities by designing an adaptive downsampling module (ADown) and a lightweight cross-scale dynamic feature fusion network (PG-CCFN). The feature extraction and fusion processes are optimized, further improving the model's lightweight level and detection efficiency. A comparison with mainstream target detection algorithms on a self-built BGA defect dataset verifies the superiority and effectiveness of the YOLO-APGC model in the BGA defect detection process. This invention provides a new lightweight solution for BGA solder ball defect detection, demonstrating significant advantages in model efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 This is the framework diagram of the YOLO-APGC model proposed in the present invention.
[0036] Figure 2 This is the ADown structure diagram.
[0037] Figure 3 This is the structure diagram of the cross-scale feature fusion module CCFM.
[0038] Figure 4 This is the PP-Block structure diagram.
[0039] Figure 5 This is the PartialConv structure diagram.
[0040] Figure 6This is the GSConv structure diagram.
[0041] Figure 7 This is the DWConv structure diagram.
[0042] Figure 8 Detection effect diagram of the experimental BGA defect dataset ((a) damage; (b) burr; (c) oxidation; (d) solder ball bridging; (e) solder ball missing). DETAILED DESCRIPTION
[0043] The present invention will be further described in detail below with reference to the accompanying drawings and specific implementation methods.
[0044] The present invention provides a BGA defect detection method based on lightweight cross-scale feature fusion, specifically:
[0045] Step 1: Obtain a BGA defect image and mark the defect image.
[0046] Obtain a BGA solder ball defect dataset, use the Labelimg tool to annotate the dataset images, and generate a label file in TXT format.
[0047] Step 2: Introduce ADown into the backbone network, design a lightweight cross-scale feature fusion network PG-CCFN, and propose a YOLO-APGC model based on YOLOv8.
[0048] The YOLO-APGC model framework is as follows Figure 1 As shown, specifically:
[0049] The dataset is input into the backbone network and passes through four levels of ADown downsampling modules, each followed by a PP-Block module. The ADown downsampling module uses a dual-path heterogeneous design and a feature preservation mechanism to simultaneously preserve both macro- and micro-feature information. The PP-Block module uses partial convolution (PartialConv) to split channels (retaining 75% of the channels and only 25% participating in the calculation), reducing computational effort. It also optimizes gradient flow through residual connections to prevent information loss. After spatial pyramid pooling (SPPF), the output is transmitted to the neck network. Within the neck network, a lightweight dynamic cross-scale feature fusion network (PartialGroup-shuffle Cross-scale Feature Fusion Network, PG-CCFN) is designed, centered around the cross-scale feature fusion module (CCFM). First, 1×1 convolutions are performed on the multi-scale feature maps output by the backbone network, unifying the number of channels to 256 to eliminate redundant information. This process then undergoes a cross-scale dual-path fusion process: high-level features are upsampled, concatenated with mid-level features, and then fused with the PP-Block module. Further upsampling occurs, concatenated with shallow-level features, and optimized through the PP-Block module to generate high-resolution features that preserve minute defect details. Shallow-level features are downsampled through GSConv, concatenated with mid-level features, and then fused with the PP-Block module to enhance global semantic expression. The fused feature maps are grouped by channels, and local features are extracted within each group through depthwise separable convolution. Global interaction is achieved across groups through channel shuffling. Finally, three sets of feature maps at different scales are output to the detection head, which outputs defect classification and location information in the detected image.
[0050] The ADown downsampling module is introduced into the backbone network to replace the original convolution. The ADown module structure is as follows: Figure 2 . First, feature smoothing is achieved by performing an average pooling operation on the input feature map to reduce interference such as reflections. After average pooling, the channel dimension of the feature map is divided into two parts. One part performs a 3×3 convolution operation, which is responsible for low-frequency feature extraction and extracting the macro features of the solder balls. The other part first performs a maximum pooling operation, and then undergoes a 1×1 convolution process, which is responsible for high-frequency feature extraction. Maximum pooling can emphasize the main features and enhance the model's ability to extract tiny features. Finally, the two processed parts are connected to output a feature map with both low-frequency and high-frequency features. This structure improves the model's anti-interference ability while retaining the characteristics of the original features to the greatest extent, while effectively reducing the computational cost of the model.
[0051] CCFM structure is as follows Figure 3As shown in Figure 2, the CCFM module achieves efficient interaction of multi-scale features through dual-path fusion, top-down and bottom-up. The input high-level (20×20×1024), mid-level (40×40×512), and shallow-level (80×80×256) feature maps are first subjected to 1×1 convolution to unify the channel size to 256. They then enter dual-path fusion: high-level features are upsampled to 40×40 via bilinear interpolation, concatenated with the compressed mid-level features, fused via the C2f module, and further upsampled to 80×80. These features are then concatenated with the shallow-level features, and high-resolution features are generated via the C2f module. Shallow-level features are downsampled to 40×40 via 3×3 convolution, concatenated with the mid-level features, and fused with the C2f module. They are further downsampled to 20×20, concatenated with the high-level features, and fused.
[0052] The present invention proposes a PP-Block module to reduce feature map redundancy and applies it to the global network. The PP-Block module structure is as follows Figure 4 As shown. The input feature map is first processed by 1×1 convolution to adjust the number of channels and fuse low-level features such as edges and textures with deep features. The channel is then divided into two parts, one of which is directly retained as a jump connection to avoid loss of details due to multiple convolutions. The other branch is used for subsequent multi-level feature processing. The incoming feature map is separated into channels again, one part of which is directly passed to avoid the calculation of redundant information, and the other part is subjected to two partial convolutions (PartialConv) to extract local features. Partial convolution is as shown Figure 5 As shown, this is a lightweight convolution design. Its core concept is to perform convolution calculations on only a subset of the input channels to reduce computational effort and minimize information loss. In this case, 75% of the channels are retained, and only 25% are used for computation. After concatenating the processed features with the other branches, a 1×1 convolution is performed to fuse information from all channels, integrating the semantics of different paths.
[0053] The structure of Group shuffle Convolution (GSConv) is as follows Figure 6 The input features are first subjected to 1×1 standard convolution to compress the number of input channels to half, and the compressed features are subjected to depthwise convolution (DWConv) operation. Figure 7 , splitting the image into multiple independent single-channel feature maps along the channel dimension. Each group undergoes a 3×3 convolution operation, with each convolution kernel performing convolution on only a single input channel to obtain a feature map. Multiple feature maps are then stacked to produce an output with the same input depth. The output is concatenated with the output of the previous 1×1 convolution along the channel dimension to restore the target number of channels. The concatenated feature tensor is then dimensionalized and reorganized to break down channel grouping barriers, ensuring information exchange between different sub-channels and enhancing feature diversity.
[0054] Step 3: Use the BGA defect image training set to train the improved algorithm model.
[0055] After improving the YOLOv8 model, the YOLO-APGC model was trained: the size of the input image was set to 640×640 pixels, the initial and final learning rates were both set to 0.01, the number of iterations was 300 epochs, and the batch size was set to 16.
[0056] Step 4: Pass the defect image test set into the trained model, record the detection results and evaluate the model performance.
[0057] The model performance indicators are:
[0058] In terms of detection accuracy, the mean average precision (mAP) is used as the evaluation indicator, which is defined as follows:
[0059]
[0060] Among them, Precision refers to the proportion of actual samples among all targets detected as positive samples, and Recall refers to the proportion of targets detected as positive samples among all actual positive samples. TP (TruePositive) represents the number of defects detected correctly, that is, defects that actually exist and are correctly predicted by the model. FP (FalsePositive) represents the number of defects detected incorrectly, that is, areas without defects are incorrectly predicted as defects by the model. FN (FalseNegative) represents the number of defects missed, that is, defects that actually exist but are not detected by the model. P(R) represents the PR curve of the model, N class is the number of defect categories (N class =5). AP i It represents the average classification accuracy of the i-th category.
[0061] In terms of computational efficiency, parameters, GFLOPs, and inference speed (FPS) are used as evaluation indicators. Parameters represent the total number of trainable model parameters and measure the model's storage and transmission costs. GFLOPs represents the floating-point operations required for forward reasoning, reflecting the model's computational complexity. Inference speed represents the number of image frames processed per second, which determines the real-time performance of production line inspections. The specific definitions are as follows:
[0062] FLOPs = 2 × H out ×W out ×K 2 ×C in ×C out
[0063] GFLOPs = 10 9 FLOPs
[0064]
[0065] Among them, H out , W out Represent the height and width of the output feature map respectively; K represents the size of the convolution kernel; C in ,C out They represent the number of input and output channels respectively; pre is the preprocessing time of the model, including the time consumed by image scaling, padding, and channel conversion; inference is the inference time of the model, that is, the forward calculation time of the model; post refers to the time occupied by the model decoding output, non-maximum suppression (NMS), and result visualization operations.
[0066] Experimental verification:
[0067] The method proposed in this paper is compared with the mainstream target detection algorithm by testing on the self-built BGA defect dataset and the PCB public dataset. The comparison results of this method on the BGA dataset are shown in Table 1, and the comparison results on the PCB dataset are shown in Table 2. The detection effect of this method is as follows Figure 8 shown.
[0068] Table 1 Performance comparison experiment on BGA dataset
[0069]
[0070] Table 2 Performance comparison experiment on PCB dataset
[0071]
[0072]
[0073] Combining the experimental data in Table 1 (BGA dataset) and Table 2 (PCB dataset), the proposed method outperforms the competing algorithms in terms of lightweightness, real-time performance, and precision-efficiency balance. Its parameter count is 0.95M, a 68.2% reduction compared to the YOLOv8 baseline model and lower than all competing models (including the lightweight YOLOv5 at 1.77M), demonstrating that the model significantly reduces parameter redundancy through structural optimization. Its GFLOPs is 3.7, a 54.3% reduction compared to the baseline model, demonstrating a significant computational efficiency advantage. The proposed method achieves the lowest parameter and computational load, achieving superior compression ratios compared to similar lightweight models (YOLOv5 / YOLOv10), laying the foundation for edge deployment. On the BGA defect dataset, the mAP@0.5 score is 0.988, a 0.7% improvement over the baseline model. While its accuracy is lower than the highest-performing YOLOv10 (0.99), its parameter count is only 35.2% of the latter, and its mAP@0.5-0.95 score is higher than all competing models. The proposed method demonstrated excellent transfer performance on a public PCB defect dataset, achieving a mAP@0.5 score of 0.986, only 0.6% lower than the top-performing YOLOv10. This significantly reduces the number of parameters and computational complexity, demonstrating that the model maintains high detection accuracy while achieving an optimal lightweight design and speed-accuracy balance. The proposed method outperformed other comparison models in inference speed on both datasets, demonstrating excellent real-time detection performance.
Claims
1. A BGA defect detection method based on lightweight cross-scale feature fusion, characterized in that: The following steps are involved: Step 1: Obtain BGA defect images and mark the defect images; Step 2: Introduce ADown into the backbone network, design a lightweight cross-scale feature fusion network PG-CCFN, and propose a YOLO-APGC model based on YOLOv8; Step 3: Use the BGA defect image training set to train the improved algorithm model; Step 4: Pass the defect image test set into the trained model, record the detection results and evaluate the model performance.
2. The BGA defect detection method based on lightweight cross-scale feature fusion according to claim 1 is characterized in that: The step 1 specifically includes: obtaining a BGA solder ball defect dataset, using the Labelimg tool to annotate the dataset images, and generating a label file in TXT format.
3. The BGA defect detection method based on lightweight cross-scale feature fusion according to claim 1 is characterized in that: The YOLO-APGC model in step 2 is specifically: The dataset is input into the backbone network and passes through a four-stage ADown downsampling module, each followed by a PP-Block module. The ADown downsampling module uses a dual-path heterogeneous design and feature retention mechanism to preserve both macro and micro features. The PP-Block module uses partial convolution (PartialConv) to split channels to reduce computational complexity and uses residual connections to optimize gradient flow and prevent information loss. The output is then transmitted to the neck network after spatial pyramid pooling (SPPF). In the neck network, a lightweight cross-scale dynamic feature fusion network PG-CCFN with the cross-scale feature fusion module CCFM as the core is designed; first, the multi-scale feature map output by the backbone network is subjected to 1×1 convolution, with the unified channel number being 256 to eliminate redundant information; then, cross-scale dual-path fusion is performed: high-level features are upsampled, spliced with middle-level features, and fused with the PP-Block module; upsampling is continued, spliced with shallow-level features, and optimized through the PP-Block module to generate high-resolution features and retain tiny defect details; shallow-level features are downsampled through grouped shuffled convolution GSConv, spliced with middle-level features, and fused with the PP-Block module to enhance global semantic expression; the fused feature map is grouped by channels, local features are extracted through depthwise separable convolution within the group, and global interaction is achieved through channel shuffling across groups. Finally, three groups of feature maps of different scales are output to the detection head, and the defect classification and location information in the detection image are output in the detection head.
4. The BGA defect detection method based on lightweight cross-scale feature fusion according to claim 3 is characterized in that: The ADown downsampling module first achieves feature smoothing by performing an average pooling operation on the input feature map; after average pooling, the channel dimension of the feature map is divided into two parts: one part undergoes a 3×3 convolution operation; the other part first undergoes a maximum pooling operation and then undergoes a 1×1 convolution process to extract high-frequency features; finally, the two processed parts are connected to output a feature map with both low-frequency and high-frequency features.
5. The BGA defect detection method based on lightweight cross-scale feature fusion according to claim 3 is characterized in that: The CCFM module achieves efficient interaction of multi-scale features through dual-path fusion of top-down and bottom-up. The input high-level, mid-level, and shallow-level feature maps are first unified to 256 channels through 1×1 convolution and then enter the dual-path fusion: The high-level features are upsampled to 40×40 through bilinear interpolation, concatenated with the compressed middle-level features, fused through the C2f module, and further upsampled to 80×80, concatenated with the shallow-level features, and high-resolution features are generated through the C2f module; the shallow-level features are downsampled to 40×40 through 3×3 convolution, concatenated with the middle-level features, and fused with the C2f module; they are further downsampled to 20×20, concatenated and fused with the high-level features.
6. The BGA defect detection method based on lightweight cross-scale feature fusion according to claim 3 is characterized in that: In the PP-Block module, the input feature map first undergoes 1×1 convolution processing, and then the channel is divided into two parts, one of which is directly retained as a skip connection, and the other is used for subsequent multi-level feature processing; the incoming feature map is separated into channels again, one part of which is directly passed, and the other part undergoes two partial convolutions PartialConv to extract local features; after the processed features are spliced with other branches, they are processed by 1×1 convolution to fuse the information of all channels and integrate the semantics of different paths; The partial convolution PartialConv performs convolution calculation on only a subset of the input channels, where 75% of the channels are retained and only 25% are involved in the calculation.
7. The BGA defect detection method based on lightweight cross-scale feature fusion according to claim 3 is characterized in that: In the grouped shuffled convolution GSConv, the input features are first subjected to a 1×1 standard convolution to compress the number of input channels to half, and the compressed features are subjected to a depthwise convolution DWConv operation. The depthwise convolution is split into multiple independent single-channel feature maps according to the channel dimension. Each group performs a 3×3 convolution operation, and each convolution kernel only completes the convolution of a single input channel to obtain a feature map. Then, multiple feature maps are stacked to obtain an output with the same input depth; the output is spliced with the output of the previous 1×1 convolution along the channel dimension to restore the target number of channels.
8. The BGA defect detection method based on lightweight cross-scale feature fusion according to claim 1, characterized in that: Specifically, step 3 is as follows: after improving the YOLOv8 model, the YOLO-APGC model is trained: the size of the input image is set to 640×640 pixels, the initial learning rate and the final learning rate are both set to 0.01, the number of iterations is 300 cycles, and the batch size is set to 16.
9. The BGA defect detection method based on lightweight cross-scale feature fusion according to claim 1, characterized in that: The model performance index in step 4 is: In terms of detection accuracy, the mean average precision (mAP) is used as the evaluation indicator, which is defined as follows: Among them, Precision refers to the proportion of actual samples among all targets detected as positive samples; Recall refers to the proportion of targets detected as positive samples among all actual positive samples; TP represents the number of correctly detected defects, that is, defects that actually exist and are correctly predicted by the model; FP represents the number of falsely detected defects, that is, areas without defects that are incorrectly predicted as defects by the model; FN represents the number of missed defects, that is, defects that actually exist but are not detected by the model; P(R) represents the PR curve of the model, N class is the number of defect categories; AP i represents the average classification accuracy of the i-th category; In terms of computing efficiency, parameters, GFLOPs, and inference speed (FPS) are used as evaluation indicators. Parameters represents the total number of trainable model parameters and measures the model storage and transmission costs. Calculation represents the floating-point operations required for forward reasoning and reflects the model's computational complexity. Inference speed represents the number of image frames processed per second and determines the real-time performance of production line inspections. Specific definitions are as follows: FLOPs=2×H out ×W out ×K 2 ×C in ×C out GFLOPs=10 9 GFLOPs Among them, H out , W out Represent the height and width of the output feature map respectively; K represents the size of the convolution kernel; C in ,C out They represent the number of input and output channels respectively; pre is the preprocessing time of the model, including the time consumed by image scaling, padding and channel conversion; inference is the inference time of the model, that is, the forward calculation time of the model; post refers to the time occupied by the model decoding output, non-maximum suppression NMS, and result visualization operations.