A PCB defect detection method for industrial incremental scene

By combining a feature selection module and a hierarchical reconstruction feature fusion module with a background adaptation mechanism and an incremental learning method, the problem of background semantic drift in PCB defect detection in industrial incremental scenarios is solved. This achieves real-time high-precision detection of minute defects and model stability, while reducing data dependence and maintenance costs.

CN122289226APending Publication Date: 2026-06-26QINGDAO INST OF COMPUTING TECH XIDIAN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610428604.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-04-02
Publication Date
2026-06-26

Smart Images

  • Figure CN122289226A_ABST
    Figure CN122289226A_ABST
Patent Text Reader

Abstract

This invention relates to the field of defect detection technology, specifically to a PCB defect detection method for industrial incremental scenarios. It includes a feature fusion method based on a lightweight segmentation strategy that combines random pruning with separate processing of strong and weak features. This strategy simplifies redundant computation by using a feature selector, and differentiates and recombines defect features of varying saliency during the feature fusion stage. This significantly improves inference speed while maintaining the precision of segmentation, solving the problems of high computational cost and difficulty in capturing minute defects in existing methods. The method also includes an incremental learning approach employing a background classifier adaptation mechanism and local semantic distillation. Class-specific regularization and spatially weighted logical alignment distillation work synergistically. By dynamically calibrating the background prediction logic and constructing a pixel-level semantic relevance matrix, it achieves deep alignment between new and old knowledge and background distribution. This effectively solves the catastrophic forgetting problem caused by the evolution of PCB background texture in existing incremental learning methods, significantly enhancing detection stability and the adaptability of the enhanced model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of defect detection technology, and specifically to a PCB defect detection method for industrial incremental scenarios. Background Technology

[0002] Printed circuit board (PCB) defect detection technology is a crucial link in intelligent manufacturing and electronic product quality control. By replacing traditional manual visual inspection with automated visual inspection methods, it enables rapid identification and location of surface defects on circuit boards, which is of great significance for ensuring product reliability and improving production yield. In the industrial PCB production process, the inspection system needs to operate in a complex and ever-changing production environment for extended periods. Variations in PCB material type, manufacturing process, and imaging conditions lead to significant differences in background texture morphology and semantic distribution. Simultaneously, defect types and their appearance characteristics also exhibit continuous evolution. Against this backdrop, PCB defect detection systems not only need high-precision identification capabilities for minute defects but also need to continuously adapt to the introduction of new defects and changes in scenarios under limited computing resources and strict time constraints. Therefore, stable detection and continuous learning capabilities for incremental industrial applications have become key issues in the design of PCB defect detection systems.

[0003] Existing deep learning-based PCB defect detection methods typically improve detection accuracy through multi-scale feature fusion, attention mechanisms, or complex network structures, achieving good results on static datasets or under one-time training conditions. However, these methods generally rely on the assumption that background semantics and defect distribution are relatively stable, failing to adequately consider the semantic drift caused by changes in background texture during industrial production as the task progresses. When the detection system needs to gradually introduce new defect categories through incremental learning, existing methods, lacking the ability to model dynamic changes in background semantics, are prone to misclassifying phased background changes as defect features or incorrectly merging old defects into background regions, leading to catastrophic forgetting problems.

[0004] In real-world industrial incremental inspection scenarios, the aforementioned issues directly lead to a difficulty in balancing the performance of identifying both new and old defects. The model needs to be frequently retrained to maintain detection accuracy, which not only significantly increases computation and annotation costs but also makes it difficult to meet the requirements of industrial production for the continuity, stability, and real-time performance of the inspection system, thereby reducing the inspection efficiency and reliability of the entire production line.

[0005] Therefore, in order to ensure that the PCB defect detection system can operate stably for a long time under industrial incremental application conditions, it is urgent to design a PCB defect detection method for industrial incremental scenarios, which can achieve efficient and accurate detection of new and old defect categories while suppressing the interference of background semantic drift on the continuous learning process of the model. Summary of the Invention

[0006] The purpose of this invention is to provide a PCB defect detection method for industrial incremental scenarios, so as to solve the existing technical problems in the background art.

[0007] To address the aforementioned technical problems, the present invention provides a PCB defect detection method for industrial incremental scenarios, comprising the following steps: Step S1: Obtain the PCB image samples and their annotation information at the current stage, and perform data preprocessing on the PCB image samples; the data preprocessing includes data balancing processing based on random cropping and cropping window adjustment based on geometric integrity constraints, so as to increase the effective proportion of defect areas in the training samples and reduce the sample distribution imbalance caused by defect truncation, and output the preprocessed training sample set. Step S2: Input the preprocessed training sample set into the PCB defect detection model for training or incremental update; wherein, the PCB defect detection model includes a feature selection module and a hierarchical reconstruction feature fusion module. The feature selection module is used to perform block-level filtering on the high-resolution input to determine defect candidate regions. The hierarchical reconstruction feature fusion module is used to decouple strong and weak features and perform hierarchical enhancement on the multi-layer features of the defect candidate regions to obtain fused features for semantic segmentation prediction; Based on the fused features, the model parameters are optimized, and the PCB defect detection model for the current stage is output; Step S3: Acquire the PCB image to be detected and input it into the PCB defect detection model of the current stage; the feature selection module performs block-level filtering on the PCB image to be detected to obtain candidate defect regions to be segmented; the hierarchical reconstruction feature fusion module performs feature fusion and semantic segmentation prediction on the candidate defect regions and outputs the PCB defect detection result. Step S4: When the untrained PCB image samples for the next incremental stage are obtained, the PCB defect detection model of the previous stage is used as the teacher model, and the corresponding student model is constructed. Based on the incremental learning method for background semantic distribution offset, the student model is incrementally trained to correct the background class information offset from the category level and semantic level. At the output end, the background dominance effect is suppressed by spatial weighted distillation of the defect area, and the updated PCB defect detection model is output. At the same time, the memory and statistics are updated for use in the next incremental stage.

[0008] Based on the above technical solution, the data preprocessing in step S1 includes the following steps: During the training phase, defect center alignment is performed on the cropping window with a preset probability. At the same time, a dynamic scaling mechanism with integrity constraints is introduced to detect the coverage rate of the defective area after cropping and compare it with a threshold. If the coverage rate is lower than the threshold, the field of view of the cropping window is automatically expanded until the defective area is completely covered or the maximum allowable scale is reached. Based on the subsequent model input requirements, the cropped image after alignment, anchoring, and dynamic scaling is resized and normalized.

[0009] Based on the above technical solution, the block-level filtering in step S2 includes the following steps: First, the input high-resolution PCB image is divided into several image blocks of the same size using a grid or sliding window method; Subsequently, a shared backbone network is used to extract features from each image block to obtain the corresponding block-level feature representation; Then, the feature selection module scores each block-level feature, outputs the confidence score that the image block belongs to the defect candidate region, and sorts all image blocks according to the confidence score or filters them according to a threshold. Ultimately, only the highest-scoring image patches are fed into the fine segmentation network and feature fusion module for depth calculation, while the remaining low-scoring background patches are either skipped or have their processing intensity reduced.

