An abnormality detection method, device and equipment of strain clamp and storage medium
By using an unsupervised training method to optimize the tension clamp image using the feature vectors in the memory matrix, the problem of high dataset requirements in existing technologies is solved, and efficient anomaly detection of tension clamps is achieved.
Patent Information
- Application Number
- CN202511375321.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-25
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2045-09-25
AI Technical Summary
Existing technologies for tension clamp detection have high requirements for datasets. Typically, a complete dataset with sufficient samples is needed to train a high-quality model, but in practice, it is difficult to obtain a large number of defect samples for training.
The reconstructed image is optimized by utilizing the feature vectors of non-abnormal clamps in the memory matrix. An unsupervised training method is adopted to avoid dependence on abnormal samples. The image is reconstructed and optimized using the preset encoder and preset teacher-student model in the preset anomaly detection model.
This technology improves the availability and accuracy of anomaly detection in tension clamps without requiring model training using anomalous samples, and reduces the workload of manual annotation.
Smart Images

Figure CN120876471B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of intelligent detection, and in particular to a tension clamp abnormality detection method, device, equipment and storage medium. BACKGROUND
[0002] Aluminum or iron metal accessories are widely used in power transmission lines of different voltage levels. Due to the large pressure borne by the metal accessories during the operation of the power transmission line, if the key components such as tension clamps are not operated in a standard manner during the production process, internal defects may be generated, and these defects are usually difficult to detect. Under the influence of external factors such as diurnal temperature difference and wind load, these defects may cause cracks to form, and even cause the tension clamp to fail or break, thereby causing large-area power outages and transmission interruptions and other faults.
[0003] At present, the detection method for the tension clamp usually adopts a supervised learning strategy to train an intelligent model, and uses the trained model to detect the tension clamp, but this method has a high requirement for the data set, and usually requires a complete and sufficient data set to train a high-quality model, and in actual situations, it is usually difficult to obtain a large number of defect samples to train the model. SUMMARY
[0004] Therefore, the purpose of the present application is to provide a tension clamp abnormality detection method, device, equipment and storage medium, which can optimize the reconstructed image by using the feature vectors of the non-abnormal tension clamp in the memory matrix, so that the present application does not need to train the model using abnormal samples, thereby ensuring the usability of the scheme. The specific scheme is as follows:
[0005] In a first aspect, the present application provides a tension clamp abnormality detection method, comprising:
[0006] obtaining an initial DR image corresponding to a tension clamp to be detected, and performing noise reduction processing on the initial DR image to obtain a target image corresponding to the initial DR image;
[0007] reconstructing the target image using a preset encoder and a preset teacher-student model in a preset abnormality detection model to obtain a corresponding reconstructed image;
[0008] optimizing the reconstructed image based on a first feature vector in the preset abnormality detection model to obtain a corresponding optimized image; wherein the first feature vector is a feature vector corresponding to each region in an image corresponding to a non-abnormal tension clamp sample, and the first feature vector is stored in a memory matrix in the preset abnormality detection model;
[0009] determine whether the image difference between the optimized image and the target image is less than a preset difference threshold, and perform abnormality detection on the to-be-detected strain clamp based on a corresponding determination result; wherein the preset abnormality detection model is a model obtained by unsupervised training using a preset training set, and the preset training set is a training set constructed using an abnormality-free strain clamp sample.
[0010] Optionally, before the initial DR image corresponding to the to-be-detected strain clamp is acquired, the method further includes:
[0011] An initial detection model is acquired, and a weight decay coefficient, a target learning rate, and a model iteration number corresponding to the initial detection model are determined.
[0012] The initial detection model is iteratively trained based on a preset optimizer, the weight decay coefficient, the target learning rate, and the model iteration number to obtain the abnormality detection model corresponding to the initial detection model.
[0013] Optionally, the denoising processing of the initial DR image includes:
[0014] The contrast of the initial DR image is enhanced using an adaptive histogram equalization technique to obtain a corresponding enhanced DR image.
[0015] The picture texture corresponding to the enhanced DR image is sharpened using a Laplace transform, and the background noise of the enhanced DR image is deleted.
[0016] Optionally, the reconstruction of the target image using a preset encoder and a preset teacher-student model in the preset abnormality detection model includes:
[0017] The target image is down-sampled using the preset encoder to obtain a corresponding down-sampled image, and image features corresponding to the down-sampling process are extracted.
[0018] The down-sampled image is up-sampled using the image features, a preset teacher model, and a preset student model to obtain a reconstructed image corresponding to the target image.
[0019] Optionally, the optimization of the reconstructed image based on a first feature vector in the preset abnormality detection model includes:
[0020] The reconstructed image is segmented to obtain image blocks corresponding to the reconstructed image, and second feature vectors corresponding to the image blocks, respectively, are obtained.
[0021] The attention mechanism is used to calculate the cosine similarity between each second feature vector and each first feature vector to obtain the attention weights corresponding to each second feature vector.
[0022] Based on the attention weights, target feature vectors corresponding to the second feature vectors are obtained respectively, and the reconstructed image is optimized using the target feature vectors.
[0023] Optionally, determining whether the image difference between the optimized image and the reconstructed image is less than a preset difference threshold, and performing anomaly detection on the tension clamp to be detected based on the corresponding determination result, includes:
[0024] If the image difference between the optimized image and the reconstructed image is not less than a preset difference threshold, the tension clamp to be detected is determined to be an abnormal tension clamp.
[0025] If the image difference between the optimized image and the reconstructed image is less than the preset difference threshold, the tension clamp to be detected is determined to be a tension clamp without abnormalities.
[0026] Secondly, this application provides a tension clamp abnormality detection device, comprising:
[0027] The image denoising module is used to acquire the initial DR image corresponding to the tension clamp to be detected, and to perform denoising processing on the initial DR image to obtain the target image corresponding to the initial DR image;
[0028] The image reconstruction module is used to reconstruct the target image using a preset encoder and a preset teacher-student model in a preset anomaly detection model, so as to obtain the corresponding reconstructed image.
[0029] The image optimization module is used to optimize the reconstructed image based on the first feature vector in the preset anomaly detection model to obtain the corresponding optimized image; wherein, the first feature vector is the feature vector corresponding to each region in the image corresponding to the sample without anomalies in the tension clamp, and the first feature vector is stored in the memory matrix in the preset anomaly detection model.
[0030] An anomaly detection module is used to determine whether the image difference between the optimized image and the target image is less than a preset difference threshold, and to perform anomaly detection on the tension clamp to be detected based on the corresponding judgment result; wherein, the preset anomaly detection model is a model obtained by unsupervised training using a preset training set, and the preset training set is a training set constructed using samples of tension clamps without anomalies.
[0031] Thirdly, this application provides an electronic device, comprising:
[0032] Memory, used to store computer programs;
[0033] A processor is used to execute the computer program to implement the aforementioned method for detecting abnormal tension clamps.
[0034] Fourthly, this application provides a computer-readable storage medium for storing a computer program, which, when executed by a processor, implements the aforementioned method for detecting abnormal tension clamps.
[0035] This application first obtains an initial DR image corresponding to the tension clamp to be detected, and performs noise reduction processing on the initial DR image to obtain a target image corresponding to the initial DR image. Then, it reconstructs the target image using a preset encoder and a preset teacher-student model in a preset anomaly detection model to obtain a corresponding reconstructed image. Afterward, it optimizes the reconstructed image based on the first feature vector in the preset anomaly detection model to obtain a corresponding optimized image. The first feature vector is the feature vector corresponding to each region in the image corresponding to the tension clamp sample without anomalies, and the first feature vector is stored in the memory matrix in the preset anomaly detection model. Finally, it determines whether the image difference between the optimized image and the target image is less than a preset difference threshold, and performs anomaly detection on the tension clamp to be detected based on the corresponding judgment result. The preset anomaly detection model is a model obtained by unsupervised training using a preset training set, and the preset training set is a training set constructed using tension clamp samples without anomalies. Therefore, this application uses a training set constructed with samples of tension clamps without abnormalities to perform unsupervised training on the anomaly detection model, avoiding the need for manual annotation of the data in the training set and reducing manual workload. Since the memory matrix only stores the feature vectors corresponding to the samples of tension clamps without abnormalities in the training dataset, there is a difference between the optimized reconstructed image corresponding to the tension clamps with abnormalities and the input image after optimizing the image using the feature vectors. Therefore, by using the feature vectors in the memory matrix to optimize the reconstructed image during the testing process, the difference between the optimized reconstructed image of the tension clamps with abnormalities and the input image can be increased, so that this application does not need to use abnormal samples to train the model, ensuring the usability of the solution. Attached Figure Description
[0036] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0037] Figure 1This is a flowchart of a method for detecting abnormalities in tension clamps disclosed in this application;
[0038] Figure 2 This is a schematic diagram of the framework structure of an anomaly detection model disclosed in this application;
[0039] Figure 3 This is a schematic diagram of an image denoising method disclosed in this application;
[0040] Figure 4 This is a schematic diagram of a codec architecture disclosed in this application;
[0041] Figure 5 This is a schematic diagram of a memory matrix structure disclosed in this application;
[0042] Figure 6 This is a schematic diagram of the structure of a tension clamp abnormality detection device disclosed in this application;
[0043] Figure 7 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation
[0044] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0045] Currently, methods for detecting tension clamps require sophisticated datasets, typically necessitating comprehensive and sufficiently large datasets to train high-quality models for identifying anomalies. However, obtaining a large number of defective samples for model training is often difficult in practice. Therefore, this application provides a method for detecting anomalies in tension clamps. By utilizing the feature vectors of clamps without anomalies from the memory matrix to optimize the reconstructed image, this method eliminates the need for training the model with anomaly samples, thus ensuring the usability of the solution.
[0046] See Figure 1 As shown, this embodiment of the invention discloses a method for detecting abnormalities in tension clamps, including:
[0047] Step S11: Obtain the initial DR image corresponding to the tension clamp to be detected, and perform noise reduction processing on the initial DR image to obtain the target image corresponding to the initial DR image.
[0048] The tension clamp anomaly detection algorithm in this embodiment is an algorithm that matches the framework of unsupervised anomaly detection algorithms. Figure 2EMFR-AD (Unsupervised Anomaly Detection Based on Efficient Memory Feature Reconstruction) is an unsupervised anomaly detection algorithm framework that integrates the features of the autoencoder structure AE (AutoEncoder) and the knowledge distillation paradigm. Without considering back-updates, it can be roughly divided into five modules: a dataset preprocessing module that integrates histogram adaptive equalization and Laplace transform AHELt (Adaptive Histogram Equalization and Laplace transform); the encoder E; and a regularizer (teacher model). Generator (Student Model) ), Discriminator D.
[0049] In this embodiment, before acquiring the initial DR (Digital Radiography) image corresponding to the tension clamp to be detected, the method further includes: acquiring an initial detection model and determining the weight decay coefficient, target learning rate, and model iteration count corresponding to the initial detection model; iteratively training the initial detection model based on a preset optimizer, weight decay coefficient, target learning rate, and model iteration count to obtain the anomaly detection model corresponding to the initial detection model; specifically, the model training uses the Adam optimizer (preset optimizer) for gradient calculation and parameter updates, the data batch size is set to 16, and the weight decay (weight decay coefficient) is set to 1e-5. The MVTec AD (an anomaly detection dataset) dataset is iterated for 600 rounds, and the initial learning rate is decayed from 1e-4 to 1e-5 (target learning rate) using a cosine annealing algorithm. The self-made tension clamp dataset is iterated for 300 rounds (model iteration count), and a node decay strategy is used, that is, every 100 rounds, the learning rate decreases to 1 / 5 of the current value. If a teacher model is used as a regularizer, bias is not used during training. To make the experimental results more comparable, the loss weights are as follows: =0.01、 =10、 =0.001、 = 0.005、 =0.005. After the model training is completed, the discriminator's detection performance on tension clamp DR images is as follows: Figure 3 As shown.
[0050] During training, the loss function values and gradient data generated by the discriminator are only used to update the student model. The teacher and student models, along with the discriminator, iteratively calibrate the data until the loss function converges to equilibrium. The trained intelligent model can accurately identify outliers in the test dataset; the discriminator is built with a lighter style, and images are distinguished at full resolution rather than patched.
[0051] Understandably, the DR image of the tension clamp is a grayscale image, so a single-channel image enhancement algorithm is considered, namely, a fusion of histogram adaptive equalization and Laplacian algorithm, AHELt. Histogram adaptive equalization can enhance the local details of the tension clamp DR image, while the Laplacian algorithm can reduce the influence of the background, thereby highlighting the features of the foreground tension clamp.
[0052] Accordingly, the noise reduction process for the initial DR image in this embodiment may specifically include: enhancing the contrast of the initial DR image using adaptive histogram equalization technology to obtain the corresponding enhanced DR image; sharpening the image texture corresponding to the enhanced DR image using Laplacian transform; and deleting the background noise of the enhanced DR image.
[0053] Specifically, AHELt extracts features from the cropped dataset to increase the data's adaptability to unsupervised models. For example... Figure 3 As shown, in the AHELt algorithm, histogram adaptive equalization is used to enhance the local feature details of the tension clamp and weaken the influence of the large background. In the histogram adaptive equalization algorithm, the image is divided into several non-overlapping 16×16 blocks, and then the histogram values are calculated for each block. The specific formula is as follows:
[0054] ;
[0055] in, It is the cumulative distribution function of each small block. L represents the probability of the j-th gray level appearing, and L is the number of gray levels.
[0056] ;
[0057] in, It is the target pixel value. These are the original pixel values.
[0058] The Laplacian transform can further sharpen texture and shape details, and filter out unnecessary background interference. The specific formula is as follows:
[0059] ;
[0060] in, is the pixel value after Laplace transform, and (x, y) are the coordinates of the pixel point to be transformed.
[0061] Understandably, the collected DR samples are too diverse, which is not conducive to establishing a normal sample space in unsupervised strategies. After processing with the AHELt algorithm, the background and target features of the tension clamp DR samples are more suitable for anomaly identification using the EMFR-AD algorithm. This algorithm is optimized for tension clamp DR images, adaptively extracting foreground (i.e., internal details of the tension clamp) features and effectively suppressing the influence of background features. Compared with other existing DR image enhancement algorithms, this algorithm significantly improves the adaptability between the tension clamp DR image dataset and the unsupervised model, thereby improving the detection accuracy of the intelligent model in anomaly detection tasks.
[0062] Step S12: Reconstruct the target image using the preset encoder and preset teacher-student model in the preset anomaly detection model to obtain the corresponding reconstructed image.
[0063] In this embodiment, the intelligent recognition algorithm framework consists of an encoder, a decoder (student model and teacher model), and a discriminator. For example... Figure 4 As shown, all network architectures are built using ordinary convolutional layers, regularization layers, and ReLU (Rectified Linear Unit, a type of activation function) activation layers. Given an input image, it is first divided into non-overlapping blocks, and then the encoder extracts patch features. In the decoder part, the student model and the teacher model are constructed exactly the same, the only difference being that an additional efficient up-convolutional module and a memory matrix module are placed in the student model.
[0064] In this embodiment, after the dataset is processed by the AHELt algorithm, it is fed into the encoder module within an unsupervised intelligent algorithm framework. Before the encoder performs feature encoding (i.e., downsampling the target image), the input image is decomposed into N×N non-overlapping matrix blocks. It should be noted that in the AE and knowledge distillation architecture, the encoder and generator can be constructed from arbitrary skeletons; here, downsampling based on max pooling and upsampling based on bilinear interpolation are chosen as the main framework.
[0065] The downsampling stage in the encoder consists of max-pooling layers, while other feature extraction layers are repeated stacks of 3×3 convolutional layers, regularization layers, and ReLU activation layers. The upsampling stage in the decoder consists of… Figure 2The suggested method uses bilinear convolutional interpolation or efficient upconvolution. Other feature extraction layers consist of repeated stacks of 3×3 convolutional layers, regularization layers, and ReLU activation layers. The decoder's first upsampling is achieved using bilinear convolutional interpolation, while the second and third upsampling are implemented using efficient upconvolutional modules. The efficient upconvolution consists of an upsampling layer (doubling the resolution), a 3×3 convolutional layer, a regularization layer, a ReLU activation layer, channel shuffling, and a 1×1 convolutional layer.
[0066] In this embodiment, the process of reconstructing the target image using the preset encoder and preset teacher-student model in the preset anomaly detection model can specifically include: downsampling the target image using the preset encoder to obtain the corresponding downsampled image, and extracting the image features corresponding to the downsampling process; upsampling the downsampled image using the image features, the preset teacher model, and the preset student model to obtain the reconstructed image corresponding to the target image. Specifically, based on the knowledge distillation paradigm, two paths, teacher and student, are introduced to complete image reconstruction. The teacher model only acts as a regularizer, assisting the student model in completing image reconstruction through a loss function, so it consists of the simplest upsampling module. The information coupling between the teacher and student models occurs after the corresponding upsampling operation. The student model, based on the teacher model, introduces an efficient upconvolution module and a memory matrix. The efficient upconvolution first increases the resolution of the feature map corresponding to the downsampling process by 2 times, and then uses a classic 3×3 convolution module to extract features. The extracted features are then subjected to channel shuffling to break the grouping structure between channels, allowing channels from different groups to interact with each other; finally, a 1×1 convolution layer is used to adjust the number of channels in the feature map.
[0067] This embodiment considers five loss functions jointly updating the EMFR-AD algorithm. The difference between the reconstructed image of the teacher-student model and the input image I is optimized using MSE (Mean Squared Error), and the corresponding loss function is defined as:
[0068] ;
[0069] ;
[0070] Following the feature information exchange method in the knowledge distillation paradigm, and using the feature map of the intermediate layer l of the teacher-student model for loss calculation, the distance loss here is defined as:
[0071] ;
[0072] Where F is the feature map, t is the teacher model, s is the student model, and i is the current intermediate layer. This indicates that the distance loss of all intermediate layers is summed.
[0073] If we use a generative loss similar to that in f-AnoGAN (an anomaly detection algorithm based on generative adversarial networks) to optimize the quality of the student model's reconstructed images, the formula would be:
[0074] ;
[0075] Where I is the input image (i.e., the target image mentioned above), and E is the output feature layer of the encoder.
[0076] The discriminator is required to maximize the average value between the features of the input image and the reconstructed image, and its formula is defined as:
[0077] ;
[0078] Finally, the loss function of the EMFR-AD algorithm includes inference loss and discrimination loss:
[0079] ;
[0080] The EMFR-AD algorithm in this embodiment is based on the knowledge distillation paradigm and employs a simple encoder and decoder (i.e., teacher-student model) structure, exhibiting high adjustability. A more suitable base model can be flexibly selected according to the different needs of the detection object. Compared with existing unsupervised anomaly detection algorithms for tension clamp DR images, this algorithm has a smaller model size and higher detection accuracy, improving the efficiency and accuracy of anomaly detection.
[0081] Step S13: Optimize the reconstructed image based on the first feature vector in the preset anomaly detection model to obtain the corresponding optimized image; wherein, the first feature vector is the feature vector corresponding to each region in the image of the sample without anomalies in the tension clamp, and the first feature vector is stored in the memory matrix in the preset anomaly detection model.
[0082] In this embodiment, the process of optimizing the reconstructed image based on the first feature vector in the preset anomaly detection model may specifically include: segmenting the reconstructed image to obtain each image patch corresponding to the reconstructed image, and obtaining the second feature vector corresponding to each image patch; calculating the cosine similarity between each second feature vector and each first feature vector using an attention mechanism to obtain the attention weight corresponding to each second feature vector; obtaining the target feature vector corresponding to each second feature vector based on each attention weight, and optimizing the reconstructed image using each target feature vector. It can be understood that the memory matrix stores normal sample information (i.e., feature vectors corresponding to each region in the image corresponding to the sample without abnormal tension clamps) based on the memory sequence during training, and uses these "normal features" to improve the quality of the reconstructed image during the decoding stage.
[0083] Understandably, since only normal samples were fed during training, the parameters in the model's neurons were fitted based on the features of these normal samples, including the feature vectors stored in the memory matrix. Therefore, when abnormal samples are input, the reconstructed samples will differ significantly from the input abnormal samples, resulting in a large abnormal score.
[0084] For example, during training, the encoded feature vectors of the non-abnormal tension clamp samples in the training set are stored in a memory matrix, the memory matrix being of size [missing information]. The storage structure, in which The total number of memory items. Consistent with the encoded feature dimensions, each memory item This represents a normal sample feature prototype; in the image recognition stage, for each block feature vector Z (i.e., the second feature vector) of the reconstructed image, its relationship with each memory item in the memory matrix is calculated through an attention mechanism. Cosine similarity is used to generate attention weight vectors. (Weigh attention), and according to Retrieve the memory item in the memory matrix that best matches the current block feature, and reconstruct the target feature by weighted summation. (i.e., target feature vector), and utilize The reconstructed image is optimized; that is, the memory matrix module, such as Figure 5 As shown, feature Z is combined with the memory queue M for memory addressing, and ReLU is used to process the addressed feature vector W, and the calculated value is then used to perform memory addressing. Multiplying by the memory queue yields the target features. .
[0085] Specifically, the memory network obtains the input feature vector Z based on a soft addressing vector W (1×N). W is also calculated based on Z (each term is non-negative), and the calculation formula is as follows:
[0086] ;
[0087] In the above formula, N is a hyperparameter, which is equal to the image size divided by the slice size.
[0088] The addressing strategy is based on an attention mechanism, calculating the sum of each item in the Z and M modules. The similarity is used to construct the attention repetition W, and the calculation formula is:
[0089] ;
[0090] ;
[0091] The ReLU function is used to optimize the attention weights W, increasing the sparsity of the addressing weights, which further makes it difficult for outlier regions to be reconstructed well. The calculation formula is as follows:
[0092] ;
[0093] max() is the ReLU function. For a very small positive number term, the threshold is usually set to... between.
[0094] This method replaces the last two convolution operations in the original student model with efficient upconvolution and a memory matrix. Compared to traditional upconvolution methods (such as bilinear interpolation), this method better preserves the feature information of normal samples. During reconstruction, new features of normal samples are constructed using a lookup-like method, minimizing the difference between the input image of normal samples and the reconstructed image, while maximizing the difference between the input image of abnormal samples and the reconstructed image. This optimization improves the model's ability to identify abnormal samples, thus significantly improving anomaly detection accuracy.
[0095] Step S14: Determine whether the image difference between the optimized image and the target image is less than a preset difference threshold, and perform anomaly detection on the tension clamp to be detected based on the corresponding judgment result; wherein, the preset anomaly detection model is a model obtained by unsupervised training using a preset training set, and the preset training set is a training set constructed using samples of tension clamps without anomalies.
[0096] In this embodiment, the process of determining whether the image difference between the optimized image and the target image is less than a preset difference threshold, and performing anomaly detection on the tension clamp to be detected based on the corresponding determination result, can specifically include: if the image difference between the optimized image and the reconstructed image is not less than the preset difference threshold, the tension clamp to be detected is determined to be an abnormal tension clamp; if the image difference between the optimized image and the reconstructed image is less than the preset difference threshold, the tension clamp to be detected is determined to be a tension clamp without anomalies. Specifically, for the memory matrix module, during the training phase, only a small number of memory items are used for reconstruction each time, ensuring that each element in the memory item is a representative prototype; during the testing phase, only normal samples can index the most similar elements, thus performing good reconstruction, while the error between abnormal samples and reconstruction will be widened (because the indexed memory items are all normal).
[0097] The discriminator calculates anomaly scores for the currently detected object by comparing pixel-level feature differences between the input image (i.e., the optimized image) and the reconstructed image. For example... Figure 2 As shown, the encoder is defined as E, and the generator (teacher-student model) is defined as... and If the discriminator is D, then the corresponding formula for calculating the anomaly score is:
[0098] ;
[0099] in, For the Sigmoid function, and These are the mean and standard deviation of the outlier scores for a single sample, respectively.
[0100] Therefore, this application uses a training set constructed with samples of tension clamps without abnormalities to perform unsupervised training on the anomaly detection model, avoiding the need for manual annotation of the data in the training set and reducing manual workload. Since the memory matrix only stores the feature vectors corresponding to the samples of tension clamps without abnormalities in the training dataset, there is a difference between the optimized reconstructed image corresponding to the tension clamps with abnormalities and the input image after optimizing the image using the feature vectors. Therefore, by using the feature vectors in the memory matrix to optimize the reconstructed image during the testing process, the difference between the optimized reconstructed image of the tension clamps with abnormalities and the input image can be increased, so that this application does not need to use abnormal samples to train the model, ensuring the usability of the solution.
[0101] See Figure 6 As shown, an embodiment of the present invention discloses a tension clamp abnormality detection device, comprising:
[0102] The image denoising module 11 is used to acquire the initial DR image corresponding to the tension clamp to be detected, and to perform denoising processing on the initial DR image to obtain the target image corresponding to the initial DR image;
[0103] Image reconstruction module 12 is used to reconstruct the target image using a preset encoder and a preset teacher-student model in a preset anomaly detection model, so as to obtain the corresponding reconstructed image;
[0104] Image optimization module 13 is used to optimize the reconstructed image based on the first feature vector in the preset anomaly detection model to obtain the corresponding optimized image; wherein, the first feature vector is the feature vector corresponding to each region in the image corresponding to the sample without anomalies in the tension clamp, and the first feature vector is stored in the memory matrix in the preset anomaly detection model.
[0105] Anomaly detection module 14 is used to determine whether the image difference between the optimized image and the target image is less than a preset difference threshold, and to perform anomaly detection on the tension clamp to be detected based on the corresponding judgment result; wherein, the preset anomaly detection model is a model obtained by unsupervised training using a preset training set, and the preset training set is a training set constructed using samples of tension clamps without anomalies.
[0106] Therefore, this application uses a training set constructed with samples of tension clamps without abnormalities to perform unsupervised training on the anomaly detection model, avoiding the need for manual annotation of the data in the training set and reducing manual workload. Since the memory matrix only stores the feature vectors corresponding to the samples of tension clamps without abnormalities in the training dataset, there is a difference between the optimized reconstructed image corresponding to the tension clamps with abnormalities and the input image after optimizing the image using the feature vectors. Therefore, by using the feature vectors in the memory matrix to optimize the reconstructed image during the testing process, the difference between the optimized reconstructed image of the tension clamps with abnormalities and the input image can be increased, so that this application does not need to use abnormal samples to train the model, ensuring the usability of the solution.
[0107] In some specific embodiments, the image noise reduction module 11 further includes:
[0108] The model acquisition unit is used to acquire an initial detection model and determine the weight decay coefficient, target learning rate, and model iteration number corresponding to the initial detection model.
[0109] The model training unit is used to iteratively train the initial detection model based on a preset optimizer, the weight decay coefficient, the target learning rate, and the number of model iterations, so as to obtain the anomaly detection model corresponding to the initial detection model.
[0110] In some specific embodiments, the image noise reduction module 11 may specifically include:
[0111] An image enhancement unit is used to enhance the contrast of the initial DR image using adaptive histogram equalization technology to obtain a corresponding enhanced DR image.
[0112] The image sharpening unit is used to sharpen the image texture corresponding to the enhanced DR image using Laplacian transform and to remove background noise from the enhanced DR image.
[0113] In some specific embodiments, the image reconstruction module 12 may specifically include:
[0114] The image downsampling unit is used to downsample the target image using the preset encoder to obtain the corresponding downsampled image and extract the image features corresponding to the downsampling process.
[0115] The image upsampling unit is used to upsample the downsampled image using the image features, a preset teacher model, and a preset student model to obtain the reconstructed image corresponding to the target image.
[0116] In some specific embodiments, the image optimization module 13 may specifically include:
[0117] An image segmentation unit is used to segment the reconstructed image to obtain each image block corresponding to the reconstructed image, and to obtain the second feature vector corresponding to each image block respectively;
[0118] The cosine similarity calculation unit is used to calculate the cosine similarity between each second feature vector and each first feature vector using an attention mechanism, so as to obtain the attention weights corresponding to each second feature vector.
[0119] The image optimization unit is used to obtain the target feature vectors corresponding to each of the second feature vectors based on each of the attention weights, and to optimize the reconstructed image using each of the target feature vectors.
[0120] In some specific embodiments, the anomaly detection module 14 may specifically include:
[0121] The first clamp determination unit is used to determine the tension clamp to be detected as an abnormal tension clamp if the image difference between the optimized image and the reconstructed image is not less than a preset difference threshold.
[0122] The second clamp determination unit is used to determine the tension clamp to be detected as a tension clamp without abnormalities if the image difference between the optimized image and the reconstructed image is less than the preset difference threshold.
[0123] Furthermore, embodiments of this application also disclose an electronic device, Figure 7 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application.
[0124] Figure 7 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. Specifically, the electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the tension clamp anomaly detection method disclosed in any of the foregoing embodiments. Alternatively, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0125] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0126] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0127] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the tension clamp anomaly detection method executed by the electronic device 20 as disclosed in any of the foregoing embodiments, the computer program 222 may further include computer programs capable of performing other specific tasks.
[0128] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned method for detecting abnormal tension clamps. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.
[0129] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0130] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0131] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0132] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0133] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for detecting abnormalities in tension clamps, characterized in that, include: Acquire the initial DR image corresponding to the tension clamp to be detected, and perform noise reduction processing on the initial DR image to obtain the target image corresponding to the initial DR image; The target image is reconstructed using a preset encoder and a preset teacher-student model in a preset anomaly detection model to obtain the corresponding reconstructed image; The reconstructed image is optimized based on the first feature vector in the preset anomaly detection model to obtain the corresponding optimized image; wherein, the first feature vector is the feature vector corresponding to each region in the image of the sample without abnormal tension clamps, and the first feature vector is stored in the memory matrix in the preset anomaly detection model. Determine whether the image difference between the optimized image and the reconstructed image is less than a preset difference threshold, and perform anomaly detection on the tension clamp to be detected based on the corresponding judgment result; wherein, the preset anomaly detection model is a model obtained by unsupervised training using a preset training set, and the preset training set is a training set constructed using samples of tension clamps without anomalies; The step of reconstructing the target image using a preset encoder and a preset teacher-student model in a preset anomaly detection model includes: using the preset encoder to downsample the target image to obtain a corresponding downsampled image, and extracting image features corresponding to the downsampling process; using the image features, the preset teacher model, and the preset student model to upsample the downsampled image to obtain a reconstructed image corresponding to the target image. The optimization of the reconstructed image based on the first feature vector in the preset anomaly detection model includes: segmenting the reconstructed image to obtain each image patch corresponding to the reconstructed image, and obtaining a second feature vector corresponding to each image patch; calculating the cosine similarity between each second feature vector and each first feature vector using an attention mechanism to obtain the attention weight corresponding to each second feature vector; obtaining the target feature vector corresponding to each second feature vector based on each attention weight, and optimizing the reconstructed image using each target feature vector.
2. The method for detecting abnormalities in tension clamps according to claim 1, characterized in that, Before acquiring the initial DR image corresponding to the tension clamp to be detected, the method further includes: Obtain an initial detection model and determine the weight decay coefficient, target learning rate, and number of model iterations corresponding to the initial detection model; The initial detection model is iteratively trained based on a preset optimizer, the weight decay coefficient, the target learning rate, and the number of model iterations to obtain the anomaly detection model corresponding to the initial detection model.
3. The method for detecting abnormalities in tension clamps according to claim 1, characterized in that, The noise reduction process for the initial DR image includes: The contrast of the initial DR image is enhanced using adaptive histogram equalization to obtain the corresponding enhanced DR image. The Laplacian transform is used to sharpen the image texture corresponding to the enhanced DR image, and the background noise of the enhanced DR image is removed.
4. The method for detecting abnormalities in tension clamps according to claim 1, characterized in that, The step of determining whether the image difference between the optimized image and the reconstructed image is less than a preset difference threshold, and performing anomaly detection on the tension clamp to be detected based on the corresponding determination result, includes: If the image difference between the optimized image and the reconstructed image is not less than a preset difference threshold, the tension clamp to be detected is determined to be an abnormal tension clamp. If the image difference between the optimized image and the reconstructed image is less than the preset difference threshold, the tension clamp to be detected is determined to be a tension clamp without abnormalities.
5. A device for detecting abnormalities in tension clamps, characterized in that, include: The image denoising module is used to acquire the initial DR image corresponding to the tension clamp to be detected, and to perform denoising processing on the initial DR image to obtain the target image corresponding to the initial DR image; The image reconstruction module is used to reconstruct the target image using a preset encoder and a preset teacher-student model in a preset anomaly detection model, so as to obtain the corresponding reconstructed image. The image optimization module is used to optimize the reconstructed image based on the first feature vector in the preset anomaly detection model to obtain the corresponding optimized image; wherein, the first feature vector is the feature vector corresponding to each region in the image corresponding to the sample without anomalies in the tension clamp, and the first feature vector is stored in the memory matrix in the preset anomaly detection model. An anomaly detection module is used to determine whether the image difference between the optimized image and the target image is less than a preset difference threshold, and to perform anomaly detection on the tension clamp to be detected based on the corresponding judgment result; wherein, the preset anomaly detection model is a model obtained by unsupervised training using a preset training set, and the preset training set is a training set constructed using samples of tension clamps without anomalies; The image reconstruction module includes: The image downsampling unit is used to downsample the target image using the preset encoder to obtain the corresponding downsampled image and extract the image features corresponding to the downsampling process. An image upsampling unit is used to upsample the downsampled image using the image features, a preset teacher model, and a preset student model to obtain the reconstructed image corresponding to the target image. The image optimization module includes: An image segmentation unit is used to segment the reconstructed image to obtain each image block corresponding to the reconstructed image, and to obtain the second feature vector corresponding to each image block respectively; The cosine similarity calculation unit is used to calculate the cosine similarity between each second feature vector and each first feature vector using an attention mechanism, so as to obtain the attention weights corresponding to each second feature vector. The image optimization unit is used to obtain the target feature vectors corresponding to each of the second feature vectors based on each of the attention weights, and to optimize the reconstructed image using each of the target feature vectors.
6. The tension clamp abnormality detection device according to claim 5, characterized in that, The image noise reduction module further includes: The model acquisition unit is used to acquire an initial detection model and determine the weight decay coefficient, target learning rate, and model iteration number corresponding to the initial detection model. The model training unit is used to iteratively train the initial detection model based on a preset optimizer, the weight decay coefficient, the target learning rate, and the number of model iterations, so as to obtain the anomaly detection model corresponding to the initial detection model.
7. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the tension clamp anomaly detection method as described in any one of claims 1 to 4.
8. A computer-readable storage medium, characterized in that, Used to store a computer program, which, when executed by a processor, implements the tension clamp anomaly detection method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Surface defect detection device and method
CN111896550A
Method and device for obtaining anomaly detection model
CN118230004A