A PCB defect detection method based on spatial geometric continuity constraint

By introducing spatial geometric continuity constraints into the loss function, the spatial inconsistency problem of existing models in industrial defect detection is solved, achieving high-precision, stable and interpretable detection results, which are applicable to a variety of industrial defect detection scenarios.

CN122368683APending Publication Date: 2026-07-10ANHUI UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610812602.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2026-06-03
Filing Date
2026-06-07
Publication Date
2026-07-10

AI Technical Summary

Technical Problem

Existing deep learning detection models struggle to effectively model the spatial geometric characteristics of defect targets in industrial defect detection, resulting in inconsistent, unstable, and uninterpretable detection results that fail to meet the needs of modern industrial visual inspection.

Method used

At the loss function level, spatial geometric continuity constraints are introduced. By calculating the geometric center distance of similar defect prediction boxes, spatial coherence is explicitly constrained. Combined with industrial scenario data augmentation strategies and dynamic learning rate scheduling, the detection model is optimized.

Benefits of technology

It improves the spatial coherence, stability, and interpretability of detection results, enhances the model's adaptability and real-time performance in complex environments, reduces computational overhead, and improves detection accuracy and reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122368683A_ABST
    Figure CN122368683A_ABST
Patent Text Reader

Abstract

This invention discloses a PCB defect detection method based on spatial geometric continuity constraints. This method introduces spatial geometric continuity regularization loss into the deep detection model, explicitly constraining the spatial geometric continuity of similar defects during training, thereby reducing fragmented predictions and improving detection coherence and robustness. This invention overcomes the limitations of existing methods that only focus on single-target detection accuracy. It innovatively introduces a spatial geometric continuity constraint mechanism at the loss function level, and combines it with industrial scenario data augmentation strategies, a single-stage target detection structure, dynamic learning rate scheduling, and a detection evaluation mechanism. This transforms the detection results from "independent discrete predictions" to "holistic predictions with spatial structural consistency," thus significantly improving the spatial coherence, stability, and engineering interpretability of the detection results while ensuring detection accuracy, ultimately enhancing the practical value and reliability of industrial defect detection systems.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention patent relates to the fields of computer vision and intelligent manufacturing technology, specifically to a PCB defect detection method based on spatial geometric continuity constraints. Background Technology

[0002] In the fields of intelligent manufacturing and industrial visual inspection, automated defect identification is a crucial step in achieving high-quality production. With the rapid development of deep learning, target detection algorithms based on convolutional neural networks (CNNs) have become a core means of industrial inspection. In particular, end-to-end detection models, represented by the YOLO (You Only Look Once) series, achieve real-time, high-precision target recognition through single-stage feature extraction and prediction.

[0003] However, although existing deep learning detection models have achieved a high level in the field of general object detection, a series of challenges still exist in industrial surface defect detection tasks. These challenges mainly stem from the following aspects:

[0004] (1) The spatial geometric characteristics of defect targets are difficult to model. Industrial defects (such as PCB pad oxidation, steel plate scratches, and chip cracks) usually exhibit local continuity and geometric consistency in space. That is, similar defects are often distributed along a certain direction, presenting a certain topological connection structure. However, traditional models such as YOLO, SSD, and Faster R-CNN treat the detection task as an independent bounding box regression problem, only optimizing the localization and classification accuracy of a single target, while ignoring the spatial dependencies between different targets. This leads to the same physical defect region being segmented into multiple isolated fragmented boxes in the inference results, with discontinuous or broken defect boundaries. This "spatial fragmentation" phenomenon not only affects the visual integrity of the detection but also reduces the reliability of subsequent defect statistics and classification evaluation.

[0005] (2) Traditional regularization strategies cannot constrain geometric coherence. To improve the robustness of detection models, existing research has introduced regularization mechanisms at the feature level, such as channel attention (SE, CBAM), context fusion (SPP, PANet), or feature smoothness regularization. These methods enhance representational power in the feature space, but do not directly characterize the geometric relationships between targets in the loss function. In other words, they only improve the uniformity of feature distribution, but cannot guarantee the geometric continuity of similar defects in space. Some studies have attempted to use graph neural networks (GNN) or Transformer structures to model spatial dependencies, but such methods often require additional relational graph construction or large-scale computational resources, making real-time deployment in industrial detection systems difficult. Therefore, how to explicitly introduce spatial geometric constraints at the loss function level while maintaining model structural simplicity has become a key challenge in current research.