[0010] Based on the above technical solution, the hierarchical reconstruction feature fusion in step S2 includes the following steps: In each fusion layer, the lower layer features are first upsampled to align with the upper layer features in terms of spatial resolution, and the aligned two types of features are then fused to obtain the initial fused features. The initial fused features are adaptively decomposed to obtain strong semantic components and weak texture components. The adaptive decomposition process involves generating a weight threshold by statistically modeling the channel response, and comparing the feature responses from different layers with the weight threshold to obtain strong semantic components and weak texture components. For strong semantic components, a lightweight channel transformation is used to extract their semantics; for weak texture components, a multi-scale enhancement module is introduced to obtain multi-scale context and long-distance dependency information in the weak texture components, and repetitive texture noise is suppressed by multi-branch asymmetric convolution and dilated receptive field expansion. The processed strong semantic components and weak texture components are fused to obtain fused features that integrate cross-layer semantic information, which are then used for PCB defect semantic segmentation and prediction tasks.

[0011] Based on the above technical solution, step S2 further includes introducing a geometric perception correlation reasoning mechanism to enhance the preliminary fused features, including the following steps: By using strip convolution to model the structural responses in the horizontal and vertical directions respectively, spatial weights with orientation selectivity are generated. Spatially weight the preliminary fusion features to obtain directionally enhanced fusion features, thereby strengthening the response of linear defects and fine fractures with obvious directional targets and suppressing irregular noise regions. Features are grouped and interacted along the channel dimension, and channels within each group are selected to form a more discriminative channel response distribution. This distribution is then added to the fusion features that incorporate cross-layer semantic information to obtain high-quality fusion features that simultaneously integrate cross-layer semantic information and geometric perception constraints. These features are then used for PCB defect semantic segmentation and prediction tasks.

[0012] Based on the above technical solution, the incremental learning method for background semantic distribution shift in step S4 is implemented in an incremental phase. For example, the steps include: Construct teacher and student models, where the teacher model is the PCB defect detection model from the previous stage. The student model is a combination of the teacher model. The model obtained after parameter initialization And use the teacher model to distill the student model for learning; Before training the student model, based on the background classifier adaptation mechanism, the initialization of the new category classifier inheriting the old background classifier and the weight norm balancing of the seen category classifier are completed. During the training of the student model, local semantic feature alignment distillation is used to dynamically update the semantic memory bank and constrain the pixel-level semantic relevance distribution generated by the new and old models to remain consistent. During the training process, class-specific regularization is performed, and the decision boundary of the classifier is constrained by statistical replay to ensure that the model does not shift its semantic perception of the old category in the feature space. During the training of the student model, spatial weighted logical alignment distillation is performed to enhance the alignment of defect areas at the output end, avoid distillation being dominated by large areas of background pixels, and balance the contribution of distillation. The joint loss function optimizes and updates the student model, outputting the incremental stage. The corresponding student model is optimized and the memory and statistics are updated for the next incremental phase.

[0013] Based on the above technical solution, the application of the background classifier adaptation mechanism includes the following process: New category classifier inheritance initialization: For each newly introduced category classifier, inherit the weights from the old background classifier and add a small perturbation: ,in Random noise of a preset amplitude, For background classifier, For the new category classifier; Calculate the average nonnegative scaling factor of the norm of all class weights. As a criterion, the weight vectors of each category are then normalized and rescaled to the average non-negative scaling factor value. .

[0014] Based on the above technical solution, the local semantic feature alignment distillation includes the following process: Confidence-weighted prototype generation: Based on the confidence-weighted pooling strategy, the confidence of the current student model in pixel classification is used as the weight to aggregate semantic features in a weighted manner to generate a semantic prototype; Dynamic semantic memory maintenance and update: Construct a global semantic memory containing semantic prototypes of all historical categories; at the start of the incremental phase, the global semantic memory is initialized to the state of the previous phase; during training, for the categories appearing in the current batch of data, the prototype of the current batch is calculated using a confidence-weighted pooling strategy, and the corresponding prototype in the global memory is updated online using an exponential moving average strategy. Correlation matrix calculation: The input image is fed into the frozen old model and the currently trained new model respectively, and feature maps are extracted respectively; the feature maps are reshaped into two-dimensional matrices and normalized; then, the correlation matrix between the feature maps and the global semantic memory is calculated respectively, where the elements in the matrix represent the cosine similarity between a pixel and a semantic prototype in the global semantic memory. Distillation loss optimization: Softmax normalization with temperature parameter is applied to each row of the correlation matrix; the final local semantic distillation loss is the KL divergence between the output distributions of the old and new models; the local semantic distillation loss is minimized and constrained to the new model.

[0015] Based on the above technical solution, the class-specific regularization includes the following process: In the incremental phase At that time, for each old category Extract the corresponding pixel embedding set from the global semantic feature memory, and calculate the mean and covariance of the category in the feature space:

[0016] in This indicates that the category belongs to the global semantic memory. The set of embedded features; Subsequently, assuming that the old category features approximately follow a Gaussian distribution, Several virtual old class embeddings are generated in the feature space for the parameters as replay samples. ,in It is a non-negative scaling factor; The generated embeddings are copied and stacked with the features. Figure 1 The tensor structure is then fed into... The cross-entropy replay loss is calculated in a classifier implemented using convolution.

[0017] Based on the above technical solution, the spatially weighted logically aligned distillation operation includes the following process: First, temperature scaling is introduced at the output of the teacher model and the student model to soften the logic of both and obtain a smoother soft probability distribution. Subsequently, a spatial weighting mechanism is introduced to construct a pixel-level weighted mask: for each pixel Assign a spatial weight When the pixel's true label When it belongs to the background category, the weight is 1; when When it belongs to any foreground defect category, the weight is taken as follows: ;in This is used to increase the contribution of defective pixels to loss calculation; Finally, during loss calculation, the difference between the teacher's soft distribution and the student's soft distribution is calculated for each pixel location, and the difference terms are weighted and summarized using the aforementioned spatial weights; the total weights are normalized to stabilize the loss scale under different image / different defect proportion conditions.

[0018] Based on the above technical solution, the joint loss function optimization operation includes the following process: Construct the overall objective loss function:

[0019] in, For standard pixel-level cross-entropy loss, For local semantic distillation loss, For class-specific regularization loss, For spatially weighted logical alignment distillation loss, , , For the corresponding , , The non-negative hyperparameter of the loss; In the incremental phase During the training process, by minimizing Update the student model parameters and output the optimized student model for the next incremental phase.

