A distribution-adaptive based semi-supervised defect detection method and system
By employing a distribution-adaptive semi-supervised defect detection method, high-quality pseudo-labels are generated using a teacher detector and different enhancement processes. This solves the problem of pseudo-labels caused by a single confidence threshold, achieving stable detection and high recall for rare or minor defects, and improving the accuracy and robustness of detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHANDONG JIAOTONG UNIV
- Filing Date
- 2026-05-09
- Publication Date
- 2026-07-31
AI Technical Summary
Existing technologies for detecting small defects in industry suffer from a mismatch between the false label admission criteria and the category confidence distribution due to the use of a single global confidence threshold. This makes it easy for false labels of rare or minor defects to be over-filtered or mixed with noise, resulting in decreased recall and increased false detections, which affects training stability.
By employing a distribution-adaptive semi-supervised defect detection method, a teacher detector is trained using a small amount of labeled data and its parameters are frozen. Weak and strong enhancements are applied to unlabeled data respectively, and the admission threshold and screening criteria are dynamically adjusted to generate high-quality pseudo-labels. Combined with cross-branch consistency verification, the quality and stability of the pseudo-labels are ensured.
It significantly improves the stability and generalization performance of semi-supervised defect detection, enhances the recall capability for rare defects, suppresses false detections caused by complex backgrounds, and improves the overall accuracy and robustness of detection.
Smart Images