[0006] (3) Lack of spatial coherence leads to instability in detection results. Existing detection algorithms typically predict targets independently on each image, lacking spatial consistency constraints. In industrial inspection scenarios, this design has two direct consequences:

[0007] ① Local fluctuations: When there are slight changes in illumination or reflection noise in the imaging environment, the model may produce drastically different prediction results for the same area.

[0008] ② Category Confusion: For defects with similar shapes but continuous spatial locations (such as cracks, scratches, and broken lines), the model may misclassify them into different categories. This problem stems from the model's failure to establish statistical priors about spatial structure during training. Traditional loss functions (such as YOLO's Box Loss, Cls Loss, and Obj Loss) only measure error at the single-object level, without considering the global distribution patterns of similar objects.

[0009] Therefore, the consistency of the detection results depends entirely on the implicit learning of the network, making it difficult to guarantee stability and structural consistency.

[0010] (4) The need for interpretability and geometric structure analysis in industrial inspection: With the popularization of intelligent manufacturing systems, industrial inspection not only requires high inspection accuracy, but also interpretability and physical consistency of the results. In PCB or wafer inspection tasks, engineers often need to infer the cause of defects or process deviations based on the inspection results, which requires the inspection frame to have a reasonable spatial structure. If the inspection results have obvious breaks or discrepancies, the system cannot distinguish whether the defects belong to the same structural area, thus affecting subsequent decisions and rework processes. Therefore, relying solely on traditional inspection frames is no longer sufficient to meet the needs of modern industrial visual inspection. There is an urgent need for a method that, while maintaining inspection accuracy, introduces spatial geometric continuity constraints to enhance the structural consistency and interpretability of the inspection results.

[0011] Research Motivation and Innovation Breakthrough: Addressing the aforementioned problems, this invention proposes a defect detection method based on "Spatial Geometric Continuity Constraint." This method, without altering the original detection network structure, introduces a geometric regularization term at the loss function level, achieving spatial continuity constraint by measuring the spatial center distance between similar targets. Summary of the Invention

[0012] This invention addresses the shortcomings of existing PCB defect detection methods in terms of spatial structural constraints by proposing a PCB defect detection method based on spatial geometric continuity constraints. This method introduces spatial geometric continuity regularization loss into the deep detection model (such as YOLOv8) to explicitly constrain the spatial geometric continuity of similar defects during training, thereby reducing fragmented predictions and improving the consistency and robustness of detection.

[0013] Core Idea: Traditional detection loss only considers bounding box regression error, classification error, and confidence error. This invention further introduces a spatial continuity constraint term. The basic idea is that if multiple defects of the same category are spatially adjacent, the geometric centers of these detection boxes should maintain a certain degree of continuity. To this end, this invention calculates the mean Euclidean distance between the center points of defects of the same category in the loss function and uses this as a regularization term for penalty. A larger distance indicates a more discrete prediction result and a higher loss, thus encouraging the model to generate spatially continuous and morphologically coherent prediction regions. This invention achieves this through the following technical solutions:

[0014] This invention discloses a PCB defect detection method based on spatial geometric continuity constraints, comprising the following steps:

[0015] Preparatory stage:

[0016] 1) Obtain the original image dataset containing the target object and divide it into a training set and a validation set; 2) Based on the characteristics of industrial defect imaging, perform industrial scene simulation enhancement on the samples in the training set to obtain enhanced samples, which are used to input the target detection model for training; 3) Use the target detection model to perform forward computation on the enhanced samples to generate prediction boxes and corresponding category and location information;

[0017] Model training phase:

[0018] 4) Based on the predicted bounding boxes and their corresponding categories and location information, a composite loss function is constructed that includes detection loss and spatial geometric continuity regularization loss. The spatial geometric continuity regularization loss is decoupled from the forward inference computation graph of the object detection model and only participates in the backpropagation link as a penalty term during the model training phase, so that the forward inference network topology and inference computational overhead of the object detection model remain unchanged. The spatial geometric continuity regularization loss is used to break the assumption of single-target independent bounding box regression. By explicitly calculating the geometric topology matrix between different predicted boxes within the same category, an intra-class node relationship prior is constructed to impose macroscopic physical topology constraints, thereby suppressing the spatial fragmentation of local predicted boxes. 5) Use the composite loss function for backpropagation to update the model parameters and obtain the iteratively optimized target detection model;