[0020] The beneficial effects of the technical solution provided by this invention are as follows: Compared with the prior art, the technical effects of the technical solution of this application are as follows: (1) Construct an efficient feature extraction mechanism to achieve real-time high-precision detection of small defects in complex backgrounds: One of the objectives of this invention is to break the constraint relationship between accuracy and efficiency and design a lightweight and efficient feature fusion network structure. By making full use of multi-scale features and heterogeneous information, the model's ability to perceive small, low-contrast defects in complex PCB backgrounds is enhanced, while significantly reducing computational complexity and ensuring that the algorithm can meet the requirements of real-time inference on industrial edge devices. (2) Solving the forgetting problem caused by background semantic drift and ensuring the stability of continuous learning: Another objective of this invention is to overcome the limitations of existing technologies that assume static background. By designing specific background adaptation or calibration mechanisms, the model can dynamically adapt to the semantic drift of background texture during the production process. While introducing new defect categories, it effectively distinguishes between background changes and real defects, suppresses the forgetting of old knowledge, and ensures the discrimination stability of the model during long-term operation.

[0021] (3) Reduce data dependency and maintenance costs, and improve the flexibility of industrial deployment: This invention achieves efficient incremental learning, allowing the detection system to quickly update its model with new task data without accessing or only accessing a very small amount of historical data. This not only significantly reduces data storage and annotation costs, but also reduces the training time required for model updates, thereby significantly improving the iterative efficiency and adaptability of the PCB production line quality control system. Attached Figure Description

[0022] Figure 1 This is a flowchart illustrating the present invention; Figure 2 This is a framework diagram of the hierarchical feature fusion method for texture noise interference in this invention; Figure 3 This is a schematic diagram illustrating the principle of the hierarchical reconstruction feature fusion strategy in this invention; Figure 4 This is a schematic diagram illustrating the principle of the geometric perception-related reasoning mechanism in this invention; Figure 5 This is a schematic diagram of the overall framework of the incremental learning method for background semantic distribution shift in this invention; Figure 6 This is a schematic diagram illustrating the principle of local semantic feature alignment distillation in this invention; Figure 7 This is a schematic diagram illustrating the principle of spatially weighted logical alignment distillation in this invention; Detailed Implementation The present invention will be further described below with reference to the accompanying drawings and embodiments: In this invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," "linking," and "fixing," etc., should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral part; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.

[0023] In the description of this invention, it should be understood that the terms "left", "right", "front", "rear", "top", "bottom", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this invention.

[0024] like Figures 1 to 7 As shown, a PCB defect detection method for industrial incremental scenarios includes the following steps: Step S1: Obtain PCB image samples and their annotation information for the current stage, and perform data preprocessing on the PCB image samples; the data preprocessing includes data balancing processing based on random cropping and cropping window adjustment based on geometric integrity constraints, so as to increase the effective proportion of defect areas in training samples and reduce the sample distribution imbalance caused by defect truncation, and output the preprocessed training sample set; improve the learning efficiency and generalization ability of the detection model for small defects. Step S2 involves inputting the preprocessed training sample set into the PCB defect detection model for training or incremental updates. The PCB defect detection model includes a feature selection module and a hierarchical reconstruction feature fusion module. The feature selection module performs block-level filtering on the high-resolution input to determine candidate defect regions. The hierarchical reconstruction feature fusion module decouples and enhances the strong and weak features of the multi-layer features in the candidate defect regions, obtaining fused features for semantic segmentation prediction. Based on the fused features, model parameters are optimized, and the current stage of the PCB defect detection model is output. This reduces redundant computation on large-area background textures, lowers computational load and memory consumption, while maintaining detection accuracy. It also improves the detection accuracy and result stability of small defects.

[0025] Step S3: Acquire the PCB image to be detected and input it into the PCB defect detection model of the current stage; the feature selection module performs block-level filtering on the PCB image to be detected to obtain candidate defect regions to be segmented; the hierarchical reconstruction feature fusion module performs feature fusion and semantic segmentation prediction on the candidate defect regions and outputs the PCB defect detection result. Step S4: When untrained PCB image samples for the next incremental stage are obtained, the PCB defect detection model from the previous stage is used as the teacher model, and a corresponding student model is constructed. Based on an incremental learning method targeting background semantic distribution shift, the student model is incrementally trained to correct background class information shifts at both the category and semantic levels. At the output end, spatial weighted distillation of the defect region is used to suppress the background dominance effect, resulting in an updated PCB defect detection model. Simultaneously, the memory and statistics are updated for use in the next incremental stage. This addresses the issues of false detections and catastrophic forgetting caused by the continuous occurrence of PCB defects in industrial incremental scenarios and the drift of background semantic distribution with batches.

[0026] This invention proposes a PCB defect detection method for incremental industrial scenarios, comprising two key parts: a feature fusion method addressing texture noise and an incremental learning method targeting background semantic distribution shifts. The hierarchical feature fusion method extracts minute defect features from complex backgrounds and suppresses texture noise during the inference phase, while the incremental learning method updates model parameters while retaining old knowledge when the production environment changes or new defects appear, achieving closed-loop learning feedback. Specifically: To address the issues of weak feature extraction of minute defects in PCB images due to repetitive textures such as circuit traces, pads, and solder mask layers, as well as imaging noise interference, leading to easy confusion between these defects and the background and resulting in missed or false detections, and the insufficient detection speed of existing methods, this paper proposes a feature fusion method oriented towards texture noise. This method aims to achieve high-precision segmentation and stable detection of minute defects under complex background conditions. Figure 2 As shown, this method consists of three collaborative parts: random data balancing, lightweight inference based on feature selection, and feature fusion through hierarchical reconstruction, forming a complete optimized chain from data to inference to fusion. Specifically, it employs a lightweight segmentation strategy based on random pruning and separate processing of strong and weak features, combined with a feature selector to reduce redundant computations. Furthermore, in the feature fusion stage, it performs differentiated extraction and recombination of defect features with varying saliency. This significantly improves inference speed while maintaining the precision of segmentation results, solving the problems of high computational overhead and difficulty in balancing the capture of minute defects with real-time requirements in existing deep learning segmentation methods. This enables efficient online monitoring of PCB defects in complex industrial environments.

[0027] Simultaneously, addressing the dynamic visual perception process in non-stationary manufacturing environments—where production batches, material sources, surface treatment processes, and imaging lighting conditions evolve over time, leading to continuous changes in the color, texture details, and background noise distribution of the PCB substrate, resulting in background semantic drift—this invention proposes an incremental learning method to address background semantic distribution shifts. This method, in conjunction with a feature fusion method oriented towards texture noise, enables efficient online detection of PCB defects in complex industrial environments. Specifically, it employs a collaborative incremental learning method combining a background classifier adaptation mechanism with Local Semantic Distillation (LSD), Class-Specific Regularization (CSR), and Spatial Weighted Logical Alignment Distillation (SWLD). By dynamically calibrating the background prediction logic and constructing a pixel-level semantic relevance matrix, it achieves deep alignment between new and old knowledge and background distribution. This effectively solves the shortcomings of existing incremental learning methods that suffer from catastrophic forgetting due to PCB background texture evolution, significantly enhancing the continuous learning stability and memory retention capability of the detection system in non-stationary manufacturing environments, while reducing data acquisition and training costs.

