Defect detection method and system based on texture enhancement and dynamic pseudo label screening
By introducing a texture enhancement module and a category-based dynamic pseudo-label screening module into industrial surface defect detection, the problems of pseudo-label noise and category supervision imbalance are solved, and efficient detection under low labeling conditions is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CENT SOUTH UNIV
- Filing Date
- 2026-01-22
- Publication Date
- 2026-04-17
AI Technical Summary
Existing semi-supervised inspection methods suffer from problems such as high false label noise and unbalanced category supervision in industrial surface defect detection, especially in the case of texture ambiguity and low contrast background, resulting in poor detection performance.
A texture enhancement module is introduced to improve texture discrimination ability in the shallow feature stage of the backbone network. A pseudo-label selection module is used to adaptively select pseudo-labels. Combined with a teacher-student self-training framework and exponential moving average to update parameters, the reliability and class balance of pseudo-labels are improved.
It improves the quality of pseudo-labels and training stability with a low annotation ratio, thereby enhancing the accuracy and reliability of defect detection, and is suitable for industrial online visual inspection scenarios.
Smart Images

Figure CN121883995A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of surface defect detection technology, and in particular to a defect detection method and system based on texture enhancement and dynamic pseudo-label screening. Background Technology
[0002] Automated visual inspection is a crucial part of industrial manufacturing, and surface defect detection directly impacts product reliability and production safety. Although deep learning object detection has made progress in natural images, its widespread application in industrial defect scenarios is hampered by the difficulty in obtaining high-quality labeled data. Since defects are often subtle, low-contrast anomalies with unclear boundaries, the labeling process relies on domain knowledge and requires consistent localization accuracy. This results in high data acquisition and labeling costs, long cycles, and susceptibility to labeling inconsistencies, thus limiting the scalable application of fully supervised methods.
[0003] Semi-supervised object detection utilizes a teacher-student self-training framework to generate pseudo-labels from unlabeled data, thereby reducing reliance on manual annotation. However, industrial surface defect images differ significantly from natural scene images. Existing general-purpose semi-supervised detection methods for industrial surface defects are prone to problems such as high pseudo-label noise and class imbalance in supervision, mainly manifested in: 1) Texture Ambiguity and Low-Contrast Background: Industrial surfaces often exhibit repetitive textures and weak-contrast backgrounds. Defects and substrate textures are mixed and have unclear boundaries, making the shallow texture feature stage of the network prone to foreground-background confusion. As a result, the teacher detector may miss real defects, produce low-confidence predictions, or produce false detections due to class confusion, leading to a decrease in the quality of false labels, which is amplified in the self-training loop.
[0004] 2) Significant differences in category detection difficulty: The visibility of different defect categories varies greatly, and the teacher prediction confidence shows category bias. If a single global threshold is used to filter pseudo-labels, it often discards real positive samples of difficult categories while retaining noisy pseudo-labels of easy categories, causing an imbalance in category supervision and affecting overall performance and the performance of long-tail categories.
[0005] Therefore, there is an urgent need for a semi-supervised detection scheme for industrial surface defects that can improve the ability to distinguish shallow features in areas of texture ambiguity and can adaptively filter pseudo-labels based on different confidence distributions, thereby improving the reliability and class balance of pseudo-labels. Summary of the Invention
[0006] This invention provides a defect detection method and system based on texture enhancement and dynamic pseudo-label screening, aiming to solve at least one of the above-mentioned technical problems.
[0007] This invention provides the following technical solution: On the one hand, the present invention provides a defect detection method based on texture enhancement and dynamic pseudo-label screening, comprising the following steps: S10: Obtain original images of industrial surface defects, construct an industrial surface defect detection dataset, and divide it into labeled and unlabeled datasets; S20: Construct a defect detection network structure, which consists of a backbone feature extraction network, a feature fusion network, and a detection head network, and introduces a texture enhancement module in the shallow feature stage of the backbone feature extraction network; S30: Construct teacher detectors and student detectors, and establish a teacher-student self-training and update mechanism, updating teacher detector parameters based on student detector parameters using an exponential moving average method; S40: During the training iteration, generate weakly augmented and strongly augmented views for the unlabeled image; S50: Input the weakly enhanced view of the unlabeled image obtained in step S40 into the teacher detector to generate a set of candidate pseudo-labels; S60: Input the candidate pseudo-label set obtained in step S50 into the category-based dynamic pseudo-label filtering module, determine the category adaptive filtering threshold according to the confidence score distribution of each defect category, and perform category-based dynamic filtering on the candidate pseudo-labels accordingly, and output the filtered pseudo-label set. S70: Input the strongly augmented view of the unlabeled image and the labeled image obtained in step S40 into the student detector. Perform semi-supervised training on the strongly augmented view of the unlabeled image using the filtered pseudo-label set output in step S60, and perform supervised training using the real labels of the labeled dataset as the supervision signal to obtain the updated student detector parameters. Then, update the teacher detector parameters according to the updated student detector parameters using an exponential moving average method. Iterate through steps S40 to S70 until the preset convergence condition is met. S80: After training, the trained detection model is used to detect defects in the industrial surface image to be inspected, and the defect category and location information are output.
[0008] Preferably, the texture enhancement module in step S20 is used to perform texture-aware enhancement processing on the shallow features of the backbone network. The texture enhancement module includes a texture descriptor construction unit, a routing feature construction unit, a block-level routing and expert transformation unit, and a feature fusion unit.
[0009] Preferably, step S20 specifically includes the following steps: S21: Input C3 feature map; S22: The texture descriptor construction unit projects the C3 feature map and constructs a global texture prototype; S23: A texture consistency representation is obtained by the similarity between local features and global texture prototypes, and a texture descriptor is obtained by statistical mapping; S24: The routing feature construction unit concatenates the C3 feature map with the texture descriptor to obtain a routing feature map; S25: The block-level routing and expert transformation unit divides the routing feature map into multiple non-overlapping blocks and performs embedding serialization. Based on the affinity between the sequence and multiple experts, it determines the set of selected experts and obtains normalized gating weights. The corresponding block performs transformation on the selected experts and is weighted and aggregated according to the gating weights to obtain the block-level enhancement result. S26: The feature fusion unit folds the enhancement results of each block back to their original spatial positions and performs residual fusion with the original C3 feature map to obtain the texture-enhanced output features.
[0010] Preferably, in step S20, steps S22-S24 specifically include: S221: First, the C3 feature map is projected into low-dimensional local features through 1×1 convolution. Then, global average pooling is applied to the low-dimensional local features to obtain the global prototype vector. S222: For each spatial location on the feature map, calculate the cosine similarity between the local feature and the global prototype vector to obtain the similarity map; S223: The similarity graph was subsequently soft-quantized to Several levels to capture the distribution of local texture consistency; S224: Finally, local average pooling is applied to the neighborhood to aggregate the spatial context, followed by 1×1 convolution to generate the final texture-aware descriptor. S225: Concatenate the C3 feature map with the texture-aware descriptor in parallel to form a routing feature map.
[0011] Preferably, in step S20, step S25 specifically includes: S251: The routing feature map is divided into multiple non-overlapping regions of the same size, and each region is processed by global average pooling and multilayer perceptron for image block-level embedding. S252: The linear router calculates an affinity score for each expert with each image patch embedding sequence; S253: Each expert selects the one with the highest affinity score. A sequence is formed into an allocation set, and pairs are allocated using capacity factors. Parameterization is performed to maintain a stable routing budget across different resolutions; S254: Define a binary selection mask, which normalizes the expert weight matrix for each image block for the selected expert, and image blocks not selected by any expert directly bypass the expert calculation. S255: Each expert network is implemented as a lightweight depthwise separable convolutional module, which outputs the corresponding feature signal for the image patch extracted from the C3 feature map. The final refined feature of the image patch is the gated weighted sum of the output signals of each expert. S256: By extracting non-overlapping image patches from the C3 feature map and performing the inverse operation, each image patch is restored to its original spatial position to reconstruct the feature map, forming texture refinement features; S257: Finally, the output features of the texture enhancement module are obtained through residual linking.
[0012] Preferably, the class-based dynamic pseudo-label filtering module in step S60 is used to perform class-based adaptive filtering of candidate pseudo-labels output by the teacher detector. The class-based dynamic pseudo-label filtering module includes a class-based confidence caching unit, a class-based distribution modeling unit, a threshold generation unit, and a pseudo-label filtering unit.
[0013] Preferably, step S60 specifically includes the following steps: S61: The confidence cache unit by category maintains a first-in-first-out cache area for each defect category, which is used to store the confidence scores of the candidate pseudo-labels corresponding to the defect category and update them iteratively; S62: The class-based distribution modeling unit performs bimodal probability modeling on the score distribution of defect categories based on the cache area, distinguishing between low-confidence components and high-confidence components; S63: The threshold generation unit generates an adaptive screening threshold for each category based on the modeling results, and sets a lower limit constraint on the adaptive screening threshold; S64: The pseudo-label filtering unit retains or removes candidate pseudo-labels belonging to the defect category according to rules. When its confidence score is greater than or equal to the adaptive scoring threshold of the updated defect category, it is retained; otherwise, it is filtered out. This enables dynamic filtering of candidate pseudo-labels of different categories and alleviates the imbalance of category supervision caused by the global threshold.
[0014] On the other hand, the present invention provides a defect detection system based on texture enhancement and dynamic pseudo-label screening, for performing the above-mentioned defect detection method based on texture enhancement and dynamic pseudo-label screening, including: The data acquisition and enhancement module is used to acquire images of industrial surface defects and construct a dataset, which is divided into labeled data and unlabeled data, and generates weakly enhanced and strongly enhanced views for the unlabeled images. A teacher detector is used to detect weakly augmented views to generate candidate pseudo-labels; A student detector is used for training and updating under the joint supervision of labeled data and filtered pseudo-labels. A texture enhancement module is introduced into the shallow feature stage of the backbone network of the teacher detector and the student detector to enhance the texture perception of shallow features in order to improve the reliability of candidate pseudo-labels. The dynamic pseudo-label filtering module by category is used to determine the adaptive filtering threshold for each category based on the confidence score distribution of each defect category, and to perform dynamic filtering of candidate pseudo-labels by category. The training optimization module is used for supervised training based on labeled data and semi-supervised training on unlabeled data using filtered pseudo-labels, while updating the teacher detector parameters through exponential moving average.
[0015] Compared with the prior art, the beneficial effects of the present invention are: This invention provides a defect detection method and system based on texture enhancement and dynamic pseudo-label selection, which can better solve the problems of high pseudo-label noise and class supervision imbalance in semi-supervised detection of surface defects under complex textures and low contrast backgrounds. Specifically, in the teacher-student self-training framework, a texture enhancement module is introduced at the shallow feature stage of the backbone network to enhance the shallow discriminative features of texture ambiguity and low contrast regions, thereby reducing foreground-background confusion and improving the reliability of candidate pseudo-labels generated by the teacher detector. At the same time, a dynamic pseudo-label selection module is set up to determine the class adaptive selection threshold based on the confidence distribution of different defect categories, realizing the dynamic selection of candidate pseudo-labels by category. This suppresses noisy pseudo-labels while retaining effective positive samples of difficult categories, alleviating the class supervision imbalance caused by the global threshold.
[0016] Compared with existing semi-supervised defect detection methods, this invention synergistically improves pseudo-label quality and training stability from two aspects: "shallow texture feature enhancement" and "dynamic pseudo-label selection by category". It also combines the teacher detector parameter update mechanism of exponential moving average to make the training process more stable and convergence more reliable, and can still achieve better defect detection results under the condition of low label ratio. In addition, this invention only uses a single detection model to output defect category and location information during the inference stage, and the dynamic pseudo-label selection module does not participate in inference. Therefore, the deployment process is simplified and the inference overhead is low, making it suitable for industrial online visual inspection scenarios.
[0017] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description
[0018] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. In the drawings: Figure 1 The flowchart of the defect detection method and system based on texture enhancement and dynamic pseudo-label screening provided by the present invention is shown below. Figure 2 This is a schematic diagram of the overall texture enhancement module of the defect detection method and system based on texture enhancement and dynamic pseudo-label screening provided by the present invention. Figure 3 A schematic diagram of the texture descriptor in the texture enhancement module of the defect detection method and system based on texture enhancement and dynamic pseudo-label filtering provided by the present invention; Figure 4 In the diagram, A represents the GMM score distribution for the easy category, and B represents the GMM score distribution for the difficult category. Detailed Implementation
[0019] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.
[0020] The present invention will now be described in detail with reference to the accompanying drawings and embodiments. The following experimental examples and embodiments are used to further illustrate, but are not limited to, the present invention.
[0021] Please refer to the following: Figures 1 to 4 This invention provides a defect detection method and system based on texture enhancement and dynamic pseudo-label screening, specifically including a texture enhancement module and a category-based dynamic pseudo-label screening module.
[0022] This invention proposes a texture enhancement module and introduces it into the shallow feature stage of the backbone network of a defect detection network. Addressing the characteristics of industrial surface images, such as repetitive textures, low-contrast backgrounds, and unclear defect boundaries, existing semi-supervised detection methods are prone to foreground-background confusion in the shallow texture feature stage. This leads to false labels generated by the teacher detector being prone to missed detections, false detections, or low confidence levels.
[0023] To this end, the present invention enhances texture perception on shallow features, strengthens the discrimination cues in ambiguous texture regions, and reduces background interference, thereby improving the reliability of candidate pseudo-labels generated by the teacher detector and improving the feature learning quality of the student detector's self-training process.
[0024] This invention proposes a class-based dynamic pseudo-label filtering module for adaptively filtering candidate pseudo-labels output by the teacher detector. Addressing the issues of significant differences in detection difficulty across different defect categories and class bias in teacher prediction confidence, using a uniform global threshold for pseudo-label filtering easily discards genuine positive samples from difficult categories while retaining noisy pseudo-labels from easy categories, resulting in an imbalance in class supervision. Therefore, this invention determines an adaptive filtering threshold based on the confidence distribution of each defect category, enabling dynamic class-based filtering of candidate pseudo-labels. This suppresses noisy pseudo-labels while retaining valid positive samples from difficult categories, improving training stability and detection performance. After training, during the inference phase, only a single detection model outputs defect category and location information; the class-based dynamic pseudo-label filtering module does not participate in inference.
[0025] Figure 1 The algorithm flow is described below. First, surface defect images are acquired from industrial production sites, and a dataset containing both labeled and unlabeled data is constructed. Then, within a teacher-student self-training framework, weakly enhanced and strongly enhanced views are generated for the unlabeled images. The weakly enhanced view is input into the teacher detector to generate candidate pseudo-labels. These candidate pseudo-labels are then filtered by a class-based dynamic pseudo-label filtering module and used for semi-supervised training of the student detector on the strongly enhanced view. Simultaneously, labeled data is used for supervised training of the student detector, with the teacher detector parameters updated by the student detector parameters using an exponential moving average. After training, during the inference phase, only a single detection model is used to output defect category and location information for the image to be detected; the class-based dynamic pseudo-label filtering module does not participate in inference.
[0026] The method provided by this invention can accurately detect industrial defects while ensuring real-time detection.
[0027] Specifically, the defect detection method based on texture enhancement and dynamic pseudo-label screening proposed in this invention includes the following steps: S10: Obtain raw images of industrial surface defects, construct an industrial surface defect detection dataset, and divide it into an labeled dataset and an unlabeled dataset; the labeled data includes images, defect detection boxes and their category labels, while the unlabeled data only contains images; S20: Construct a defect detection network structure, which consists of a backbone feature extraction network, a feature fusion network, and a detection head network. In a specific embodiment, the defect detection network structure is a two-stage detection structure, preferably Faster R-CNN, using ResNet-50 as the backbone feature extraction network, and introducing a texture enhancement module (TEM) in the shallow feature stage of the backbone feature extraction network. The texture enhancement module is preferably deployed in stage C3 to perform texture-aware enhancement processing on the shallow features.
[0028] For details, please refer to Figure 2 The diagram illustrates the structure of the Texture Enhancement Module (TEM) in step S20, which operates in three stages: 1) Construct the texture descriptor; 2) Divide the features into blocks and route them to the expert module; 3) Apply expert transformations and merge the results. First, construct the texture descriptor, such as Figure 3 As shown, this is used to quantify the deviation between the local texture and the global texture prototype, thereby highlighting potential anomalous areas.
[0029] The input C3 feature map is first projected into low-dimensional local features through a 1×1 convolution, and then global average pooling (GAP) is applied to the low-dimensional local features to obtain the global prototype vector. (1) (2) in, This is a low-dimensional local feature map obtained through 1×1 convolution. The input is the C3 feature map. This is the global prototype vector. as well as It represents the dimensional space of the data.
[0030] For each spatial location on the feature map, the cosine similarity between the local feature and the global prototype vector is calculated to obtain the similarity map: (3) in, , For spatial location on the feature map, For position Local feature vectors at that location Location The corresponding similarity value, Local feature vectors With global prototype vector dot product, Local feature vectors L2 norm, Global prototype vector The L2 norm.
[0031] The similarity graph was then soft-quantized to Several levels are defined to capture the distribution of local texture consistency. The quantification center and interval are as follows: (4) in, For the first Quantitative centers at various levels It is the minimum similarity value in the entire image. It is the maximum similarity value in the entire image. It is the step size of the quantization interval. It is the number of quantization levels.
[0032] The similarity graph is calculated as follows: (5) in, for Level similarity graph , For position In the Quantized values at each quantization level It is the dimensional space representation of this feature.
[0033] Finally, local average pooling is applied to the neighborhood to aggregate the spatial context, followed by 1×1 convolution to generate the final texture-aware descriptor: (6) in, This is a local average pooling operation.
[0034] The C3 feature map is concatenated with the texture-aware descriptor and then linked in parallel to form a routing feature map: (7) in, The number of channels in the texture descriptor. This is the concatenated routing feature map; The routing feature map is divided into Non-overlapping regions, among which The size of the region is , recorded as Each region undergoes image patch-level embedding processing using Global Average Pooling (GAP) and a Multilayer Perceptron (MLP). (8) in, Indicates the first Features of an image patch Indicates the first Embedded sequences of image patches, Represents an embedded sequence The dimension; The linear router calculates an affinity score for each expert with each image patch embedding sequence: (9) in, Indicates the first The expert and the first Affinity score for each image patch Indicates the first The weight vector corresponding to each expert Indicates the first The bias term corresponding to each expert This refers to the total number of experts.
[0035] An expert-selected routing strategy is employed, where each expert selects the route with the highest affinity score. A sequence is formed, which constitutes its allocation set: (10) in, Indicates the first The allocation set of experts, This means that each expert selects the one with the highest affinity score. Operations on a sequence; To maintain stable routing budgets at different resolutions, a capacity factor is used. Perform parameterization: (11) in, As capacity factor, , The total number of image patches. The total number of experts; Define a binary selection mask: (12) in, Choose a mask for binary data, with dimensions of . ,Right now , For the first The expert and the first i Matching tags for each image patch; Since an image patch can be assigned to multiple experts, the expert weight matrix for each image patch is normalized for the selected experts: (13) in, For the first The expert on the first Normalized weights for each image patch For the first The expert on the first Affinity score for each image patch For the exponentialization of affinity scores, The total number of experts For the first For each image patch, the sum of the "mask × exponential affinity" of all the experts responsible for it is used; image patches not selected by any expert are completely bypassed from expert calculations. .
[0036] Each expert network implements a lightweight, depthwise separable convolutional module.
[0037] The output of the expert network is: (14) (15) in, For the first The expert network on the first The output results of each image patch For the first A network of experts, To extract from C3 feature map The extracted first Image blocks, , For image blocks dimensional space, Indicates group normalization, It is a nonlinear activation function (SiLU). For the 1×1 convolution operation of the output, For the intermediate 1×1 convolution operation, This is a 3×3 depthwise convolution operation.
[0038] The final refinement feature of the image patch is the gated weighted sum of the expert output signal: (16) in, For the first The final refinement features of each image patch, for dimensional space; make Indicates from The inverse operation of extracting non-overlapping image patches reconstructs the feature map by restoring each image patch to its original spatial location, thus forming texture refinement features: (17) in, This is the final texture refinement feature map. This is the inverse operation of the image patch. For all The final set of refined features for each image patch for The dimensional space; image patches not selected by any expert will be set to The corresponding spatial region remains unchanged.
[0039] Finally, the output features of the TEM module are obtained through residual linking: (18) in Convolution, as a lightweight linear projection, is used to recalibrate and blend the channels of the expert-refined results before residual injection.
[0040] S30: Construct a teacher detector and a student detector, which adopt the same defect detection network structure described in step S20 but with different parameters; and establish a teacher-student self-training update mechanism, updating the teacher detector parameters based on the student detector parameters using an exponential moving average method. Let the student parameters be... Teacher parameters are Then, an EMA update can be represented as: (19) in The attenuation coefficient of the EMA has a range of values. ; For student model parameters, For teacher model parameters; S40: During the training iteration, weakly augmented views and strongly augmented views are generated for the unlabeled images; the weakly augmented views are used for prediction by the teacher detector to generate candidate pseudo-labels, and the strongly augmented views are used for consistency learning by the student detector; the labeled images are used for supervised training of the student detector.
[0041] S50: Input the weakly enhanced view of the unlabeled image obtained in step S40 into the teacher detector to generate a candidate pseudo-label set; the candidate pseudo-label includes the location information of the candidate detection box, the defect category information, and the corresponding category confidence score.
[0042] S60: Input the candidate pseudo-label set obtained in step S50 into the class-wise dynamic pseudo-label filtering module (CDPF), determine the class adaptive filtering threshold according to the confidence distribution of each defect category, and perform class-wise dynamic filtering on the candidate pseudo-labels accordingly, and output the filtered pseudo-label set.
[0043] Specifically, in step S60 Figure 4 This diagram illustrates Class-Based Dynamic Pseudo-Label Filtering (CDPF), where the teacher detector confidence score exhibits both class-dependent and training-phase-dependent characteristics. Difficult defect categories tend to receive systematically lower scores, while easy categories often show overconfidence. Therefore, a static global threshold... It cannot simultaneously suppress the false positive rate of easy classes and maintain the true positive rate of hard classes. To mitigate this bias, CDPF learns independent, adaptive scoring thresholds for each class using a lightweight probabilistic model. .
[0044] For each category Maintain a first-in, first-out (FIFO) buffer, which stores the most recent values assigned to the defect category by the teacher detector on the unlabeled data. Each confidence score prediction; in a given training iteration At that time, collect the set of confidence scores corresponding to all teacher predictions classified as defective categories in the current unlabeled batch. Then, update the buffer by appending new sets if the total number of entries exceeds [a certain threshold]. Then discard the oldest fraction to maintain a fixed capacity: (20) Here, Indicates the defect category The corresponding first-in-first-out (FIFO) buffer, Indicates training iteration At that time, in the current unlabeled batch, those predicted by teachers as defect categories The set of confidence scores, ,in Indicates the quantity of such predictions; operators This means only the most recent ones will be retained. Each element. This mechanism provides a confidence distribution throughout the training process. It provides a compact and continuously updated approximation.
[0045] A two-component one-dimensional Gaussian mixture model (GMM) is used to fit the empirical score distribution for each class, which is represented by the confidence scores in the buffer. Its density function is given by the following formula: (twenty one) in, The probability density function represents the confidence score corresponding to the defect category. This represents the confidence score in the buffer. superscript and These represent the mixed components of negative (low score) and positive (high score), respectively. The mixed weights represent the negative components (low scores). The mixed weights of the positive components (high scores) satisfy the following conditions: , This represents the mean of the normal distribution corresponding to the negative component. This represents the variance of the normal distribution corresponding to the negative component. This represents the mean of the normal distribution corresponding to the positive components. This represents the variance of the normal distribution corresponding to the positive component. The parameters are estimated from the buffer using the Expectation-Maximization (EM) algorithm. After fitting, components with higher means are identified as positive components. .
[0046] Based on the fitted GMM parameters, the probability that the confidence score originates from the positive component is given by the posterior distribution: (twenty two) Select pseudo-labels for defect categories using the CDPF method: (twenty three) in, Pre-set a confidence level threshold for the posterior probability. This represents the posterior probability that a sample of the defect category is a "positive sample" given a confidence score. hyperparameters The (preset confidence level threshold for posterior probability) controls the trade-off between precision and recall, and the preset confidence level threshold is set to 0.5, i.e. =0.5, which corresponds to the Bayesian decision boundary under the mixed distribution of the model.
[0047] To achieve efficient online filtering, the posterior rule is transformed into an adaptive scoring threshold. Specifically, the posterior probability of a defect category belonging to a "positive sample" is calculated for the buffered scoring set, and the minimum confidence score satisfying the following constraints is selected: (twenty four) in, Given a threshold function, output the minimum confidence score that satisfies the condition; To prevent the threshold from being set too wide when the model is underfitting in the early stages of training, we introduce a minimum threshold lower bound: (25) in, Indicates the adaptive scoring threshold. Compare the adaptive scoring threshold and the minimum threshold lower limit, and choose the larger value; During training, for candidate pseudo-labels of defect categories, when their confidence scores are greater than or equal to the adaptive scoring threshold of the updated defect category, i.e. If a pseudo-label is selected, it is retained; otherwise, it is filtered out, thus outputting a dynamically filtered set of pseudo-labels for use in training the student detector. Since the EM algorithm deals with a two-component one-dimensional Gaussian mixture model with a limited buffer size, the overall computational cost is negligible.
[0048] S70: Input the strongly augmented view of the unlabeled image and the labeled image obtained in step S40 into the student detector; wherein, semi-supervised training is performed on the strongly augmented view of the unlabeled image using the filtered pseudo-label set output in step S60, and supervised training is performed using the real labels of the labeled dataset as the supervision signal to obtain the updated student detector parameters; and the teacher detector parameters are updated according to the updated student detector parameters by exponential moving average, and steps S40 to S70 are iteratively executed until the preset convergence condition is met.
[0049] S80: After training, during the inference phase, only a single detection model is used to detect defects in the industrial surface image to be inspected, and the defect category and location information are output.
[0050] As an experimental example of this invention, the NEU-DET dataset, a hot-rolled strip surface defect detection database from Northeastern University, was used for testing. To verify the semi-supervised defect detection performance of this invention under different annotation ratios, the training set was set to three cases with annotation ratios of 1%, 5%, and 10%, respectively, and the remaining samples were used as unlabeled data to participate in the teacher-student self-training process; the testing phase was uniformly evaluated on the NEU-DET test set.
[0051] Meanwhile, several mainstream semi-supervised object detection methods (Soft Teacher, PseCo, Mix Teacher, Unbiased Teacher v2, DSL, Semi-DETR) are introduced as a comparison group to highlight the superiority of the method of this invention.
[0052] Table 1 summarizes the quantitative evaluation results of different methods on the NEU-DET dataset. It can be seen that, under the same detector backbone framework (preferably Faster R-CNN) and the same annotation ratio, the method of this invention achieves better mean accuracy (mAP) in scenarios with 1%, 5%, and 10% annotation ratios. This indicates that the texture enhancement module (TEM) and class-based dynamic pseudo-label selection module (CDPF) proposed in this invention can effectively improve pseudo-label quality and enhance training stability, thus achieving more reliable defect detection performance even under low annotation conditions. In summary, the experimental results show that the method of this invention has better applicability and effectiveness in industrial surface defect detection scenarios with complex textures and low contrast backgrounds.
[0053] Table 1. Quantitative evaluation results of different methods.
[0054] The defect detection method and system based on texture enhancement and dynamic pseudo-label screening provided by this invention achieves accurate identification and stable training of industrial surface defects under conditions of low labeling ratio.
[0055] On the one hand, this invention introduces a texture enhancement module (TEM) in the shallow feature stage of the detector backbone network. To address the foreground-background confusion problem caused by repetitive textures and low-contrast backgrounds on industrial surfaces, the shallow features are refined and enhanced through an image block-level expert selection mechanism guided by texture-aware descriptors. This improves the reliability of candidate pseudo-labels generated by the teacher detector and promotes the learning of more discriminative texture cues by the student detector.
[0056] On the other hand, this invention proposes a class-based dynamic pseudo-label filtering module (CDPF). Based on the differences in confidence distribution among different defect categories during training, it estimates the adaptive filtering threshold for each category online and dynamically filters candidate pseudo-labels by category. This suppresses noisy pseudo-labels while retaining valid positive samples from difficult categories, alleviating the class supervision imbalance caused by the global threshold. Compared with various existing semi-supervised target detection methods, this invention achieves better detection accuracy under low-labeling conditions. Furthermore, only a single detection model is needed to output defect category and location information during the inference stage, as the class-based dynamic pseudo-label filtering module does not participate in inference, thus facilitating engineering deployment and meeting the needs of industrial online detection applications.
[0057] The above are merely specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. In the absence of conflict, the embodiments and features of the embodiments of the present invention can be combined with each other. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A defect detection method based on texture enhancement and dynamic pseudo-tag screening, characterized in that, Includes the following steps: S10: Obtain raw images of industrial surface defects, construct an industrial surface defect detection dataset, and divide it into labeled and unlabeled datasets; S20: Construct a defect detection network structure, which consists of a backbone feature extraction network, a feature fusion network, and a detection head network, and introduces a texture enhancement module in the shallow feature stage of the backbone feature extraction network; S30: Construct teacher detectors and student detectors, and establish a teacher-student self-training and update mechanism, updating teacher detector parameters based on student detector parameters using an exponential moving average method; S40: During the training iteration, generate weakly augmented and strongly augmented views for the unlabeled images; S50: Input the weakly enhanced view of the unlabeled image obtained in step S40 into the teacher detector to generate a set of candidate pseudo-labels; S60: Input the candidate pseudo-label set obtained in step S50 into the category-based dynamic pseudo-label filtering module, determine the category adaptive filtering threshold according to the confidence score distribution of each defect category, and perform category-based dynamic filtering on the candidate pseudo-labels accordingly, and output the filtered pseudo-label set. S70: Input the strongly augmented view of the unlabeled image and the labeled image obtained in step S40 into the student detector. Perform semi-supervised training on the strongly augmented view of the unlabeled image using the filtered pseudo-label set output in step S60, and perform supervised training using the real labels of the labeled dataset as the supervision signal to obtain the updated student detector parameters. Then, update the teacher detector parameters according to the updated student detector parameters using an exponential moving average method. Iterate through steps S40 to S70 until the preset convergence condition is met. S80: After training, the trained detection model is used to detect defects in the industrial surface image to be inspected, and the defect category and location information are output.
2. The defect detection method based on texture enhancement and dynamic pseudo-tag screening according to claim 1, characterized in that, The texture enhancement module in step S20 is used to perform texture-aware enhancement processing on the shallow features of the backbone network. The texture enhancement module includes a texture descriptor construction unit, a routing feature construction unit, a block-level routing and expert transformation unit, and a feature fusion unit.
3. The defect detection method based on texture enhancement and dynamic pseudo-tag screening according to claim 2, characterized in that, Step S20 specifically includes the following steps: S21: Input C3 feature map; S22: The texture descriptor construction unit projects the C3 feature map and constructs a global texture prototype; S23: A texture consistency representation is obtained by the similarity between local features and global texture prototypes, and a texture descriptor is obtained by statistical mapping; S24: The routing feature construction unit concatenates the C3 feature map with the texture descriptor to obtain a routing feature map; S25: The block-level routing and expert transformation unit divides the routing feature map into multiple non-overlapping blocks and performs embedding serialization. Based on the affinity between the sequence and multiple experts, it determines the set of selected experts and obtains normalized gating weights. The corresponding block performs transformation on the selected experts and is weighted and aggregated according to the gating weights to obtain the block-level enhancement result. S26: The feature fusion unit folds the enhancement results of each block back to their original spatial positions and performs residual fusion with the original C3 feature map to obtain the texture-enhanced output features.
4. The defect detection method based on texture enhancement and dynamic pseudo-tag screening according to claim 3, characterized in that, In step S20, steps S22-S24 specifically include: S221: First, the C3 feature map is projected into low-dimensional local features through 1×1 convolution. Then, global average pooling is applied to the low-dimensional local features to obtain the global prototype vector. S222: For each spatial location on the feature map, calculate the cosine similarity between the local feature and the global prototype vector to obtain the similarity map; S223: The similarity graph was subsequently soft-quantized to K Several levels to capture the distribution of local texture consistency; S224: Finally, local average pooling is applied to the neighborhood to aggregate the spatial context, followed by 1×1 convolution to generate the final texture-aware descriptor. S225: Concatenate the C3 feature map with the texture-aware descriptor in parallel to form a routing feature map.
5. The defect detection method based on texture enhancement and dynamic pseudo-tag screening according to claim 4, characterized in that, In step S20, step S25 specifically includes: S251: Routing Feature Map The image is divided into multiple non-overlapping regions of the same size, and each region is processed by global average pooling and multilayer perceptron for image block-level embedding. S252: The linear router calculates an affinity score for each expert with each image patch embedding sequence; S253: Each expert selects the one with the highest affinity score. A sequence is formed into an allocation set, and pairs are allocated using capacity factors. Parameterization is performed to maintain a stable routing budget across different resolutions; S254: Define a binary selection mask, which normalizes the expert weight matrix for each image block for the selected expert, and image blocks not selected by any expert directly bypass the expert calculation. S255: Each expert network is implemented as a lightweight depthwise separable convolutional module, which outputs the corresponding feature signal for the image patch extracted from the C3 feature map. The final refined feature of the image patch is the gated weighted sum of the output signals of each expert. S256: By extracting non-overlapping image patches from the C3 feature map and performing the inverse operation, each image patch is restored to its original spatial position to reconstruct the feature map, forming texture refinement features; S257: Finally, the output features of the texture enhancement module are obtained through residual linking.
6. The defect detection method based on texture enhancement and dynamic pseudo-tag screening according to claim 1, characterized in that, The class-based dynamic pseudo-label filtering module in step S60 is used to perform class-based adaptive filtering of candidate pseudo-labels output by the teacher detector. The class-based dynamic pseudo-label filtering module includes a class-based confidence caching unit, a class-based distribution modeling unit, a threshold generation unit, and a pseudo-label filtering unit.
7. The defect detection method based on texture enhancement and dynamic pseudo-tag screening according to claim 6, characterized in that, Step S60 specifically includes the following steps: S61: The confidence cache unit by category maintains a first-in-first-out cache area for each defect category, which is used to store the confidence scores of the candidate pseudo-labels corresponding to the defect category and update them iteratively; S62: The class-based distribution modeling unit performs bimodal probability modeling on the score distribution of defect categories based on the cache area, distinguishing between low-confidence components and high-confidence components; S63: The threshold generation unit generates an adaptive screening threshold for each category based on the modeling results, and sets a lower limit constraint on the adaptive screening threshold; S64: The pseudo-label filtering unit retains or removes candidate pseudo-labels belonging to the defect category according to rules. When the confidence score is greater than or equal to the adaptive scoring threshold of the updated defect category, it is retained; otherwise, it is filtered.
8. A defect detection system based on texture enhancement and dynamic pseudo-tag screening, characterized in that, A defect detection method based on texture enhancement and dynamic pseudo-label screening as described in any one of claims 1-7, comprising: The data acquisition and enhancement module is used to acquire images of industrial surface defects and construct a dataset, which is divided into labeled data and unlabeled data, and generates weakly enhanced and strongly enhanced views for the unlabeled images. A teacher detector is used to detect weakly augmented views to generate candidate pseudo-labels; A student detector is used for training and updating under the joint supervision of labeled data and filtered pseudo-labels. A texture enhancement module is introduced into the shallow feature stage of the backbone network of the teacher detector and the student detector to enhance the texture perception of shallow features in order to improve the reliability of candidate pseudo-labels. The dynamic pseudo-label filtering module by category is used to determine the adaptive filtering threshold for each category based on the confidence score distribution of each defect category, and to perform dynamic filtering of candidate pseudo-labels by category. The training optimization module is used for supervised training based on labeled data and semi-supervised training on unlabeled data using filtered pseudo-labels, while updating the teacher detector parameters through exponential moving average.