[0019] Model validation and evaluation phase:

[0020] 6) After training is completed, the iteratively optimized target detection model is used to infer the images in the validation set and output detection results with spatial geometric consistency. 7) Evaluate the accuracy of the detection results to measure the detection performance of the model.

[0021] As a further improvement, the formula for calculating the composite loss function of the spatial geometric continuity regularization loss described in this invention is as follows:

[0022]

[0023] Where C is the total number of target categories, and Nc is the number of predicted boxes belonging to the same category c. When Nc ≥ 2, the regularization loss component for the c-th target is calculated; when Nc < 2, the regularization loss component for the c-th target is 0. i Let p be the center point coordinates of the i-th prediction box. j Let be the center coordinates of the j-th prediction box, ||·||2 represent the L2 Euclidean distance metric, S is the spatial scale transformation factor linearly related to the input image resolution, and λ is the topological penalty adjustment weight ranging from 0.01 to 0.1.

[0024] As a further improvement, the present invention performs industrial scene simulation enhancement on the samples in the training set, and adopts a combined enhancement strategy targeting industrial defect features to perform geometric transformation, brightness and contrast adjustment and image distribution enhancement processing on the training samples, so as to improve the robustness of the model while maintaining the defect structure features.

[0025] As a further improvement, the target detection model of the present invention adopts a single-stage target detection structure based on convolutional neural networks. Its backbone network includes a multi-layer feature extraction module, a feature fusion network for fusing features at different scales, and a detection head for outputting the target's category and location prediction. The model is trained under fixed input resolution conditions.

[0026] As a further improvement, the updated model parameters described in this invention specifically involve introducing a learning rate scheduling strategy that dynamically changes with the model training process, so that the learning rate gradually increases in the early stage of parameter update and gradually decreases in the later stage of parameter update, in order to improve the model convergence stability and suppress overfitting.

[0027] As a further improvement, the accuracy evaluation of the detection results described in this invention to measure the detection performance of the model specifically involves: using a custom evaluation module to perform refined detection evaluation on the validation set; the custom evaluation module calculates various target detection performance evaluation indicators, including overall detection accuracy indicators and category-level detection indicators, and stores the evaluation results for analysis.

[0028] The beneficial effects of this invention are as follows:

[0029] 1) This invention, based on the traditional target detection framework, breaks through the limitation of existing methods that only focus on the accuracy of single-target detection. It innovatively introduces a spatial geometric continuity constraint mechanism at the loss function level, and combines it with industrial scenario data augmentation strategies, a single-stage target detection structure, dynamic learning rate scheduling, and a detection evaluation mechanism to achieve joint modeling of defect "appearance features + spatial distribution features." This transforms the detection results from "independent discrete predictions" to "holistic predictions with spatial structural consistency," thereby significantly improving the spatial coherence, stability, and engineering interpretability of the detection results while ensuring detection accuracy, ultimately enhancing the practical value and reliability of the industrial defect detection system.

[0030] 2) This invention differs from existing technologies that only improve the feature layer or network structure. It innovatively constructs a spatial geometric continuity regularization term in the loss function, achieving explicit modeling of the target spatial distribution by measuring the geometric distance between the center points of prediction boxes of the same class. This allows the model to not only focus on the localization and classification accuracy of individual targets during optimization but also learn the spatial distribution patterns among defects of the same class, thereby effectively reducing the fragmentation problem of detection boxes and significantly improving the spatial coherence and structural integrity of the detection results.

[0031] 3) The spatial geometric continuity constraint described in this invention relies solely on the coordinates and category information of the predicted bounding box for calculation, without introducing additional network structures or complex computational processes. This enhances the ability to model spatial relationships without increasing model complexity or computational burden, thereby reducing computational overhead while maintaining detection performance and improving the model's real-time performance and deployability in industrial online detection scenarios.

[0032] 4) This invention collaboratively designs a spatial geometric continuity constraint mechanism with a combined data augmentation strategy oriented towards industrial defect features, enabling the model to simultaneously learn the appearance changes and spatial distribution characteristics of defects. This allows the model to maintain stable detection performance even under complex backgrounds, lighting variations, and noise interference, significantly improving its adaptability to real-world industrial scenarios and its cross-scenario generalization ability.