[0028] Based on the above technical solution, the data preprocessing in step S1 includes the following steps: During the training phase, defect center alignment is performed on the cropping window with a preset probability. At the same time, a dynamic scaling mechanism with integrity constraints is introduced to detect the coverage rate of the defective area after cropping and compare it with a threshold. If the coverage rate is lower than the threshold, the field of view of the cropping window is automatically expanded until the defective area is completely covered or the maximum allowable scale is reached. Based on the subsequent model input requirements, the cropped image after alignment, anchoring, and dynamic scaling is resized and normalized to meet the input specifications for the network training or inference phase.

[0029] Traditional random cropping in PCB defect data can easily cause two types of problems: First, the defect area is truncated by the cropping boundary, resulting in incomplete geometric and semantic information of the defect; second, the proportion of defect pixels is extremely low, causing a serious imbalance between positive and negative samples, making the model more inclined to learn the background texture. To address this, this invention proposes a center-anchored, dynamically scaled random cropping strategy: During the training phase, defect center alignment is performed on the cropping window with a preset probability, i.e., the center of the cropping box is anchored near the coordinates of the defect center, thereby significantly increasing the probability of the defect region appearing in the cropped image, increasing the proportion of foreground defect samples, and alleviating sample imbalance. Simultaneously, a dynamic scaling mechanism with integrity constraints is introduced. Considering the large scale variation and irregular shape of defects, when the cropping window is too small, causing significant truncation of the defect structure, the inclusion rate of the cropped defect region is detected and compared with a threshold. If the inclusion rate is lower than the threshold, the field of view of the cropping window is automatically expanded until the defect region is completely covered or reaches the maximum allowable scale. Finally, the cropped image after anchoring and scaling is subjected to size unification and normalization processing to ensure consistent input size for subsequent networks, while simultaneously considering the integrity of the defect geometry and a more balanced category distribution, thereby improving the model's learning efficiency and stability for small defects.

[0030] Based on the above technical solution, the block-level filtering in step S2 includes the following steps: First, the input high-resolution PCB image is divided into several image blocks of the same size using a grid or sliding window method; Subsequently, a shared backbone network is used to extract features from each image block to obtain the corresponding block-level feature representation; Then, the feature selection module scores each block-level feature, outputs the confidence score that the image block belongs to the defect candidate region, and sorts all image blocks according to the confidence score or filters them according to a threshold. Ultimately, only the highest-scoring image patches are fed into the fine segmentation network and feature fusion module for depth calculation, while the remaining low-scoring background patches are either skipped or have their processing intensity reduced.

[0031] Lightweight inference based on a feature selection module aims to address the real-time performance limitations caused by high-resolution PCB images, large computational redundancy in whole-image inference, and extremely high background texture ratios in industrial scenarios. Specifically, this method first divides the input high-resolution PCB image into several uniformly sized image blocks using a grid or sliding window approach, enabling subsequent processing to be performed on a region-by-region basis. Then, a shared backbone network is used to perform low-cost feature extraction on each image block, obtaining a corresponding block-level feature representation. The purpose of this step is not to directly achieve fine segmentation, but rather to quickly determine whether the region may contain defects. Based on this, a feature selection module is introduced to score each block-level feature, outputting a confidence score that the image block belongs to a defect candidate region, and all image blocks are sorted or filtered by a threshold. Finally, only the image blocks with the highest scores are fed into a more complex fine-segmentation network and feature fusion module for deep computation, while the remaining low-scoring background blocks are skipped or have their processing intensity reduced, thus significantly reducing unnecessary computation and GPU memory usage. Since PCB defects are usually sparsely distributed and only account for a small proportion of the image, this screening and then fine-segmentation mechanism can concentrate computing power on high-value defect areas, improve inference speed and deployment feasibility while ensuring detection accuracy. At the same time, it reduces the interference of complex background textures on model judgment, allowing the fine network to focus more on the expression of defect boundaries and morphological details, and ultimately achieves a simultaneous improvement in the detection accuracy and inference efficiency of small defects.

[0032] Based on the above technical solution, the hierarchical reconstruction feature fusion in step S2 includes the following steps: In each fusion layer, the lower layer features are first upsampled to align with the upper layer features in terms of spatial resolution, and the aligned two types of features are then fused to obtain the initial fused features. The initial fused features are adaptively decomposed to obtain strong semantic components and weak texture components. The adaptive decomposition process involves generating a weight threshold by statistically modeling the channel response, and comparing the feature responses from different layers with the weight threshold to obtain strong semantic components and weak texture components. For strong semantic components, a lightweight channel transformation is used to extract their semantics; for weak texture components, a multi-scale enhancement module is introduced to obtain multi-scale context and long-distance dependency information in the weak texture components, and repetitive texture noise is suppressed by multi-branch asymmetric convolution and dilated receptive field expansion. The processed strong semantic components and weak texture components are fused to obtain fused features that integrate cross-layer semantic information, which are then used for PCB defect semantic segmentation and prediction tasks.

[0033] To address the issues of minute defects in PCBs being easily obscured by complex linear textures, and the accumulation of semantic biases and dilution of detailed information caused by simple addition or splicing in traditional feature pyramid fusion, this invention proposes a feature fusion strategy based on hierarchical reconstruction. This strategy uses multi-scale features from adjacent layers as the fusion object, and works collaboratively along two paths: cross-layer strong / weak decoupling reconstruction and geometrically perceptual correlation reasoning enhancement. This ensures that the fused features possess both stable semantic consistency and fine-grained perception of minute defect structures, thereby improving segmentation accuracy and robustness in scenarios with repetitive textures and noise interference.

[0034] In terms of cross-layer strong and weak decoupling and reconstruction, such as Figure 3 As shown, in each fusion layer, the lower-layer features are first upsampled and aligned with the upper-layer features in terms of spatial resolution, and then fused along the channel dimension to obtain the initial fused features. To avoid redundant superposition caused by direct mixing of deep and shallow features, this invention introduces a strong-weak decoupling reconstruction mechanism to adaptively decompose the fused features: on the one hand, extracting strong semantic components with higher information content and class discriminative power; on the other hand, retaining weak texture components with weaker responses but containing boundary details and contextual clues. This decomposition process generates weight thresholds by statistically modeling the channel responses and compares the feature responses from different layers with these thresholds to achieve the separation and aggregation of strong and weak features. In this way, the interference of irrelevant background textures in the fusion process can be explicitly reduced, and the dilution or submersion of minor defect features in the layer-by-layer fusion can be avoided.

[0035] When processing strong and weak features separately, for strong semantic components, this invention employs lightweight channel transformation to extract their semantic meaning, maintaining stable category representation and reducing redundancy. For weak texture components, considering that PCB micro-defects often exhibit local structural features such as thinness, breakage, and scratches, and are easily mixed with horizontal and vertical background trace textures, directly weakening or discarding weak features would lead to the loss of defect boundary information. Therefore, this invention introduces a multi-scale enhancement module for weak features, mining multi-scale context and long-distance dependency information in weak features with low computational overhead, and suppressing repetitive texture noise through multi-branch asymmetric convolution and hole receptive field expansion, thereby enhancing the response intensity of micro-defects while preserving details.

