Alternating current filter defect detection method and storage medium
By using deep learning models of feature extraction, enhancement and fusion in AC filter defect detection, the problems of low real-time performance and insufficient detection capabilities of small objects in the prior art are solved, and efficient and accurate defect detection is achieved.
Patent Information
- Application Number
- CN202510220975.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-27
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2045-02-27
AI Technical Summary
The existing defect detection algorithm based on deep learning has problems such as low real-time performance and insufficient detection capabilities for small targets in AC filter defect detection, which cannot meet the detection needs of large targets and small target defects in AC filters.
An AC filter defect detection method is proposed. The AC filter image to be detected is extracted, enhanced and fused through a trained defect detection model, and defect detection is realized by using a feature extraction module, a feature fusion module and a defect detection module. The model includes a space/channel interactive self-attention submodule and a cross-scale fusion submodule. Feature fusion is performed through affine transformation to improve detection efficiency and accuracy.
It improves the efficiency and accuracy of AC filter defect detection, and can effectively detect defects between large and small targets in AC filters, meeting the needs of real-time detection.
Smart Images

Figure CN119722670A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a detection method and storage medium for defects of an AC filter. Background Art
[0002] With the development of smart grid, the status monitoring and defect detection of AC filter have become an important guarantee for the safe operation of the power grid. As a key device in the DC transmission system, AC filter is mainly used to suppress harmonic interference and improve the quality of power. Since AC filter mostly works outdoors and is exposed to long-term wind and sun, it is easy to have defects such as component failure, mechanical damage, and connector aging. The appearance of defects is as follows: Figure 1 , Figure 2 , Figure 3 These defects may not only lead to increased harmonics and unbalanced three-phase currents, but also affect the stability of the power transmission system and even cause serious problems such as equipment tripping.
[0003] At present, the detection methods for AC filter defects mainly include manual inspection, infrared temperature measurement and protection alarm. Among them, manual inspection is limited by low frequency and strong randomness, making it difficult to detect problems in time; although infrared temperature measurement can effectively detect hot spots on the surface of AC filters, it cannot detect external defects of AC filters; and protection alarms are often triggered only after the operation of AC filters is affected. Therefore, it is particularly important to study and apply technical means that can identify AC filter defects at an early stage.
[0004] In recent years, target detection technology has been widely used in the field of industrial inspection, providing new solutions for equipment status monitoring in complex scenarios. Traditional target detection methods are based on manually designed features and classifiers, such as HOG (Histogram of Oriented Gradients) + SVM (Support Vector Machine) and Cascade model. Although this method performs well in simple scenarios, it has limited detection capabilities for complex equipment defects. With the development of deep learning technology, target detection methods based on CNN (Convolutional Neural Networks), such as Faster R-CNN, YOLO (You Only Look Once) and SSD (Single Shot MultiBox Detector), have rapidly emerged, demonstrating powerful feature extraction and target positioning capabilities. Therefore, in equipment defect detection, target detection technology can give full play to its ability to process complex scenes and subtle features. Combined with a large amount of visible light image defect data, the deep learning model can automatically extract defect features, such as foreign matter, damage and rust, and quickly locate and classify them. By introducing target detection technology, intelligent monitoring of equipment operating status can be achieved, greatly improving detection efficiency and accuracy, and providing technical support for the stable operation of the power system.
[0005] However, directly using the existing deep learning-based defect detection algorithm for AC filter defect detection will have the following shortcomings: (1) The Faster R-CNN method needs to generate candidate regions first, and then classify and regress these candidate regions into fine bounding boxes. This cumbersome working mode leads to low real-time performance. (2) The YOLO algorithm needs to use NMS (Non-Maximum Suppression) to sort a large number of detection boxes and calculate overlapping areas. In practical applications, it will affect the speed of defect reasoning and is not conducive to the real-time performance requirements of the model, especially in the case of AC filters where there are many targets to be inspected. (3) SSD (Single Shot MultiBox Detector) relies on high-level features in the network to detect small targets. However, high-level features have a large receptive field, resulting in insufficient ability to capture detailed information of small targets. Small targets may be projected to very small areas or even lost on the feature map. Therefore, it cannot meet the detection requirements for AC filters where large and small target defects occur at the same time. Summary of the invention
[0006] The present invention aims to solve one of the technical problems in the related art to at least a certain extent. To this end, the purpose of the present invention is to propose a detection method and storage medium for AC filter defects to improve the detection efficiency of AC filter defects and meet the detection requirements of large and small target defects in AC filters.
[0007] In a first aspect, an embodiment of the present invention provides a method for detecting defects in an AC filter, the method comprising: obtaining an image of an AC filter to be detected; inputting the image of the AC filter to be detected into a trained defect detection model for defect detection to obtain a detection result; wherein the defect detection model comprises a feature extraction module, a feature fusion module and a defect detection module, the feature extraction module being used to perform feature extraction on the image of the AC filter to be detected to obtain features of N different scales, where N is an integer greater than or equal to 2; the feature fusion module being used to perform enhancement processing on features of at least one scale, and to perform fusion processing on the enhanced features and the unenhanced features by means of affine transformation; and the defect detection module being used to perform defect detection based on the fused features.
[0008] Exemplarily, the training process of the defect detection model includes: obtaining a number of positive sample images and a number of negative sample images of multiple types of defects in the AC filter; randomly dividing the positive sample images and the negative sample images into a training set and a test set according to a first preset ratio, wherein the first preset ratio is greater than 1; constructing the defect detection model, and using the training set and the test set to train and test the defect detection model to obtain the trained defect detection model.
[0009] Exemplarily, the feature fusion module includes a spatial / channel interactive self-attention submodule and a cross-scale fusion submodule; the feature fusion module enhances features of at least one scale, and fuses the enhanced features with the unenhanced features by means of affine transformation, including: the spatial / channel interactive self-attention submodule enhances the features of the smallest scale among N scale features by means of spatial self-attention and channel self-attention, respectively, to obtain enhanced features, wherein the spatial self-attention and the channel self-attention use different numbers of self-attention heads; the cross-scale fusion submodule fuses the enhanced features with the unenhanced features by means of affine transformation.
[0010] Exemplarily, the spatial / channel interactive self-attention submodule includes a feature mapping unit, a multi-head division unit, a spatial self-attention unit, a channel self-attention unit and a first splicing unit; the spatial / channel interactive self-attention submodule enhances the smallest scale feature among N scale features through spatial self-attention and channel self-attention respectively, including: the feature mapping unit uses a preset convolution kernel to map the smallest scale feature into a query feature, a key feature and a value feature; the multi-head division unit groups the query feature, the key feature and the value feature according to a second preset ratio of attention heads to obtain a first group and a second group, wherein the second preset ratio is not equal to 1; the spatial self-attention unit obtains a first enhancer feature based on the query feature, the key feature and the value feature of the first group based on the spatial self-attention; the channel self-attention unit obtains a second enhancer feature based on the query feature, the key feature and the value feature of the second group based on the channel self-attention; the first splicing unit splices the first enhancer feature and the second enhancer feature to obtain the enhanced feature.
[0011] Exemplarily, the spatial self-attention unit obtains the first enhancer feature by the following formula: in, represents the enhancer feature of the i-th attention head in the first group, represents the normalization function, represents the cosine similarity function, T represents the rank transformation, , , They respectively represent the query features, key features, and value features of the i-th attention head in the first group after the preset size window shift operation is performed in space, represents the constant coefficient, B represents the relative position bias, represents the first enhancer feature, represents 1×1 convolution, inverse window shift and shape transformation operations, represents the channel splicing function, Represents the number of attention heads corresponding to the first group.
[0012] Exemplarily, the channel self-attention unit obtains the second enhancer feature by the following formula: in, represents the enhancer feature of the i-th attention head in the second group, represents the normalization function, represents the cosine similarity function, T represents the rank transformation, , , denote the query feature, key feature, and value feature of the i-th attention head in the second group, respectively. represents the constant coefficient, represents the second enhancer feature, represents a 1×1 convolution and shape transformation operation, represents the channel splicing function, represents the number of attention heads corresponding to the first group, and L represents the total number of attention heads.
[0013] Exemplarily, the first splicing unit obtains the enhanced feature by the following formula: in, represents the enhanced feature, represents 3×3 convolution, represents the channel splicing function, represents the first enhancer feature, Represents the second enhancer feature.
[0014] Exemplarily, the cross-scale fusion submodule includes a second splicing unit, N-1 first affine fusion units, a second affine fusion unit and a third affine fusion unit, the N-1 first affine fusion units are connected in sequence and correspond one-to-one to the N-1 features except the minimum scale feature, the first first affine fusion unit is used to fuse the enhanced feature and the feature of the corresponding scale, the first affine fusion unit except the first first affine fusion unit is used to fuse the feature output by the previous first affine fusion unit and the feature of the corresponding scale, the second affine fusion unit is used to fuse the features output by the last two first affine fusion units, and the third affine fusion unit is used to fuse the enhanced feature and the feature output by the second affine fusion unit; the first affine fusion unit, the second affine fusion unit and the third affine fusion unit all use the following formula to fuse the two features to be fused. , Perform fusion processing: in, represents 3×3 convolution, represents 1×1 convolution, represents the learned reflection transformation coefficient, represents the learned shift coefficient, Indicates that the convolution kernel size is 3×3 for learning The convolution of Indicates that the convolution kernel size is 3×3 for learning The convolution of The corresponding scale is smaller than The corresponding scale, represents the initial fusion feature, represents the non-parametric instance normalization function, Representation characteristics and Features The fusion characteristics of The second splicing unit is used to splice the fusion features output by the last first affine fusion unit, the second affine fusion unit and the third affine fusion unit to obtain the final fusion features.
[0015] Exemplarily, the feature extraction module adopts the EfficientViT model, and the defect detection module adopts the RT-DETR network.
[0016] In a second aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the method for detecting defects of an AC filter as described in the first aspect above is implemented.
[0017] The detection method and storage medium of AC filter defects in the embodiment of the present invention divide the detection process of AC filter defects into three stages through a trained defect detection model: the first stage is the feature extraction stage, which can realize the extraction of multiple different scale features of the AC filter image to be detected; the second stage is feature enhancement and fusion, which realizes the enhancement processing of at least one scale feature in feature enhancement to improve the distinguishing strength of the feature; in feature fusion, the fusion of enhanced features and other unenhanced features is realized, which can make full use of feature semantics and details to mine large and small target features; the third stage is the prediction stage, which completes defect identification and positioning according to the fused features. In this way, the efficiency of AC filter defect detection can be improved, and the detection requirements of large and small target defects in AC filters can be met. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 is a schematic diagram of an example AC filter defect; Figure 2 is a schematic diagram of another example of an AC filter defect; Figure 3 is a schematic diagram of yet another example of an AC filter defect; Figure 4is a schematic diagram of the structure of a defect detection model according to an embodiment of the present invention; Figure 5 is a schematic diagram of the structure of a spatial / channel interactive self-attention submodule according to an embodiment of the present invention; Figure 6 is a schematic diagram of the structure of a spatial self-attention unit according to an embodiment of the present invention; Figure 7 is a schematic structural diagram of a channel self-attention unit according to an embodiment of the present invention; Figure 8 is a schematic diagram of a cross-scale feature fusion structure according to an embodiment of the present invention; Fig. 9 is a schematic diagram of a mAP curve of an example of the present invention; Fig.10 It is a schematic diagram of the mAP curve of another example of the present invention. DETAILED DESCRIPTION
[0019] In view of the low detection efficiency of the existing recognition model and its inability to meet the detection requirements of large and small target defects in AC filters, the present invention provides a detection method and storage medium for AC filter defects.
[0020] The following describes an AC filter defect detection method and a storage medium according to an embodiment of the present invention with reference to the accompanying drawings.
[0021] In an embodiment of the present invention, the method for detecting AC filter defects includes the following steps S21-S22: S21, obtaining an image of the AC filter to be tested.
[0022] Exemplarily, the image of the AC filter to be inspected can be acquired through a monitoring camera at a corresponding position, or through a drone equipped with a camera.
[0023] S22, inputting the AC filter image to be detected into the trained defect detection model to perform defect detection and obtain a detection result.
[0024] In this embodiment, if Figure 4 As shown, the defect detection model includes a feature extraction module, a feature fusion module and a defect detection module. The feature extraction module is used to extract features of the AC filter image to be detected to obtain features of N different scales, where N is an integer greater than or equal to 2, such as 3, 4, etc.; the feature fusion module is used to enhance features of at least one scale, and fuse the enhanced features with the unenhanced features by affine transformation; the defect detection module is used to perform defect detection based on the fused features.
[0025] Specifically, the defect detection model can be configured in an electronic device such as a smart terminal or a host computer, which can communicate with the aforementioned monitoring camera to obtain an image of the AC filter to be detected. Afterwards, the AC filter image to be detected can be input into the trained defect detection model for defect detection to obtain a detection result. Figure 4 When using the defect detection model for defect detection, the feature extraction module is used to extract features of the AC filter image to be detected, and N scale features are obtained. For example, three scale features are obtained. , , , the accuracy and robustness of defect detection can be improved by extracting multi-scale features. Then, the feature fusion module is used to extract features of at least one scale, such as high-level features. (corresponding to the smallest scale) is enhanced to improve the recognition of various defect features for subsequent detection; and the enhanced and unenhanced features of different scales are fused across scales. By integrating defect features of different scales, the defect features of large and small targets are fully explored. Finally, the defect detection module is used to achieve rapid decoupling of fused features and ultimately achieve defect detection, which can include detecting the presence or absence of defects, defect types, defect locations, etc.
[0026] Therefore, this detection method can improve the detection efficiency of AC filter defects and meet the detection needs of large and small target defects in AC filters.
[0027] In some examples, the feature extraction module may use the EfficientViT model.
[0028] In this example, EfficientViT has significant advantages as the feature extraction backbone network in the target detection task. First, it has excellent computational and memory efficiency. By reducing the redundant operations of MHSA (Multi-Head Self-Attention) and adopting CGA (Cascaded Group Attention), it effectively improves the computational speed and feature extraction capabilities. Secondly, it combines multi-scale feature fusion and efficient lightweight encoders, which enables it to perform well in processing multi-scale target detection, especially in resource-constrained scenarios (such as drones and satellite platforms), to ensure detection accuracy and speed.
[0029] Specifically, the EfficientViT model combines a lightweight multi-scale attention mechanism and MBConv (hybrid convolution) blocks to achieve efficient performance in image processing. The lightweight multi-scale attention module is used to extract contextual information to assist the model in understanding the global information in the image; the MBConv block is mainly used to extract and utilize local information. Global receptive field and multi-scale learning are very important for target detection tasks and can significantly improve the performance of the model. Therefore, using EfficientViT as the backbone network for AC filter defect detection can achieve an effective balance between detection speed, accuracy, and model complexity.
[0030] Exemplarily, the feature extraction module may also use methods such as but not limited to image pyramid, multi-scale convolutional layer, SSD (Single Shot MultiBox Detector), FPN (Feature Pyramid Network) to extract N features of different scales.
[0031] In some examples of the present invention, the defect detection module may use a RT-DETR (Real-Time DEtection Transformer) network as a head network of the defect detection model.
[0032] Specifically, RT-DETR is a real-time end-to-end target detection model based on the Transformer architecture, which not only has efficient and fast real-time object detection performance, but also maintains high accuracy.
[0033] Exemplarily, the defect detection module may also adopt but is not limited to a YOLO network, a DETR network, and the like.
[0034] In some embodiments of the present invention, the training process of the defect detection model includes the following steps S41-S43: S41, obtaining a plurality of positive sample images and a plurality of negative sample images of multiple types of defects of the AC filter.
[0035] Among them, the positive sample image refers to an image containing AC filter defects (such as damage, rust, foreign matter, etc.), and the negative sample image refers to an image that does not contain AC filter defects. Positive and negative sample images can be obtained from the Internet or by taking pictures with a camera.
[0036] S42, randomly dividing the positive sample images and the negative sample images into a training set and a test set according to a first preset ratio.
[0037] The first preset ratio is greater than 1, such as 7:3, 8:2, etc., and can be set as needed. For example, the labels involved in the training set and the test set may include whether the AC filter has defects, defect types, defect locations, etc.
[0038] S43, constructing a defect detection model, and using the training set and the test set to train and test the defect detection model to obtain a trained defect detection model.
[0039] Optionally, the test set may not be set, and the defect detection model may be trained directly by the training set.
[0040] In some embodiments of the present invention, Figure 4 As shown, the feature fusion module includes a spatial / channel interactive self-attention submodule and a cross-scale fusion submodule.
[0041] In this embodiment, the feature fusion module enhances the features of at least one scale, and fuses the enhanced features with the unenhanced features by means of affine transformation, including: the spatial / channel interactive self-attention submodule performs spatial self-attention and channel self-attention on the smallest scale (such as Figure 4 In ) to obtain enhanced features, where spatial self-attention and channel self-attention use different numbers of self-attention heads; the cross-scale fusion submodule uses affine transformation to fuse the enhanced features with the unenhanced features.
[0042] Specifically, in order to improve high-level visual tasks such as defect detection, it is crucial to refer to the feature distribution in the entire image (global or non-global context). Improving the semantic information of the features can effectively improve the distinctiveness of AC filter defects, enhance the degree of separation between defect categories, and improve the model's classification performance for different defects. In this regard, in order to obtain high-level semantic features with local and global context, the present invention designs a spatial / channel interactive self-attention submodule, which allows the high-level features (i.e., the smallest scale features) output by the backbone network to interact within the scale through the joint interaction of spatial self-attention and channel self-attention, enhances its local and global context information expression capabilities, and improves the semantic information of the features, thereby effectively improving the distinctiveness of AC filter defect features (i.e., improving the distinguishing strength of the features), enhancing the degree of separation between defect categories, and improving the model's classification performance for different defects.
[0043] Since high-level features have more abstract semantic information, while low-level features have more detailed information, if high-level features and low-level features are simply spliced and fused after up- and down-sampling, it will not only affect the detailed information but also cause duplication and confusion between high-level features and low-level features. Therefore, the present invention designs a cross-scale fusion submodule based on affine transformation, which provides adaptively modified image features for the entire fusion process and reduces unnecessary influences. Through cross-scale feature fusion based on affine transformation, the features of large and small targets can be fully explored, providing valuable feature guidance for defect recognition of different scales of the final AC filter.
[0044] For example, see Figure 4 Before enhancing and fusing the features, the N scale features can be convolved separately. For example, using a 3×3 convolution kernel can speed up model training and detection.
[0045] In some examples, such as Figure 5 As shown in the figure, the spatial / channel interactive self-attention submodule includes a feature mapping unit, a multi-head division unit, a spatial self-attention unit, a channel self-attention unit and a first splicing unit. The spatial / channel interactive self-attention submodule focuses on the local and global contexts respectively by operating spatial self-attention (S-SA) and channel self-attention (C-SA) in parallel.
[0046] In this example, the spatial / channel interactive self-attention submodule enhances the smallest scale feature among N scale features by spatial self-attention and channel self-attention respectively, including: the feature mapping unit maps the smallest scale feature into a query feature, a key feature and a value feature using a preset convolution kernel (such as 3×3); the multi-head division unit groups the query feature, the key feature and the value feature according to a second preset ratio of attention heads to obtain a first group and a second group, wherein the second preset ratio is not equal to 1, such as 6:4, so that the number of self-attention heads used by the spatial self-attention and the channel self-attention is different; the spatial self-attention unit obtains a first enhancer feature according to the query feature, the key feature and the value feature of the first group based on the spatial self-attention; the channel self-attention unit obtains a second enhancer feature according to the query feature, the key feature and the value feature of the second group based on the channel self-attention; the first splicing unit splices the first enhancer feature and the second enhancer feature to obtain an enhanced feature.
[0047] As an implementation method, the spatial self-attention unit obtains the first enhancer feature through the following formulas (1) and (2): (1) (2) in, represents the enhancer feature of the i-th attention head in the first group, represents the normalization function, represents the cosine similarity function, T represents the rank transformation, , , They represent the query features, key features, and value features of the i-th attention head in the first group after the window shift operation of preset size (which can be set as needed, such as 8×8) in space. represents the constant coefficient (the value can be calibrated as needed, such as 0.01), B represents the relative position offset, represents the first enhancer feature, Represents 1×1 convolution, inverse window shift, and shape transformation operations (i.e., reshape operations, which are used to transform the specified matrix into a matrix of a specific dimension). represents the channel splicing function, Indicates the number of attention heads corresponding to the first group.
[0048] Specifically, taking N=3 as an example, see Figure 4 , Figure 5 , the high-level features output by the feature extraction module Input to the feature mapping unit. The feature mapping unit uses 3×3 convolution to transform the features Mapped into query features (Q), key features (K) and value features (V), and then the multi-head division unit divides the attention heads (total number is ) is divided in the ratio of 6:4.
[0049] The implementation structure of S-SA can be as follows Figure 6 As shown in the figure, the calculation process of S-SA can be described as follows: First, , and An 8×8 window shift operation is performed in space, after which the features are rearranged and split into vectors , and ,use and Calculate cosine similarity and compare with relative position offset Add, then After normalization, the weights are obtained and The reweighted feature vector is first subjected to a 1×1 convolution, then an inverse window shift operation, and then a reshape operation to obtain the feature vector. , the above process can be expressed by the above formulas (1) and (2).
[0050] As an implementation method, the channel self-attention unit obtains the second enhancer feature through the following formulas (3) and (4): (3) (4) in, represents the enhancer feature of the i-th attention head in the second group, represents the normalization function, represents the cosine similarity function, T represents the rank transformation, , , They represent the query feature, key feature, and value feature of the i-th attention head in the second group, respectively. represents the constant coefficient, Indicates the second enhancer feature, represents 1×1 convolution and reshape operation, represents the channel splicing function, represents the number of attention heads corresponding to the first group, and L represents the total number of attention heads.
[0051] Since the 8×8 window shift operation is used in the calculation process of S-SA, each , and The S-SA receptive field is limited to an 8×8 window, so it only contains local context information. , and Participate in attention calculation, so C-SA contains global context information. The implementation structure of C-SA can be as follows Figure 7 As shown, it can be expressed by the above formulas (3) and (4).
[0052] As an implementation method, the first splicing unit obtains enhanced characteristics through the following formula (5): (5) in, Represents enhanced features, represents 3×3 convolution, represents the channel splicing function, represents the first enhancer feature, Indicates the second enhancer signature.
[0053] Specifically, see Figure 5 , after obtaining the first enhancer feature and second enhancer features After that, and Splicing on the channel, and mixing local features and global features through 3×3 convolution, finally obtaining spatial / channel attention , the implementation process can be expressed by the above formula (5). It has high-level semantic features of local and global contexts, so it can effectively improve the distinctiveness of AC filter defects and enhance the separation between defect categories.
[0054] In some embodiments of the present invention, see Figure 4 (Take N=3 as an example), the cross-scale fusion submodule includes a second splicing unit, N-1 first affine fusion units, a second affine fusion unit and a third affine fusion unit. The N-1 first affine fusion units are connected in sequence and correspond one-to-one to the N-1 features except the minimum scale feature. The first first affine fusion unit is used to fuse the enhanced feature and the feature of the corresponding scale. The first affine fusion unit except the first first affine fusion unit is used to fuse the feature output by the previous first affine fusion unit and the feature of the corresponding scale. The second affine fusion unit is used to fuse the features output by the last two first affine fusion units. The third affine fusion unit is used to fuse the enhanced feature and the feature output by the second affine fusion unit.
[0055] Among them, the first affine fusion unit, the second affine fusion unit and the third affine fusion unit all use the following formula to fusion the two features to be fused: , Perform fusion processing: (6) (7) (8) (9) in, represents 3×3 convolution, represents 1×1 convolution, represents the learned reflection transformation coefficient, represents the learned shift coefficient, Indicates that the convolution kernel size is 3×3 for learning The convolution of Indicates that the convolution kernel size is 3×3 for learning convolution. The corresponding scale is smaller than The corresponding scale, represents the initial fusion feature, represents the non-parametric instance normalization function, Representation characteristics and Features fusion characteristics.
[0056] Specifically, see Figure 4 , taking N=3 as an example, the two first affine fusion units are connected from bottom to top, the second affine fusion unit and the third affine fusion unit are connected from top to bottom, and the second affine fusion unit is connected to the top two first affine fusion units. First, the size and number of channels of the enhanced feature p5 are changed using Conv1 and upsampling operations, and then p4 and p5 are fused using the first first affine fusion unit. At this time, the output of the first first affine fusion unit contains the information of the two features p4 and p5, and the output is recorded as (p4+p5). Then, repeat the above operation and use the second first affine fusion unit to fuse p3, and the output is recorded as (p3+p4+p5). Considering that the target detection framework has a greater demand for high-level semantic features, that is, features with smaller scales, the second affine fusion unit is used to fuse (p4+p5) with (p3+p4+p5) (first use the Conv3 operation, that is, use the convolution with a step size of 2 and a convolution kernel size of 3×3 to adjust the size), and the output is recorded as [(p4+p5)+(p3+p4+p5)]. Similarly, the third affine fusion unit fuses [(p4+p5)+(p3+p4+p5)] with the un-upsampled p5 after the Conv1 operation. It should be noted that Figure 4 Conv1 and Conv3 in the cross-scale fusion submodule shown are convolutions with convolution kernels of 1×1 and 3×3 respectively with SiLU as the activation function, where Conv1 is used to modify the number of channels and Conv3 has a step size of 2 for modifying the feature map size.
[0057] In the process of feature fusion of each affine fusion unit, the affine transformation parameters , It is learned from semantic priors instead of using images or semantic maps as conditional inputs, thereby reducing the risk of duplication and confusion between high-level features and low-level features. Figure 8 As shown, we first normalize the non-parametric instance ) to normalize the low-level features of the input (The low-level features here are relative, such as Relative to is a low-level feature). Then from the semantic prior (Semantic priors are high-level features, and high-level features are also relative, such as Relative to is a high-level feature) learns two different sets of parameters , (which can be expressed by the above formulas (6) and (7)) in order to Perform spatial pixel affine transformation (which can be expressed by equation (8) above).
[0058] feature Although the details and semantic information are available, in order to further explore local and global information and considering the efficiency of the integration fusion process, the present invention uses simple convolution to implement this process. Considering that a smaller convolution kernel is suitable for extracting detailed features and local textures, while a larger convolution kernel is more suitable for extracting global image information. Therefore, Two paths are input respectively. The first path uses a single 1×1 convolution operation to extract local features; the second path uses a single 1×1 convolution operation and three 3×3 convolution operations to achieve deeper information extraction. Finally, the local features and global features are added to obtain the final fusion features of the two scales. The implementation process can be expressed by the above formula (9).
[0059] The second splicing unit (in Figure 4 The fusion feature is used to concatenate the fusion features output by the last first affine fusion unit, the second affine fusion unit, and the third affine fusion unit to obtain the final fusion feature. Figure 4 , and finally 3 different (Right now , , , which can contain high-level semantic features) are spliced and input into the RT-DETR-based defect detection module to achieve the final defect detection. Therefore, the final cross-scale fusion submodule based on affine transformation fuses high / low-level features of three different scales in an adaptive manner, fully exploits the features of large and small targets, and provides valuable feature guidance for the final defect detection.
[0060] In some other embodiments of the present invention, the cross-scale fusion submodule includes a second splicing unit, N-1 first affine fusion units and N-1 fourth affine fusion units, and the N-1 first affine fusion units have the same connection structure (bottom-up connection) and function as the N-1 first affine fusion units in the above embodiment. The N-1 fourth affine fusion units are connected in sequence (top-down connection) and correspond to the N-1 first affine fusion units one by one. The first fourth affine fusion unit is used to fuse the features output by the corresponding first affine fusion unit (after Conv3 operation) and its input features (unsampled features after Conv1 operation), and the other fourth affine fusion units are used to fuse the unsampled features input below the corresponding first affine fusion unit and the features output by the previous fourth affine fusion unit (after Conv3 operation). The second splicing unit is used to splice the fused features output by the last first affine fusion unit, the first fourth affine fusion unit and the last fourth affine fusion unit.
[0061] For example, to reduce the processing complexity, the feature The second splicing unit is directly input for splicing, that is, the process of formula (9) is not performed.
[0062] Combine the following Fig. 9 and Fig.10 , the detection performance of the defect detection model designed by the present invention is explained by tracking the mAP (mean Average Precision) results during the training process; Fig. 9 and Fig.10 The change curves of mAP50 and mAP50:90 during the training process are shown respectively, with the horizontal axis being epoch, indicating the training round of the defect detection model, and the vertical axis being the mAP value. It can be seen that the change curves of mAP50 and mAP50:90 can quickly reach a stable state, where mAP50 can be maintained above 0.75 and mAP50:90 can be maintained above 0.50, indicating that the average accuracy of the designed defect detection model for different defect categories of the AC filter is very impressive.
[0063] It should be noted that in the object detection task, mAP is used to measure the average accuracy of the model under different categories and different IoU (Intersection over Union) thresholds. Among them, mAP50 measures the average accuracy of the model when the IoU threshold is 0.5; mAP50:95 measures the average accuracy of the model when the IoU threshold ranges from 0.5 to 0.95.
[0064] Based on the AC filter defect detection method of the above embodiment, the present invention also proposes a computer-readable storage medium.
[0065] In this embodiment, a computer program is stored on a computer-readable storage medium. When the computer program is executed by a processor, the method for detecting defects of an AC filter of the above embodiment is implemented.
[0066] In summary, the AC filter defect detection method and storage medium of the embodiment of the present invention, when detecting AC filter defects, the defect detection model used divides the detection process into three stages: the first stage is the feature extraction stage, which implements image feature extraction based on the EfficientViT model. This network containing the Transformer structure can realize efficient feature extraction. The second stage is the feature enhancement and fusion stage. In terms of feature enhancement, a Tranformer-style spatial / channel interactive self-attention is designed. By using different numbers of spatial and channel self-attentions to achieve high-level feature scale interaction, high-level semantic features with local and global contexts are extracted to enhance the feature discrimination strength; in terms of feature fusion, a cross-scale fusion based on affine transformation is designed. The affine transformation method is used to achieve efficient fusion of high-level features and low-level features, and the feature semantics and details are fully utilized to mine large and small target features, providing valuable feature guidance for the final defect detection, which is conducive to improving the model detection accuracy. The third stage is the prediction stage, in which the head network of RT-DETR is used to complete defect identification and positioning. This network containing the Transfomer structure can quickly process multi-scale defect features by decoupling spatial / channel interactive self-attention and cross-scale fusion based on affine transformation, which can improve the detection speed and accuracy and can adapt to AC filter defects of different scales.
[0067] It should be noted that the logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be specifically implemented in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples (non-exhaustive list) of computer-readable media include the following: an electrical connection portion with one or more wirings (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.
[0068] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0069] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0070] In the description of the present invention, it is to be understood that the terms “center”, “longitudinal”, “lateral”, “length”, “width”, “thickness”, “up”, “down”, “front”, “back”, “left”, “right”, “vertical”, “horizontal”, “top”, “bottom”, “inside”, “outside”, “clockwise”, “counterclockwise”, “axial”, “radial”, “circumferential”, etc., indicating orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the referred device or element must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as limiting the present invention.
[0071] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0072] In the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements, unless otherwise clearly defined. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0073] In the present invention, unless otherwise clearly specified and limited, a first feature being "above" or "below" a second feature may mean that the first and second features are in direct contact, or the first and second features are in indirect contact through an intermediate medium. Moreover, a first feature being "above", "above" or "above" a second feature may mean that the first feature is directly above or obliquely above the second feature, or simply means that the first feature is higher in level than the second feature. A first feature being "below", "below" or "below" a second feature may mean that the first feature is directly below or obliquely below the second feature, or simply means that the first feature is lower in level than the second feature.
[0074] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.
Claims
1. A method for detecting defects in an AC filter, characterized in that: The method comprises: Acquire an image of the AC filter to be tested; Inputting the AC filter image to be inspected into a trained defect detection model to perform defect detection and obtain a detection result; Among them, the defect detection model includes a feature extraction module, a feature fusion module and a defect detection module. The feature extraction module is used to extract features of the AC filter image to be detected to obtain features of N different scales, where N is an integer greater than or equal to 2; the feature fusion module is used to enhance features of at least one scale, and use affine transformation to fuse the enhanced features and the unenhanced features; the defect detection module is used to perform defect detection based on the fused features.
2. The method for detecting defects of an AC filter according to claim 1, characterized in that: The training process of the defect detection model includes: Acquire a number of positive sample images and a number of negative sample images of multiple types of defects of AC filters; Randomly dividing the positive sample images and the negative sample images into a training set and a test set according to a first preset ratio, wherein the first preset ratio is greater than 1; The defect detection model is constructed, and the defect detection model is trained and tested using the training set and the test set to obtain the trained defect detection model.
3. The method for detecting defects of an AC filter according to claim 1 or 2, characterized in that: The feature fusion module includes a spatial / channel interactive self-attention submodule and a cross-scale fusion submodule; the feature fusion module enhances features of at least one scale, and fuses the enhanced features with the unenhanced features by using an affine transformation, including: The spatial / channel interactive self-attention submodule enhances the smallest scale feature among N scale features through spatial self-attention and channel self-attention respectively to obtain enhanced features, wherein the number of self-attention heads used by the spatial self-attention and the channel self-attention is different; The cross-scale fusion submodule fuses the enhanced features and the unenhanced features by means of affine transformation.
4. The method for detecting defects of an AC filter according to claim 3, characterized in that: The spatial / channel interactive self-attention submodule includes a feature mapping unit, a multi-head division unit, a spatial self-attention unit, a channel self-attention unit and a first splicing unit; the spatial / channel interactive self-attention submodule enhances the smallest scale feature among N scale features through spatial self-attention and channel self-attention, respectively, including: The feature mapping unit maps the minimum scale feature into a query feature, a key feature and a value feature using a preset convolution kernel; The multi-head division unit groups the query features, key features, and value features according to a second preset ratio of attention heads to obtain a first group and a second group, wherein the second preset ratio is not equal to 1; The spatial self-attention unit obtains a first enhancer feature according to the query feature, the key feature and the value feature of the first group based on the spatial self-attention; The channel self-attention unit obtains a second enhancer feature according to the query feature, key feature and value feature of the second group based on the channel self-attention; The first splicing unit splices the first enhancer feature and the second enhancer feature to obtain the enhancement feature.
5. The method for detecting defects of an AC filter according to claim 4, characterized in that: The spatial self-attention unit obtains the first enhancer feature by the following formula: in, represents the enhancer feature of the i-th attention head in the first group, represents the normalization function, represents the cosine similarity function, T represents the rank transformation, , , They respectively represent the query features, key features, and value features of the i-th attention head in the first group after the preset size window shift operation is performed in space, represents the constant coefficient, B represents the relative position bias, represents the first enhancer feature, represents 1×1 convolution, inverse window shift and shape transformation operations, represents the channel splicing function, Represents the number of attention heads corresponding to the first group.
6. The method for detecting defects of an AC filter according to claim 4, characterized in that: The channel self-attention unit obtains the second enhancer feature by the following formula: in, represents the enhancer feature of the i-th attention head in the second group, represents the normalization function, represents the cosine similarity function, T represents the rank transformation, , , denote the query feature, key feature, and value feature of the i-th attention head in the second group, respectively. represents the constant coefficient, represents the second enhancer feature, represents a 1×1 convolution and shape transformation operation, represents the channel splicing function, represents the number of attention heads corresponding to the first group, and L represents the total number of attention heads.
7. The method for detecting defects of an AC filter according to claim 4, characterized in that: The first splicing unit obtains the enhanced feature by the following formula: in, represents the enhanced feature, represents 3×3 convolution, represents the channel splicing function, represents the first enhancer feature, Represents the second enhancer feature.
8. The method for detecting defects of an AC filter according to claim 4, characterized in that: The cross-scale fusion submodule includes a second splicing unit, N-1 first affine fusion units, a second affine fusion unit and a third affine fusion unit, the N-1 first affine fusion units are connected in sequence and correspond one-to-one to the N-1 features except the minimum scale feature, the first first affine fusion unit is used to fuse the enhanced feature and the feature of the corresponding scale, the first affine fusion unit except the first first affine fusion unit is used to fuse the feature output by the previous first affine fusion unit and the feature of the corresponding scale, the second affine fusion unit is used to fuse the features output by the last two first affine fusion units, and the third affine fusion unit is used to fuse the enhanced feature and the feature output by the second affine fusion unit; The first affine fusion unit, the second affine fusion unit and the third affine fusion unit all use the following formula to combine the two features to be combined , Perform fusion processing: in, represents 3×3 convolution, represents 1×1 convolution, represents the learned reflection transformation coefficient, represents the learned shift coefficient, Indicates that the convolution kernel size is 3×3 for learning The convolution of Indicates that the convolution kernel size is 3×3 for learning The convolution of The corresponding scale is smaller than The corresponding scale, represents the initial fusion feature, represents the non-parametric instance normalization function, Representation characteristics and Features The fusion characteristics of The second splicing unit is used to splice the fusion features output by the last first affine fusion unit, the second affine fusion unit and the third affine fusion unit to obtain the final fusion features.
9. The method for detecting defects of an AC filter according to claim 1 or 2, characterized in that: The feature extraction module adopts the EfficientViT model, and the defect detection module adopts the RT-DETR network.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for detecting defects of an AC filter according to any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Multi-modal medical image fusion method based on significant information enhancement
CN117333411A
PCB defect detection method based on improved YOLO v5 algorithm
CN117351288A
PCB surface defect detection method and system based on RT-DETR detector
CN118822989A
Automatic substrate glass surface defect detection method and system based on machine vision
CN119006469A
Mini LED defect detection method, electronic equipment and medium
CN119090851A
Cited By
GIS basin-type insulator ultrasonic flaw detection risk quantification method and device and storage medium
CN120577408A