[0033] 5) Unlike existing technologies that do not consider the spatial relationships between targets, this invention models the spatial distribution relationships of similar defects, enabling the model to perceive the overall structure of the defects. For defect types that exhibit clustered distributions or have process-related characteristics, it can significantly improve the completeness and continuity of detection results, while enhancing the ability to identify small targets and dense defects, and reducing the false negative and false positive rates.

[0034] 6) Unlike existing technologies that do not constrain the spatial continuity of defects, this invention uses spatial geometric continuity constraints to make the output detection results smoother and more continuous in space. This makes the detection results more consistent with the actual physical distribution of defects, facilitating subsequent defect cause analysis, area localization, and process optimization, and improving the engineering interpretability and application value of the detection system.

[0035] 7) The spatial geometric continuity constraint mechanism proposed in this invention is independent of specific datasets and detection model structures. This allows the method to be flexibly applied to various target detection frameworks and can be transferred to different industrial defect detection scenarios without redesigning the model structure, demonstrating good versatility and promotional value.

[0036] 8) This invention differs from evaluation methods that only provide a single accuracy indicator. It constructs a multi-dimensional detection and evaluation mechanism, enabling refined analysis of overall performance and category-level performance, and supporting the storage and feedback of evaluation results. This provides data support for continuous model optimization, facilitates system integration and engineering deployment, thereby improving the maintainability and scalability of the entire detection system. Attached Figure Description

[0037] Figure 1 This is a flowchart illustrating the overall algorithm of the method of the present invention;

[0038] Figure 2 This is a comparison chart of PCB defect detection models. Detailed Implementation

[0039] Preparatory stage:

[0040] 1) Obtain the original image dataset containing the target object, and divide the original image dataset into a training set and a validation set according to a preset ratio, wherein the original image dataset contains various types of PCB defect samples; 2) Based on the characteristics of industrial defect imaging, perform industrial scene simulation enhancement on the samples in the training set, the enhancement including but not limited to geometric transformation, brightness and contrast adjustment, and image distribution perturbation processing, in order to expand the sample diversity and improve the model's adaptability to complex industrial environments, to obtain enhanced samples; 3) Input the enhanced samples into a preset target detection model for forward calculation to generate prediction boxes and corresponding category and location information;

[0041] Model training phase: 4) Construct a composite loss function based on the predicted bounding boxes and corresponding category and location information. The composite loss function includes detection loss and spatial geometric continuity regularization loss. The spatial geometric continuity regularization loss constrains the spatial distance relationship between the center points of the same category predicted bounding boxes, so that the detection results maintain coherence and consistency in spatial distribution; 5) Use the composite loss function to perform backpropagation calculation on the target detection model, and combine iterative updates to the model parameters with optimization algorithms until the preset convergence condition is met, to obtain the iteratively optimized target detection model;

[0042] Model Validation and Evaluation Stage: 6) After completing model training, the iteratively optimized target detection model is used to perform inference processing on the images in the validation set, and output detection information containing the target category, location and spatial geometric consistency constraint results; 7) The detection results are evaluated for accuracy to measure the detection performance of the model. The evaluation includes a comprehensive analysis of the overall detection effect and the detection effect of each category, thereby verifying the applicability and stability of the model in actual industrial scenarios.

[0043] The method of the present invention mainly includes the following technical steps, such as Figure 1 As shown, Figure 1 This is a flowchart of the overall algorithm of the method of the present invention.

[0044] I. Preparatory Stage

[0045] 1. Obtain the original image dataset containing the target object, and divide the original image dataset into a training set and a validation set according to a preset ratio. The original image dataset contains original images of various types of PCB defect samples, such as short circuits, open circuits, rodent bites, and debris. Obtain the target's category and location information (cls, x_1, y_1, x_2, y_2) using an annotation tool. Strictly divide the dataset into a training set and a validation set.

[0046] 2. To address the characteristics of industrial defect imaging, industrial scene simulation enhancement is applied to the samples in the training set. This enhancement includes, but is not limited to, geometric transformations, brightness and contrast adjustments, and image distribution perturbation processing. This aims to expand sample diversity and improve the model's adaptability to complex industrial environments, resulting in enhanced samples. A combined enhancement strategy targeting industrial defect features is employed:

[0047] (1) Brightness / contrast adjustment: Randomly adjust within ±20% range to simulate changes in factory lighting;

[0048] Simulates fluctuations in lighting intensity on a factory production line.

