A few-shot industrial defect target detection method and system based on dinov3 and SAM
By combining Dinov3 and SAM models, the detection dilemma caused by the scarcity of defect samples is solved, enabling rapid deployment and efficient data accumulation, improving detection accuracy and stability, and laying a data foundation for subsequent model optimization.
Patent Information
- Application Number
- CN202511468203.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-15
- Publication Date
- 2025-12-23
- Estimated Expiration
- 2045-10-15
AI Technical Summary
In the early stages of new product trial production, production line process changes, or the emergence of new defect patterns, the number of defect samples is extremely small, which makes it impossible to effectively train traditional detection models or result in extremely poor performance, creating a dilemma of 'having defects but being unable to reliably detect them'.
By combining Dinov3 and SAM models, a method is adopted to generate a defect reference feature library, calculate pixel-wise similarity, filter neighborhoods, filter using spatial attention mechanism, and perform fine segmentation. Combined with semantic matching, texture consistency, and shape regularity evaluation, it can achieve rapid deployment and high-confidence detection, and automatically accumulate structured labeled data.
Achieving rapid and effective detection in the early stages when defect samples are scarce, automatically accumulating high-quality labeled data, improving detection accuracy and stability, reducing false positives and false negatives, and promoting subsequent model optimization.
Smart Images

