AI-based product sampling detection accuracy evaluation method and system
By using negative immune screening of key samples and analysis of occlusion interference features, combined with difference curve correction, an accuracy evaluation model was constructed, which solved the accuracy deviation problem in AI visual inspection under complex backgrounds and achieved efficient and accurate evaluation of detection results.
Patent Information
- Application Number
- CN202511144258.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-15
- Publication Date
- 2026-01-27
- Estimated Expiration
- 2045-08-15
AI Technical Summary
Existing technologies in AI vision product quality inspection lack effective modeling under interference such as complex backgrounds and lighting changes, resulting in large deviations in the accuracy assessment results. Furthermore, they cannot quantify the impact of key samples on the model's detection performance, making it difficult to improve assessment efficiency and accuracy.
By employing negative immune screening of key samples, occlusion interference feature analysis, and topological persistence annotation, combined with difference curve correction, an accuracy evaluation model is constructed to quantify detection stability under occlusion conditions and provide interpretable feature evolution curves.
It improves the efficiency and accuracy of AI sampling inspection accuracy assessment, provides a mapping from local errors to global credibility, and supports interpretable basis for production line release and model iteration.
Smart Images

Figure CN120976181B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of evaluation, and more particularly to an AI-based method and system for evaluating the accuracy of product sampling inspection. Background Technology
[0002] With the advancement of intelligent manufacturing, AI vision-based product quality inspection has been widely applied in industries such as 3C, lithium batteries, and pharmaceuticals. High-speed production lines generate millions of images every day. Enterprises rely on deep learning models to identify and classify defects, and use sampling evaluation to determine the pass rate of the entire batch of products. The reliable assessment of the accuracy of the inspection is directly related to the release risk and after-sales costs.
[0003] Existing technologies largely rely on simple AI sampling or statistics, lacking effective modeling for interferences such as complex backgrounds, lighting changes, and partial occlusion. This leads to significant biases in evaluation results. Modeling large amounts of data is time-consuming, and it is also difficult to quantify the impact of key samples on model detection performance. Furthermore, it is difficult to reveal the detection stability and asymptotic behavior of defect features under different occlusion conditions during long-term detection. Improving the efficiency and accuracy of detection result evaluation has become an urgent problem to be solved. This invention improves the efficiency and interpretability of detection result evaluation by using immune negative screening of key samples, occlusion interference and topological persistence analysis, difference curve correction, and asymptotic calculation. This enhances the timeliness and sample range of AI sampling detection accuracy evaluation. Summary of the Invention
[0004] The purpose of this invention is to provide an AI-based method and system for evaluating the accuracy of product sampling inspection.
[0005] To achieve the above objectives, the present invention is implemented according to the following technical solution:
[0006] The first aspect of this invention provides an AI-based method for evaluating the accuracy of product sampling inspection, comprising:
[0007] Acquire image data and real-labeled samples of the product to be tested, and use an immune negative selection algorithm to screen key samples from the image data;
[0008] Gradient occlusion is performed on the secondary dataset of the image data based on the edge information of the key samples to obtain a first occluded image, a second occluded image, and an image occlusion degree. The first occluded image and the second occluded image are used to extract occlusion interference features through a wavelet convolutional network.
[0009] The occlusion interference features of the first occluded image and the second occluded image are topologically persistently annotated. The annotated data, image data and real annotated samples are input into the AI detection model to obtain the first result, the second result, the real annotated result and the image detection result.
[0010] Based on the first and second results, a first difference curve and a second difference curve are obtained through detection time sequence. The first difference curve is scaled using the real annotation results in the detection results to obtain a third difference curve.
[0011] The detection deviation is obtained based on the real annotation results and image detection results. The second difference curve is corrected according to the detection deviation and the third difference curve. The image detection asymptoticity is obtained through the image occlusion degree according to the fourth difference curve obtained by correction.
[0012] An accuracy evaluation model is obtained based on the image detection asymptoticism, key sample ratio, image occlusion degree, and third difference curve. The accuracy evaluation model is then used to output the AI detection accuracy evaluation result.
[0013] Furthermore, the method for screening the key samples includes:
[0014] Defect-free self-samples are generated based on real labeled samples using an immune negative selection algorithm. Initial detectors are randomly generated according to the feature dimensions of the image data, with the number of initial detectors set to 1.2 to 1.5 times the total number of image data samples. The Euclidean distance and cosine similarity between the initial detectors and the self-samples are calculated. Affinity is calculated by weighting the Euclidean distance and cosine similarity. The initial average affinity is increased by 15% to 20% as the affinity threshold, and detectors below the affinity threshold are used as the optimized detector set.
[0015] The optimized average affinity is calculated based on the optimized detector set and image data. Samples with optimized average affinity lower than the affinity threshold are selected as candidate key samples. If the real annotation corresponding to the candidate key sample has defective features, the matching degree between the defective features and the sensitive features of the AI detection model is calculated. Candidate key samples with matching degree higher than the preset judgment threshold are selected as key samples. The position, feature type and correspondence between the key sample and the real annotation in the image data are recorded.
[0016] If the candidate key sample has no defect features, the candidate sample affinity between the candidate key sample and the self sample is calculated. The candidate key sample with a candidate sample affinity lower than the initial average affinity is taken as the key sample. The sensitive features include edge mutation features, regional gray-level anomaly features, and shape distortion features.
[0017] Furthermore, the method for obtaining the first occlusion image, the second occlusion image, and the image occlusion degree includes:
[0018] Based on key samples, edge feature similarity is calculated according to the cosine distance of the edge direction histogram. Samples with edge feature similarity greater than 60% in the image data are used as secondary datasets. Based on the images of the secondary datasets, edge contours are extracted by edge detection algorithms. The edge contours are expanded by 5 pixels and the horizontal gradient, vertical gradient, gradient direction and gradient magnitude are calculated by Sobel operator.
[0019] The first occlusion template is the union of the horizontal gradient and gradient direction between -15° and 15° and between 165° and 195°. The second occlusion template is the union of the vertical gradient and gradient direction between 75° and 105° and between 255° and 285°. The occlusion intensity is determined by positive correlation linear mapping based on the gradient magnitude. The first and second occlusion templates are then processed pixel-by-pixel with samples from the secondary dataset to obtain the first and second occlusion images. The areas of regions with a pixel value change rate greater than 20% in the first and second occlusion images are counted, and the proportion of the region area to the total area of the corresponding occlusion image is taken as the image occlusion degree.
[0020] Furthermore, the method for obtaining the occlusion interference features includes:
[0021] Based on the first and second occlusion images, the occlusion inpainting model iteratively repairs the occlusion area until the absolute value of the difference between the energy function outputs in two consecutive iterations is less than 1. The first and second restored images are obtained respectively. The expression for the occlusion restoration model is:
[0022] ,
[0023] Where E is the energy function output of the occlusion inpainting model, and u is the inpainted image. The pixel matrix range of each occluded image. Let be the L1 norm of the image gradient, which is obtained from the horizontal and vertical gradients corresponding to each occluded image, and S be the image occlusion degree. To mask the image, M is the gradient magnitude. The maximum gradient magnitude of the secondary dataset. Let L0 be the norm of the image gradient;
[0024] The first and second restored images are respectively input into a dual wavelet-based convolutional network. The dual wavelet-based convolutional network extracts gradient defect features using a db4 wavelet-based convolutional kernel and extracts abrupt defect features using a haar wavelet-based convolutional kernel. Max pooling and sigmoid activation are performed based on the gradient defect features and abrupt defect features to obtain the occlusion interference features of the first and second restored images, respectively.
[0025] Furthermore, the method for obtaining the labeled data includes:
[0026] Based on the occlusion interference feature, the Euclidean distance between the feature point and the key sample is used as the horizontal axis, and the gradient magnitude of the feature point is used as the vertical axis. The feature points are mapped to a two-dimensional topological space according to the horizontal and vertical axes. The two-dimensional topological space is triangulated. The feature points of the topological branches after triangulation are traversed in ascending order according to the gradient magnitude. If the gradient magnitude of 5 consecutive pixels exceeds the median gradient magnitude of the secondary dataset and the pixel area is greater than 10 pixels, it is used as a birth sign; otherwise, it is used as a death sign. The difference between the birth sign and the death sign is used as the feature persistence, and the average persistence of the secondary dataset is used as the persistence threshold.
[0027] Topological branches with feature persistence greater than 0.3 times the persistence threshold are designated as key topological branches. Based on the center coordinates of the topological branches, the key topological branches are mapped back to the image data using an inverse mapping algorithm. The mapping position, gradient interval, and topology type are recorded to obtain the topological mapping region. Pixel values with an image occlusion degree greater than 0.5 are labeled as occlusion-induced defects based on the topological mapping region; otherwise, they are labeled as original defects. This yields the labeled data of the image data. The labeled data includes feature persistence, the ratio of defect area to occlusion area, and the spatial overlap between occlusion interference features and true labels.
[0028] Furthermore, the method for obtaining the third difference curve includes:
[0029] Based on the first occluded image and the second occluded image, first annotation data and second annotation data are obtained through topological persistent annotation, respectively. The first annotation data, second annotation data, image data and real annotation samples are respectively input into the AI detection model to obtain the first result, the second result, the real annotation result and the image detection result. The first result includes the defect prediction location, product type and confidence level.
[0030] Based on the detection time sequence, the first result and the second result are mapped to a time sequence. The defect confidence difference between the first result and the second result is calculated for each sample according to the time sequence. The mean Euclidean distance of the predicted position is calculated to obtain the first difference curve. The defect confidence difference between the second result and the real labeled result is calculated. The mean Euclidean distance between the predicted position and the real labeled predicted position is calculated to obtain the second difference curve.
[0031] The confidence deviation and predicted position deviation between the actual annotation results and the image detection results are used as the baseline deviation features. Based on the baseline deviation features, linear regression fitting is performed on the defect confidence difference and the mean Euclidean distance of the predicted position of the first difference curve to obtain the confidence scaling factor and the position scaling factor. The first difference curve is then multiplied point by point by the confidence scaling factor and the position scaling factor to obtain the third difference curve.
[0032] Furthermore, the method for obtaining the image detection asymptotics includes:
[0033] The detection bias is obtained based on the real annotation results and image detection results. Feature persistence and spatial overlap are obtained based on the first annotation data and the second annotation data. The Pearson correlation coefficient between feature persistence and the confidence dimension of detection bias is calculated. The intersection-union ratio between spatial overlap and the location dimension of detection bias is calculated to obtain confidence association persistence and location association persistence. Max-min normalization is performed on confidence association persistence and location association persistence respectively to obtain topological confidence weight and topological location weight.
[0034] The product of the topological confidence weight and the confidence deviation is calculated based on the third difference curve. This product is then added to the confidence deviation of the corresponding position on the second difference curve, and the confidence deviation of the detection deviation is subtracted to obtain the confidence deviation of the fourth difference curve. The topological position weight is multiplied by the predicted position deviation of the third difference curve, and this product is added to the predicted position deviation of the second difference curve, and the predicted position deviation of the detection deviation is subtracted to obtain the predicted position deviation of the fourth difference curve. Based on the fourth difference curve, the image detection asymptoticism is obtained through image occlusion. The formula for calculating the image detection asymptoticism is as follows:
[0035] ,
[0036] Where A is the image detection asymptoticism. This represents the confidence level bias. For topological confidence weights, To predict positional deviation, For topological position weights, The proportion of key samples. The average gradient magnitude, Let be the mean occlusion degree of an occluded image. The mean occlusion value of the second occluded image. This is the fourth difference curve.
[0037] Furthermore, the method for obtaining the accuracy evaluation result of the quasi-AI detection includes:
[0038] A defect feature diagonal matrix is constructed based on the image detection asymptoticity, the proportion of key samples, and the mean of the occlusion degrees of the first and second occluded images. The gradient occlusion interference is negatively constrained by exponential decay based on the mean of the occlusion degrees of the first and second occluded images. A difference statistical symmetric matrix is constructed based on the mean and variance of the third difference curve. An accuracy evaluation model is obtained based on the defect feature diagonal matrix and the difference statistical symmetric matrix. The AI detection accuracy evaluation result is output based on the accuracy evaluation model. The expression of the accuracy evaluation model is as follows:
[0039] ,
[0040] in The AI detection accuracy evaluation result is shown, where A represents the image detection asymptoticity. The proportion of key samples. The occlusion degree of the first occluded image is the average of the occlusion degrees of the second occluded image. The third difference curve The mean, The third difference curve The variance.
[0041] A second aspect of the present invention provides an AI-based product sampling inspection accuracy evaluation system, comprising:
[0042] Key sample screening module: used to acquire image data and real labeled samples of the product to be tested, and to screen key samples from the image data using an immune negative selection algorithm;
[0043] The occluded defect feature extraction module is used to perform gradient occlusion on the secondary dataset of the image data based on the edge information of the key samples, to obtain a first occluded image, a second occluded image and an image occlusion degree, and to extract the occluded defect features using the first occluded image and the second occluded image through a wavelet convolutional network.
[0044] Topological persistence annotation module: used to perform topological persistence annotation on the occluded defect features of the first occluded image and the second occluded image, and input the annotation data, image data and real annotation samples into the AI detection model to obtain the first result, the second result, the real annotation result and the image detection result;
[0045] The third difference curve acquisition module is used to obtain the first difference curve and the second difference curve through the detection time sequence based on the first result and the second result, and to scale the first difference curve using the real annotation result in the detection result to obtain the third difference curve.
[0046] Image detection asymptoticity acquisition module: used to obtain the detection deviation based on the real annotation results and image detection results, correct the second difference curve according to the detection deviation and the third difference curve, and obtain the image detection asymptoticity through the image occlusion degree according to the fourth difference curve obtained by correction;
[0047] The detection accuracy evaluation module is used to obtain an accuracy evaluation model based on the image detection asymptoticism, key sample ratio, image occlusion degree, and third difference curve, and to output the AI detection accuracy evaluation result using the accuracy evaluation model.
[0048] Compared with the prior art, the embodiments of the present invention have at least the following advantages or beneficial effects:
[0049] This invention employs immune negative selection of key samples, using defect-free self-samples as a benchmark to adaptively generate detectors. It selects key samples most sensitive to model performance, reducing redundant computation and improving the targeting of evaluation. Through occlusion-topology joint feature analysis, it transforms the edge information of key samples into gradient occlusion templates, and then uses topological persistence annotation to quantify the stability of defects under occlusion conditions. This reveals the impact of real-world conditions such as occlusion and noise on detection results, providing interpretable feature evolution curves. By using difference curves and asymptotic correction, it uses the first to fourth difference curves to correct confidence and positional deviations layer by layer, calculates the detection asymptoticity, constructs an accuracy evaluation model, and forms a mapping from local error to global confidence, providing interpretable evidence for production line release, model iteration, and risk traceability. Attached Figure Description
[0050] Figure 1 This is a flowchart illustrating the steps of the AI-based product sampling inspection accuracy evaluation method in an embodiment of the present invention. Detailed Implementation
[0051] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0052] Reference Figure 1 As shown, this invention provides an AI-based method for evaluating the accuracy of product sampling inspection, including:
[0053] Acquire image data and real-labeled samples of the product to be tested, and use an immune negative selection algorithm to screen key samples from the image data;
[0054] In the actual evaluation, 1000 surface images of electronic components were acquired, including 500 defective images and 500 defect-free images. Real-world labeled samples were obtained, and the defect locations, types, and confidence levels were manually labeled. 100 images were randomly selected from the defect-free images and processed using a 5x5 Gaussian blur and histogram equalization to generate a self-sample set. LBP texture with a radius of 3 and a neighborhood of 8 was extracted from the image data, and then processed using a 5x5 pixel window gray-level co-occurrence matrix to obtain 10-dimensional features. 1300 initial detectors were generated, representing 1.3 times the total number of samples. Euclidean distance and cosine similarity were calculated between the initial detectors and the self-samples, and affinity was calculated using weighted values. ,in As the initial detector, As a self-sample, For Euclidean distance, For cosine similarity, the initial affinity was calculated iteratively, with an average value of 0.35. The average value was increased by 18% to obtain an affinity threshold of 0.413. Detectors with affinity less than 0.413 were retained as an optimized detector set, totaling 850. The average optimized affinity between each image and the detector was calculated based on the optimized detector set. Samples with an average optimized affinity lower than the affinity threshold were selected as candidate key samples, totaling 200. The matching degree between the real defects and the sensitive features of the AI detection model was calculated based on 120 candidate samples containing defects. Samples with a matching degree greater than 60% were retained, resulting in 80 key samples. The affinity between the candidate samples and their own samples was calculated based on the 80 candidate samples without defects. Samples with an affinity less than 0.35 were retained, resulting in 50 key samples. These were combined to obtain 130 key samples. Their image index, LBP features, gray-level co-occurrence matrix features, and correspondence with the real labeled defect features were recorded.
[0055] Gradient occlusion is performed on the secondary dataset of the image data based on the edge information of the key samples to obtain a first occluded image, a second occluded image, and an image occlusion degree. The first occluded image and the second occluded image are used to extract occlusion interference features through a wavelet convolutional network.
[0056] In the actual evaluation, Canny edge detection was performed on each key sample and candidate image to extract edge contours, and orientation histogram quantization was performed. The edge directions from 0° to 180° were divided into 12 bins, and the edge pixel ratio of each bin was counted to generate a 12-dimensional feature vector. Among them, a key sample containing horizontal scratches had edge directions concentrated in bin1 (0°~15°) and bin12 (165°~180°). The cosine distance of the edge orientation histograms was calculated for the candidate images and key samples. Images with a cosine distance less than 0.4 were retained, and a total of 60 images were selected as the secondary dataset. The edge contours were extended by 5 pixels, and the horizontal gradient, vertical gradient, gradient direction, and gradient magnitude were calculated using the Sobel operator. The first occlusion template and the second occlusion template were operated pixel by pixel with the samples in the secondary dataset to obtain the first occlusion image and the second occlusion image. The area of the region with a pixel value change rate greater than 20% in the first occlusion image and the second occlusion image was counted. The proportion of the region area to the total area of the corresponding occlusion image was used as the image occlusion degree, and the average occlusion degree was 0.375%.
[0057] Based on the first and second occluded images, an occluded repair model iteratively repairs the occluded region. The pixel matrix ranges from 640 to 480, the gradient magnitude of the scratch region is 150, and the maximum gradient magnitude of the secondary dataset is 200. Gradient descent is used with a learning rate of 0.01 until convergence after approximately 100 iterations. The absolute value of the difference between the energy function outputs in two consecutive iterations is less than [value missing]. The scratch area in the first repaired image was restored from a decay of 35% to a value close to the true value of 95%. After restoration, the decay was slightly reduced due to smoothing. The second repaired image had a lower occlusion degree in the original occluded image, and the difference between the repaired image and the original image was less than 5%, almost identical. The first and second repaired images were respectively input into a dual wavelet basis convolutional network. The dual wavelet basis convolutional network extracted the gradient defect features using a 3×3 db4 wavelet basis convolutional kernel and extracted the abrupt defect features using a 5×5 haar wavelet basis convolutional kernel. Based on the gradient defect features and abrupt defect features, 4×4 max pooling and sigmoid activation were performed, and the features were spliced according to the feature channels. The features were normalized to obtain the occlusion interference features of the first repaired image in 160×120×2 dimensions and the occlusion interference features of the second repaired image.
[0058] The occlusion interference features of the first occluded image and the second occluded image are topologically persistently annotated. The annotated data, image data and real annotated samples are input into the AI detection model to obtain the first result, the second result, the real annotated result and the image detection result.
[0059] In the actual evaluation, 32 feature points were obtained based on the occlusion interference features of the first repaired image, distributed around the horizontal scratch. The center coordinates of the key sample were obtained as (200, 205). The Euclidean distance between the feature points and the key sample was used as the horizontal axis, and the gradient magnitude of the feature points was used as the vertical axis. The feature points were mapped to a two-dimensional topological space according to the horizontal and vertical axes. Delaunay triangulation was performed on the two-dimensional topological space to form a petal-shaped triangle cluster around the center, reflecting the gradual edge structure of the scratch. The feature points of the topological branches after triangulation were traversed in ascending order according to the gradient magnitude. If the gradient magnitude of 5 consecutive pixels exceeds the median gradient magnitude of 100 in the secondary dataset and the triangulation area is greater than 10 pixels, it is used as a feature birth mark. Otherwise, it is used as a feature death mark. The birth position of a feature in a certain topological branch is 120, and the death mark is 80. The difference between the feature birth mark and the feature death mark is used as the feature persistence. The wider the gradient range of the feature that survives in the topological space, the higher the stability. The average persistence of the secondary dataset, 40, is used as the persistence threshold.
[0060] The topological branches with feature persistence greater than 12 are taken as key topological branches. Based on the center coordinates (5.39, 120) of the topological branches, the key topological branches are mapped back to the image data (198, 204) through linear inverse mapping. The mapping position, gradient interval and topology type are recorded to obtain the topological mapping region. Pixel values with image occlusion greater than 0.5 are marked as occlusion-induced defects according to the topological mapping region, and otherwise marked as original defects to obtain the labeled data of the image data. The labeled data includes feature persistence 40, the ratio of defect area to occlusion area 0.1, and the spatial overlap between occlusion interference features and real labels 0.0125. Based on the first occluded image and the second occluded image, the first labeled data and the second labeled data are obtained respectively through topological persistence labeling. The first labeled data, the second labeled data, the image data and the real labeled samples are input into the AI detection model to obtain the first result, the second result, the real labeled result and the image detection result. Among them, the value of sample 1 in the first result is 0.82, and the predicted position is (195, 203).
[0061] Based on the first and second results, a first difference curve and a second difference curve are obtained through detection time sequence. The first difference curve is scaled using the real annotation results in the detection results to obtain a third difference curve.
[0062] In the actual evaluation, the first and second results are mapped to a time series based on the detection time sequence. For time series 1, the confidence difference is calculated to be 0.15, and the Euclidean distance of the predicted position is 3.16 pixels, forming a two-dimensional difference curve to obtain the first difference curve. The defect confidence difference between the second result and the actual labeled result is calculated to be 0.65, and the mean Euclidean distance between the predicted position and the actual labeled predicted position is calculated to be 2.24 pixels. In time series 51, the second result is a defect-free sample, so the mean distance is infinite at this time, and the second difference curve is obtained. Based on the baseline deviation characteristics, linear regression fitting is performed on the defect confidence difference and the mean Euclidean distance of the predicted position of the effective defect samples from time series 1 to 50 to obtain a confidence scaling factor of 1.2 and a position scaling factor of 1.5. The first difference curve is multiplied point by point by the confidence scaling factor and the position scaling factor to obtain the third difference curve. In the third difference curve, the confidence deviation of time series 1 is 0.108, and the position deviation is 4.74 pixels.
[0063] The detection deviation is obtained based on the real annotation results and image detection results. The second difference curve is corrected according to the detection deviation and the third difference curve. The image detection asymptoticity is obtained through the image occlusion degree according to the fourth difference curve obtained by correction.
[0064] In the actual evaluation, feature persistence and spatial overlap are obtained based on the first and second labeled data. The Pearson correlation coefficient between feature persistence and the confidence dimension of detection bias is calculated to be 0.8, and the intersection-union ratio between spatial overlap and the location dimension of detection bias is calculated to be 0.6. Max-min normalization is performed to obtain the topological confidence weight of 0.8 and the topological location weight of 0.6. The product of the topological confidence weight and the confidence deviation is calculated based on the third difference curve. The product is added to the confidence deviation of the corresponding position of the second difference curve, and the confidence deviation of the detection bias is subtracted to obtain the confidence deviation of the fourth difference curve. The topological location weight is multiplied by the predicted location deviation of the third difference curve, and the product is added to the predicted location deviation of the second difference curve and subtracted to obtain the predicted location deviation of the detection bias to obtain the predicted location deviation of the fourth difference curve. The image detection asymptoticity is obtained based on the fourth difference curve through image occlusion, where the image detection asymptoticity of time sequence 1 is 0.631.
[0065] An accuracy evaluation model is obtained based on the image detection asymptoticism, key sample ratio, image occlusion degree, and third difference curve. The accuracy evaluation model is then used to output the AI detection accuracy evaluation result.
[0066] In the actual evaluation, a defect feature diagonal matrix was constructed based on the image detection asymptoticism of 0.63, the key sample ratio of 0.13, and the mean of the occlusion degree of the first and second occluded images of 0.00375. The gradient occlusion interference is negatively constrained by exponential decay based on the average of the occlusion degrees of the first and second occluded images. A symmetric matrix of difference statistics is constructed based on the mean of 0.15 and variance of 0.02 of the third difference curve. An accuracy evaluation model is obtained based on the diagonal matrix of defect features and the symmetric matrix of difference statistics. The AI detection accuracy evaluation result of detection sequence 1 is 0.397 based on the accuracy evaluation model.
[0067] In this embodiment, the method for screening the key samples includes:
[0068] Defect-free self-samples are generated based on real labeled samples using an immune negative selection algorithm. Initial detectors are randomly generated according to the feature dimensions of the image data, with the number of initial detectors set to 1.2 to 1.5 times the total number of image data samples. The Euclidean distance and cosine similarity between the initial detectors and the self-samples are calculated. Affinity is calculated by weighting the Euclidean distance and cosine similarity. The initial average affinity is increased by 15% to 20% as the affinity threshold, and detectors below the affinity threshold are used as the optimized detector set.
[0069] The optimized average affinity is calculated based on the optimized detector set and image data. Samples with optimized average affinity lower than the affinity threshold are selected as candidate key samples. If the real annotation corresponding to the candidate key sample has defective features, the matching degree between the defective features and the sensitive features of the AI detection model is calculated. Candidate key samples with matching degree higher than the preset judgment threshold are selected as key samples. The position, feature type and correspondence between the key sample and the real annotation in the image data are recorded.
[0070] If the candidate key sample has no defect features, the candidate sample affinity between the candidate key sample and the self sample is calculated. The candidate key sample with a candidate sample affinity lower than the initial average affinity is taken as the key sample. The sensitive features include edge mutation features, regional gray-level anomaly features, and shape distortion features.
[0071] In this embodiment, the method for obtaining the first occlusion image, the second occlusion image, and the image occlusion degree includes:
[0072] Based on key samples, edge feature similarity is calculated according to the cosine distance of the edge direction histogram. Samples with edge feature similarity greater than 60% in the image data are used as secondary datasets. Based on the images of the secondary datasets, edge contours are extracted by edge detection algorithms. The edge contours are expanded by 5 pixels and the horizontal gradient, vertical gradient, gradient direction and gradient magnitude are calculated by Sobel operator.
[0073] The first occlusion template is the union of the horizontal gradient and gradient direction between -15° and 15° and between 165° and 195°. The second occlusion template is the union of the vertical gradient and gradient direction between 75° and 105° and between 255° and 285°. The occlusion intensity is determined by positive correlation linear mapping based on the gradient magnitude. The first and second occlusion templates are then processed pixel-by-pixel with samples from the secondary dataset to obtain the first and second occlusion images. The areas of regions with a pixel value change rate greater than 20% in the first and second occlusion images are counted, and the proportion of the region area to the total area of the corresponding occlusion image is taken as the image occlusion degree.
[0074] In this embodiment, the method for obtaining the occlusion interference features includes:
[0075] Based on the first and second occlusion images, the occlusion inpainting model iteratively repairs the occlusion area until the absolute value of the difference between the energy function outputs in two consecutive iterations is less than 1. The first and second restored images are obtained respectively. The expression for the occlusion restoration model is:
[0076] ,
[0077] Where E is the energy function output of the occlusion inpainting model, and u is the inpainted image. The pixel matrix range of each occluded image. Let be the L1 norm of the image gradient, which is obtained from the horizontal and vertical gradients corresponding to each occluded image, and S be the image occlusion degree. To mask the image, M is the gradient magnitude. The maximum gradient magnitude of the secondary dataset. Let L0 be the norm of the image gradient;
[0078] The first and second restored images are respectively input into a dual wavelet-based convolutional network. The dual wavelet-based convolutional network extracts gradient defect features using a db4 wavelet-based convolutional kernel and extracts abrupt defect features using a haar wavelet-based convolutional kernel. Max pooling and sigmoid activation are performed based on the gradient defect features and abrupt defect features to obtain the occlusion interference features of the first and second restored images, respectively.
[0079] In this embodiment, the method for obtaining the labeled data includes:
[0080] Based on the occlusion interference feature, the Euclidean distance between the feature point and the key sample is used as the horizontal axis, and the gradient magnitude of the feature point is used as the vertical axis. The feature points are mapped to a two-dimensional topological space according to the horizontal and vertical axes. The two-dimensional topological space is triangulated. The feature points of the topological branches after triangulation are traversed in ascending order according to the gradient magnitude. If the gradient magnitude of 5 consecutive pixels exceeds the median gradient magnitude of the secondary dataset and the pixel area is greater than 10 pixels, it is used as a birth sign; otherwise, it is used as a death sign. The difference between the birth sign and the death sign is used as the feature persistence, and the average persistence of the secondary dataset is used as the persistence threshold.
[0081] Topological branches with feature persistence greater than 0.3 times the persistence threshold are designated as key topological branches. Based on the center coordinates of the topological branches, the key topological branches are mapped back to the image data using an inverse mapping algorithm. The mapping position, gradient interval, and topology type are recorded to obtain the topological mapping region. Pixel values with an image occlusion degree greater than 0.5 are labeled as occlusion-induced defects based on the topological mapping region; otherwise, they are labeled as original defects. This yields the labeled data of the image data. The labeled data includes feature persistence, the ratio of defect area to occlusion area, and the spatial overlap between occlusion interference features and true labels.
[0082] In this embodiment, the method for obtaining the third difference curve includes:
[0083] Based on the first occluded image and the second occluded image, first annotation data and second annotation data are obtained through topological persistent annotation, respectively. The first annotation data, second annotation data, image data and real annotation samples are respectively input into the AI detection model to obtain the first result, the second result, the real annotation result and the image detection result. The first result includes the defect prediction location, product type and confidence level.
[0084] Based on the detection time sequence, the first result and the second result are mapped to a time sequence. The defect confidence difference between the first result and the second result is calculated for each sample according to the time sequence. The mean Euclidean distance of the predicted position is calculated to obtain the first difference curve. The defect confidence difference between the second result and the real labeled result is calculated. The mean Euclidean distance between the predicted position and the real labeled predicted position is calculated to obtain the second difference curve.
[0085] The confidence deviation and predicted position deviation between the actual annotation results and the image detection results are used as the baseline deviation features. Based on the baseline deviation features, linear regression fitting is performed on the defect confidence difference and the mean Euclidean distance of the predicted position of the first difference curve to obtain the confidence scaling factor and the position scaling factor. The first difference curve is then multiplied point by point by the confidence scaling factor and the position scaling factor to obtain the third difference curve.
[0086] In this embodiment, the method for obtaining the image detection asymptotics includes:
[0087] The detection bias is obtained based on the real annotation results and image detection results. Feature persistence and spatial overlap are obtained based on the first annotation data and the second annotation data. The Pearson correlation coefficient between feature persistence and the confidence dimension of detection bias is calculated. The intersection-union ratio between spatial overlap and the location dimension of detection bias is calculated to obtain confidence association persistence and location association persistence. Max-min normalization is performed on confidence association persistence and location association persistence respectively to obtain topological confidence weight and topological location weight.
[0088] The product of the topological confidence weight and the confidence deviation is calculated based on the third difference curve. This product is then added to the confidence deviation of the corresponding position on the second difference curve, and the confidence deviation of the detection deviation is subtracted to obtain the confidence deviation of the fourth difference curve. The topological position weight is multiplied by the predicted position deviation of the third difference curve, and this product is added to the predicted position deviation of the second difference curve, and the predicted position deviation of the detection deviation is subtracted to obtain the predicted position deviation of the fourth difference curve. Based on the fourth difference curve, the image detection asymptoticism is obtained through image occlusion. The formula for calculating the image detection asymptoticism is as follows:
[0089] ,
[0090] Where A is the image detection asymptoticism. This represents the confidence level bias. For topological confidence weights, To predict positional deviation, For topological position weights, The proportion of key samples. The average gradient magnitude, Let be the mean occlusion degree of an occluded image. The mean occlusion value of the second occluded image. This is the fourth difference curve.
[0091] In this embodiment, the method for obtaining the accuracy evaluation result of the quasi-AI detection includes:
[0092] A defect feature diagonal matrix is constructed based on the image detection asymptoticity, the proportion of key samples, and the mean of the occlusion degrees of the first and second occluded images. The gradient occlusion interference is negatively constrained by exponential decay based on the mean of the occlusion degrees of the first and second occluded images. A difference statistical symmetric matrix is constructed based on the mean and variance of the third difference curve. An accuracy evaluation model is obtained based on the defect feature diagonal matrix and the difference statistical symmetric matrix. The AI detection accuracy evaluation result is output based on the accuracy evaluation model. The expression of the accuracy evaluation model is as follows:
[0093] ,
[0094] in The AI detection accuracy evaluation result is shown, where A represents the image detection asymptoticity. The proportion of key samples. The occlusion degree of the first occluded image is the average of the occlusion degrees of the second occluded image. The third difference curve The mean, The third difference curve The variance.
[0095] A second aspect of the present invention also provides an AI-based product sampling inspection accuracy evaluation system, comprising:
[0096] Key sample screening module: used to acquire image data and real labeled samples of the product to be tested, and to screen key samples from the image data using an immune negative selection algorithm;
[0097] The occluded defect feature extraction module is used to perform gradient occlusion on the secondary dataset of the image data based on the edge information of the key samples, to obtain a first occluded image, a second occluded image and an image occlusion degree, and to extract the occluded defect features using the first occluded image and the second occluded image through a wavelet convolutional network.
[0098] Topological persistence annotation module: used to perform topological persistence annotation on the occluded defect features of the first occluded image and the second occluded image, and input the annotation data, image data and real annotation samples into the AI detection model to obtain the first result, the second result, the real annotation result and the image detection result;
[0099] The third difference curve acquisition module is used to obtain the first difference curve and the second difference curve through the detection time sequence based on the first result and the second result, and to scale the first difference curve using the real annotation result in the detection result to obtain the third difference curve.
[0100] Image detection asymptoticity acquisition module: used to obtain the detection deviation based on the real annotation results and image detection results, correct the second difference curve according to the detection deviation and the third difference curve, and obtain the image detection asymptoticity through the image occlusion degree according to the fourth difference curve obtained by correction;
[0101] The detection accuracy evaluation module is used to obtain an accuracy evaluation model based on the image detection asymptoticism, key sample ratio, image occlusion degree, and third difference curve, and to output the AI detection accuracy evaluation result using the accuracy evaluation model.
[0102] The above description is merely an example and illustration of the structure of the present invention. Those skilled in the art can make various modifications or additions to the specific embodiments described, or use similar methods to replace them, as long as they do not deviate from the structure of the invention or exceed the scope defined in the claims, all of which should fall within the protection scope of the present invention.
Claims
1. An AI-based method for evaluating the accuracy of product sampling inspection, characterized in that, Includes the following steps: Acquire image data and real-labeled samples of the product to be tested, and use an immune negative selection algorithm to screen key samples from the image data; Gradient occlusion is performed on the secondary dataset of the image data based on the edge information of the key samples to obtain a first occluded image, a second occluded image, and an image occlusion degree. Occlusion interference features are extracted based on the first occluded image and the second occluded image through a wavelet convolutional network. The occlusion interference features of the first occluded image and the second occluded image are topologically persistently annotated. The annotated data, image data and real annotated samples are input into the AI detection model to obtain the first result, the second result, the real annotated result and the image detection result. Based on the first and second results, a first difference curve and a second difference curve are obtained through detection time sequence. The first difference curve is scaled using the real annotation results in the detection results to obtain a third difference curve. The detection deviation is obtained based on the real annotation results and image detection results. The second difference curve is corrected according to the detection deviation and the third difference curve. The image detection asymptoticity is obtained through the image occlusion degree according to the fourth difference curve obtained by correction. An accuracy evaluation model is obtained based on the image detection asymptoticism, key sample ratio, image occlusion degree, and third difference curve. The accuracy evaluation model is then used to output the AI detection accuracy evaluation result.
2. The AI-based product sampling inspection accuracy evaluation method according to claim 1, characterized in that, The method for screening the key samples includes: Defect-free self-samples are generated based on real labeled samples using an immune negative selection algorithm. Initial detectors are randomly generated according to the feature dimensions of the image data, with the number of initial detectors set to 1.2 to 1.5 times the total number of image data samples. The Euclidean distance and cosine similarity between the initial detectors and the self-samples are calculated. Affinity is calculated by weighting the Euclidean distance and cosine similarity. The initial average affinity is increased by 15% to 20% as the affinity threshold, and detectors below the affinity threshold are used as the optimized detector set. The optimized average affinity is calculated based on the optimized detector set and image data. Samples with optimized average affinity lower than the affinity threshold are selected as candidate key samples. If the real annotation corresponding to the candidate key sample has defective features, the matching degree between the defective features and the sensitive features of the AI detection model is calculated. Candidate key samples with matching degree higher than the preset judgment threshold are selected as key samples. The position, feature type and correspondence between the key sample and the real annotation in the image data are recorded. If the candidate key sample has no defect features, the candidate sample affinity between the candidate key sample and the self sample is calculated. The candidate key sample with a candidate sample affinity lower than the initial average affinity is taken as the key sample. The sensitive features include edge mutation features, regional gray-level anomaly features, and shape distortion features.
3. The AI-based product sampling inspection accuracy evaluation method according to claim 1, characterized in that, A method for obtaining the first occlusion image, the second occlusion image, and the image occlusion degree includes: Image data is used as candidate images. Based on key samples and the candidate images, the edge feature similarity is calculated according to the cosine distance of the edge direction histogram. Samples in the image data with edge feature similarity greater than 60% are used as secondary datasets. Based on the images in the secondary datasets, edge contours are extracted using an edge detection algorithm. The edge contours are expanded by 5 pixels and the horizontal gradient, vertical gradient, gradient direction, and gradient magnitude are calculated using the Sobel operator. The first occlusion template is the union of the horizontal gradient and gradient direction between -15° and 15° and between 165° and 195°. The second occlusion template is the union of the vertical gradient and gradient direction between 75° and 105° and between 255° and 285°. The occlusion intensity is determined by positive correlation linear mapping based on the gradient magnitude. The first and second occlusion templates are then processed pixel-by-pixel with samples from the secondary dataset to obtain the first and second occlusion images. The areas of regions with a pixel value change rate greater than 20% in the first and second occlusion images are counted, and the proportion of the region area to the total area of the corresponding occlusion image is taken as the image occlusion degree.
4. The AI-based product sampling inspection accuracy evaluation method according to claim 1, characterized in that, The method for obtaining the occlusion interference features includes: Based on the first and second occlusion images, the occlusion inpainting model iteratively repairs the occlusion area until the absolute value of the difference between the energy function outputs in two iterations is less than 1. The first and second restored images are obtained respectively. The expression for the occlusion restoration model is: ; in The energy function output of the occlusion repair model, For the repaired image, The pixel matrix range of each occluded image. Let L1 be the norm of the image gradient, which is obtained from the horizontal and vertical gradients corresponding to each occluded image. Image occlusion degree, To mask the image, For gradient magnitude, The maximum gradient magnitude of the secondary dataset. Let L0 be the norm of the image gradient; The first and second restored images are respectively input into a dual wavelet-based convolutional network. The dual wavelet-based convolutional network extracts gradient defect features using a db4 wavelet-based convolutional kernel and extracts abrupt defect features using a haar wavelet-based convolutional kernel. Max pooling and sigmoid activation are performed based on the gradient defect features and abrupt defect features to obtain the occlusion interference features of the first and second restored images, respectively.
5. The AI-based product sampling inspection accuracy evaluation method according to claim 1, characterized in that, The method for obtaining the labeled data includes: Based on the occlusion interference feature, the Euclidean distance between the feature point and the key sample is used as the horizontal axis, and the gradient magnitude of the feature point is used as the vertical axis. The feature points are mapped to a two-dimensional topological space according to the horizontal and vertical axes. The two-dimensional topological space is triangulated. The feature points of the topological branches after triangulation are traversed in ascending order according to the gradient magnitude. If the gradient magnitude of 5 consecutive pixels exceeds the median gradient magnitude of the secondary dataset and the pixel area is greater than 10 pixels, it is used as a birth sign; otherwise, it is used as a death sign. The difference between the birth sign and the death sign is used as the feature persistence, and the average persistence of the secondary dataset is used as the persistence threshold. Topological branches with feature persistence greater than 0.3 times the persistence threshold are designated as key topological branches. Based on the center coordinates of the topological branches, the key topological branches are mapped back to the image data using an inverse mapping algorithm. The mapping position, gradient interval, and topology type are recorded to obtain the topological mapping region. Pixel values with an image occlusion degree greater than 0.5 are labeled as occlusion-induced defects based on the topological mapping region; otherwise, they are labeled as original defects. This yields the labeled data of the image data. The labeled data includes feature persistence, the ratio of defect area to occlusion area, and the spatial overlap between occlusion interference features and true labels.
6. The AI-based product sampling inspection accuracy evaluation method according to claim 1, characterized in that, The method for obtaining the third difference curve includes: Based on the first occluded image and the second occluded image, first annotation data and second annotation data are obtained through topological persistent annotation, respectively. The first annotation data, second annotation data, image data and real annotation samples are respectively input into the AI detection model to obtain the first result, the second result, the real annotation result and the image detection result. The first result includes the defect prediction location, product type and confidence level. Based on the detection time sequence, the first result and the second result are mapped to a time sequence. The defect confidence difference between the first result and the second result is calculated for each sample according to the time sequence. The mean Euclidean distance of the predicted position is calculated to obtain the first difference curve. The defect confidence difference between the second result and the real labeled result is calculated. The mean Euclidean distance between the predicted position and the real labeled predicted position is calculated to obtain the second difference curve. The confidence deviation and predicted position deviation between the actual annotation results and the image detection results are used as the baseline deviation features. Based on the baseline deviation features, linear regression fitting is performed on the defect confidence difference and the mean Euclidean distance of the predicted position of the first difference curve to obtain the confidence scaling factor and the position scaling factor. The first difference curve is then multiplied point by point by the confidence scaling factor and the position scaling factor to obtain the third difference curve.
7. The AI-based product sampling inspection accuracy evaluation method according to claim 1, characterized in that, The method for obtaining the image detection asymptotics includes: The detection bias is obtained based on the real annotation results and image detection results. Feature persistence and spatial overlap are obtained based on the first annotation data and the second annotation data. The Pearson correlation coefficient between feature persistence and the confidence dimension of detection bias is calculated. The intersection-union ratio between spatial overlap and the location dimension of detection bias is calculated to obtain confidence association persistence and location association persistence. Max-min normalization is performed on confidence association persistence and location association persistence respectively to obtain topological confidence weight and topological location weight. The product of the topological confidence weight and the confidence deviation is calculated based on the third difference curve. This product is then added to the confidence deviation of the corresponding position on the second difference curve, and the confidence deviation of the detection deviation is subtracted to obtain the confidence deviation of the fourth difference curve. The topological position weight is multiplied by the predicted position deviation of the third difference curve, and this product is added to the predicted position deviation of the second difference curve, and the predicted position deviation of the detection deviation is subtracted to obtain the predicted position deviation of the fourth difference curve. Based on the fourth difference curve, the image detection asymptoticism is obtained through image occlusion. The formula for calculating the image detection asymptoticism is as follows: ; in For image asymptotic detection, This represents the confidence level bias. For topological confidence weights, To predict positional deviation, For topological position weights, The proportion of key samples. The average gradient magnitude, Let be the mean occlusion degree of an occluded image. The mean occlusion value of the second occluded image. This is the fourth difference curve.
8. The AI-based product sampling inspection accuracy evaluation method according to claim 1, characterized in that, The method for obtaining the AI detection accuracy evaluation result includes: A defect feature diagonal matrix is constructed based on the image detection asymptoticity, the proportion of key samples, and the mean of the occlusion degrees of the first and second occluded images. The gradient occlusion interference is negatively constrained by exponential decay based on the mean of the occlusion degrees of the first and second occluded images. A difference statistical symmetric matrix is constructed based on the mean and variance of the third difference curve. An accuracy evaluation model is obtained based on the defect feature diagonal matrix and the difference statistical symmetric matrix. The AI detection accuracy evaluation result is output based on the accuracy evaluation model. The expression of the accuracy evaluation model is as follows: ; in The results of the AI detection accuracy assessment For image asymptotic detection, The proportion of key samples. The occlusion degree of the first occluded image is the average of the occlusion degrees of the second occluded image. The third difference curve The mean, The third difference curve The variance.
9. An AI-based product sampling inspection accuracy evaluation system, used to execute the AI-based product sampling inspection accuracy evaluation method according to any one of claims 1 to 8, characterized in that, The system includes: Key sample screening module: used to acquire image data and real labeled samples of the product to be tested, and to screen key samples from the image data using an immune negative selection algorithm; The occluded defect feature extraction module is used to perform gradient occlusion on the secondary dataset of image data based on the edge information of the key samples to obtain a first occluded image, a second occluded image, and an image occlusion degree. Based on the first occluded image and the second occluded image, the occluded defect features are extracted through a wavelet convolutional network. Topological persistence annotation module: used to perform topological persistence annotation on the occluded defect features of the first occluded image and the second occluded image, and input the annotation data, image data and real annotation samples into the AI detection model to obtain the first result, the second result, the real annotation result and the image detection result; The third difference curve acquisition module is used to obtain the first difference curve and the second difference curve through the detection time sequence based on the first result and the second result, and to scale the first difference curve using the real annotation result in the detection result to obtain the third difference curve. Image detection asymptoticity acquisition module: used to obtain the detection deviation based on the real annotation results and image detection results, correct the second difference curve according to the detection deviation and the third difference curve, and obtain the image detection asymptoticity through the image occlusion degree according to the fourth difference curve obtained by correction; The detection accuracy evaluation module is used to obtain an accuracy evaluation model based on the image detection asymptoticism, key sample ratio, image occlusion degree, and third difference curve, and to output the AI detection accuracy evaluation result using the accuracy evaluation model.
Citation Information
Patent Citations
Product detection method, electronic equipment and storage medium
CN117522773A
Disease marker expression network reconstruction feature key point determination method
CN120279988A