[0049] (2) Geometric transformation: Perform random 90-degree rotation and horizontal flip to improve the robustness of the model to PCB boards with different orientations.

[0050] (3) Blur and noise reduction: Apply mild blurring operation (such as median filtering with kernel size of 3~7) to simulate the imaging blur that may occur during the movement of industrial cameras.

[0051] (4) Image distribution enhancement: By color normalization, the image is standardized to a specified distribution to eliminate the imaging differences between industrial cameras of different brands.

[0052] 3. The enhanced samples are input into a preset target detection model for forward computation. The model outputs the original predicted bounding boxes and corresponding category and location information, providing a basis for subsequent loss function calculation.

[0053] II. Model Training Phase

[0054] 1. Based on the predicted bounding boxes and their corresponding categories and location information, a composite loss function is constructed. This composite loss function includes detection loss and spatial geometric continuity regularization loss. The spatial geometric continuity regularization loss constrains the spatial distance relationship between the center points of predicted bounding boxes of the same category, ensuring the detection results maintain consistency and uniformity in spatial distribution. The traditional detection loss only includes bounding box regression loss, classification loss, and confidence loss, in the form of:

[0055]

[0056] This invention adds a spatial geometric continuity regularization loss term L to this. spatial This is used to constrain the spatial coherence of similar defects. It is defined as follows: Suppose there are N prediction boxes in an image, and the number of prediction boxes belonging to the same category c is N. c p i Let p be the center point coordinates of the i-th prediction box. jLet be the coordinates of the center point of the j-th predicted bounding box. Calculate the Euclidean distance between any two center points:

[0057]

[0058] For all predicted bounding boxes belonging to category c, calculate their normalized distance matrix and take the average:

[0059]

[0060] Where S is the image size (normalization factor). This term measures the spatial dispersion of similar predicted boxes; greater dispersion results in higher loss. Next, the total loss is fused by incorporating the spatial regularization term as a weighted average:

[0061]

[0062] It is worth noting that the spatial geometric continuity regularization loss designed in this invention has unique non-intrusive engineering advantages. In the construction of the computational graph of the deep learning framework, this regularization loss achieves physical and logical decoupling from the forward inference computational graph of the object detection model. Specifically, this mechanism is used to break the assumption of single-object independent bounding box regression, and constructs intra-class node relationship priors by explicitly calculating the geometric topological distance matrix between different predicted boxes within the same category. During the model training phase, this prior is only used as a penalty term in the backpropagation link to guide the model weights to update gradients along the spatial continuity direction; while in the production line inference deployment phase after the model is solidified, this regularization module completely exits the computational graph. This decoupling design allows the model to obtain macroscopic physical topological constraints and effectively suppress local predicted box spatial fragmentation, while its forward inference network topology and inference-period computational overhead remain absolutely unchanged, achieving spatial perception enhancement with zero additional computational cost. Table 1 shows the influence of the spatial continuity regularization coefficient λ.

[0063]

[0064] Here, λ represents the topology penalty adjustment weight, with its value strictly limited to the range of 0.01 to 0.1. Through ablation experiments on a large number of industrial datasets, the applicant discovered that this range is not an arbitrarily chosen conventional parameter, but rather a key threshold that constrains the model's detection precision to the nonlinear optimal response range. When λ < 0.01, the regularization penalty is too weak to effectively suppress similar defect breaks and spatial fragmentation caused by industrial reflection noise; when λ > 0.1, excessive topology distance penalty disrupts the original detection regression loss gradient, causing the model to overemphasize spatial clustering and resulting in missed detections (recall decrease). Therefore, setting λ in the range of 0.01 to 0.1 allows the composite loss function to achieve an optimal balance between microscopic independent positioning accuracy and macroscopic physical topology constraints, resulting in an unexpected improvement in detection performance.

[0065] 2. The target detection model is backpropagated using the composite loss function, and the model parameters are iteratively updated using an optimization algorithm until the preset convergence condition is met, thus obtaining the iteratively optimized target detection model.

[0066] (1) Single-stage detection structure: The model adopts a single-stage structure based on convolutional neural networks (CNN) (YOLOv8s), using a backbone network for feature extraction and fusing multi-scale features through a feature fusion network (PAN-FPN). The model mainly consists of three parts:

[0067] Backbone (feature extraction network): It adopts a C2f module structure and achieves cross-layer information fusion through branch convolution and feature concatenation;