Figure CN120953269B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of artificial intelligence and industrial visual inspection technology, and in particular to a few-shot industrial defect target detection method and system based on Dinov3 and SAM. BACKGROUND
[0002] In intelligent manufacturing and automatic quality inspection systems, deep learning models have become the core technology for defect detection. However, its successful application is highly dependent on large-scale, high-quality labeled data sets for supervised training. In the initial stage of new product trial production, process changes on the production line or the appearance of new defect patterns, the number of defect samples is extremely small, even zero, which leads to the fact that traditional detection models cannot be effectively trained or have poor performance, forming a dilemma of "having defects but being unable to reliably detect". Therefore, there is an urgent need for a technical solution that can quickly deploy and achieve effective detection in the initial stage of extremely scarce defect samples.
[0003] Recently, the self-supervised learning model DINOv3 has shown strong zero-shot transferability in visual representation learning through large-scale unsupervised pre-training. SAM, as a general segmentation base model, can generate high-quality instance masks according to geometric cues without fine-tuning for specific categories. Combining the two models can achieve a fast and effective technical solution, not only for immediate quality control, but more importantly, providing a data basis for subsequent construction of high-quality labeled data sets and training of more optimal specialized models. SUMMARY
[0004] The present application provides a few-shot industrial defect target detection method and system based on Dinov3 and SAM, aiming to solve the problem of being unable to train effective detection models due to insufficient number of defect samples in the initial stage of industrial projects, and to achieve rapid deployment, accurate detection, and accumulation of high-quality labeled data for subsequent model iteration.
[0005] To achieve the above purpose, the present application provides a few-shot industrial defect target detection method based on Dinov3 and SAM, which comprises the following steps:
[0006] S1: Obtain reference images of different industrial defect categories, extract reference image features through a pre-trained Dinov3 model, aggregate the reference image features of each industrial defect category by weighting, generate category prototype feature vectors, and construct a defect reference feature library;
[0007] S2: Extract the features of the test image using the Dinov3 model, calculate the pixel-by-pixel similarity between the test image features and the category prototype feature vectors in the defect reference feature library, generate an initial response map, and enhance it using a neighborhood filtering algorithm to obtain an enhanced response map;
[0008] S3: Based on the enhanced response map, a spatial attention mechanism is introduced to filter significant response regions and generate prompt bounding boxes or prompt key points corresponding to the enhanced response map.
[0009] S4: Input the cue bounding box or cue key points into SAM, perform fine segmentation on the significant response regions in the enhanced response map, and output the defect instance mask;
[0010] S5: Combining semantic matching strength, regional texture consistency, and shape regularity, calculate the comprehensive confidence score of each segmentation result, use dynamic thresholds to filter high-confidence results, and output the final detection result.
[0011] Optionally, in step S1, when generating the category prototype feature vector by weighted aggregation of the reference image features for each industrial defect category, the weights used in the weighted aggregation are configured to be determined based on the average cosine similarity between each reference image feature and other reference image features of the same category.
[0012] The expressions for the weights used in weighted aggregation are as follows:
[0013]
[0014]
[0015] In the formula, For the first Weights of features in a reference image. The average cosine similarity between this feature and the other n-1 similar reference features. For temperature coefficient, The total number of reference images for this defect category; This is the aggregated category prototype feature vector. For the first Features of a reference image.
[0016] Optionally, in step S2, the neighborhood filtering algorithm is used to enhance the response map and obtain an enhanced response map. This is configured as follows: the neighborhood filtering algorithm is used to calculate the similarity between the response values of each spatial location in the initial response map and its local neighborhood, and the original response is weighted and smoothed.
[0017] The expression for the filtered initial response map is as follows:
[0018]
[0019] in, This is the initial response diagram. This is the enhanced response diagram after filtering. For coordinates a center-based local window, a Gaussian kernel function, a kernel width parameter.
[0020] Optionally, in step S3, when introducing the spatial attention mechanism to screen the salient response region, the spatial attention mechanism generates an expression of an attention weight map, which is specifically:
[0021]
[0022] wherein, is the attention weight map, is the enhanced response map, is a learnable position encoding, represents channel dimension concatenation, represents a 3x3 convolution operation, is a Sigmoid activation function, and the salient response region is obtained from . represents element-wise multiplication.
[0023] Optionally, in step S5, the comprehensive confidence score of each segmentation result is calculated by combining the semantic matching strength, the region texture consistency, and the shape regularity, and the expression is specifically:
[0024]
[0025] wherein, is the comprehensive confidence score, is the normalized semantic matching strength, is the texture consistency score calculated based on the local gray variance, is the shape regularity score calculated based on the contour compactness, , , is a non-negative weight coefficient, and satisfies .
[0026] Optionally, the expressions of the normalized semantic matching strength , the texture consistency score , and the shape regularity score are specifically:
[0027]
[0028]
[0029]
[0030] wherein, is the mask region enhanced response map The average value, The attenuation coefficient is... For mask Gray-level variance in the original gray-level image For the area, For the perimeter of the outline, The 1st step after performing fine-grained segmentation on the salient response region Candidate regions, For mask Enhanced response map within the region The Middle The average value of each candidate region.
[0031] Optionally, in step S5, the expression for the dynamic threshold is specifically as follows:
[0032]
[0033] in, For dynamic thresholds, and These are the mean and standard deviation of the overall confidence scores for all candidate regions in the current image under test, respectively. These are the sensitivity adjustment parameters.
[0034] Optionally, a dynamic threshold is used to filter high-confidence results, and the final detection result is output, configured as follows: when the overall confidence score of the segmentation result is... Above the dynamic threshold If the result is positive, retain it; otherwise, delete it as a low-confidence result.
[0035] Optionally, the method further includes:
[0036] S6: Automatically store the high confidence results output in step S5 and their corresponding association information into the defect sample database to form a structured labeled dataset for subsequent model training;
[0037] The associated information stored in the defect sample database includes: the original image to be tested, the mask of the detected defect instance, the defect category label, the detection timestamp, and the comprehensive confidence score.
[0038] Furthermore, to achieve the above objectives, the present invention also provides a few-sample industrial defect target detection system based on Dinov3 and SAM, comprising:
[0039] The module is used to acquire reference images for different industrial defect categories, extract reference image features through a pre-trained Dinov3 model, perform weighted aggregation of reference image features for each industrial defect category, generate category prototype feature vectors, and build a defect reference feature library.
[0040] The enhancement module is used for extracting features of the to-be-tested image using a Dinov3 model, performing pixel-by-pixel similarity calculation on the features of the to-be-tested image and a category prototype feature vector in a defect reference feature library, generating an initial response graph, and performing enhancement using a neighborhood filtering algorithm to obtain an enhanced response graph.
[0041] The generation module is used for introducing a spatial attention mechanism to screen a significant response region based on the enhanced response graph, and generating a prompt bounding box or a prompt key point corresponding to the enhanced response graph.
[0042] The segmentation module is used for inputting the prompt bounding box or the prompt key point into a SAM to perform fine segmentation on the significant response region in the enhanced response graph, and outputting a defect instance mask.
[0043] The screening module is used for combining semantic matching strength, regional texture consistency and shape regularity to calculate a comprehensive confidence score of each segmentation result, screening a high-confidence result using a dynamic threshold, and outputting a final detection result.
[0044] The present application has the following advantages:
[0045] Solve the problem of initial sample scarcity: in the initial stage of a project where the number of defect samples is insufficient to train a conventional supervised model, only a small number of reference images are used to achieve rapid deployment and effective detection, filling the quality monitoring gap.
[0046] Efficient data accumulation: through automatic detection and high-confidence result screening, high-quality and structured defect annotation data is continuously generated, significantly accelerating the construction process of the data set required for subsequent special model training.
[0047] Improve system robustness: through a powerful feature extraction model and a general segmentation base model, weighted feature aggregation, context enhancement and multi-dimensional confidence evaluation are added to effectively improve the detection accuracy and stability in complex industrial environments and reduce false positives and omissions.
[0048] Promote model iteration: not only provides few-sample detection capability, but more importantly, establishes a solid data foundation for training a special supervised model with better performance, forming a virtuous cycle of data accumulation and model optimization. BRIEF DESCRIPTION OF DRAWINGS
[0049] Figure 1 FIG. 1 is a flowchart of a few-sample industrial defect target detection method based on Dinov3 and SAM according to an embodiment of the present application;
[0050] Figure 2 FIG. 2 is a schematic diagram of the principle of a few-sample industrial defect target detection method based on Dinov3 and SAM according to an embodiment of the present application;
[0051] Figure 3 A schematic diagram of the architecture of the few-shot industrial defect target detection method based on Dinov3 and SAM according to an embodiment of the present application is shown in FIG. 1.
[0052] Figure 4 A flowchart of the feature extraction process in the few-shot industrial defect target detection method based on Dinov3 and SAM according to an embodiment of the present application is shown in FIG. 2.
[0053] Figure 5 A schematic diagram of the structure of the few-shot industrial defect target detection system based on Dinov3 and SAM according to an embodiment of the present application is shown in FIG. 3. DETAILED DESCRIPTION
[0054] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and do not limit the present application.
[0055] An embodiment of the present application provides a few-shot industrial defect target detection method based on Dinov3 and SAM, which is described below with reference to Figure 1 , Figure 1 A flowchart of the few-shot industrial defect target detection method based on Dinov3 and SAM according to an embodiment of the present application is shown in FIG. 4.
[0056] In this embodiment, a few-shot industrial defect target detection method based on Dinov3 and SAM includes the following steps:
[0057] S1: Obtain reference images of different industrial defect categories, extract reference image features through a pre-trained Dinov3 model, aggregate the reference image features of each industrial defect category by weighting, generate a category prototype feature vector, and construct a defect reference feature library;
[0058] S2: Extract the features of the test image using the Dinov3 model, calculate the pixel-by-pixel similarity between the test image features and the category prototype feature vectors in the defect reference feature library, generate an initial response map, and enhance it using a neighborhood filtering algorithm to obtain an enhanced response map;
[0059] S3: Based on the enhanced response map, introduce a spatial attention mechanism to screen significant response regions, generate a prompt bounding box or prompt key point corresponding to the enhanced response map;
[0060] S4: Input the prompt bounding box or prompt key point into SAM, perform fine segmentation on the significant response regions in the enhanced response map, and output a defect instance mask;
[0061] S5: Combine semantic matching strength, regional texture consistency and shape regularity to calculate the comprehensive confidence score of each segmentation result, use dynamic threshold to filter high confidence results, and output the final detection result.
[0062] It should be noted that in the intelligent manufacturing and automatic quality inspection system, the deep learning model has become the core technology of defect detection. However, its successful application is highly dependent on large-scale and high-quality labeled data sets for supervised training. In the initial stage of new product trial production, process change of production line or appearance of new defect mode, the number of defect samples is extremely small, even zero, which leads to the fact that the traditional detection model cannot be effectively trained or has poor performance, forming the dilemma of "having defects but being unable to reliably detect". Therefore, there is an urgent need for a technical solution that can quickly deploy and achieve effective detection in the initial stage of extremely scarce defect samples.
[0063] To solve the above problems, the embodiment constructs a reference feature library: the features of a small number of defect reference images are extracted by using a Dinov3 model, and a category prototype is generated by weighted aggregation; a similarity response map is generated: the pixel-by-pixel similarity between the to-be-tested image and the reference prototype is calculated, and context enhancement filtering is performed; a segmentation prompt is generated: the significant area is filtered by combining a spatial attention mechanism to generate the geometric prompt required by the SAM model; fine segmentation is performed: the SAM model is used to generate the accurate mask of the defect instance; confidence evaluation: multi-dimensional scoring is performed by combining semantic matching, texture consistency and shape regularity, and a dynamic threshold is used to filter the results; data accumulation: high-confidence detection results are automatically stored to form a structured labeled data set. Thus, without model fine-tuning, rapid deployment can be realized, the problem of insufficient data in the initial stage can be effectively addressed, and data can be continuously accumulated through automated detection, laying a foundation for training a better specialized model, and being suitable for new product introduction or new defect discovery scenarios.
[0064] In order to explain the application more clearly, a specific example of a few-sample industrial defect target detection method based on Dinov3 and SAM is provided as follows: Figures 2-4 As shown in the figure, it includes the following execution process:
[0065] Step S1: Construct a reference feature library.
[0066] A small number of reference image samples of each type of industrial defect are obtained. In this embodiment, for the defect category, 3-10 reference images with a resolution of 1280x1280 pixels are collected, each containing a typical defect instance, and equipped with a corresponding mask.
[0067] Each reference image is input into a pre-trained and weight-frozen Dinov3 model to extract the feature map output by the model. For each reference image , according to its mask , the average feature vector of the scratch region is calculated as the prototype of this instance:
[0068]
[0069] wherein represents the non-zero pixel coordinate set of the mask .
[0070] The multiple instance prototypes of the same defect category are weighted aggregated. First, the average cosine similarity between the th instance prototype and other instance prototypes of the same category is calculated:
[0071]
[0072] wherein is the total number of reference images of this category, is the cosine similarity function.
[0073] The weight is calculated according to the similarity :
[0074]
[0075] wherein is the temperature coefficient, which is taken as 2 in this embodiment.
[0076] The category prototype feature vector of this defect category is aggregated:
[0077]
[0078] is stored in the defect feature library for subsequent matching.
[0079] Step S2: generating a semantic similarity response map.
[0080] The image to be tested is obtained, with a size of 1280x1280 pixels. It is input into the Dinov3 model to extract the feature map . The feature vector of each spatial position in is calculated with the cosine similarity with the category prototype constructed in step S1 to generate an initial semantic response map
[0081] Step S3: generating a segmentation hint.
[0082] The feature aggregation operation is performed on the initial response map :
[0083] The response map is smoothed by Gaussian kernel weighted average. For each position , the 3x3 neighborhood is calculated:
[0084]
[0085] where, is the Gaussian kernel function, is the kernel width parameter, taking the value of 0.1. This operation effectively suppresses isolated noise responses and enhances the connectivity of continuous defect regions.
[0086] The enhanced response map is concatenated with the learnable two-dimensional sinusoidal position encoding along the channel dimension, and after inputting a 3x3 convolutional layer followed by activation function, the spatial attention weight map is generated:
[0087]
[0088] The response map is weighted:
[0089]
[0090] to obtain the enhanced semantic response map .
[0091] The enhanced response map is upsampled to the original image resolution. Threshold segmentation (threshold value of 0.5) is applied to the upsampled response map to obtain a binary saliency map. Through connected component analysis, the salient regions are identified, and the minimum bounding rectangle of each connected component is calculated as the bounding box prompt input to the SAM model.
[0092] Step S4: Perform fine instance segmentation.
[0093] The bounding box prompt generated in step S3 is input into the SAM model (e.g., the second-generation SMA2 model under the SAM series model), and fine segmentation is performed on the candidate regions, outputting the binary mask of the defect instances.
[0094] Step S5: Confidence evaluation and result optimization.
[0095] The comprehensive confidence score is calculated for each segmentation result:
[0096] Semantic matching strength : The average value of the enhanced response map in the mask region is calculated Min-Max normalization is performed on all candidate regions in the current image:
[0097]
[0098] Texture consistency score : Compute mask Gray level variance in the original gray image , and convert to consistency score:
[0099]
[0100] where the attenuation coefficient is 0.1.
[0101] Shape regularity score : Compute mask Compactness of the contour:
[0102]
[0103] where is the area of the region, is the contour perimeter.
[0104] The three scores are weighted and summed to obtain the comprehensive confidence score:
[0105]
[0106] where the weight coefficients , , satisfy .
[0107] Dynamic threshold strategy is used to filter the results. The mean and standard deviation of all candidate regions in the current image are calculated, and the dynamic threshold is set as:
[0108]
[0109] where the sensitivity adjustment parameter is 1. If , the detection result is retained, otherwise it is considered as a low confidence result and is deleted.
[0110] Step S6: Data accumulation.
[0111] The high confidence detection results filtered out in step S5 are accumulated together with their original images to be tested, defect category labels, detection time stamps, and comprehensive confidence scores , and stored in a defect sample library to form a structured pre-labeled data set for subsequent training and optimization of a supervised learning model.
[0112] It should be noted that the present application proposes a few-sample industrial defect target detection method based on Dinov3 and SAM, which is applied to the initial stage of new product introduction, process change of production line or discovery of new defect type. When the number of defect samples is insufficient to train a conventional supervised learning model, it is used as a transitional detection scheme and for accumulating training data.
[0113] Therefore, the present application proposes a few-sample industrial defect target detection method based on Dinov3 and SAM, which has the following technical effects:
[0114] Solve the problem of initial sample scarcity: in the initial stage of the project when the number of defect samples is insufficient to train a conventional supervised model, only a small number of reference images are used to realize rapid deployment and effective detection, filling the quality monitoring blank period;
[0115] Efficient data accumulation: through automated detection and high-confidence result screening, high-quality and structured defect labeling data is continuously generated, significantly accelerating the construction process of the data set required for subsequent special model training;
[0116] Improve system robustness: through powerful feature extraction models and general segmentation base models, weighted feature aggregation, context enhancement and multi-dimensional confidence evaluation are added to effectively improve the detection accuracy and stability in complex industrial environments and reduce false positives and omissions.
[0117] Promote model iteration: not only provide few-sample detection capability, but more importantly, establish a solid data foundation for training a special supervised model with better performance, forming a virtuous cycle of data accumulation-model optimization.
[0118] Reference Figure 5 , Figure 5 The structure of the few-sample industrial defect target detection system based on Dinov3 and SAM of the embodiment of the present application is shown in the figure.
[0119] As Figure 5 shown, the few-sample industrial defect target detection system based on Dinov3 and SAM proposed by the embodiment of the present application comprises:
[0120] The construction module 10 is used to acquire reference images of different industrial defect categories, extract reference image features through a pre-trained Dinov3 model, aggregate the reference image features of each industrial defect category, generate a category prototype feature vector, and construct a defect reference feature library.
[0121] The enhancement module 20 is configured to extract features of the to-be-tested image by using the Dinov3 model, perform pixel-by-pixel similarity calculation on the features of the to-be-tested image and a category prototype feature vector in the defect reference feature library, generate an initial response map, and perform enhancement by using a neighborhood filtering algorithm to obtain an enhanced response map;
[0122] The generation module 30 is configured to introduce a spatial attention mechanism to filter a significant response region based on the enhanced response map, and generate a prompt bounding box or a prompt key point corresponding to the enhanced response map;
[0123] The segmentation module 40 is configured to input the prompt bounding box or the prompt key point into the SAM, and perform fine segmentation on the significant response region in the enhanced response map to output a defect instance mask.
[0124] The screening module 50 is configured to calculate a comprehensive confidence score of each segmentation result in combination with semantic matching strength, regional texture consistency and shape regularity, screen a high-confidence result by using a dynamic threshold, and output a final detection result.
[0125] Other embodiments or specific implementation manners of the few-shot industrial defect target detection system based on the Dinov3 and the SAM can refer to the above-mentioned method embodiments, and details are not described herein.
[0126] It can be understood that, in the description of the present specification, the description of the terms “one embodiment”, “another embodiment”, “other embodiments”, or “first embodiment to Nth embodiment” means that the specific features, structures, materials or characteristics described in combination with the embodiments or examples are included in at least one embodiment or example of the present application. In the present specification, the illustrative description of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0127] It should be noted that, in this paper, the terms “include”, “contain” or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or system including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or includes elements inherent to such process, method, article or system. Without more limitations, the element defined by the statement “including a …” does not exclude the presence of another identical element in the process, method, article or system including the element.
[0128] The above merely describes the preferred embodiments of the present application, and is not intended to limit the patent scope of the present application, and any equivalent structure or equivalent process conversion, or direct or indirect application in other related technical fields, which are made by using the content of the present application specification and drawings, are also included in the patent protection scope of the present application.
Claims
1. A method for detecting industrial defects using a small sample size based on Dinov3 and SAM, characterized in that, The method includes the following steps: S1: Obtain reference images for different industrial defect categories, extract features from the reference images using a pre-trained Dinov3 model, perform weighted aggregation of the reference image features for each industrial defect category, generate category prototype feature vectors, and construct a defect reference feature library. S2: Use the Dinov3 model to extract features from the image to be tested, calculate pixel-wise similarity between the features of the image to be tested and the category prototype feature vectors in the defect reference feature library, generate an initial response map, and use a neighborhood filtering algorithm to enhance it to obtain an enhanced response map. S3: Based on the enhanced response map, a spatial attention mechanism is introduced to filter significant response regions and generate prompt bounding boxes or prompt key points corresponding to the enhanced response map. S4: Input the cue bounding box or cue key points into SAM, perform fine segmentation on the significant response regions in the enhanced response map, and output the defect instance mask; S5: Combining semantic matching strength, regional texture consistency, and shape regularity, calculate the comprehensive confidence score of each segmentation result, use dynamic thresholds to filter high-confidence results, and output the final detection result; S6: Automatically store the high-confidence output results and their corresponding association information into the defect sample database to form a structured labeled dataset for subsequent model training; The associated information stored in the defect sample database includes: the original image to be tested, the mask of the detected defect instance, the defect category label, the detection timestamp, and the comprehensive confidence score.
2. The method for detecting industrial defects using a small sample size based on Dinov3 and SAM as described in claim 1, characterized in that, In step S1, when generating the category prototype feature vector by weighted aggregation of the reference image features for each industrial defect category, the weights used in the weighted aggregation are configured to be determined based on the average cosine similarity between each reference image feature and other reference image features of the same category. The expression for the weights used in the weighted aggregation is as follows: In the formula, For the first Weights of features in a reference image. The average cosine similarity between this feature and the other n-1 similar reference features. For temperature coefficient, The total number of reference images for this defect category; This is the aggregated category prototype feature vector. For the first Features of a reference image.
3. The method for detecting industrial defects using a small sample size based on Dinov3 and SAM as described in claim 1, characterized in that, In step S2, a neighborhood filtering algorithm is used for enhancement to obtain an enhanced response map. The configuration is as follows: the neighborhood filtering algorithm is used to calculate the similarity between the response values of each spatial location in the initial response map and its local neighborhood, and the original response is weighted and smoothed. The expression for the filtered enhanced response map is as follows: in, This is the initial response diagram. This is the enhanced response diagram after filtering. For coordinates A local window centered on the center. For Gaussian kernel function, This is the kernel width parameter.
4. The method for detecting industrial defects using a small sample size based on Dinov3 and SAM as described in claim 3, characterized in that, In step S3, when introducing a spatial attention mechanism for salient response region filtering, the expression for the attention weight map generated by the spatial attention mechanism is as follows: In the formula, For attention weights, To enhance the response map, For learnable location encoding, This indicates concatenation along the channel dimension. This represents a 3×3 convolution operation. The sigmoid activation function is used, and the significant response region is formed by... get, This indicates element-wise multiplication.
5. The method for detecting industrial defects using a small sample size based on Dinov3 and SAM as described in claim 1, characterized in that, In step S5, the comprehensive confidence score of each segmentation result is calculated by combining semantic matching strength, region texture consistency, and shape regularity. The specific expression is as follows: In the formula, To calculate the overall confidence score, The normalized semantic matching strength. This is a texture consistency score calculated based on local gray-level variance. For shape regularity scoring based on contour compactness, , , The weight coefficients are non-negative and satisfy the following conditions: .
6. The method for detecting industrial defects using a small sample size based on Dinov3 and SAM as described in claim 5, characterized in that, Normalized semantic matching strength Texture consistency score and shape regularity score The expression is as follows: In the formula, For mask Enhanced response map within the region The average value, The attenuation coefficient is... For mask Gray-level variance in the original gray-level image For the area, For the perimeter of the outline, The 1st step after performing fine-grained segmentation on the salient response region Candidate regions, For mask Enhanced response map within the region The Middle The average value of each candidate region.
7. The method for detecting industrial defects using a small sample size based on Dinov3 and SAM as described in claim 1, characterized in that, In step S5, the expression for the dynamic threshold is as follows: in, For dynamic thresholds, and These are the mean and standard deviation of the overall confidence scores for all candidate regions in the current image under test, respectively. These are the sensitivity adjustment parameters.
8. The method for detecting industrial defects using a small sample size based on Dinov3 and SAM as described in claim 1, characterized in that, A dynamic threshold is used to filter high-confidence results, and the final detection result is output, which is configured as: the overall confidence score of the segmentation result. Above the dynamic threshold If the result is positive, retain it; otherwise, delete it as a low-confidence result.
9. A few-sample industrial defect target detection system based on Dinov3 and SAM, characterized in that, The system includes: The module is used to acquire reference images for different industrial defect categories, extract reference image features through a pre-trained Dinov3 model, perform weighted aggregation of reference image features for each industrial defect category, generate category prototype feature vectors, and build a defect reference feature library. The enhancement module is used to extract features of the image under test using the Dinov3 model, calculate pixel-by-pixel similarity between the features of the image under test and the category prototype feature vectors in the defect reference feature library, generate an initial response map, and enhance it using a neighborhood filtering algorithm to obtain an enhanced response map. The generation module is used to introduce a spatial attention mechanism to filter significant response regions based on the enhanced response map and generate prompt bounding boxes or prompt key points corresponding to the enhanced response map. The segmentation module is used to input the cue bounding box or cue key points into SAM, perform fine segmentation on the significant response regions in the enhanced response map, and output defect instance masks; The filtering module is used to combine semantic matching strength, regional texture consistency and shape regularity to calculate the comprehensive confidence score of each segmentation result, use dynamic threshold to filter high confidence results, and output the final detection result; The storage module is used to automatically store the high-confidence output results and their corresponding related information into the defect sample database, forming a structured labeled dataset for subsequent model training; The associated information stored in the defect sample database includes: the original image to be tested, the mask of the detected defect instance, the defect category label, the detection timestamp, and the comprehensive confidence score.
Citation Information
Patent Citations
MicroLED direct display module appearance defect detection method
CN117830268A
Automatic defect labeling method and device, electronic equipment and readable storage medium
CN120198913A