[0036] like Figure 3 As shown, the fusion feature that integrates cross-layer semantic information is represented as follows:

[0037] in For the reconstructed strong semantic features, For the reconstructed weak texture features, This represents a multi-scale enhancement operation on weak features. Based on the above technical solution, step S2 further includes introducing a geometric perception correlation reasoning mechanism to enhance the preliminary fused features, including the following steps: By using strip convolution to model the structural responses in the horizontal and vertical directions respectively, spatial weights with orientation selectivity are generated. Spatially weight the preliminary fusion features to obtain directionally enhanced fusion features, thereby strengthening the response of linear defects and fine fractures with obvious directional targets and suppressing irregular noise regions. Features are grouped and interacted along the channel dimension, and channels within each group are selected to form a more discriminative channel response distribution. This distribution is then added to the fusion features that incorporate cross-layer semantic information to obtain high-quality fusion features that simultaneously integrate cross-layer semantic information and geometric perception constraints. These features are then used for PCB defect semantic segmentation and prediction tasks.

[0038] Furthermore, after completing the strong and weak reconstruction, to further inject the inherent geometric prior information of the PCB image, this invention introduces a geometrically aware correlation reasoning mechanism during the fusion process. For example... Figure 4 As shown, this mechanism utilizes strip convolution to model the structural responses in the horizontal and vertical directions respectively, generating spatial weights with directional selectivity. These weights spatially weight the fused features, thereby enhancing the responses of targets with clear directional characteristics, such as linear defects and minor fractures, while suppressing irregular noise regions. Subsequently, to improve the correlation expression and discriminative competitiveness between channels, this invention performs grouping interaction and intra-group channel selection on the features along the channel dimension, forming a more discriminative channel response distribution. Residual gating is used to prevent key channels from being over-suppressed, thus stabilizing gradient propagation and enhancing the separability of minor defects. Finally, a high-quality fused feature that simultaneously integrates cross-layer semantic information and geometrically perceptual constraints is obtained for subsequent segmentation prediction.

[0039] In summary, the hierarchical reconstruction feature fusion strategy of this invention achieves fine-grained structural reconstruction and semantic consistency maintenance of minute defects in complex texture backgrounds through a collaborative mechanism of "strong-weak decoupling reconstruction—weak feature multi-scale enhancement—geometric perception correlation reasoning". Through the above fusion output, the boundary representation ability of minute defects can be effectively improved, and the interference of repetitive linear textures on model prediction can be reduced, thereby improving detection and segmentation accuracy and stability.

[0040] Based on the above technical solution, the incremental learning method for background semantic distribution shift in step S4 is implemented in an incremental phase. For example, the steps include: Construct teacher and student models, where the teacher model is the PCB defect detection model from the previous stage. The student model is a combination of the teacher model. The model obtained after parameter initialization And use the teacher model to distill the student model for learning; Before training the student model, based on the background classifier adaptation mechanism, the initialization of the new category classifier inheriting the old background classifier and the weight norm balancing of the seen category classifier are completed. During the training of the student model, local semantic feature alignment distillation is used to dynamically update the semantic memory bank and constrain the pixel-level semantic relevance distribution generated by the new and old models to remain consistent. During the training process, class-specific regularization is performed, and the decision boundary of the classifier is constrained by statistical replay to ensure that the model does not shift its semantic perception of the old category in the feature space. During the training of the student model, spatial weighted logical alignment distillation is performed to enhance the alignment of defect areas at the output end, avoid distillation being dominated by large areas of background pixels, and balance the contribution of distillation. The joint loss function optimizes and updates the student model, outputting the incremental stage. The corresponding student model is optimized and the memory and statistics are updated for the next incremental phase.

[0041] To address the persistent occurrence of PCB defects in industrial incremental scenarios and the false detections and catastrophic forgetting caused by batch-wise drift in background semantic distribution, this invention proposes an incremental learning method targeting background semantic distribution shifts. The overall system framework diagram is shown below. Figure 5 As shown, the method jointly corrects background class information offset at both the category and semantic levels, and suppresses the background dominance effect at the output through spatial weighted distillation of defect regions. This method is applied in each incremental stage. The overall process is as described above.

[0042] Based on the above technical solution, the application of the background classifier adaptation mechanism includes the following process: New category classifier inheritance initialization: For each newly introduced category classifier, inherit the weights from the old background classifier and add a small perturbation: ,in Random noise of a preset amplitude, For background classifier, For the new category classifier; Calculate the average nonnegative scaling factor of the norm of all class weights. As a criterion, the weight vectors of each category are then normalized and rescaled to the average non-negative scaling factor value. .

[0043] During the incremental learning process, changes in the classifier output layer structure are a direct cause of catastrophic forgetting. This occurs when entering a new phase. At that time, the model needs to be a new set of categories. Add a new classifier The weight vector. However, the background area of ​​the PCB image contains complex and regular circuit textures (pads, traces, solder mask, etc.), in Background classifier in stages The model has learned the discrimination boundary between complex background noise and old defects. If the new classifier is randomly initialized, the new class features are easily mismapped to the background space in the early stages of training, forming a "semantic conflict," which in turn induces the model to overclassify potential old defect regions as background. To address this, this invention introduces a background classifier adaptation mechanism before formal training, which consists of two key steps.

[0044] (1) The new class classifier is inherited and initialized. In this way, the new class classifier has the prior discrimination ability to separate new defects from complex backgrounds in the early stage of training, reducing the initialization conflict between the new class and the background.

[0045] (2) In the initial stage of incremental learning, because the new class classifier receives strong supervision signals from the current data for updates, its weight update frequency is significantly higher than that of the old class, leading to a change in the norm of the new class weights. Rapid expansion is prone to occur. This "magnitude imbalance" between new and old categories can cause the model's predicted probability distribution to be severely skewed towards the new category, thereby suppressing the recognition response to the old category. To eliminate this numerical unfairness, this paper implements a norm balancing strategy for the classifier weights of all seen categories. This preprocessing step forces the discriminative power of new and old categories back to the same magnitude, ensuring that the model's decision depends primarily on the direction of the feature vector (i.e., semantic similarity) rather than the magnitude. This corrects the background semantic distribution shift at the start of training, providing a stable foundation for subsequent distillation and regularization optimization.

[0046] Based on the above technical solution, the local semantic feature alignment distillation includes the following process: Confidence-weighted prototype generation: Based on the confidence-weighted pooling strategy, the confidence of the current student model in pixel classification is used as the weight to aggregate semantic features in a weighted manner to generate a semantic prototype; Dynamic semantic memory maintenance and update: Construct a global semantic memory containing semantic prototypes of all historical categories; at the start of the incremental phase, the global semantic memory is initialized to the state of the previous phase; during training, for the categories appearing in the current batch of data, the prototype of the current batch is calculated using a confidence-weighted pooling strategy, and the corresponding prototype in the global memory is updated online using an exponential moving average strategy. Correlation matrix calculation: The input image is fed into the frozen old model and the currently trained new model respectively, and feature maps are extracted respectively; the feature maps are reshaped into two-dimensional matrices and normalized; then, the correlation matrix between the feature maps and the global semantic memory is calculated respectively, where the elements in the matrix represent the cosine similarity between a pixel and a semantic prototype in the global semantic memory. Distillation loss optimization: Softmax normalization with temperature parameter is applied to each row of the correlation matrix; the final local semantic distillation loss is the KL divergence between the output distributions of the old and new models; the local semantic distillation loss is minimized and constrained to the new model.