[0068] Neck (feature fusion layer): Employs a PAN-FPN structure to fuse multi-scale features;

[0069] Head (Detection Head): Responsible for outputting bounding box coordinates, class probability, and confidence level.

[0070] The model was initialized using COCO pre-trained weights, with an input resolution of 640×640, a batch size of 8, and 50 training epochs.

[0071] During training, disable YOLO's built-in enhancement strategies such as Mosaic, MixUp, and CutMix to avoid conflicts with custom enhancements.

[0072] (2) Dynamic learning rate scheduling: A learning rate strategy that changes dynamically with the training process is introduced, which gradually increases in the early stage of training (Warm-up) and gradually decreases in the later stage to ensure model convergence and suppress overfitting.

[0073] (3) Parameter update: The composite loss function is used for backpropagation, and the model weights are updated through SGD or AdamW optimizer to finally obtain an optimized model with spatial geometric consistency.

[0074] III. Model Validation and Evaluation Phase

[0075] 1. After model training is complete, the model automatically saves the optimal weights (best.pt). The iteratively optimized target detection model is then used to perform inference processing on the images in the validation set, outputting detection information containing target category, location, and spatial geometric consistency constraints, including the following metrics:

[0076] mAP@0.5: Average detection accuracy;

[0077] mAP@0.5:0.95: Multi-threshold comprehensive detection accuracy;

[0078] Class-wise AP: Detection performance for each defect category.

[0079] 2. The detection results are evaluated for accuracy to measure the model's detection performance. This evaluation includes a comprehensive analysis of the overall detection effect and the detection effect of each category, calculating multiple target detection performance evaluation indicators. These evaluation indicators include at least average detection accuracy, multi-threshold comprehensive detection accuracy, and category-level detection accuracy for each PCB defect category. The evaluation results are stored for analysis, generating a detection performance report to verify the model's applicability and stability in real-world industrial scenarios. The optimized model is used for inference on the validation set. To further demonstrate the core feature L of this application... spatial To address the non-obviousness of setting the weight coefficient λ, this embodiment conducted an ablation experiment on the same industrial dataset to adjust the weight λ. The experimental results are shown in Table 1. The experiment shows that when this mechanism is not introduced (λ=0), the model has a high false detection rate due to "spatial fragmentation," with a precision of only 82.2%. This application innovatively limits λ to the range of 0.01~0.1. Within this range, the model precision steadily increases to a maximum of 83.5%. The discovery of this optimal numerical range objectively confirms that spatial topological constraints effectively reduce fracture prediction and edge false alarms of similar defects, which is far beyond what can be achieved by simple feature layer splicing or conventional methods in existing technologies. This demonstrates significant substantial characteristics and technological progress. At this point, the model output already possesses spatial geometric consistency, reducing the abnormal discrete distribution among similar defects.

[0080] IV. Method Universality and Transfer Application

[0081] The method of this invention is independent of specific datasets and tasks. Although its primary objective is PCB defect detection, it can be adapted to the following application scenarios:

[0082] Detection of scratches and corrosion on metal surfaces;

[0083] Detection of chip cracks and solder joint anomalies;

[0084] Solar cell crack detection;

[0085] Detection of bubbles and wrinkles in plastic products, etc.

[0086] During migration, only the training data and category definition files need to be replaced to reuse the spatial geometric continuity regularization constraint mechanism, without redesigning the network structure. This invention can be modified and varied in all relevant object detection fields; however, any modifications, equivalent substitutions, improvements, etc., made within the spirit of this invention should be included within the scope of protection of this invention.

[0087] Figure 2 The comparison chart shows the qualitative results of the most cutting-edge PCB defect detection models in the current industrial AI field (such as YOLOv10, Co-DETR, RT-DETR, etc.) and the self-developed model (Ours) proposed in this study on nine core defect types (including BMFO broken seam, CFO open copper foil, CS copper surface scratch, HB via damage, MB seam, OP open circuit, SC short circuit, SH burr and SP excess copper).

[0088] A horizontal comparison with the Ground Truth benchmark clearly shows that the "Ours" model (marked in purple) demonstrates superior detection performance in almost all complex scenarios. It not only achieves extremely high positioning accuracy and high overlap with the ground truth bounding box, but also significantly outperforms other state-of-the-art (SOTA) models in confidence scores (mostly between 0.85 and 0.93). Particularly when dealing with large-area defects such as CFO (open copper foil), the self-developed model exhibits excellent robustness, effectively solving the detection fragmentation and false alarm issues commonly found in YOLOv10 or RT-DETR, fully validating the algorithm's core value in improving PCB defect detection accuracy.

