A method, system, equipment, and medium for detecting surface defects in cable production with a small sample size.
By employing transfer learning and adaptive threshold segmentation techniques, and utilizing the ImageNet pre-trained ResNet50 model and K-Means algorithm to construct a positive sample feature library, the accuracy and adaptability issues of cable surface defect detection are resolved, achieving efficient and accurate defect identification.
Patent Information
- Application Number
- CN202411738759.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-11-14
- Estimated Expiration
- 2044-11-29
AI Technical Summary
Existing methods for detecting surface defects in cables suffer from low detection accuracy, poor adaptability, and insufficient real-time performance. They are particularly difficult to effectively identify minute defects and complex backgrounds, and existing algorithms are not adaptable to small sample datasets.
We employ transfer learning techniques to utilize a ResNet50 model pre-trained on the ImageNet dataset, add a channel-space attention module, construct a core feature library of positive samples using the K-Means algorithm, design an adaptive threshold segmentation module, and achieve defect detection through cosine distance metric and adaptive threshold processing.
It improves the accuracy and adaptability of cable surface defect detection, reduces the data volume requirement, has good generalization ability and real-time performance, reduces false detection rate, and is suitable for cable defect detection in different scenarios.
Smart Images

Figure CN119515866B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of cable quality inspection technology, specifically a method, system, equipment, and medium for detecting surface defects in a small sample of cable production. Background Technology
[0002] With the continuous improvement of industrial automation, the requirements for product quality in the cable manufacturing industry are also increasing. As an important carrier for power transmission and signal conduction, ensuring the surface quality of cables without defects is crucial during their production process. Traditional methods for detecting surface defects in cables mostly rely on manual visual inspection. This method is not only inefficient, but also prone to eye fatigue due to prolonged work, resulting in a high rate of missed detections.
[0003] In recent years, with the development of image processing technology and machine vision, automated cable surface defect detection systems have gradually become a research hotspot. These systems utilize high-speed cameras to capture images of cable surfaces and analyze them using computer software, enabling real-time detection of common defects such as bulges, dents, scratches, and pinholes. However, current technical solutions still have some shortcomings: traditional vision algorithms have low detection accuracy, and are prone to false positives or false negatives when dealing with subtle defects or defects in complex backgrounds; deep learning-based detection algorithms are slow, and with the increasing speed of cable production lines, higher demands are placed on the real-time performance of detection systems; furthermore, industrial scenarios are highly variable, and algorithm adaptability is also an important indicator: existing algorithms have poor adaptability, especially for specific scenarios and products, making it difficult to build large-scale datasets, which are insufficient to support the training needs of existing deep learning algorithms. Therefore, there is an urgent need in the field of cable defect detection for cable defect detection methods based on fewer samples. Summary of the Invention
[0004] To address the shortcomings of existing technologies, this invention provides a method, system, equipment, and medium for detecting surface defects in cable production with a small sample size, which improves the accuracy of cable identification and enables the identification of minute defects or defects in complex backgrounds.
[0005] To solve the aforementioned technical problem, the present invention adopts the following technical solution: a method for detecting surface defects in cable production with a small sample size, comprising the following steps:
[0006] S01. Load the ResNet50 model pre-trained on the ImageNet dataset and add a channel-space attention module to the ResNet50 model.
[0007] S02. Read normal cable sample images. After preprocessing, the normal cable sample images are input into the ResNet50 model in step S01. The ResNet50 model performs feature extraction, feature dimension transformation and feature filtering on the normal cable sample images to obtain the core feature library.
[0008] S03. Read the test cable defect image. The test cable defect image is preprocessed and input into the Resnet50 model in step S01. The Resnet50 model performs feature extraction and feature dimension transformation on the test cable defect image to obtain query feature vectors. All query feature vectors constitute the feature vector query library.
[0009] S04. Calculate the distance between all query feature vectors in the feature vector query library and the feature vectors in the core feature library. For a single query feature vector in the feature vector query library, calculate its distance with all feature vectors in the core feature library, take the minimum distance as the result, and traverse all query feature vectors to obtain the metric matrix.
[0010] S05. Reshape and interpolate the metric matrix to obtain the defect detection feature heatmap matrix;
[0011] S06. Input the defect detection feature heatmap matrix into the adaptive threshold segmentation module. The adaptive threshold segmentation module consists of three parts: fixed threshold, percentage truncation threshold, and adaptive threshold. The adaptive threshold segmentation module truncates the defect detection feature heatmap matrix, and the resulting matrix is named the threshold segmentation matrix. A convolution kernel is used to perform boundary detection on the threshold segmentation matrix, and the detection result is projected onto the original input image to obtain the final surface defect detection image.
[0012] Furthermore, the ResNet50 model performs feature extraction and feature dimension transformation on normal cable sample images and test cable defect images as follows:
[0013] S11 and ResNet50 models extract features from normal cable sample images and test cable defect images to obtain the second and third layer features of the ResNet50 model.
[0014] S12. Perform sliding window processing on the second and third layer features of each input image, stretching all features within the window into a one-dimensional vector;
[0015] S13. The two sets of feature tensors after sliding window processing are transformed by the permute operation, the dimensions are expanded by linear interpolation, the two sets of features are compressed by the adaptive pooling layer and then concatenated. The concatenated result is reduced in dimension by the adaptive pooling layer to obtain the feature representation of a single image sample.
[0016] S14. All input images are processed through S12 and S13 to obtain their respective feature representations. The feature representations of all input images are concatenated and reshaped to obtain a combination of the feature representations of the input images.
[0017] S15. The feature representations obtained in step S14 are combined and the tensor dimensions are adjusted through a Linear layer. The adjusted tensors constitute the sample feature library.
[0018] Furthermore, the K-Means algorithm is used to filter features from the positive sample feature library to obtain the core feature library.
[0019] Furthermore, the fixed threshold is 0.3.
[0020] Furthermore, percentage-based thresholding. The 90th percentile of all elements in the defect feature heatmap matrix, adaptive threshold. The value is taken as mean_value × 1.8, where mean_value is the mean of the defect feature heatmap matrix.
[0021] Percentage threshold Adaptive threshold The calculation process is as follows:
[0022] ,
[0023] Where M is the defect feature heatmap matrix, and the elements are... This represents the pixel value in the i-th row and j-th column of the matrix. To calculate the values of more than 90% of the elements in M, It is the value of the 90th percentile in M, and N is the number of all elements in M;
[0024] renew Pixel value:
[0025] ,
[0026] Represents the threshold segmentation matrix, elements express The pixel value in the i-th row and j-th column of the matrix.
[0027] Furthermore, in step S04, the cosine distance between all query feature vectors in the feature vector query library and the feature vectors in the core feature library is calculated.
[0028] This invention also discloses a surface defect detection system for cable production with few samples, including a data acquisition module, a feature extraction module, a positive sample core feature library construction module, a feature measurement module, and an adaptive threshold segmentation module;
[0029] The data acquisition module is used to acquire training set images and test set images;
[0030] The feature extraction module uses a ResNet50 model pre-trained on the ImageNet dataset, and adds a channel-space attention module to the ResNet50 model to extract features from the training set images and the test set images. It extracts the outputs of the second and third layers of the ResNet50 model as the extracted features, and performs dimensionality transformation and pooling on the output features.
[0031] The positive sample core feature library construction module uses the K-Means algorithm to cluster and filter the feature vectors obtained by the feature extraction module to obtain the core feature library, which is used as the metric support set in the inference stage.
[0032] The feature measurement module is used to calculate the distance between the feature vector of the test image and the vector in the core feature library during the inference stage. The larger the distance value, the greater the difference in direction between the two vectors, that is, the lower the similarity between the two vectors.
[0033] The adaptive threshold segmentation module performs thresholding on the metric matrix output by the feature measurement module. The processed result is then used for boundary detection via a convolution kernel. Finally, the detected boundaries are projected onto the initial input image to obtain the cable defect detection result.
[0034] A computer device includes a processor and a memory, the memory being used to store a computer-executable program, the processor reading the computer-executable program from the memory and executing it, and the processor executing the executable program performing the surface defect detection method for small sample cable production as described above.
[0035] A computer-readable storage medium storing a computer program, which, when executed by a processor, provides a method for detecting surface defects in the production of small-sample cables as described above.
[0036] The beneficial effects of this invention are as follows: This invention utilizes transfer learning technology to transfer the general feature extraction model ResNet50 trained on large datasets to the field of cable defect detection, providing better model initialization for cable defect detection, and integrates a channel-spatial attention mechanism to enhance the model's ability to focus on defect locations. This invention proposes a K-Means method for constructing a core feature set of positive samples in the field of cable defect detection, and designs a plug-and-play core feature library construction module with high portability, which can be quickly applied to other fields. This invention designs an adaptive threshold extraction module. Currently, most defect detection methods use fixed thresholds, which can only detect defects on specific datasets. When the data distribution changes, the original threshold defect detection effect is significantly reduced, requiring manual adjustment based on the data. The adaptive threshold extraction module proposed in this invention can automatically adjust the segmentation threshold according to the input data, exhibiting significantly better adaptability than existing solutions. Based on the above points, this invention proposes a novel framework for detecting surface defects in cables using few samples. It constructs a positive sample feature library using positive sample data as the support set, models the distribution pattern of the positive sample data, and uses defect images as the query set for measurement via cosine distance. The advantage of this framework lies in its flexibility with limited sample data. It does not impose any dimensional or quantity limitations on the input support set; that is, when there is only one positive sample image, the framework can still operate normally and maintain good segmentation results. When there are multiple positive sample images, it can construct a more accurate positive sample model and provide more accurate segmentation.
[0037] Compared to existing algorithms, this algorithm uses only defect-free positive samples during the training phase, eliminating the need for defective data and significantly reducing the data requirements. This addresses the cable defect detection needs in scenarios with limited samples. Furthermore, the post-processing stage utilizes an adaptive threshold truncation method to effectively reduce the false detection rate. Simultaneously, this algorithm demonstrates excellent generalization ability in visible light image-based defect detection, making it highly valuable for application across various scenarios. Attached Figure Description
[0038] Figure 1 This is a flowchart of the surface defect detection method for small sample cable production described in Example 1;
[0039] Figure 2 This is a diagram of the surface defect detection system for low-sample cable production described in Example 2.
[0040] Figure 3 A schematic diagram of the Channel-Spatial Attention (CBAM) module added to the Resnet50 network;
[0041] Figure 4 This is a diagram showing the effect of adaptive threshold segmentation.
[0042] Figure 5This is a diagram showing the results of dual-threshold segmentation.
[0043] Figure 6 This is a screenshot showing the segmentation effect with a fixed threshold.
[0044] Figure 7 This is a schematic diagram of cable surface defects detected by this method;
[0045] Figure 8 This is a schematic diagram providing an overview of the detection results. Detailed Implementation
[0046] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this disclosure. All other embodiments obtained by those skilled in the art based on the described embodiments of this disclosure without creative effort are within the scope of protection of this disclosure.
[0047] Example 1
[0048] This embodiment discloses a method for detecting surface defects in cable production using a limited sample size. The method first loads a ResNet50 model pre-trained on the ImageNet dataset, transferring the model's general feature extraction capabilities learned from large datasets to this method. This transfer learning provides a good model initialization for the cable defect detection algorithm. Then, a channel-spatial attention mechanism is introduced to enhance the model's ability to perceive cable surface defect features. Unsupervised learning is used to model the structure and distribution of positive sample features, constructing a positive sample feature library. During the algorithm inference stage, abnormal features are detected by comparing the differences between test image features and the positive sample library. The detected abnormal feature heatmap matrix is then input into an adaptive threshold truncation module to obtain the defect detection results. Figure 1 As shown, the specific steps include:
[0049] S01. Load the ResNet50 model pre-trained on the ImageNet dataset and add a channel-space attention module to the ResNet50 model. Figure 3 This is a schematic diagram of the Channel-Spatial Attention (CBAM) module added to the ResNet50 network. The ResNet50 model uses the Channel-Spatial Attention module as the backbone for feature extraction.
[0050] S02. Read the normal cable sample image. After preprocessing such as Resize and Normalize, the data dimension is 3×224×224. Input it into the Resnet50 model in step S01. The Resnet50 model extracts features from the normal cable sample image, and obtains the second-layer and third-layer features of the network through the Hook function. The dimension of the second-layer feature A is 1×512×28×28, and the dimension of the third-layer feature B is 1×1024×14×14.
[0051] Perform sliding window processing on the second-layer and third-layer features. The sliding window size of the second-layer feature group is 3×3×512. Slide the entire feature group in the 28×28 dimension, stretch all the features within the window into a one-dimensional vector, and transform the second-layer feature A of 1×512×28×28 into a tensor of 1×4608×784; for the third-layer feature group B, the sliding window size is 3×3×1024, and the output tensor dimension is 1×9216×196.
[0052] Perform dimension transformation on the output two groups of feature tensors through the permute operation, transform them into 4608×28×28 and 9216×14×14, and expand the dimension of B from 9216×14×14 to 9216×28×28 through the linear interpolation method. Then compress the two groups of features through the adaptive pooling layer and splice them to get 784×2×1024. Pass the splicing result through the adaptive pooling layer and reduce the dimension to the dimension of 784×1,024 to obtain the feature representation of a single image sample. After all input images go through the above operations respectively, splice and reshape all the obtained image feature vectors to get the feature representation combination of the input images. Assume that a total of N positive sample images are input, then the output is (N×784)×1024.
[0053] Construct the positive sample core feature library C. Pass the spliced and pooled and dimension-reduced features through the Linear layer to get a tensor of (N×784)×128, and name this tensor the positive sample feature library S. Use the K-Means algorithm to perform feature screening on the positive sample feature library to obtain the core feature library ((M×784)×128, M << N). The K-Means operation can reduce the number of features while enhancing the difference between features, and screen out better features to represent the model of positive sample data.
[0054] S03. Read the test cable defect image. The test cable defect image is preprocessed and input into the Resnet50 model in step S01. The Resnet50 model performs the same feature extraction and feature dimension transformation on the test cable defect image as in step S02 to obtain the query feature vector. All query feature vectors form the feature vector query library; for a test image, the dimension of its feature vector query library is 784*1024.
[0055] S04. Calculate the cosine distance between all query feature vectors in the feature vector query library and the feature vectors in the core feature library to measure the difference between the query feature and the positive sample feature. For a single query feature vector in the feature vector query library, calculate its distance with all feature vectors in the core feature library, take the minimum distance as the result, and traverse all query feature vectors to obtain the metric matrix, which has a dimension of 1×784.
[0056] S05. Reshape the metric matrix into a 28×28 matrix, where each element corresponds to an image patch at the corresponding position of the initial input data; perform interpolation transformation on the reshaped metric matrix to obtain a 224×224 Mask matrix, which is the defect feature heatmap matrix.
[0057] S06. Input the defect detection feature heatmap matrix into the adaptive threshold segmentation module. The adaptive threshold segmentation module consists of three parts: fixed threshold, percentage truncation threshold, and adaptive threshold. The adaptive threshold segmentation module truncates the defect detection feature heatmap matrix, and the resulting matrix is named the threshold segmentation matrix. A convolution kernel is used to perform boundary detection on the threshold segmentation matrix, and the detection result is projected onto the original input image to obtain the final surface defect detection image.
[0058] In this embodiment, the fixed threshold is 0.3.
[0059] Percentage threshold The 90th percentile of all elements in the defect feature heatmap matrix, adaptive threshold. The value is taken as mean_value × 1.8, where mean_value is the mean of the defect feature heatmap matrix.
[0060] Percentage threshold Adaptive threshold The calculation process is as follows:
[0061] ,
[0062] Where M is the defect feature heatmap matrix, and the elements are... This represents the pixel value in the i-th row and j-th column of the matrix. To calculate the values of more than 90% of the elements in M, It is the value of the 90th percentile in M, and N is the number of all elements in M;
[0063] renew Pixel value:
[0064] ,
[0065] Represents the threshold segmentation matrix, elements express The pixel value in the i-th row and j-th column of the matrix.
[0066] The matrix obtained from the truncation result Named the threshold segmentation matrix, a convolutional kernel (Cov_kernel) is used to perform boundary detection on this matrix. The convolutional kernel (Cov_kernel) for boundary detection of the threshold segmentation matrix is:
[0067] .
[0068] This embodiment implements the method proposed in this paper, and performs defect detection on cable images collected from actual factories. In the cable dataset used, all 42 defective images are used as the test set. By cropping the defective images and stretching the non-defective parts, 60 positive sample images are generated. 30 of these images are used as the support set for training, and 30 are used as the test set.
[0069] With hyperparameters set to resize=240 and imagesize=224, the test results are as follows: 0% false positive rate for normal images and 100% detection rate for defective images. 69 defects were detected, with all 62 defects detected, resulting in a recall rate of 100% and a precision of approximately 89.86%.
[0070] In this embodiment, the present invention compares different threshold segmentation methods. Figure 4 This is a diagram showing the effect of adaptive threshold segmentation described in this method. Figure 5 This is a screenshot showing the segmentation results using two thresholds (fixed threshold and percentile truncation threshold). Figure 6 This is a comparison of the segmentation results with a fixed threshold. Figure 4 , Figure 5 and Figure 6 The proposed adaptive threshold segmentation method was found to be the most effective.
[0071] For the final implementation results, please refer to Figure 7 This method can identify defect-free images (such as...) Figure 7 (a) shown), pit defect image (e.g. Figure 7 (b) shown), bulge defect image (e.g. Figure 7 (c) shown), scratch defect image (e.g. Figure 7 (d) and images of trachoma defects (e.g.) Figure 7 (e) is shown), and an overview of the detection results is given (as shown in the figure). Figure 8 (As shown).
[0072] Example 2
[0073] This embodiment discloses a surface defect detection system for cable production with a small sample size, such as... Figure 2 As shown, it includes a data acquisition module, a feature extraction module, a positive sample core feature library construction module, a feature measurement module, and an adaptive threshold segmentation module.
[0074] The data acquisition module is used to acquire training set images and test set images (also known as support set and query set in the few-shot domain).
[0075] The feature extraction module uses a ResNet50 model pre-trained on the ImageNet dataset, such as... Figure 3 As shown, a channel-space attention module is added as the backbone of the ResNet50 model to extract features. This network is used to extract features from the training set images and the test set images. The outputs of the second and third layers of the ResNet50 model are extracted as features, and the output features are subjected to dimensionality transformation and pooling.
[0076] The positive sample core feature library construction module uses the K-Means algorithm to cluster and filter the feature vectors obtained by the feature extraction module to obtain the core feature library, which is used as the metric support set in the inference stage.
[0077] The feature measurement module is used to calculate the distance between the feature vector of the test image and the vector in the core feature library during the inference phase. The measurement method is cosine distance. The larger the distance value, the greater the difference in direction between the two vectors, that is, the lower the similarity between the two vectors.
[0078] The adaptive threshold segmentation module is used to perform threshold processing on the metric matrix output by the feature measurement module. The processing result is then used for boundary detection through a convolution kernel, and the detected boundary is projected onto the initial input image to obtain the cable defect detection result.
[0079] Example 3
[0080] This embodiment discloses a computer device, including a processor and a memory. The memory is used to store computer executable programs. The processor reads the computer executable programs from the memory and executes them. When the processor executes the executable programs, it performs the surface defect detection method for small sample cable production as described in Embodiment 1.
[0081] Example 4
[0082] A computer-readable storage medium storing a computer program, which, when executed by a processor, enables the adaptive threshold method for detecting surface defects in cable production using a small sample size as described in Example 1.
[0083] The contents not described in detail in this specification are common knowledge to those skilled in the art.
[0084] The above are embodiments of this application. The above embodiments and specific parameters are only for clearly illustrating the verification process of the application and are not intended to limit the scope of patent protection of this application. The scope of patent protection of this application shall still be determined by its claims. Similarly, any equivalent structural changes made based on the description and drawings of this application shall also be included within the scope of protection of this application.
Claims
1. A method for detecting surface defects in cable production with a small sample size, characterized in that: Includes the following steps: S01. Load the ResNet50 model pre-trained on the ImageNet dataset and add a channel-space attention module to the ResNet50 model. S02. Read normal cable sample images. After preprocessing, the normal cable sample images are input into the ResNet50 model in step S01. The ResNet50 model performs feature extraction, feature dimension transformation and feature filtering on the normal cable sample images to obtain the core feature library. S03. Read the test cable defect image. The test cable defect image is preprocessed and input into the Resnet50 model in step S01. The Resnet50 model performs feature extraction and feature dimension transformation on the test cable defect image to obtain query feature vectors. All query feature vectors constitute the feature vector query library. S04. Calculate the distance between all query feature vectors in the feature vector query library and the feature vectors in the core feature library. For a single query feature vector in the feature vector query library, calculate its distance with all feature vectors in the core feature library, take the minimum distance as the result, and traverse all query feature vectors to obtain the metric matrix. S05. Reshape and interpolate the metric matrix to obtain the defect detection feature heatmap matrix; S06. Input the defect detection feature heatmap matrix into the adaptive threshold segmentation module. The adaptive threshold segmentation module consists of three parts: fixed threshold, percentage truncation threshold, and adaptive threshold. The adaptive threshold segmentation module truncates the defect detection feature heatmap matrix, and the resulting matrix is named the threshold segmentation matrix. A convolutional kernel is used to perform boundary detection on the threshold segmentation matrix, and the detection result is projected onto the original input image to obtain the final surface defect detection image; percentage truncation threshold. The 90th percentile of all elements in the defect feature heatmap matrix, adaptive threshold. The value is taken as mean_value × 1.8, where mean_value is the mean of the defect feature heatmap matrix. Percentage cutoff threshold Adaptive threshold The calculation process is as follows: , Where M is the defect feature heatmap matrix, and the elements are... This represents the pixel value in the i-th row and j-th column of the matrix. To calculate the values of more than 90% of the elements in M, It is the value of the 90th percentile in M, and N is the number of all elements in M; renew Pixel value: , Represents the threshold segmentation matrix, elements express The pixel value in the i-th row and j-th column of the matrix.
2. The method for detecting surface defects in cable production with a small sample size according to claim 1, characterized in that: The process of feature extraction and feature dimension transformation of normal cable sample images and test cable defect images by the ResNet50 model is as follows: S11 and ResNet50 models extract features from normal cable sample images and test cable defect images to obtain the second and third layer features of the ResNet50 model. S12. Perform sliding window processing on the second and third layer features of each input image, stretching all features within the window into a one-dimensional vector; S13. The two sets of feature tensors after sliding window processing are transformed by the permute operation, the dimensions are expanded by linear interpolation, the two sets of features are compressed by the adaptive pooling layer and then concatenated. The concatenated result is reduced in dimension by the adaptive pooling layer to obtain the feature representation of a single image sample. S14. All input images are processed through S12 and S13 to obtain their respective feature representations. The feature representations of all input images are concatenated and reshaped to obtain a combination of the feature representations of the input images. S15. Combine all the image feature representations obtained in step S14 and adjust the tensor dimension through a Linear layer. The adjusted tensors constitute the sample feature library.
3. The method for detecting surface defects in cable production with a small sample size according to claim 2, characterized in that: The K-Means algorithm is used to filter features from the positive sample feature library to obtain the core feature library.
4. The method for detecting surface defects in cable production with a small sample size according to claim 1, characterized in that: The fixed threshold is 0.
3.
5. The method for detecting surface defects in cable production with a small sample size according to claim 1, characterized in that: The Cov_kernel used for boundary detection of the threshold segmentation matrix is: 。 6. The method for detecting surface defects in cable production with a small sample size according to claim 1, characterized in that: In step S04, the cosine distance between all query feature vectors in the feature vector query library and the feature vectors in the core feature library is calculated.
7. A surface defect detection system for cable production with a small sample size, characterized in that: It includes a data acquisition module, a feature extraction module, a positive sample core feature library construction module, a feature measurement module, and an adaptive threshold segmentation module; The data acquisition module is used to acquire training set images and test set images; The feature extraction module uses a ResNet50 model pre-trained on the ImageNet dataset, and adds a channel-space attention module to the ResNet50 model to extract features from the training set images and the test set images. It extracts the outputs of the second and third layers of the ResNet50 model as the extracted features, and performs dimensionality transformation and pooling on the output features. The positive sample core feature library construction module uses the K-Means algorithm to cluster and filter the feature vectors obtained by the feature extraction module to obtain the core feature library, which is used as the metric support set in the inference stage. The feature measurement module is used to calculate the distance between the feature vector of the test image and the vector in the core feature library during the inference stage. The larger the distance value, the greater the difference in direction between the two vectors, that is, the lower the similarity between the two vectors. The adaptive threshold segmentation module is used to perform threshold processing on the metric matrix output by the feature measurement module. The processing result is used for boundary detection through a convolution kernel, and the detected boundary is projected onto the initial input image to obtain the cable defect detection result. The adaptive threshold segmentation module consists of three parts: a fixed threshold, a percentage-based truncation threshold, and an adaptive threshold. The percentage-based truncation threshold... The 90th percentile of all elements in the defect feature heatmap matrix, adaptive threshold. The value is taken as mean_value × 1.8, where mean_value is the mean of the defect feature heatmap matrix. Percentage cutoff threshold Adaptive threshold The calculation process is as follows: , Where M is the defect feature heatmap matrix, and the elements are... This represents the pixel value in the i-th row and j-th column of the matrix. To calculate the values of more than 90% of the elements in M, It is the value of the 90th percentile in M, and N is the number of all elements in M; renew Pixel value: , Represents the threshold segmentation matrix, elements express The pixel value in the i-th row and j-th column of the matrix.
8. A computer device, comprising a processor and a memory, the memory for storing a computer-executable program, the processor reading the computer-executable program from the memory and executing it, the processor executing the method for detecting surface defects in the production of a few-sample cable as described in any one of claims 1-6 when executing the computer-executable program.
9. A computer-readable storage medium storing a computer program, which, when executed by a processor, performs the method for detecting surface defects in the production of a few-sample cable according to any one of claims 1-6.
Citation Information
Patent Citations
Surface defect detection method based on positive case training
CN108961217A
Unsupervised defect detection method based on deep learning feature correlation
CN114862772A