[0047] In incremental semantic segmentation tasks, as new categories are continuously added, older categories are often labeled as background in the current training data. This lack of supervision signals leads to the model rapidly forgetting the feature distributions of older categories, a phenomenon known as catastrophic forgetting. To maintain the memory of older categories without storing large amounts of old data, this paper proposes an improved local semantic feature alignment distillation step. For example... Figure 6 As shown, the core idea of ​​this module is: A cross-stage semantic memory is constructed, and a correlation matrix between current image pixels and historical semantic prototypes is established during training. By constraining the consistency of the old and new models in generating this correlation matrix, it is ensured that the model's semantic perception of old categories in the feature space does not shift. To improve the representational ability of prototypes and adapt to the evolution of the feature space, the Local Semantic Feature Alignment Distillation (LSFAD) module introduces a confidence-weighted pooling strategy to generate higher-quality category prototypes and employs a dynamic memory update mechanism to optimize the memory in real time during training. The specific implementation process of the LFAD module mainly includes four steps: confidence-weighted prototype generation, dynamic memory maintenance, correlation matrix calculation, and distillation loss optimization.

[0048] To preserve feature information from older categories with limited storage overhead, this paper employs prototypes to represent the semantic centers of each category. A traditional approach is to perform simple average pooling on the features of all pixels within a category. However, during incremental learning, the model's predictions of the current data may contain noise, and simple averaging will include low-quality or misclassified pixel features in the prototype calculation, weakening the representativeness of the prototype. Therefore, this paper proposes a confidence-weighted pooling strategy. This strategy uses the current model's confidence in pixel classification as weights to perform weighted aggregation of features. By introducing confidence weighting, the model can focus more on high-confidence, representative pixel features, thereby generating more robust and accurate category prototypes.

[0049] As the incremental steps progress, the system maintains a global semantic memory, which is a collection of semantic prototypes for all historical categories. In the old approach, the memory was only updated during stage transitions, and the old category prototypes remained unchanged. However, with the addition of new classes and model updates, the entire feature space changes, and the completely frozen old category prototypes may gradually deviate from their true distribution in the current feature space. To address this issue, this paper proposes a dynamic memory update mechanism. At the start of the incremental stage, the memory is initialized to the state of the previous stage. During training, for each category appearing in the current batch of data, we use the aforementioned confidence-weighted pooling to calculate the prototype for the current batch, and then use an exponential moving average (EMA) strategy to update the corresponding prototype in the global memory online. This dynamic update mechanism ensures that the prototypes in the memory can slowly adapt to changes in the feature space of the current model, maintaining their freshness, while the momentum mechanism guarantees the stability of the prototypes, avoiding excessive interference from noise in the current batch.

[0050] During the training phase, for any new input image, the Local Semantic Feature Alignment Distillation (LSFAD) module aims to measure the semantic similarity between pixels in the current image and semantic prototypes stored in the semantic memory. First, the input image is fed into both the frozen old model and the currently trained new model to extract feature maps. These feature maps are then reshaped into two-dimensional matrices and normalized. Subsequently, the correlation matrix between the feature maps and the global semantic memory is calculated. The elements in the matrix represent the cosine similarity between a pixel and a semantic prototype in the memory. This matrix encodes the structured semantic relationship between the current pixel and historical knowledge (represented by dynamic prototypes).

[0051] To transfer the semantic relationships understood by the old model to the new model, the Local Semantic Feature Alignment Distillation (LSFAD) module achieves knowledge distillation by minimizing the difference in the distribution of the correlation matrices of the two models. Before calculating the loss, to smooth the distribution and focus on high-response regions, each row of the correlation matrix (i.e., the response of each pixel to all prototypes) is subjected to Softmax normalization with a temperature parameter. The final local semantic distillation loss is defined as the KL divergence between the output distributions of the old and new models. Constrained by this loss, the new model is forced to maintain a feature response pattern highly consistent with the old model for regions that potentially belong to the old category when processing new images. By combining high-level confidence prototypes and a dynamic update mechanism, this method more effectively prevents the feature extractor from destroying the existing semantic space structure when learning new defects, thereby mitigating catastrophic forgetting.

[0052] Based on the above technical solution, the class-specific regularization includes the following process: In the incremental phase At that time, for each old category Extract the corresponding pixel embedding set from the global semantic feature memory, and calculate the mean and covariance of the category in the feature space:

[0053] in This indicates that the category belongs to the global semantic memory. The set of embedded features; Subsequently, assuming that the old category features approximately follow a Gaussian distribution, Several virtual old class embeddings are generated in the feature space for the parameters as replay samples. ,in It is a non-negative scaling factor; used to adjust the dispersion of the generated samples.

[0054] The generated embeddings are copied and stacked with the features. Figure 1 The tensor structure is then fed into... The cross-entropy replay loss is calculated in a classifier implemented using convolution.

[0055] To further mitigate classifier decision boundary drift caused by background semantic distribution shift, this invention designs a class-specific regularization module. The core idea of ​​this module is to statistically replay the old class distribution in the deep feature space using class-specific feature statistics accumulated in historical stages without storing old image data. This prompts the classifier to continuously review the discrimination boundary of the old class while learning the new class, reducing the risk of the old class being encroached upon by the new background semantics.

[0056] To adapt to the classifier input format of semantic segmentation networks, the generated embeddings can be copied and stacked with the features. Figure 1 The tensor structure is then fed into... In the convolutional classifier, the cross-entropy replay loss is calculated. This regularization term continuously constrains the classifier to the vicinity of the statistical distribution of the old classes during optimization, thus suppressing excessive shifts in the decision boundary with the distribution of data in the new stage. Furthermore, when the number of old classes or generated samples is large, leading to increased computational cost, an upper bound estimate can be used to approximate the generation replay loss, reducing computational cost while maintaining the constraint effect.

[0057] Based on the above technical solution, the spatially weighted logically aligned distillation operation includes the following process: First, temperature scaling is introduced at the output of the teacher model and the student model to soften the logits of both models and obtain a smoother soft probability distribution. Subsequently, a spatial weighting mechanism is introduced to construct a pixel-level weighted mask: for each pixel Assign a spatial weight When the pixel's true label When it belongs to the background category, the weight is 1; when When it belongs to any foreground defect category, the weight is taken as follows: ;in This is used to increase the contribution of defective pixels to loss calculation; Finally, during loss calculation, the difference between the teacher's soft distribution and the student's soft distribution is calculated for each pixel location, and the difference terms are weighted and summarized using the aforementioned spatial weights; the total weights are normalized to stabilize the loss scale under different image / different defect proportion conditions.