[0089] It should be noted that the above embodiments are merely preferred embodiments of the present invention. Those skilled in the art can make various modifications and substitutions to the network structure, loss function, preprocessing method, synthesis degradation strategy, block inference method, and multi-angle fusion strategy without departing from the concept of the present invention, and all such equivalent modifications and substitutions should fall within the protection scope of the present invention.

Claims

1. A PCB defect detection method based on spatial geometric continuity constraints, characterized in that, Includes the following steps: Preparatory stage: 1) Obtain the original image dataset containing the target object and divide it into a training set and a validation set; 2) Based on the characteristics of industrial defect imaging, perform industrial scene simulation enhancement on the samples in the training set to obtain enhanced samples, which are used to input the target detection model for training; 3) Use the target detection model to perform forward computation on the enhanced samples to generate prediction boxes and corresponding category and location information; Model training phase: 4) Based on the predicted box and corresponding category and location information, construct a composite loss function that includes detection loss and spatial geometric continuity regularization loss; the spatial geometric continuity regularization loss is decoupled from the forward inference computation graph of the target detection model, and only participates in the backpropagation link as a penalty term during the model training phase, so that the forward inference network topology and inference period computational overhead of the target detection model remain unchanged. The spatial geometric continuity regularization loss is used to break the assumption of single-target independent bounding box regression. By explicitly calculating the geometric topology matrix between different predicted boxes within the same category, an intra-class node relationship prior is constructed to impose macroscopic physical topological constraints, thereby suppressing the spatial fragmentation of local predicted boxes; 5) The composite loss function is used for backpropagation to update the model parameters and obtain the iteratively optimized target detection model. Model validation and evaluation phase: 6) After training is completed, the iteratively optimized target detection model is used to infer the images in the validation set and output detection results with spatial geometric consistency; 7) The accuracy of the detection results is evaluated to measure the detection performance of the model.

2. The PCB defect detection method based on spatial geometric continuity constraints according to claim 1, characterized in that: The formula for calculating the spatial geometric continuity regularization loss is as follows: ; Where C is the total number of target categories, and N is the number of predicted boxes belonging to the same category c. c N c Calculate the regularization loss component for the c-th type of objective when N ≥ 2. c When p < 2, the regularization loss term for the c-th target is 0. i Let p be the center point coordinates of the i-th prediction box. j Let be the center coordinates of the j-th prediction box, ||·||2 represent the L2 Euclidean distance metric, S is the spatial scale transformation factor linearly related to the input image resolution, and λ is the topological penalty adjustment weight ranging from 0.01 to 0.

1.

3. The PCB defect detection method based on spatial geometric continuity constraints according to claim 1, characterized in that: The process involves enhancing the training samples through industrial scene simulation. This is achieved by employing a combined enhancement strategy targeting industrial defect features. The training samples undergo geometric transformation, brightness and contrast adjustment, and image distribution enhancement to improve model robustness while preserving defect structural features.

4. The PCB defect detection method based on spatial geometric continuity constraints according to claim 1 or 2, characterized in that: The target detection model adopts a single-stage target detection structure based on convolutional neural networks. Its backbone network includes a multi-layer feature extraction module, a feature fusion network for fusing features at different scales, and a detection head for outputting the target's category and location prediction. The model is trained under a fixed input resolution.

5. The PCB defect detection method based on spatial geometric continuity constraints according to claim 4, characterized in that: The aforementioned update of model parameters specifically involves introducing a learning rate scheduling strategy that dynamically changes with the model training process, so that the learning rate gradually increases in the early stage of parameter update and gradually decreases in the later stage of parameter update, in order to improve the model convergence stability and suppress overfitting.

6. The PCB defect detection method based on spatial geometric continuity constraints according to claim 1, 2, or 5, characterized in that: The aforementioned accuracy evaluation of the detection results to measure the detection performance of the model specifically involves: using a custom evaluation module to perform refined detection evaluation on the validation set. The custom evaluation module calculates various target detection performance evaluation indicators, including overall detection accuracy indicators and category-level detection indicators, and stores the evaluation results for analysis.