Figure CN122492629A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of target detection technology, and specifically to a semi-supervised defect detection method and system based on distribution adaptive detection. Background Technology
[0002] As industrial manufacturing precision continues to improve, minute defects on product surfaces have become a key factor affecting yield and reliability. Traditional manual inspection is inefficient and prone to fatigue, making it difficult to meet the real-time and consistency requirements of high-speed production lines. Therefore, there is an urgent need for high-performance visual inspection methods that can automatically identify extremely small, sparse, and complex textured defects.
[0003] Currently, existing methods widely employ a teacher-student framework for semi-supervised object detection. This involves first training a teacher model using a small amount of labeled data, and then having the teacher framework generate pseudo-labels for unlabeled data to supervise the iterative learning of the student model. Simultaneously, strategies such as data augmentation consistency constraints, confidence threshold-based filtering rules, candidate box matching, and non-maximum value suppression are used to reduce pseudo-label noise and improve training stability.
[0004] In the aforementioned prior art, since a single global confidence threshold is used to retain or remove pseudo-labels, in industrial scenarios where defect sizes are extremely small, category distributions are extremely uneven, and confidence levels differ significantly between different categories, setting the threshold too high will lead to a large number of tiny or rare defects being falsely filtered out, resulting in a decrease in recall. Setting it too low will introduce a large number of noisy pseudo-labels, causing an increase in false detections, training oscillations, and even amplifying confirmation bias. Furthermore, high-confidence pseudo-labels may still exhibit location shifts or inconsistencies under different enhancement branches, making it difficult to stably guarantee the quality of pseudo-supervision. Summary of the Invention
[0005] To address the shortcomings of existing technologies, the present invention aims to provide a semi-supervised defect detection method and system based on distributional adaptation. This addresses the technical problems in existing technologies where the use of a single global confidence threshold leads to a mismatch between the false label admission standard and the category confidence distribution in industrial small defect detection scenarios. This mismatch results in rare or minor defect false labels being over-filtered or mixed with noise, ultimately causing a decrease in recall and an increase in false detections, which in turn affects training stability.
[0006] This invention provides a semi-supervised defect detection method based on distribution adaptation, comprising: Data acquisition steps: Acquire the original captured images, and based on the original captured images, obtain the labeled dataset and the unlabeled dataset; Model training steps: Based on the labeled dataset, supervised training is performed on the teacher detector, and the parameters of the teacher detector are frozen after supervised training to obtain the trained teacher detector; Enhanced inference steps: After performing weak data augmentation and strong data augmentation on the unlabeled dataset, inference is performed through the trained teacher detector to obtain a weak prediction set and a strong prediction set; Admission determination steps: Based on the first confidence distribution of each prediction box in the weak prediction set and the strong prediction set, determine the admission threshold, and filter the prediction boxes in the weak prediction set and the strong prediction set respectively based on the admission threshold to obtain the weak admission set and the strong admission set. The fusion filtering steps are as follows: the weak admission set and the strong admission set are fused to obtain a fused set; the predicted boxes in the fused set are filtered based on a consistency threshold to obtain a consistency set; a filtering threshold is determined based on the second confidence distribution of each predicted box in the consistency set; and the predicted boxes in the consistency set are filtered based on the filtering threshold to obtain a pseudo-label dataset. Target detection steps: Train a student detector based on the pseudo-label dataset and the labeled dataset to obtain a target detector; perform defect detection on the image to be detected based on the target detector to obtain the detection result.
[0007] By first training the teacher detector on a small amount of labeled data and freezing the parameters, and then performing weak and strong enhancement processing on the unlabeled data respectively, the two types of prediction results are used to jointly construct the category adaptive admission threshold and fusion screening threshold, so as to stably generate high-quality pseudo-labels using a large amount of unlabeled data with only a small number of labeled samples. By dynamically adjusting the screening criteria based on the differences in confidence distribution among different categories, the problem of false label noise propagation caused by category imbalance or extremely small target size is effectively solved. This allows the final trained student detector to significantly improve its recall capability for rare defects while maintaining high accuracy and suppressing false detections caused by complex backgrounds. Overall, this improves the stability and generalization performance of semi-supervised defect detection.
[0008] In some embodiments of the present invention, the admission determination step specifically includes: The first confidence score corresponding to each category in the weak prediction set and the strong prediction set is statistically analyzed to obtain the first confidence distribution of each prediction box corresponding to each category; If the absolute value of the number of confidence samples in the first confidence distribution of each prediction box is less than the preset sample count back-off threshold, then the preset basic threshold is used as the admission threshold. Otherwise, calculate the first quantile of the first confidence distribution of each prediction box, and use the maximum value between the preset base threshold and the first quantile as the admission threshold.
[0009] By separately calculating the confidence scores for each category in the weak prediction set and the strong prediction set, the first confidence distribution of each category is obtained. Based on the sample size and quantiles, an independent admission threshold for each category is calculated, so that the threshold setting can adaptively reflect the true confidence level of various defects on unlabeled data. By using the maximum value of the distribution quantile and the basic threshold for classes with sufficient samples, reliable predictions are fully preserved, while for classes with sparse samples, the threshold is reverted to the basic threshold. This avoids unreasonable thresholds due to insufficient statistics, thus effectively balancing the false label admission rate between common and rare classes. It prevents rare defects from being systematically filtered out due to low confidence, and enhances the adaptability of semi-supervised learning in extremely imbalanced scenarios.
[0010] In some embodiments of the present invention, the admission determination step further includes: The first confidence score of each prediction box in the weak prediction set and the strong prediction set is compared with the admission threshold corresponding to the category of the prediction box to obtain the admission result. Based on the admission results, it is determined whether to retain the prediction boxes in the weak prediction set and the strong prediction set, so as to obtain the weak admission set and the strong admission set.
[0011] By comparing the confidence scores of each prediction box in the weak prediction set and the strong prediction set with the admission threshold corresponding to its category one by one, a clear admission result is obtained, and each prediction box is individually determined as to whether to retain it, so that the pseudo-label screening process has a clear individualized decision logic. By precisely controlling the inclusion or exclusion of each predicted bounding box, noise or loss of valid targets due to global or coarse-grained screening can be avoided, ensuring that only predicted bounding boxes with sufficiently high confidence can enter subsequent fusion steps. Simultaneously, by processing the prediction results of the two enhancement branches separately, the diversity of predictions under different views is preserved, providing a richer source of candidate bounding boxes for subsequent cross-branch consistency matching, thus improving the overall accuracy and robustness of the screening process.
[0012] In some embodiments of the present invention, the admission determination step further includes: If the first confidence score is greater than or equal to the admission threshold, the admission result is to retain the prediction boxes in the weak prediction set or the strong prediction set. If the first confidence score is less than the admission threshold, the admission result is to not retain the prediction boxes in the weak prediction set or the strong prediction set.
[0013] By explicitly setting a binary decision rule that the result is retained when the confidence score of the prediction box reaches or exceeds the admission threshold, and otherwise the result is not retained, a simple and strict correspondence is formed between the admission result and the quality of the prediction box. The aforementioned determination mechanism eliminates ambiguous intervals, ensuring that only high-confidence predicted boxes can enter the admission set. This effectively eliminates noisy pseudo-labels caused by low confidence. At the same time, this rule applies uniformly to both enhancement branches, ensuring that the weak admission set and the strong admission set have the same quality threshold. This provides candidate pseudo-labels with consistent sources and high reliability for subsequent fusion steps, reducing the risk of matching conflicts and incorrect retention caused by different standards between branches.
[0014] In some embodiments of the present invention, the fusion screening step specifically includes: For each prediction box in the fusion set, determine whether the prediction box originates from the weak admission set or the strong admission set, and obtain the source admission set corresponding to the prediction box. In another admission set different from the source admission set, find the prediction box with the same category as the prediction box, and determine the prediction box with the largest intersection-union ratio with the prediction box as the matching prediction box; Calculate the intersection-union ratio (CUIR) between the predicted bounding box and the matched predicted bounding box, and compare the CUIR with the consistency threshold to obtain the consistency result; Based on the consistency results, determine whether to retain the prediction boxes in the fusion set to obtain the consistency set.
[0015] By calculating the intersection-union ratio (IUR) of each predicted box in the fusion set with the same predicted box in another admission set, and comparing the IUR with the consistency threshold, the consistency result is obtained. Based on the result, it is decided whether to retain the predicted box, thus realizing the spatial location consistency verification across branches. By identifying predicted bounding boxes that stably locate the same target in both weak and strong augmented views, and filtering out random responses or positioning offsets caused by augmentation disturbances, the spatial stability and repeatability of false labels can be significantly improved, reducing duplicate predictions and false detections caused by box inconsistencies. This provides a more accurate and reliable set of predicted bounding boxes for subsequent confidence-based secondary screening.
[0016] In some embodiments of the present invention, the fusion screening step further includes: If the intersection-union ratio between the predicted bounding box and the matching predicted bounding box is greater than or equal to the consistency threshold, then the consistency result is to retain the predicted bounding boxes in the fusion set. If the intersection-union ratio between the predicted bounding box and the matching predicted bounding box is less than the consistency threshold, or if there is no matching predicted bounding box, then the consistency result is to not retain the predicted bounding boxes in the fusion set.
[0017] By setting a decision rule that the result is retained when the cross-union ratio reaches or exceeds the consistency threshold, and not retained when the cross-union ratio is less than the consistency threshold or there is no matching prediction box, the cross-branch consistency test has a clear and strict quantitative standard. By requiring that the positions of the prediction box under different augmented views must be highly overlapping in order to pass the screening, unstable predictions such as accidental response, boundary drift or positioning error caused by augmentation perturbation are effectively eliminated. Meanwhile, the above-mentioned judgment mechanism can ensure that the predicted boxes entering the consistency set have good spatial consistency, which significantly reduces the risk of false positives in subsequent processing, improves the overall credibility of pseudo-labels, and provides a high-quality source of candidate boxes for spatial verification in the final screening stage.
[0018] In some embodiments of the present invention, the fusion screening step further includes: The second confidence score corresponding to each category in the consistency set is calculated to obtain the second confidence distribution of each prediction box corresponding to each category; If the absolute value of the number of confidence samples in the second confidence distribution of each prediction box is less than the preset sample count back-off threshold, then the preset basic screening threshold is used as the screening threshold. Otherwise, calculate the second quantile of the second confidence distribution of each prediction box, and use the maximum value between the preset basic screening threshold and the second quantile as the screening threshold.
[0019] By statistically analyzing the confidence scores of each category in the consistency set, a second confidence distribution is obtained. Then, based on the sample size and quantiles, an independent screening threshold for each category is calculated, so that the final screening criteria can dynamically adapt to the true confidence characteristics of various defects after passing the consistency test. For categories with sufficient samples, a higher threshold is used to eliminate low-confidence predictions, while for categories with insufficient samples, the threshold is lowered back to avoid over-filtering. This approach retains the effective pseudo-label density while suppressing the mixing of unreliable predictions. Based on spatial consistency screening, a category-adaptive confidence constraint is added, further improving the purity and reliability of pseudo-labels.
[0020] In some embodiments of the present invention, the fusion screening step further includes: The second confidence score of each prediction box in the consistency set is compared with the filtering threshold corresponding to the category of the prediction box to obtain the filtering result; Based on the filtering results, determine whether to retain the predicted boxes in the consistency set to obtain the pseudo-label dataset.
[0021] By comparing the confidence score of each predicted box in the consistency set with the screening threshold corresponding to its category one by one, a clear screening result is obtained, and the retention of each predicted box is determined accordingly. This enables the generation of the final pseudo-label to have a refined individual decision-making ability. Under the premise that the spatial consistency screening is passed, the predicted boxes are screened again at the confidence level according to the category. This ensures that only predicted boxes that meet both spatial consistency and high confidence conditions can become the final pseudo-labels. At the same time, it fully considers the differences in confidence distribution among different categories, effectively avoids the quality unevenness caused by a uniform threshold, and significantly improves the overall quality of the pseudo-label dataset.
[0022] In some embodiments of the present invention, the fusion screening step further includes: If the second confidence score is greater than or equal to the filtering threshold, the filtering result is to retain the prediction boxes in the consistency set; If the second confidence score is less than the filtering threshold, the filtering result is to not retain the prediction boxes in the consistency set.
[0023] By clearly defining the judgment rule that the result is retained when the confidence score reaches or exceeds the screening threshold, and not retained otherwise, the final admission of pseudo-labels has a strict and unified quantitative basis. Based on the cross-branch consistency verification, prediction boxes with relatively low confidence are further removed by category. This ensures that the final retained pseudo-labels are not only spatially stable, but also that the model has a high degree of confidence in their predictions. This effectively suppresses the interference of low-quality pseudo-labels on student training, reduces the risk of accumulated confirmation bias, and enables the student detector to learn from purer and more reliable supervision signals, ultimately achieving stronger generalization ability and better detection performance.
[0024] Some embodiments of the present invention further provide a semi-supervised defect detection system based on distributional adaptation, comprising: The data acquisition module acquires the original captured images and, based on the original captured images, obtains an labeled dataset and an unlabeled dataset. The model training module performs supervised training on the teacher detector based on the labeled dataset, and freezes the parameters of the teacher detector after supervised training to obtain the trained teacher detector. The augmented inference module performs weak data augmentation and strong data augmentation on the unlabeled dataset, and then performs inference through the trained teacher detector to obtain a weak prediction set and a strong prediction set. The admission determination module determines the admission threshold based on the first confidence distribution of each prediction box in the weak prediction set and the strong prediction set, and filters the prediction boxes in the weak prediction set and the strong prediction set based on the admission threshold to obtain the weak admission set and the strong admission set. The fusion filtering module merges the weak admission set and the strong admission set to obtain a fusion set, filters the predicted boxes in the fusion set based on a consistency threshold to obtain a consistency set, determines a filtering threshold based on the second confidence distribution of each predicted box in the consistency set, and filters the predicted boxes in the consistency set based on the filtering threshold to obtain a pseudo-label dataset. The target detection module trains a student detector based on the pseudo-label dataset and the labeled dataset to obtain a target detector. Based on the target detector, it performs defect detection on the image to be detected and obtains the detection result.
[0025] Each module completes data acquisition, model training, augmented inference, admission determination, fusion screening and target detection functions, forming a complete and highly automated defect detection system. This enables the system to automatically generate pseudo-labels and train the student detector using the category confidence distribution without manual labeling of unlabeled data, significantly reducing the cost and manpower investment of large-scale labeling in industrial scenarios. Meanwhile, because the system retains core mechanisms such as adaptive thresholding by category and cross-branch consistency verification, it can still run stably in detection tasks with extremely small target size, complex texture, or severe class imbalance, and output detection results with accurate position and high confidence, which has high practicality and promotion value. Attached Figure Description
[0026] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. Figure 1 A schematic flowchart of a semi-supervised defect detection method based on distribution adaptation provided in an embodiment of the present invention; Figure 2 A flowchart of another semi-supervised defect detection method based on distribution adaptation provided in an embodiment of the present invention; Figure 3 A schematic diagram illustrating different categories of confidence distributions provided in an embodiment of the present invention; Figure 4 A schematic diagram of a fusion-based conservative screening SCPL process provided for an embodiment of the present invention; Figure 5This is a schematic diagram of a distributed adaptive semi-supervised defect detection system provided in an embodiment of the present invention. Detailed Implementation
[0027] To make the objectives, technical solutions, and advantages of this application clearer, the application is described and illustrated below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application. All other embodiments obtained by those skilled in the art based on the embodiments provided in this application without inventive effort are within the scope of protection of this application. It should be noted that the terminology used herein is for the purpose of describing particular implementations only and is not intended to limit the exemplary implementations according to this application. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. Furthermore, it should be understood that the terms “comprising” and “having”, and any variations thereof, are intended to cover a non-exclusive inclusion, for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such process, method, product, or apparatus. Where there is no conflict, the embodiments and features in the embodiments of the present invention can be combined with each other. The technical solution of the present invention will be described in detail below with reference to specific embodiments and accompanying drawings.
[0028] like Figure 1 and Figure 2 As shown, this invention provides a semi-supervised defect detection method based on distribution adaptation, comprising: Data acquisition step S1: Acquire the original captured images, and based on the original captured images, obtain the labeled dataset and the unlabeled dataset; Furthermore, image acquisition devices on the industrial production line, such as industrial cameras, scanners, or online inspection equipment, are used to acquire original surface images of the products to be inspected. These original surface images can be surface images of PCB boards, which can reflect various minor defects that may exist on the PCB board, including open circuits, short circuits, burrs, notches, pinholes, and other defect types. The image acquisition device continuously acquires the original images of the product to be inspected to form an initial image set. Each image in the initial image set is an original grayscale or color image without any manual annotation. It may contain various minor defects or may not contain any defects. A small number of representative images were selected from the initial image set above, and professional annotators used annotation tools such as LabelImg, RectLabel, or custom bounding box annotation software to accurately annotate the defect targets in each image. The annotation content includes the location information and category information of the defect target; the location information of the defect target is usually represented by the coordinates of the upper left and lower right corners of the rectangular bounding box, or by the coordinates of the center point plus the width and height; the category information of the defect target can be "open circuit", "short circuit", "burr", etc. The collection of images after annotation constitutes the labeled dataset. labeled dataset Each sample contains the original acquired image and its corresponding ground truth annotation information; Meanwhile, the remaining images in the initial image set that were not selected for annotation are directly used as the unlabeled dataset. Unlabeled dataset It contains no manually labeled information, only the original captured images; In real-world industrial scenarios, the number of unlabeled datasets is usually much larger than that of labeled datasets. For example, labeled datasets account for only 5% to 20% of the total acquired images, while unlabeled datasets account for 80% to 95%, which is consistent with the typical data distribution assumptions of semi-supervised learning.
[0029] It should be noted that the labeled dataset and unlabeled datasets There is no image overlap between them, meaning that the same image cannot appear in both datasets at the same time, in order to ensure the effectiveness of subsequent semi-supervised training and the fairness of evaluation; In addition, the images in both datasets retain their original size and resolution, without any preprocessing operations that affect the semantics, and may only undergo necessary normalization or mean removal standardization.
[0030] Model training step S2: Based on the labeled dataset, supervise the training of the teacher detector, and freeze the parameters of the teacher detector after supervised training to obtain the trained teacher detector; Furthermore, by labeling the dataset The teacher detector is trained under full supervision. During training, each image in the labeled dataset, along with its corresponding ground truth bounding box coordinates and class label, is input into the teacher detector. The teacher detector calculates the prediction results through forward propagation and calculates the difference between the prediction results and the ground truth labels based on a predefined loss function. The predefined loss function typically includes a weighted sum of classification loss and regression loss. Then, the gradient of the parameters of each layer of the network is calculated using the backpropagation algorithm, and the network parameters of the teacher detector are updated using the optimizer. The training process continues until the performance index of the teacher detector on the validation set tends to converge or reaches the preset maximum number of training rounds. During training, data augmentation techniques can be used to enhance the input images online, thereby improving the generalization ability of the teacher detector. After supervised training is completed, the teacher detector has the basic ability to detect defective targets in images. Setting the requires_grad attribute of all learnable parameters in the teacher detector to False ensures that it only produces prediction results during forward propagation without performing gradient calculations or parameter updates, and no longer participates in any subsequent parameter updates. This ensures that the output of the teacher detector remains stable and consistent during the subsequent generation of pseudo-labels for unlabeled data, avoiding fluctuations in pseudo-label quality due to parameter changes.
[0031] Enhanced inference step S3: After performing weak data augmentation and strong data augmentation on the unlabeled dataset, inference is performed through the trained teacher detector to obtain the weak prediction set and the strong prediction set; Furthermore, in order to obtain prediction results for the same image under different views for subsequent cross-branch consistency checks, the unlabeled dataset will be... Each original image in the process is subjected to two different data processing intensities: weak data augmentation and strong data augmentation. Weak data augmentation employs lightweight image transformations that do not alter the target's semantics, including one or more combinations of standard inference preprocessing, horizontal flipping, minor scaling, or slight translation. Standard inference preprocessing only performs size and pixel value normalization without applying any random perturbations. Horizontal flipping is performed with a low probability, such as flipping the image horizontally with a 50% probability. Minor scaling refers to controlling the image scaling factor between 0.8 and 1.2, causing a slight change in image size without altering the overall structure of the target. Slight translation involves moving the image slightly horizontally or vertically, with the translation magnitude controlled within 5% of the original image size, ensuring the target does not move out of the image boundaries. Weak data augmentation preserves the original structure of the image and the appearance features of the target as much as possible, so that the prediction results of the teacher detector under this branch have high confidence and stable localization accuracy.
[0032] Strong data augmentation processing employs large-amplitude image transformation methods to simulate changes in images under different shooting conditions or from different perspectives; Strong data augmentation processing includes one or more combinations of random cropping, random rotation, color dithering, Gaussian blurring, random erasure, and multi-scale transformation. Random cropping involves randomly selecting a sub-region from the original image as a new image; the cropped area can cover 50% to 100% of the original image area. Random rotation involves rotating the image within a plane by a certain angle, controlled between -15° and +15°. Color dithering involves randomly adjusting the image's brightness, contrast, and saturation to simulate image changes under different lighting conditions. Gaussian blurring involves applying a Gaussian smoothing filter to the image to simulate slight defocusing or motion blur during image acquisition. Random erasure involves randomly selecting a rectangular region in the image and setting the pixel values of that region to random values or the image mean to simulate partial occlusion of the target. Multi-scale transformation involves scaling the image to multiple different sizes, performing inference separately for each size, and then fusing all inference results to enhance the model's ability to detect targets at different scales. The aforementioned strong data augmentation processing can be a random combination of multiple operations, or it can be a test-time augmentation method, that is, applying multiple different augmentation transformations to the same original image, performing inference separately, and then merging all prediction results into a set.
[0033] The image after weak data augmentation is input into the teacher detector with frozen parameters. The teacher detector performs forward inference on each augmented image and outputs a set of prediction results for the corresponding image. For each image, the teacher detector outputs predictions containing multiple bounding boxes, each represented as... ;in, The coordinates of the predicted bounding box; The category to which the predicted bounding box belongs; The confidence scores of the predicted bounding boxes are used to summarize the prediction results obtained after weak data augmentation of all images, forming a weak prediction set. ; Similarly, the image after strong data augmentation is input into the teacher detector with the same set of frozen parameters. The teacher detector also performs forward inference and outputs a set of prediction results, which are then aggregated to form a strong prediction set. ; Weak prediction set Strong prediction set These are two independent prediction results obtained from the same batch of unlabeled data. The number of prediction boxes in the two prediction sets may be different, and the position and confidence of the prediction boxes generated by the same real target under different augmentation branches may differ. This difference provides a basis for subsequent cross-branch consistency tests. If a predicted box has a high confidence level under a weak enhancement branch and can find a matching box of the same category and with a high degree of spatial overlap under a strong enhancement branch, then the predicted box is considered to have good stability and reliability.
[0034] Admission determination step S4: Based on the first confidence distribution of each prediction box in the weak prediction set and the strong prediction set, determine the admission threshold, and filter the prediction boxes in the weak prediction set and the strong prediction set respectively based on the admission threshold to obtain the weak admission set and the strong admission set. In some embodiments, the admission determination step S4 specifically comprises: The first confidence score corresponding to each category in the weak prediction set and the strong prediction set is statistically analyzed to obtain the first confidence distribution of each prediction box corresponding to each category; If the absolute value of the number of confidence samples in the first confidence distribution of each prediction box is less than the preset sample count back-off threshold, then the preset basic threshold will be used as the admission threshold. Otherwise, calculate the first quantile of the first confidence distribution of each prediction box, and use the maximum value between the preset base threshold and the first quantile as the admission threshold.
[0035] By separately calculating the confidence scores for each category in the weak prediction set and the strong prediction set, the first confidence distribution of each category is obtained. Based on the sample size and quantiles, an independent admission threshold for each category is calculated, so that the threshold setting can adaptively reflect the true confidence level of various defects on unlabeled data. By using the maximum value of the distribution quantile and the basic threshold for classes with sufficient samples, reliable predictions are fully preserved, while for classes with sparse samples, the threshold is reverted to the basic threshold. This avoids unreasonable thresholds due to insufficient statistics, thus effectively balancing the false label admission rate between common and rare classes. It prevents rare defects from being systematically filtered out due to low confidence, and enhances the adaptability of semi-supervised learning in extremely imbalanced scenarios.
[0036] Furthermore, after obtaining the weak prediction set and the strong prediction set, the prediction box is admitted by the distribution-aware threshold module (DAT). For each index is The category, from the weak prediction set Strong prediction set Filter out all that meet the criteria The predicted bounding boxes are then assigned confidence scores. Collect the data and statistically analyze the confidence distribution to obtain the first confidence distribution. First confidence distribution The elements in the table represent the categories identified by the teacher detector on unlabeled data. The confidence scores of all predicted boxes output; After obtaining the first confidence distribution for each category, the admission threshold for each category is further calculated. If the number of confidence samples in the first confidence distribution for a certain category is less than a preset sample count backoff threshold, the admission threshold is determined. If the sample size for that category is insufficient, the resulting confidence distribution is not representative. At this point, to avoid abnormal threshold settings due to insufficient samples, the preset base threshold is directly set. This serves as the admission threshold for that category; The base threshold is a pre-defined global lower limit value, such as 0.5 or 0.6, which means that only prediction boxes with a confidence level not lower than this value are likely to be retained; Conversely, if the number of confidence samples in the first confidence distribution of that category is greater than or equal to the preset sample count backoff threshold... If the sample size is sufficient, it indicates that the confidence distribution obtained from the statistics is statistically significant. At this point, the first quantile is first calculated using the quantile statistical function based on the first confidence distribution and the preset quantile parameters; Preset quantile parameters It is a preset ratio value, typically ranging from 0.5 to 0.8; for example, when the preset quantile parameter... When the value is 0.6, the first quantile represents the confidence value that is at the 60th percentile after all confidence scores for that category are sorted from smallest to largest. Then, the calculated first quantile is compared with the preset base threshold. The two values are compared, and the maximum value is taken as the admission threshold for that category. Its expression is:
[0037] in, This is a quantile statistical function; For categories with sufficient samples, the admission threshold setting should consider both the overall distribution of confidence in that category and ensure a basic lower limit protection. Using quantiles as the threshold can effectively remove low-confidence prediction boxes at the tail end, while taking the maximum value of the quantile and the basic threshold ensures that the admission threshold will not be lower than the basic threshold, thus guaranteeing quality.
[0038] In some embodiments, the admission determination step S4 further includes: The first confidence score of each prediction box in the weak prediction set and the strong prediction set is compared with the admission threshold corresponding to the category of the prediction box to obtain the admission result; Based on the admission results, determine whether to retain the prediction boxes in the weak prediction set and the strong prediction set, so as to obtain the weak admission set and the strong admission set.
[0039] By comparing the confidence scores of each prediction box in the weak prediction set and the strong prediction set with the admission threshold corresponding to its category one by one, a clear admission result is obtained, and each prediction box is individually determined as to whether to retain it, so that the pseudo-label screening process has a clear individualized decision logic. By precisely controlling the inclusion or exclusion of each predicted bounding box, noise or loss of valid targets due to global or coarse-grained screening can be avoided, ensuring that only predicted bounding boxes with sufficiently high confidence can enter subsequent fusion steps. Simultaneously, by processing the prediction results of the two enhancement branches separately, the diversity of predictions under different views is preserved, providing a richer source of candidate bounding boxes for subsequent cross-branch consistency matching, thus improving the overall accuracy and robustness of the screening process.
[0040] In some embodiments, the admission determination step S4 further includes: If the first confidence score is greater than or equal to the admission threshold, the admission result is to retain the prediction boxes in the weak prediction set or the strong prediction set. If the first confidence score is less than the admission threshold, the admission result is to not retain the prediction boxes in the weak prediction set or the strong prediction set.
[0041] By explicitly setting a binary decision rule that the result is retained when the confidence score of the prediction box reaches or exceeds the admission threshold, and otherwise the result is not retained, a simple and strict correspondence is formed between the admission result and the quality of the prediction box. The aforementioned determination mechanism eliminates ambiguous intervals, ensuring that only high-confidence predicted boxes can enter the admission set. This effectively eliminates noisy pseudo-labels caused by low confidence. At the same time, this rule applies uniformly to both enhancement branches, ensuring that the weak admission set and the strong admission set have the same quality threshold. This provides candidate pseudo-labels with consistent sources and high reliability for subsequent fusion steps, reducing the risk of matching conflicts and incorrect retention caused by different standards between branches.
[0042] Furthermore, after calculating the admission threshold, the prediction boxes in the weak prediction set and the strong prediction set are judged separately. For weak prediction sets Iterate through each prediction box. According to its category Obtain the corresponding admission threshold And the first confidence score of each prediction box in the weak prediction set and the strong prediction set. The admission result is obtained by comparing the predicted bounding box with the admission threshold corresponding to its category. The expression for this result is as follows:
[0043] in, This is the admission decision function for the Distribution Aware Thresholding (DAT) module; if the result of the admission decision function is 1, then the admission result is to retain the predicted box in the weak admission set. If the result of the admission decision function is , then the prediction box will be removed if the admission result is . Based on the above process, the weak admission set It can also be formally represented as ; Similarly, for strong prediction sets The same filtering logic is used to select those that meet the criteria. The prediction frame retains the set of strongest admission criteria. ,Right now ; Through the above operations, the global fixed threshold filtering is refined into category adaptive admission, which effectively reduces the risk of rare category pseudo-labels being systematically filtered out when there is class imbalance or the overall confidence of small defects is low. At the same time, it suppresses the excessive admission of noisy categories and achieves more balanced pseudo-label coverage.
[0044] like Figure 3 As shown, taking the three defect categories of "open circuit", "short circuit" and "pinhole" as examples, the unlabeled dataset is input into the trained teacher detector, and weak data augmentation and strong data augmentation are performed respectively to obtain the prediction results, that is, the weak prediction set and the strong prediction set. For each category, the teacher detector outputs multiple prediction boxes, each containing a confidence score. The confidence distribution of these prediction boxes is statistically analyzed by category. The horizontal axis represents the confidence score, and the vertical axis represents the number of prediction boxes. There are significant differences in the confidence distribution among different categories, reflecting the class imbalance phenomenon commonly seen in industrial small defect detection.
[0045] The Distributed Aware Threshold (DAT) module then performs admission determination. For each category, the admission threshold is calculated based on its confidence distribution. If the number of confidence samples for that category is less than a preset sample count fallback threshold, the preset base threshold is used as the admission threshold. Otherwise, the quantiles of the confidence distribution are calculated, and the maximum value between the preset base threshold and the quantile is used as the admission threshold. The admission thresholds for different categories are different.
[0046] After the Distributed Aware Thresholding (DAT) module determines the admission criteria, the confidence score of each prediction box is compared with the admission threshold of its category. Prediction boxes with confidence scores greater than or equal to the admission threshold are retained, while those with confidence scores less than the admission threshold are removed. This process yields pseudo-labels that have passed the DAT admission criteria. In other words, weak admission sets and strong admission sets are obtained from the weak prediction set and strong prediction set, providing candidate pseudo-labels with controllable quality for subsequent fusion and screening steps. By processing each category separately, the Distribution Aware Threshold (DAT) module can use a higher threshold for categories with sufficient samples to ensure the quality of pseudo-labels, and a lower threshold for rare categories with scarce samples to ensure the density of pseudo-labels, thereby achieving a more balanced and reasonable pseudo-label admission control.
[0047] Fusion filtering step S5: Fusion of weak admission set and strong admission set to obtain fusion set; filtering of prediction boxes in fusion set based on consistency threshold to obtain consistency set; determination of filtering threshold based on second confidence distribution of each prediction box in consistency set; filtering of prediction boxes in consistency set based on filtering threshold to obtain pseudo-label dataset; Furthermore, after completing the above admission determination and obtaining the weak admission set... and strong access set Then, the two sets of admission results are merged and deduplicated. Calculate the union of the two admission sets, and merge all candidate prediction boxes from the weak admission set and the strong admission set into a unified candidate set; To remove duplicate predicted boxes and redundant candidates caused by enhanced perturbations, a category-aware nonmaximum suppression operation is performed on the candidate set. The fusion result can be formally represented as follows: ,in For those with preset parameters The non-maximum suppression algorithm is used to control the degree of merging of overlapping boxes; By using the union operation, as much complementary prediction information from the two different enhancement processes as possible can be retained, thus avoiding missed detections due to the lack of information from a single branch. Non-maximum suppression effectively suppresses duplicate predictions and redundant boxes caused by small perturbations, thereby controlling the density of candidate boxes while ensuring recall, and providing higher quality input for subsequent consistency screening. The fused set obtained after the above fusion and deduplication processes Each prediction box within it is a candidate result that has undergone dual verification through category adaptive threshold filtering and spatial deduplication, thus possessing the basic conditions for further, more refined cross-branch consistency filtering.
[0048] In some embodiments, the fusion screening step S5 specifically includes: For each prediction box in the fusion set, determine whether the prediction box comes from the weak admission set or the strong admission set, and obtain the source admission set corresponding to the prediction box. In a different admission set than the source admission set, find the prediction box with the same category as the prediction box, and determine the prediction box with the largest intersection-union ratio with the prediction box as the matching prediction box; Calculate the intersection-union ratio (IU) between the predicted bounding box and the matching predicted bounding box, and compare the IU with the consistency threshold to obtain the consistency result; Based on the consistency results, determine whether to retain the predicted boxes in the fusion set to obtain the consistency set.
[0049] By calculating the intersection-union ratio (IUR) of each predicted box in the fusion set with the same predicted box in another admission set, and comparing the IUR with the consistency threshold, the consistency result is obtained. Based on the result, it is decided whether to retain the predicted box, thus realizing the spatial location consistency verification across branches. By identifying predicted bounding boxes that stably locate the same target in both weak and strong augmented views, and filtering out random responses or positioning offsets caused by augmentation disturbances, the spatial stability and repeatability of false labels can be significantly improved, reducing duplicate predictions and false detections caused by box inconsistencies. This provides a more accurate and reliable set of predicted bounding boxes for subsequent confidence-based secondary screening.
[0050] In some embodiments, the fusion screening step S5 further includes: If the intersection-union ratio between the predicted bounding box and the matching predicted bounding box is greater than or equal to the consistency threshold, the consistency result is to retain the predicted bounding boxes in the fused set. If the intersection-union ratio between the predicted bounding box and the matching predicted bounding box is less than the consistency threshold, or if there is no matching predicted bounding box, the consistency result is that the predicted bounding boxes in the fused set are not retained.
[0051] By setting a decision rule that the result is retained when the cross-union ratio reaches or exceeds the consistency threshold, and not retained when the cross-union ratio is less than the consistency threshold or there is no matching prediction box, the cross-branch consistency test has a clear and strict quantitative standard. By requiring that the positions of the prediction box under different augmented views must be highly overlapping in order to pass the screening, unstable predictions such as accidental response, boundary drift or positioning error caused by augmentation perturbation are effectively eliminated. Meanwhile, the above-mentioned judgment mechanism can ensure that the predicted boxes entering the consistency set have good spatial consistency, which significantly reduces the risk of false positives in subsequent processing, improves the overall credibility of pseudo-labels, and provides a high-quality source of candidate boxes for spatial verification in the final screening stage.
[0052] Furthermore, in obtaining the fusion set Subsequently, the fused set was processed using the Conservative Screening Module (SCPL). Perform cross-branch consistency checks on each candidate prediction box in the data; For any candidate prediction box in the fusion set First, it is necessary to determine the predicted bounding box. Does it belong to a weakly permissible set or a strongly permissible set? If the prediction box If the bounding box originates from the weak admission set, then search for and predict the bounding box in the strong admission set. Predicted boxes of the same category; Conversely, if the prediction box If the bounding box originates from the strong admission set, then search for and predict the bounding box in the weak admission set. Predicted boxes of the same category; Filter out all boxes that match the prediction box For each predicted bounding box of the same category, calculate their correlation with the predicted bounding box. The cross-union ratio (CUIR) of the predicted bounding boxes is used as the predicted bounding boxes. Matching prediction boxes in another set ; If there is no matching prediction box in either the strong or weak admission set. If the predicted boxes are of the same category, then the predicted boxes are considered to be... No matching box was found. Through this bidirectional cross-branch search mechanism, it is possible to find the corresponding prediction box with the best spatial location for each prediction box in the fusion set in its complementary set, thereby laying the foundation for subsequent consistency determination. If the predicted bounding box matches If it exists, then the prediction box will be... Matching prediction boxes The crossover ratio (CROR) between the nodes is compared with a consistency threshold to obtain the consistency result, which is expressed as:
[0053] in, The Cross-Union Ratio (CUNR) function takes the bounding box coordinates of two predicted boxes as input and outputs the overlap ratio between the two predicted boxes. For any two predicted boxes, the CUNR function first calculates the area of the intersection region of the two boxes, that is, the area of the spatial overlap of the two boxes. Then it calculates the area of the union region of the two boxes, that is, the sum of the areas of the two boxes minus the intersection area. Finally, the intersection area is divided by the union area, and the resulting ratio is the CUNR. This is the consistency threshold, used to determine whether two prediction boxes have sufficient consistency under different augmentation branches; If the prediction box Matching prediction boxes If the intersection-union ratio between the predicted boxes is greater than or equal to the consistency threshold, i.e., the above inequality holds, then the predicted boxes are considered to be... It exhibits good consistency across the two sets and preserves the predicted bounding boxes. To a consistent set; Otherwise, the prediction box is considered... Insufficient stability, therefore not retained; The cross-branch consistency test described above can effectively identify predicted boxes that stably locate the same target in both weak and strong augmentation views, filtering out random responses or positioning offsets caused by augmentation disturbances. This significantly improves the spatial stability and repeatability of pseudo-labels, reduces duplicate predictions and false detections caused by box inconsistencies, and provides a more accurate and reliable set of predicted boxes for subsequent confidence-based secondary screening.
[0054] In some embodiments, the fusion screening step S5 further includes: The second confidence score corresponding to each category in the statistical consistency set is used to obtain the second confidence distribution of each prediction box corresponding to each category; If the absolute value of the number of confidence samples in the second confidence distribution of each prediction box is less than the preset sample count back-off threshold, then the preset basic screening threshold will be used as the screening threshold. Otherwise, calculate the second quantile of the second confidence distribution of each prediction box, and use the maximum value between the preset basic screening threshold and the second quantile as the screening threshold.
[0055] By statistically analyzing the confidence scores of each category in the consistency set, a second confidence distribution is obtained. Then, based on the sample size and quantiles, an independent screening threshold for each category is calculated, so that the final screening criteria can dynamically adapt to the true confidence characteristics of various defects after passing the consistency test. For categories with sufficient samples, a higher threshold is used to eliminate low-confidence predictions, while for categories with insufficient samples, the threshold is lowered back to avoid over-filtering. This approach retains the effective pseudo-label density while suppressing the mixing of unreliable predictions. Based on spatial consistency screening, a category-adaptive confidence constraint is added, further improving the purity and reliability of pseudo-labels.
[0056] Furthermore, such as Figure 4 As shown, after obtaining the consistency set, the second confidence distribution is recalculated for each prediction box in the consistency set according to its category. And calculate the screening threshold. Its expression is:
[0057] in, To filter based on the basic threshold; To filter quantile parameters; When the number of confidence samples for a certain category in the consistency set is less than the preset sample count back-off threshold, the preset basic screening threshold is directly used as the screening threshold for that category. When the sample size is sufficient, the second quantile of the second confidence distribution for that category is calculated, and the maximum value of the second quantile and the basic screening threshold is used as the final screening threshold.
[0058] In some embodiments, the fusion screening step S5 further includes: The second confidence score of each prediction box in the consistency set is compared with the filtering threshold corresponding to the category of the prediction box to obtain the filtering result; Based on the filtering results, determine whether to retain the predicted boxes in the consistency set to obtain the pseudo-label dataset.
[0059] By comparing the confidence score of each predicted box in the consistency set with the screening threshold corresponding to its category one by one, a clear screening result is obtained, and the retention of each predicted box is determined accordingly. This enables the generation of the final pseudo-label to have a refined individual decision-making ability. Under the premise that the spatial consistency screening is passed, the predicted boxes are screened again at the confidence level according to the category. This ensures that only predicted boxes that meet both spatial consistency and high confidence conditions can become the final pseudo-labels. At the same time, it fully considers the differences in confidence distribution among different categories, effectively avoids the quality unevenness caused by a uniform threshold, and significantly improves the overall quality of the pseudo-label dataset.
[0060] In some embodiments, the fusion screening step S5 further includes: If the second confidence score is greater than or equal to the screening threshold, the screening result is the prediction box in the consistent set; If the second confidence score is less than the screening threshold, the screening result is that the predicted boxes in the consistency set are not retained.
[0061] By clearly defining the judgment rule that the result is retained when the confidence score reaches or exceeds the screening threshold, and not retained otherwise, the final admission of pseudo-labels has a strict and unified quantitative basis. Based on the cross-branch consistency verification, prediction boxes with relatively low confidence are further removed by category. This ensures that the final retained pseudo-labels are not only spatially stable, but also that the model has a high degree of confidence in their predictions. This effectively suppresses the interference of low-quality pseudo-labels on student training, reduces the risk of accumulated confirmation bias, and enables the student detector to learn from purer and more reliable supervision signals, ultimately achieving stronger generalization ability and better detection performance.
[0062] Furthermore, after calculating the screening threshold, the fused conservative screening module SCPL makes the final retention decision on the prediction boxes in the consistency set. For the consistency set, iterate through each prediction box within it. According to its category Get the corresponding filtering threshold And the second confidence score of each prediction box in the consistency set. The filtering result is obtained by comparing the predicted bounding box with the filtering threshold corresponding to its category. The expression is as follows:
[0063] in, This is the retention decision function for the conservative selection module SCPL after fusion; if the result of the retention decision function is 1, the selection result is to retain the predicted box in the pseudo-label dataset; if the result of the retention decision function is 0, the selection result is to remove the predicted box. By making the above judgments, we can ensure that the final retained pseudo-labels not only have stable spatial localization under different augmented views, but also reach a high standard for the category in terms of confidence. This allows for a more comprehensive evaluation of the reliability of pseudo-labels, effectively filtering out random responses with high confidence but inconsistent localization, as well as weak responses with consistent localization but low confidence. This significantly improves the overall quality of the final pseudo-label dataset and provides more reliable supervision signals for the stable training of the student detector.
[0064] Object detection step S6: Train the student detector based on the pseudo-label dataset and the labeled dataset to obtain the object detector. Perform defect detection on the image to be detected based on the object detector to obtain the detection result.
[0065] Furthermore, after generating the pseudo-label dataset, the labeled dataset will be... With pseudo-label dataset Merge the datasets to create a significantly larger training dataset; The labeled dataset provides reliable supervision signals, while the pseudo-label dataset provides a large number of quality-controlled unlabeled data mining results.
[0066] The training dataset is input into the student detector for training. During the training process, the student detector simultaneously receives real labels from the labeled dataset and pseudo labels from the pseudo label dataset as supervision signals. For each image in the labeled dataset, the student detector learns in a standard fully supervised manner, calculating the loss between the predicted result and the ground truth bounding box and the category label; for each image in the pseudo-label dataset, the student detector learns in a semi-supervised manner, treating the selected high-quality pseudo-labels as ground truth labels, calculating the loss between the predicted result and the pseudo-labels. The total loss function is usually a weighted sum of the two losses, where the weight of the pseudo-label loss can be dynamically adjusted according to the overall confidence level of the pseudo-labels. During the training of the student detector, the labeled dataset and the pseudo-label dataset can be mixed and then randomly sampled in batches, or an alternating sampling strategy can be adopted, that is, samples are drawn from the two datasets in each training batch according to a preset ratio. The training process continues until the detection performance index of the student detector on the validation set tends to converge or reaches the preset maximum number of training rounds. After training, the parameters of the student detector are fixed, becoming the final deployable target detector, which has the ability to detect various minute defects in the original acquired images. In practical applications, the system acquires the image to be inspected, which is a raw product surface image collected in real time on the production line without any labeling. The object detector performs a single forward inference on the image to be detected and outputs the detection results in the image. The detection results typically include the bounding box coordinates of each detected defect object, the category label of the defect, and the model's confidence score for the detection results. In the context of printed circuit board defect detection, the detection results can accurately identify the location and type of various minor defects such as open circuits, short circuits, burrs, and gaps, providing a basis for subsequent quality sorting or process improvement.
[0067] Based on the above semi-supervised defect detection method, the teacher detector is first trained on a small amount of labeled data and the parameters are frozen. Then, weak and strong enhancement processing is performed on the unlabeled data respectively. The two types of prediction results are used to jointly construct the category adaptive admission threshold and the fusion screening threshold. Thus, high-quality pseudo-labels can be stably generated using a large amount of unlabeled data when there are only a small number of labeled samples. By dynamically adjusting the screening criteria based on the differences in confidence distribution among different categories, the problem of false label noise propagation caused by category imbalance or extremely small target size is effectively solved. This allows the final trained student detector to significantly improve its recall capability for rare defects while maintaining high accuracy and suppressing false detections caused by complex backgrounds. Overall, this improves the stability and generalization performance of semi-supervised defect detection.
[0068] The semi-supervised defect detection method described above uses the Distribution Aware Threshold Module (DAT) for admission determination and the Conservative Screening Module (SCPL) for retention determination. The DAT module can adaptively determine the admission threshold based on the confidence distribution of each defect category on unlabeled data, thereby avoiding over-filtering of effective pseudo-labels when there is class imbalance and low confidence of small defects. The conservative screening module SCPL further suppresses unstable predictions after fusion, making pseudo-labels more reliable and consistent without significantly reducing density. Combining the Distribution Aware Thresholding (DAT) module with the fused Conservative Screening (SCPL) module can effectively reduce training interference caused by noise pseudo-labels and duplicate boxes, thereby improving the stability and overall detection performance of semi-supervised small defect detection. Furthermore, the test results analysis of the PCB small defect detection task shows that, compared with the pure supervised baseline and the fixed threshold semi-supervised baseline, the above semi-supervised defect detection method shows a more stable detection effect in the scenario where extremely small defects coexist with complex texture backgrounds. For defects that are small in size, have indistinct boundaries, or have low confidence levels, the above-mentioned semi-supervised defect detection method is more likely to achieve effective detection and reduce the occurrence of missed detections. For complex texture regions or background interference regions, the above semi-supervised defect detection method can reduce scattered false detections and duplicate bounding boxes to a certain extent, making the prediction results more concise and stable. In summary, the aforementioned semi-supervised defect detection methods demonstrate superior performance in terms of small defect recovery capability, complex background suppression capability, and result consistency. Under the same experimental settings, the above semi-supervised defect detection method achieved better overall performance in PCB small defect detection tasks, with precision P reaching 0.938, recall R reaching 0.901, mAP50 reaching 0.964, and mAP reaching 0.717. Compared with the fixed threshold semi-supervised baseline, the mAP of the above semi-supervised defect detection method increased from 0.702 to 0.717, mAP50 increased from 0.948 to 0.964, and recall increased from 0.882 to 0.901, while precision remained at a high level. This shows that by using the distributed sensing threshold module DAT and the fused conservative screening module SCPL, the effective detection capability can be improved without excessively sacrificing precision. Furthermore, compared to using only the Distributed Aware Threshold Module (DAT), the semi-supervised defect detection method described above, after introducing the fusion-based conservative screening module (SCPL), further improved the mAP from 0.715 to 0.717 and the mAP50 from 0.949 to 0.964, indicating that the fusion-based screening mechanism can effectively suppress unstable pseudo-labels and further improve the detection quality.
[0069] like Figure 5 As shown, this embodiment of the invention also provides a distributed adaptive semi-supervised defect detection system, comprising: The data acquisition module acquires the raw images and, based on the raw images, obtains labeled and unlabeled datasets. The model training module performs supervised training on the teacher detector based on the labeled dataset, and freezes the parameters of the teacher detector after supervised training to obtain the trained teacher detector. The augmentation inference module performs weak and strong data augmentation on the unlabeled dataset, and then performs inference through the trained teacher detector to obtain weak and strong prediction sets. The admission determination module determines the admission threshold based on the first confidence distribution of each prediction box in the weak prediction set and the strong prediction set. Based on the admission threshold, the prediction boxes in the weak prediction set and the strong prediction set are filtered to obtain the weak admission set and the strong admission set. The fusion filtering module merges the weak admission set and the strong admission set to obtain a fusion set. It filters the predicted boxes in the fusion set based on a consistency threshold to obtain a consistency set. Based on the second confidence distribution of each predicted box in the consistency set, it determines a filtering threshold. Based on the filtering threshold, it filters the predicted boxes in the consistency set to obtain a pseudo-label dataset. The object detection module trains a student detector based on a pseudo-label dataset and a labeled dataset to obtain an object detector. Based on the object detector, defect detection is performed on the image to be detected to obtain the detection result.
[0070] Each module completes data acquisition, model training, augmented inference, admission determination, fusion screening and target detection functions, forming a complete and highly automated defect detection system. This enables the system to automatically generate pseudo-labels and train the student detector using the category confidence distribution without manual labeling of unlabeled data, significantly reducing the cost and manpower investment of large-scale labeling in industrial scenarios. Meanwhile, because the system retains core mechanisms such as adaptive thresholding by category and cross-branch consistency verification, it can still run stably in detection tasks with extremely small target size, complex texture, or severe class imbalance, and output detection results with accurate position and high confidence, which has high practicality and promotion value.
[0071] It should be noted that the above is a reference method and system for a distributed adaptive semi-supervised defect detection method, and the present invention is not limited thereto.
[0072] This invention implements adaptive admission control for unlabeled data pseudo-labels by class. By statistically analyzing the confidence distribution of each class and calculating the differentiated admission threshold, the pseudo-label screening criteria can dynamically adapt to the data characteristics of different defect categories. At the same time, the cascade mechanism of cross-branch consistency test and fusion distribution screening suppresses unstable predictions and noisy pseudo-labels. This solves the technical problems in the prior art where the pseudo-label admission criteria and class confidence distribution are mismatched due to a single global confidence threshold, rare or minor defect pseudo-labels are easily over-filtered or mixed with noise, resulting in decreased recall and increased false detection rate.
[0073] Finally, it should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other. The above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them; although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications can still be made to the specific implementation of the present invention or equivalent substitutions can be made to some technical features without departing from the spirit of the technical solutions of the present invention, and all such modifications and substitutions should be covered within the scope of the technical solutions claimed in the present invention.
Claims
1. A distribution-adaptive based semi-supervised defect detection method, characterized in that, include: Data acquisition steps: Acquire the original captured images, and based on the original captured images, obtain the labeled dataset and the unlabeled dataset; Model training steps: Based on the labeled dataset, supervised training is performed on the teacher detector, and the parameters of the teacher detector are frozen after supervised training to obtain the trained teacher detector; Enhanced inference steps: After performing weak data augmentation and strong data augmentation on the unlabeled dataset, inference is performed through the trained teacher detector to obtain a weak prediction set and a strong prediction set; Admission determination steps: Based on the first confidence distribution of each prediction box in the weak prediction set and the strong prediction set, determine the admission threshold, and filter the prediction boxes in the weak prediction set and the strong prediction set respectively based on the admission threshold to obtain the weak admission set and the strong admission set. The fusion filtering steps are as follows: the weak admission set and the strong admission set are fused to obtain a fused set; the predicted boxes in the fused set are filtered based on a consistency threshold to obtain a consistency set; a filtering threshold is determined based on the second confidence distribution of each predicted box in the consistency set; and the predicted boxes in the consistency set are filtered based on the filtering threshold to obtain a pseudo-label dataset. Target detection steps: Train a student detector based on the pseudo-label dataset and the labeled dataset to obtain a target detector; perform defect detection on the image to be detected based on the target detector to obtain the detection result.
2. The distribution-adaptive based semi-supervised defect detection method of claim 1, wherein, The specific steps for determining access are as follows: The first confidence score corresponding to each category in the weak prediction set and the strong prediction set is statistically analyzed to obtain the first confidence distribution of each prediction box corresponding to each category; If the absolute value of the number of confidence samples in the first confidence distribution of each prediction box is less than the preset sample count back-off threshold, then the preset basic threshold is used as the admission threshold. Otherwise, calculate the first quantile of the first confidence distribution of each prediction box, and use the maximum value between the preset base threshold and the first quantile as the admission threshold.
3. The distribution-adaptive based semi-supervised defect detection method of claim 2, wherein, The admission determination step also includes: The first confidence score of each prediction box in the weak prediction set and the strong prediction set is compared with the admission threshold corresponding to the category of the prediction box to obtain the admission result. Based on the admission results, it is determined whether to retain the prediction boxes in the weak prediction set and the strong prediction set, so as to obtain the weak admission set and the strong admission set.
4. The distribution-adaptive based semi-supervised defect detection method of claim 3, wherein, The admission determination step also includes: If the first confidence score is greater than or equal to the admission threshold, the admission result is to retain the prediction boxes in the weak prediction set or the strong prediction set. If the first confidence score is less than the admission threshold, the admission result is to not retain the prediction boxes in the weak prediction set or the strong prediction set.
5. The semi-supervised defect detection method based on distribution adaptation according to claim 1, characterized in that, The fusion screening step is specifically as follows: For each prediction box in the fusion set, determine whether the prediction box originates from the weak admission set or the strong admission set, and obtain the source admission set corresponding to the prediction box. In another admission set different from the source admission set, find the prediction box with the same category as the prediction box, and determine the prediction box with the largest intersection-union ratio with the prediction box as the matching prediction box; Calculate the intersection-union ratio (IUU) between the predicted bounding box and the matched predicted bounding box, and compare the IUU with the consistency threshold to obtain the consistency result; Based on the consistency results, determine whether to retain the prediction boxes in the fusion set to obtain the consistency set.
6. The semi-supervised defect detection method based on distribution adaptation according to claim 5, characterized in that, The fusion screening step also includes: If the intersection-union ratio between the predicted bounding box and the matching predicted bounding box is greater than or equal to the consistency threshold, then the consistency result is to retain the predicted bounding boxes in the fusion set. If the intersection-union ratio between the predicted bounding box and the matching predicted bounding box is less than the consistency threshold, or if there is no matching predicted bounding box, then the consistency result is to not retain the predicted bounding boxes in the fusion set.
7. The semi-supervised defect detection method based on distribution adaptation according to claim 1, characterized in that, The fusion screening step also includes: The second confidence score corresponding to each category in the consistency set is calculated to obtain the second confidence distribution of each prediction box corresponding to each category; If the absolute value of the number of confidence samples in the second confidence distribution of each prediction box is less than the preset sample count back-off threshold, then the preset basic screening threshold is used as the screening threshold. Otherwise, calculate the second quantile of the second confidence distribution of each prediction box, and use the maximum value between the preset basic screening threshold and the second quantile as the screening threshold.
8. The semi-supervised defect detection method based on distribution adaptation according to claim 7, characterized in that, The fusion screening step also includes: The second confidence score of each prediction box in the consistency set is compared with the filtering threshold corresponding to the category of the prediction box to obtain the filtering result; Based on the filtering results, determine whether to retain the predicted boxes in the consistency set to obtain the pseudo-label dataset.
9. The semi-supervised defect detection method based on distribution adaptation according to claim 8, characterized in that, The fusion screening step also includes: If the second confidence score is greater than or equal to the filtering threshold, the filtering result is to retain the prediction boxes in the consistency set; If the second confidence score is less than the filtering threshold, the filtering result is to not retain the prediction boxes in the consistency set.
10. A semi-supervised defect detection system based on distributed adaptive methods, characterized in that, include: The data acquisition module acquires the original captured images and, based on the original captured images, obtains an labeled dataset and an unlabeled dataset. The model training module performs supervised training on the teacher detector based on the labeled dataset, and freezes the parameters of the teacher detector after supervised training to obtain the trained teacher detector. The augmented inference module performs weak data augmentation and strong data augmentation on the unlabeled dataset, and then performs inference through the trained teacher detector to obtain a weak prediction set and a strong prediction set. The admission determination module determines the admission threshold based on the first confidence distribution of each prediction box in the weak prediction set and the strong prediction set, and filters the prediction boxes in the weak prediction set and the strong prediction set based on the admission threshold to obtain the weak admission set and the strong admission set. The fusion filtering module merges the weak admission set and the strong admission set to obtain a fusion set, filters the predicted boxes in the fusion set based on a consistency threshold to obtain a consistency set, determines a filtering threshold based on the second confidence distribution of each predicted box in the consistency set, and filters the predicted boxes in the consistency set based on the filtering threshold to obtain a pseudo-label dataset. The target detection module trains a student detector based on the pseudo-label dataset and the labeled dataset to obtain a target detector. Based on the target detector, it performs defect detection on the image to be detected and obtains the detection result.