[0058] In PCB defect detection scenarios, where targets are extremely sparse, traditional pixel-level logic distillation often fails. Since background pixels occupy the majority of the image area, simple full-image average distillation leads to the distillation signal for critical defect areas being overwhelmed or diluted by massive background noise. Therefore, this invention designs a spatially weighted logic-aligned distillation at the output end, aiming to rebalance the distillation contribution through a foreground-aware spatial reweighting strategy.

[0059] like Figure 7 As shown, specifically, by introducing temperature scaling at the output, its function is to explicitly expose the relative confidence information of the suboptimal category, enabling the distillation process not only to align the final prediction result but also to convey fine-grained similarity relationships between categories. In PCB defect segmentation tasks, this type of dark knowledge is particularly important for defect types with similar appearances, blurred boundaries, or significant noise interference.

[0060] Subsequently, to overcome the characteristics of PCB scenarios where background pixels constitute the vast majority and defect pixels are extremely sparse, this module introduces a spatial weighting mechanism to construct a pixel-level weight mask. This prevents the distillation process from being dominated by massive background pixels, instead focusing the learning on the defect regions that truly affect performance. Specifically, based on the current stage's actual annotations, background pixels are assigned basic weights, while any defect pixel (whether old or new) is assigned a higher weight. This significantly amplifies the contribution of defect regions to the distillation loss, enabling them to generate sufficiently strong gradient signals during backpropagation.

[0061] During loss calculation, this module calculates the difference (e.g., KL divergence) between the teacher's soft distribution and the student's soft distribution for each pixel location, and uses the aforementioned spatial weights to weight and summarize the difference terms. Simultaneously, the total weights are normalized to stabilize the loss scale under different image / defect ratio conditions. This ensures that even if the defect region occupies only a very small proportion of the image, its impact on distillation optimization remains sufficiently significant and is not "diluted" by the background region.

[0062] Through the above design, spatial weighted logical alignment distillation can force the student model to more precisely imitate the decision-making pattern of the teacher model in sparse defect regions: on the one hand, it strengthens the preservation of old knowledge at the output probability level and reduces the probability of old defects being misclassified as background; on the other hand, it improves the learning efficiency and boundary characterization ability of small new defects, thereby obtaining more stable and robust segmentation performance in incremental scenarios with significant background semantic drift.

[0063] Based on the above technical solution, the joint loss function optimization operation includes the following process: Construct the overall objective loss function:

[0064] in, For standard pixel-level cross-entropy loss, For local semantic distillation loss, For class-specific regularization loss, For spatially weighted logical alignment distillation loss, , , For the corresponding , , The non-negative hyperparameter of the loss; In the incremental phase During the training process, by minimizing Update the student model parameters and output the optimized student model for the next incremental phase.

[0065] To effectively suppress catastrophic forgetting while learning new categories, this invention employs a joint optimization strategy, combining the supervised loss of the segmentation task with the aforementioned multi-level anti-forgetting regularization term. Standard pixel-level cross-entropy loss is used. Based on this, an overall objective function is constructed, in which non-negative hyperparameters are used to dynamically adjust the contribution weights of semantic feature alignment, class-specific statistical regularization, and spatial logical distillation to the overall objective.

[0066] By minimizing Update the student model parameters. Simultaneously, update the local semantic memory and old class statistics online. After training, output the incremental model for the current stage, and pass the updated memory and statistical information to the next stage, forming a closed-loop continuous learning system.

[0067] The foregoing has shown and described the basic principles and main features of the present invention. It will be apparent to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments. Therefore, the embodiments should be considered as exemplary and not restrictive. The scope of the present invention is defined by the appended claims rather than the foregoing description. Therefore, it is intended that all variations falling within the meaning and scope of the equivalents of the claims be included within the present invention.

[0068] Furthermore, it should be understood that although this specification describes embodiments, not every embodiment contains only one independent technical solution. This narrative style is merely for clarity. Those skilled in the art should consider the specification as a whole, and the technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by those skilled in the art.

Claims

1. A PCB defect detection method for incremental industrial scenarios, characterized in that, Includes the following steps: Step S1: Obtain PCB image samples and their annotation information for the current stage, and perform data preprocessing on the PCB image samples; the data preprocessing includes data balancing processing based on random cropping and cropping window adjustment based on geometric integrity constraints, to increase the effective proportion of defect areas in the training samples and reduce the sample distribution imbalance caused by defect truncation, and output the preprocessed training sample set. Step S2: Input the preprocessed training sample set into the PCB defect detection model for training or incremental update; wherein, the PCB defect detection model includes a feature selection module and a hierarchical reconstruction feature fusion module. The feature selection module is used to perform block-level filtering on the high-resolution input to determine defect candidate regions. The hierarchical reconstruction feature fusion module is used to decouple strong and weak features and perform hierarchical enhancement on the multi-layer features of the defect candidate regions to obtain fused features for semantic segmentation prediction; Based on the fused features, the model parameters are optimized, and the PCB defect detection model for the current stage is output; Step S3: Acquire the PCB image to be detected and input it into the PCB defect detection model of the current stage; the feature selection module performs block-level filtering on the PCB image to be detected to obtain candidate defect regions to be segmented; the hierarchical reconstruction feature fusion module performs feature fusion and semantic segmentation prediction on the candidate defect regions and outputs the PCB defect detection result. Step S4: When the untrained PCB image samples for the next incremental stage are obtained, the PCB defect detection model of the previous stage is used as the teacher model, and the corresponding student model is constructed. Based on the incremental learning method for background semantic distribution offset, the student model is incrementally trained to correct the background class information offset from the category level and semantic level. At the output end, the background dominance effect is suppressed by spatial weighted distillation of the defect area, and the updated PCB defect detection model is output. At the same time, the memory and statistics are updated for use in the next incremental stage.

2. The PCB defect detection method for incremental industrial scenarios according to claim 1, characterized in that, The data preprocessing in step S1 includes the following steps: During the training phase, defect center alignment is performed on the cropping window with a preset probability. At the same time, a dynamic scaling mechanism with integrity constraints is introduced to detect the coverage rate of the defective area after cropping and compare it with a threshold. If the coverage rate is lower than the threshold, the field of view of the cropping window is automatically expanded until the defective area is completely covered or the maximum allowable scale is reached. Based on the subsequent model input requirements, the cropped image after alignment, anchoring, and dynamic scaling is resized and normalized.

3. The PCB defect detection method for incremental industrial scenarios according to claim 1, characterized in that, The block-level filtering in step S2 includes the following steps: First, the input high-resolution PCB image is divided into several image blocks of the same size using a grid or sliding window method; Subsequently, a shared backbone network is used to extract features from each image block to obtain the corresponding block-level feature representation; Then, the feature selection module scores each block-level feature, outputs the confidence score that the image block belongs to the defect candidate region, and sorts all image blocks according to the confidence score or filters them according to a threshold. Ultimately, only the highest-scoring image patches are fed into the fine segmentation network and feature fusion module for depth calculation, while the remaining low-scoring background patches are either skipped or have their processing intensity reduced.

4. The PCB defect detection method for incremental industrial scenarios according to claim 1, characterized in that, The hierarchical reconstruction feature fusion in step S2 includes the following steps: In each fusion layer, the lower layer features are first upsampled to align with the upper layer features in terms of spatial resolution, and the aligned two types of features are then fused to obtain the initial fused features. The initial fused features are adaptively decomposed to obtain strong semantic components and weak texture components. The adaptive decomposition process involves generating a weight threshold by statistically modeling the channel response, and comparing the feature responses from different layers with the weight threshold to obtain strong semantic components and weak texture components. For strong semantic components, a lightweight channel transformation is used to extract their semantics; for weak texture components, a multi-scale enhancement module is introduced to obtain multi-scale context and long-distance dependency information in the weak texture components, and repetitive texture noise is suppressed by multi-branch asymmetric convolution and dilated receptive field expansion. The processed strong semantic components and weak texture components are fused to obtain fused features that integrate cross-layer semantic information, which are then used for PCB defect semantic segmentation and prediction tasks.

5. The PCB defect detection method for incremental industrial scenarios according to claim 4, characterized in that, Step S2 further includes introducing a geometric perception correlation reasoning mechanism to enhance the preliminary fused features, including the following steps: By using strip convolution to model the structural responses in the horizontal and vertical directions respectively, spatial weights with orientation selectivity are generated. Spatially weight the preliminary fusion features to obtain directionally enhanced fusion features, thereby strengthening the response of linear defects and fine fractures with obvious directional targets and suppressing irregular noise regions. Features are grouped and interacted along the channel dimension, and channels within each group are selected to form a more discriminative channel response distribution. This distribution is then added to the fusion features that incorporate cross-layer semantic information to obtain high-quality fusion features that simultaneously integrate cross-layer semantic information and geometric perception constraints. These features are then used for PCB defect semantic segmentation and prediction tasks.

6. The PCB defect detection method for incremental industrial scenarios according to claim 1, characterized in that, The incremental learning method for background semantic distribution shift in step S4 is based on an incremental phase. For example, the steps include: Construct teacher and student models, where the teacher model is the PCB defect detection model from the previous stage. The student model is a combination of the teacher model. The model obtained after parameter initialization And use the teacher model to distill the student model for learning; Before training the student model, based on the background classifier adaptation mechanism, the initialization of the new category classifier inheriting the old background classifier and the weight norm balancing of the seen category classifier are completed. During the training of the student model, local semantic feature alignment distillation is used to dynamically update the semantic memory bank and constrain the pixel-level semantic relevance distribution generated by the new and old models to remain consistent. During the training process, class-specific regularization is performed, and the decision boundary of the classifier is constrained by statistical replay to ensure that the model does not shift its semantic perception of the old category in the feature space. During the training of the student model, spatial weighted logical alignment distillation is performed to enhance the alignment of defect areas at the output end, avoid distillation being dominated by large areas of background pixels, and balance the contribution of distillation. The joint loss function optimizes and updates the student model, outputting the incremental stage. The corresponding student model is optimized and the memory and statistics are updated for the next incremental phase.

7. The PCB defect detection method for incremental industrial scenarios according to claim 6, characterized in that, The application of the background classifier adaptation mechanism includes the following processes: New category classifier inheritance initialization: For each newly introduced category classifier, inherit the weights from the old background classifier and add a small perturbation: ,in Random noise of a preset amplitude, For background classifier, For the new category classifier; Calculate the average nonnegative scaling factor of the norm of all class weights. As a criterion, the weight vectors of each category are then normalized and rescaled to the average non-negative scaling factor value. .

8. A PCB defect detection method for incremental industrial scenarios according to claim 6, characterized in that, The local semantic features are aligned and distilled. The process includes the following: Confidence-weighted prototype generation: Based on the confidence-weighted pooling strategy, the confidence of the current student model in pixel classification is used as the weight to aggregate semantic features in a weighted manner to generate a semantic prototype; Dynamic semantic memory maintenance and update: Construct a global semantic memory containing semantic prototypes of all historical categories; at the start of the incremental phase, the global semantic memory is initialized to the state of the previous phase; during training, for the categories appearing in the current batch of data, the prototype of the current batch is calculated using a confidence-weighted pooling strategy, and the corresponding prototype in the global memory is updated online using an exponential moving average strategy. Correlation matrix calculation: The input image is fed into the frozen old model and the currently trained new model respectively, and feature maps are extracted respectively; The feature map is reshaped into a two-dimensional matrix and then normalized. Subsequently, the correlation matrix between the feature map and the global semantic memory is calculated, where the elements in the matrix represent the cosine similarity between a pixel and a semantic prototype in the global semantic memory. Distillation loss optimization: Softmax normalization with temperature parameter is applied to each row of the correlation matrix; the final local semantic distillation loss is the KL divergence between the output distributions of the old and new models; the local semantic distillation loss is minimized and constrained to the new model.

9. A PCB defect detection method for industrial incremental scenarios according to claim 6, characterized in that, The class-specific regularization includes the following process: In the incremental phase At that time, for each old category Extract the corresponding pixel embedding set from the global semantic feature memory, and calculate the mean and covariance of the category in the feature space: in This indicates that the category belongs to the global semantic memory. The set of embedded features; Subsequently, assuming that the old category features approximately follow a Gaussian distribution, Several virtual old class embeddings are generated in the feature space for the parameters as replay samples. ,in It is a non-negative scaling factor; The generated embeddings are copied and stacked into a tensor structure consistent with the feature map, and then fed into... The cross-entropy replay loss is calculated in a classifier implemented using convolution.

10. A PCB defect detection method for incremental industrial scenarios according to claim 6, characterized in that, The spatially weighted logically aligned distillation operation includes the following process: First, temperature scaling is introduced at the output of the teacher model and the student model to soften the logic of both and obtain a smoother soft probability distribution. Subsequently, a spatial weighting mechanism is introduced to construct a pixel-level weighted mask: for each pixel Assign a spatial weight When the pixel's true label When it belongs to the background category, the weight is 1; when When it belongs to any foreground defect category, the weight is taken as follows: ;in This is used to increase the contribution of defective pixels to loss calculation; Finally, during loss calculation, the difference between the teacher's soft distribution and the student's soft distribution is calculated for each pixel location, and the difference terms are weighted and summarized using the aforementioned spatial weights; the total weights are normalized to stabilize the loss scale under different image / different defect proportion conditions.

11. The PCB defect detection method for incremental industrial scenarios according to claim 1, characterized in that, The joint loss function optimization operation The process includes the following: Construct the overall objective loss function: in, For standard pixel-level cross-entropy loss, For local semantic distillation loss, For class-specific regularization loss, For spatially weighted logical alignment distillation loss, , , For the corresponding , , The non-negative hyperparameter of the loss; In the incremental phase During the training process, by minimizing Update the student model parameters and output the optimized student model for the next incremental phase.