Attention-aligned domain-adaptive complex weather insulator defect detection method

Through the domain adaptive method of attention-aligned domain offset problem of insulator defect detection in severe weather, it realizes accurate detection under a variety of complex weather conditions, reduces calculation costs and labeling requirements, and improves detection accuracy and model generalization capabilities.

CN119723238APending Publication Date: 2025-03-28NANJING INST OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411704799.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-26
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

In severe weather conditions, existing insulator defect detection technologies are difficult to achieve accurate detection, mainly because the model is trained on sunny images, resulting in domain offset problems, and traditional methods require additional labeling data and high computing costs.

Method used

The domain adaptive method of attention alignment is adopted, and the domain adaptive module is constructed, including the domain classifier and the channel attention submodule, and the YOLO model is used to train on sunny data, calculate the attention alignment loss, and perform backpropagation iterative output of the best weight model, which is suitable for insulator defect detection in complex weather.

Benefits of technology

It realizes accurate insulator defect detection under a variety of complex weather conditions, reduces calculation costs, is suitable for real-time applications, and does not require additional data labeling, improving the generalization ability and detection accuracy of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119723238A_ABST
    Figure CN119723238A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of power system inspection, in particular to an attention-alignment domain-adaptive complex weather insulator defect detection method, which designs an attention-alignment-assisted domain classifier for a YOLO network, and performs feature alignment on a source domain (sunny day) and a plurality of target domains (foggy day, rainy day and snowy day) to obtain an attention-alignment-assisted domain-adaptive complex weather insulator defect detection result. And adaptation to different complex weather conditions is realized. The attention alignment mechanism utilizes potential feature information of a domain classifier to accurately align feature distribution of a source domain and a target domain, and the insulator defect detection precision of the model under low-visibility conditions such as foggy days, rainy days and snowy days is remarkably improved. The technology supports multiple YOLO versions, can adapt to diversified severe weather environments without marking data of complex weather images, and keeps the reasoning speed of the original YOLO at the same time.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0002] Insulators are core components of power transmission systems, responsible for supporting and fixing conductors, and providing electrical insulation between conductive parts to prevent current leakage and short circuit accidents. Insulator defects may lead to serious power transmission accidents and power outages, threatening the safety and stability of the entire power grid. Therefore, timely and accurate detection of the health status of insulators is crucial to maintaining the reliable operation of the power grid.

[0003] With the advancement of technology, especially the combination of drones and target detection technology, insulator inspection has become more efficient and safer. Under sunny conditions, due to the abundance of images and corresponding annotation data, advanced target detection algorithms such as YOLO can efficiently identify insulator defects in real time. However, complex and severe weather (such as fog, rain, and snow) poses major challenges to the detection task. In low-visibility weather conditions, even advanced detection technologies will have difficulty coping due to a significant drop in performance. This is because the model is usually trained on sunny images (source domain), while the feature distribution of images in severe weather (target domain) is significantly different from that of sunny images, resulting in a domain shift problem.

[0004] To address this problem, deep dehazing, deraining, and desnowing algorithms can improve image clarity and target detection accuracy, but they significantly increase computational costs and are not suitable for real-time applications. Although directly training models with datasets of severe weather can improve detection performance, it is difficult to collect and annotate these data. In addition, traditional domain adaptation methods based on adversarial learning have some effect on feature alignment, but they also have shortcomings. First, they rely too much on domain classifiers and use domain classification loss as the only optimization target. When the performance of the domain classifier is insufficient, feature alignment will be inaccurate. Intermediate features generated by domain classifiers are also often ignored. These features are used as high-level representations between the source domain and the target domain, and their use helps enhance the domain adaptation capabilities of the model.

[0005] Therefore, it is of great significance to design an insulator defect detection method that can adapt to severe weather and does not rely on additional annotation data. Summary of the invention

[0006] The main purpose of the present invention is to provide an attention-aligned domain-adaptive complex weather insulator defect detection method to effectively solve the above-mentioned problems mentioned in the background technology.

[0007] The technical solution of the present invention is as follows:

[0008] A domain adaptive complex weather insulator defect detection method based on attention alignment is proposed. The method includes the following steps:

[0009] S1. Obtain a public sunny insulator dataset and divide it into a training set and a test set in a ratio of 8:2. Use a weather generation algorithm to add fog, rain, and snow to the sunny insulator dataset to construct the corresponding complex weather insulator dataset. Use the labeled sunny insulator dataset as the source domain and the unlabeled complex weather insulator dataset as the target domain.

[0010] S2. construct a domain adaptation module, wherein the domain adaptation module includes a domain classifier and a channel attention submodule;

[0011] S3, use the source domain image and the corresponding target domain image to train the YOLO model, use the Backbone part of YOLO to extract image features of three different scales and send them to three domain adaptation modules respectively;

[0012] S4. Calculate the attention alignment loss to evaluate and constrain the difference between the attention maps of the source domain and the target domain at the same spatial position;

[0013] S5. Calculate the detection loss of YOLO using the sunny image and its labeled data.

[0014] S6. Add YOLO's detection loss, domain classification loss, and attention alignment loss to get the total loss, perform back propagation, and iteratively output the best weight model.

[0015] S7. Use the trained YOLO model to detect insulator defects under complex weather conditions.

[0016] A further improvement of the present invention is that the weather generation algorithm in S1 includes the synthesis of fog, rain and snow;

[0017] The synthesis of the fog adopts the synthetic fog algorithm, and the specific formula is:

[0018] I(x)=J(x)t(x)+L(1-t(x))

[0019]

[0020] Among them, I(x) represents the synthetic fog image, J(x) represents the original fog-free image, L is the atmospheric brightness, which is between 0 and 1, 0 represents pure black, 1 represents pure white, t(x) is the transmittance, (w c ,w h ) represents the fog center, s represents the fog size, i.e., the square root of the maximum value of the image width and height, and D represents the fog thickness coefficient;

[0021] The rain synthesis is based on the TPSeNCE framework and introduces triangular probability similarity loss and semantic noise contrast estimation strategy to generate rainy day images, wherein the generation of rainy day images is based on generative adversarial networks and contrastive learning, and the specific formula is:

[0022]

[0023] Among them, X is a clear image, Y is a real rainy day image, Z is a generated rainy day image, D represents the output probability matrix of the discriminator, and H and W are the height and width of the matrix;

[0024] The snow synthesis uses the TPSeNCE framework and introduces triangular probabilistic similarity loss and semantic noise contrast estimation strategy to generate snowy images.

[0025] A further improvement of the present invention is that the domain classifier in S2 uses statistical information of image features to determine whether the features are from the source domain or the target domain. The domain classifier takes maximizing the distinguishability between domains as the goal and optimizes by minimizing the adversarial training loss function. The specific formula of the adversarial training loss function is:

[0026]

[0027] in, represents the domain label of the i-th training image, represents the predicted probability of the m-th level domain classifier at position (x, y) in the feature map of the ith image.

[0028] A further improvement of the present invention is that the channel attention submodule in S2 dynamically adjusts the weight of each channel by integrating the global average pooling information and the global maximum pooling information, normalizes the result through the Sigmoid activation function, outputs the attention weight of each channel, adds the weighted results of the feature maps obtained by the global average pooling and the global maximum pooling, and outputs the final attention map.

[0029] A further improvement of the present invention is that the specific content of S4 is: introducing a channel attention submodule, generating attention maps for the source domain and the target domain respectively, and using the mean square error to quantify the difference in the attention maps between the two domains. The specific formula of the loss function is:

[0030]

[0031] in, represents the kth attention map generated by the source domain mth level domain classifier for the ith image, represents the attention map of the corresponding i-th image in the target domain, d m,k denotes the total number of elements in the k-th attention map of the m-th domain classifier.

[0032] A further improvement of the present invention is that the detection loss of the YOLO model in S5 includes a bounding box loss, a confidence loss and a classification loss.

[0033] A further improvement of the present invention is that the total loss in S6 is expressed as:

[0034]

[0035] in, is the detection loss of the YOLO model, λ1 and λ2 represent the weights of the domain adversarial loss and the attention alignment loss, respectively.

[0036] A further improvement of the present invention is that the domain adaptation module is connected to YOLO only during the training phase, ensuring that the model maintains the reasoning speed of the original YOLO while adapting to complex weather.

[0037] The technical effects of the present invention are as follows:

[0038] (1) Adaptability to various complex weather conditions: The present invention uses complex weather conditions such as foggy days, rainy days, and snowy days as target domains for joint training, so that the model can achieve accurate insulator defect detection in different severe weather conditions, effectively solving the detection problem in low visibility environments;

[0039] (2) Reduce computational cost and be suitable for real-time detection: Different from traditional deep defogging, deraining, and desnowing algorithms, the present invention realizes feature alignment through domain adaptation instead of frame-by-frame image processing, thus achieving efficient detection in complex weather conditions and avoiding additional computational overhead, which is suitable for real-time application scenarios;

[0040] (3) No need for additional annotation data: The present invention does not require complex weather annotation data other than sunny days, which greatly reduces the annotation cost and makes the technology more feasible in practical applications;

[0041] (4) Optimized feature alignment strategy: This paper introduces an attention alignment mechanism to achieve fine-grained feature alignment between the source domain and the target domain by utilizing the intermediate features of the domain classifier, thereby improving the generalization ability of the model and the detection accuracy of the target domain, making up for the shortcomings of traditional adversarial learning methods;

[0042] (5) Support for multiple YOLO versions and easy deployment: The domain adaptive detection method of the present invention is compatible with multiple YOLO versions and can be easily integrated into the existing detection system while maintaining the original YOLO reasoning speed, which is convenient for promotion and application. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:

[0044] Figure 1 A schematic diagram of detailed steps of an attention-aligned domain-adaptive complex weather insulator defect detection method of the present invention;

[0045] Figure 2 A network structure diagram of an attention-aligned domain-adaptive complex weather insulator defect detection method of the present invention;

[0046] Figure 3 Detailed diagram of the attention alignment method;

[0047] Figure 4 It is a schematic diagram of actual detection results of an attention-aligned domain-adaptive complex weather insulator defect detection method of the present invention under foggy conditions;

[0048] Figure 5 It is a schematic diagram of actual detection results of an attention-aligned domain-adaptive complex-weather insulator defect detection method under rainy conditions according to the present invention;

[0049] Figure 6 It is a schematic diagram of actual detection results of an attention-aligned domain-adaptive complex-weather insulator defect detection method of the present invention under snowy conditions. DETAILED DESCRIPTION

[0050] The present invention aims to propose an attention-aligned domain-adaptive complex weather insulator defect detection method. An attention-aligned assisted domain classifier is designed for the YOLO network. By aligning the features in the source domain (sunny day) and multiple target domains (foggy day, rainy day, snowy day), adaptation to different complex weather conditions is achieved. The attention alignment mechanism uses the potential feature information of the domain classifier to accurately align the feature distribution of the source domain and the target domain, significantly improving the model's insulator defect detection accuracy under low visibility conditions such as foggy days, rainy days, and snowy days. This technology supports multiple YOLO versions and can adapt to a variety of severe weather environments without the need for labeled data for complex weather images, while maintaining the inference speed of the original YOLO.

[0051] Embodiment 1:

[0052] This embodiment proposes an attention-aligned domain adaptive complex weather insulator defect detection method, specifically, Figure 1 As shown, the specific steps include:

[0053] S1: Obtain a public sunny insulator dataset and divide it into a training set and a test set in a ratio of 8:2. Use a weather generation algorithm to add fog, rain, and snow to the sunny insulator dataset to construct the corresponding complex weather insulator dataset. Take the labeled sunny insulator dataset as the source domain and the unlabeled complex weather insulator dataset as the target domain.

[0054] In this embodiment, the complex weather generation algorithm includes the synthesis of foggy days, rainy days and snowy days. The foggy day synthesis adopts the synthetic fog algorithm to generate a foggy day image through the following formula:

[0055] I(x)=J(x)t(x)+L(1-t(x));

[0056] Among them, I(x) represents the synthetic fog image, J(x) represents the original fog-free image, and L is the atmospheric brightness. This parameter affects the overall brightness of the image. Its value is usually between 0 and 1, with 0 representing complete black and 1 representing pure white. t(x) is the transmittance, which describes the degree of light attenuation from the scene point to the observer. The calculation formula is:

[0057]

[0058] Among them, -0.04 is the selected fixed parameter. (w c ,w h ) represents the center of fog. s represents the size of fog, which is the square root of the maximum value of the image width and height. D represents the fog thickness coefficient. The larger D is, the smaller t(x) is, the thicker the fog is, and the smaller the transmittance is; the smaller D is, the larger t(x) is, the thinner the fog is, and the greater the transmittance is.

[0059] In this embodiment, rainy day synthesis is based on the TPSeNCE framework, and rainy day image generation introduces the triangular probabilistic similarity (TPS) loss and semantic noise contrast estimation (SeNCE) strategy. The generated rainy day image simulates the real rainy day effect by controlling the number, distribution and transparency of raindrops. The rainy day generation formula is based on the generative adversarial network (GAN) and contrastive learning, and the specific formula is:

[0060]

[0061] Among them, X is a clear image, Y is a real rainy day image, Z is a generated rainy day image, D represents the output probability matrix of the discriminator, and H and W are the height and width of the matrix.

[0062] In this embodiment, snow synthesis uses the TPSeNCE framework to generate snow images, and generates realistic snow effects by adjusting the shape, brightness and density of snowflakes. Similar to rainy day generation, snow generation also uses the triangular probabilistic similarity (TPS) loss and semantic noise contrast estimation (SeNCE) strategy to optimize the generated snow effect and avoid artifacts.

[0063] In particular, sunny images have labeled data, including the category labels of the targets and the normalized bounding box parameters, while foggy, rainy, and snowy images have no labeled data.

[0064] S2: construct a domain adaptation module, wherein the domain adaptation module includes a domain classifier and a channel attention submodule.

[0065] In this embodiment, the network structure diagram is as follows: Figure 2 As shown, the domain classifier uses statistical information of image features to determine whether the features are from the source domain or the target domain. The goal of the domain classifier is to maximize the distinguishability between domains, thereby improving the generalization ability of the model between the source domain and the target domain. Specifically, the domain classifier is optimized by minimizing the following adversarial training loss function:

[0066]

[0067] in, Represents the domain label of the i-th training image. represents the predicted probability of the m-th level domain classifier at position (x, y) in the feature map of the ith image.

[0068] In this embodiment, the channel attention module is a feature re-weighting mechanism that dynamically adjusts the weight of each channel by integrating the information of global average pooling and global maximum pooling, thereby enhancing the model's responsiveness to key features. This module uses two different types of pooling techniques to capture more comprehensive statistical information and improve the representativeness of features. Finally, the results are normalized by the Sigmoid activation function to generate the attention weights for each channel. The weighted results of the feature maps obtained by global average pooling and global maximum pooling are added to form the final attention map.

[0069] The specific process is as follows:

[0070] Global average pooling (AvgPool) and global maximum pooling (MaxPool): These two pooling operations process the input feature map x separately. The global average pooling operation calculates the average value of each channel in the feature map to capture background and general feature information; the global maximum pooling operation extracts the maximum value of each channel to highlight the most significant features. The results of these two pooling operations are processed separately to extract their respective information.

[0071] Compression and activation: The pooled result first passes through a dimension reduction convolution layer (fc1), which reduces the number of input channels to reduce computational complexity and improve efficiency. Then, the ReLU activation function is used to increase nonlinearity to help learn more complex feature relationships.

[0072] Dimensionality upscaling and reweighting: The features activated by ReLU are then passed through a dimension upscaling convolution layer (fc2) to restore the number of channels from the value after dimensionality reduction to the number of channels of the original input. This step is to readjust the weight of each channel.

[0073] Generate attention map: Finally, the results of the above processing are normalized by the Sigmoid activation function to generate the attention weight of each channel. The weighted results of the feature maps obtained by global average pooling and global maximum pooling are added together to form the final attention map.

[0074] Apply attention map: This attention map is multiplied by the original input feature map x to adjust the importance of input features by channel. In this way, the network can pay more attention to the features that are more important to the current task, improving the recognition accuracy and robustness of the model.

[0075] S3, use the source domain image and the corresponding target domain image to train the YOLO model, use the Backbone part of YOLO to extract image features of three different scales and send them to three domain adaptation modules respectively;

[0076] In this embodiment, the source domain image and the corresponding target domain image are used to train the YOLO model. In this step, the Backbone part of the YOLO model is responsible for extracting image features from the source domain and the target domain. In particular, the Backbone part extracts image features at three different scales, which correspond to the outputs of different depth levels of the network. The feature maps of each scale are fed into a specially designed domain adaptation module. The task of these modules is to adjust and optimize the feature maps to reduce the difference in feature distribution between the source domain and the target domain. During the training process, these domain adaptation modules use adversarial training methods to enhance the generalization ability of the model. This training strategy prompts the model to generate domain-invariant feature representations, thereby improving detection performance under complex weather conditions. In this way, the domain adaptation module helps the model learn how to effectively identify and locate insulators under different environmental conditions, especially when visually affected by complex weather.

[0077] S4. Calculate the attention alignment loss to evaluate and constrain the difference between the attention maps of the source domain and the target domain at the same spatial position;

[0078] In this embodiment, the explicit attention alignment method is as follows Figure 3 As shown in Figure 2, the attention alignment loss quantifies and limits the difference between the attention maps of the source and target domains, aiming to force the model to establish similar attention distributions in the two domains.

[0079] In this embodiment, the attention alignment loss is specifically used to evaluate and minimize the difference between the attention maps of the source domain and the target domain at the same spatial position in the domain classifier. By introducing the channel attention module, attention maps are generated for the source domain and the target domain respectively. These attention maps reflect the response strength of the model to the input features of the respective domains, providing a high-level representation that captures the importance of features. Specifically, this loss function uses the mean square error (MSE) to quantify the difference in attention maps between the two domains, and the formula is expressed as:

[0080]

[0081] in, represents the kth attention map generated by the mth level domain classifier in the source domain for the ith image. represents the attention map of the corresponding i-th image in the target domain. m,k denotes the total number of elements in the k-th attention map of the m-th domain classifier.

[0082] This attention alignment method can be flexibly inserted into domain adversarial training as a plug-and-play module. The module dynamically generates similar attention distributions based on the data features of the source and target domains, directly guiding the learning process of the domain classifier. It also enhances the feature extraction ability of the domain classifier network and alleviates its mismatch with the backbone network's capabilities. In addition, the design of the attention alignment loss provides a clear optimization direction beyond the domain classification loss, potentially alleviating some optimization issues brought about by domain adversarial training.

[0083] S5. Calculate the detection loss of YOLO using the sunny image and its labeled data.

[0084] In this embodiment, the detection loss of the YOLO model mainly includes three parts: bounding box loss, confidence loss and classification loss.

[0085] Bounding box loss: This part of the loss calculates the deviation between the predicted bounding box and the actual labeled bounding box. YOLO usually uses IOU (intersection over union) or more complex variants such as GIOU and CIOU to evaluate the degree of alignment between the predicted box and the true box.

[0086] Confidence loss: Evaluates the confidence of the model in predicting whether the bounding box contains an object and compares it with the actual situation. If the predicted box correctly contains the object, the loss value is small; conversely, if the predicted box is incorrectly marked as containing an object or fails to identify the real object, the loss value increases.

[0087] Classification loss: If the predicted box correctly identifies the object, this part of the loss calculates the error between the predicted category and the actual category. This is usually implemented through cross entropy loss, which evaluates the difference between the model's predicted probability for each category and the actual label.

[0088] S6. Add YOLO's detection loss, domain classification loss, and attention alignment loss to get the total loss, perform backpropagation, and iteratively output the optimal weight model.

[0089] In this embodiment, the total loss is obtained by adding the detection loss, domain adversarial loss and attention alignment loss of YOLO. The total loss expression can be expressed as:

[0090]

[0091] Among them, λ1 and λ2 represent the weights of domain adversarial loss and attention alignment loss, respectively.

[0092] S7. Use the trained YOLO model to detect insulator defects under complex weather conditions.

[0093] In this embodiment, the domain adaptation module is connected to YOLO only during the training phase to ensure that the model maintains the reasoning speed of the original YOLO while adapting to complex weather.

[0094] In this embodiment, the actual application effect of the proposed insulator defect detection method under complex weather conditions is as follows: Figure 4 , Figure 5 and Figure 6 As shown. Among them, Figure 4 The test results in foggy environment are shown. Figure 5 The test results in rainy weather are shown. Figure 6 The test results in a snowy environment are shown.

[0095] The colored boxes indicate the category and confidence of the test results: the green box indicates the detected "normal insulator", the blue box indicates the "defective insulator", and the red box is used to identify the specific fault location of the defective insulator. The confidence value next to the box (such as 0.93) indicates the confidence of the model in the test result. The higher the value, the more certain the model is in its judgment result.

[0096] By comparing the original YOLO model with the AA-YOLO model obtained by the method proposed in the present invention, it can be seen that the YOLO model trained with sunny data performs poorly under complex weather conditions. For example, the original YOLO model mistakenly identifies defective insulators as normal insulators, and the phenomenon of missed detection is obvious. However, the method of the present invention significantly improves the accuracy and confidence of detection under severe weather conditions, effectively reduces missed detection and false detection, and verifies its adaptability and robustness under complex weather conditions.

[0097] Embodiment 2:

[0098] This embodiment provides an electronic device, including: a processor and a memory, wherein the memory stores a computer program that can be called by the processor; the processor executes the above-mentioned attention-aligned domain-adaptive complex weather insulator defect detection method by calling the computer program stored in the memory.

[0099] The electronic device may have relatively large differences due to different configurations or performances, and may include one or more processors (Central Processing Units, CPU) and one or more memories, wherein the memory stores at least one computer program, and the computer program is loaded and executed by the processor to implement an attention-aligned domain-adaptive complex weather insulator defect detection method provided by the above method embodiment. The electronic device may also include other components for implementing the functions of the device. For example, the electronic device may also have components such as a wired or wireless network interface and an input / output interface to input and output data. This embodiment will not be described in detail here.

[0100] Those skilled in the art know that the present invention can be implemented as a system, method or computer program product. Therefore, the present disclosure can be specifically implemented in the following forms, namely: it can be complete hardware, it can be complete software (including firmware, resident software, microcode, etc.), and it can also be a combination of hardware and software, which is generally referred to as "circuit", "module" or "system" herein. In addition, in some embodiments, the present invention can also be implemented in the form of a computer program product in one or more computer-readable media, and the computer-readable medium contains computer-readable program code.

[0101] Any combination of one or more computer-readable media may be used. A computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. More specific examples of computer-readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.

[0102] The present invention is described with reference to flowcharts and block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process or block in the flowchart and block diagram, as well as the combination of processes and blocks in the flowchart or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts. Figure 1 Process or multiple processes and boxes Figure 1A device that provides the functions specified in a block or multiple blocks.

[0103] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 Process or multiple processes and boxes Figure 1 A step that specifies a function in one or more boxes.

[0104] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the enlightenment of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the purpose of the present invention and the claims, which all fall within the protection of the present invention.

Claims

1. A domain adaptive complex weather insulator defect detection method with attention alignment, characterized in that: The specific steps include: S1. Obtain a public sunny insulator dataset and divide it into a training set and a test set in a ratio of 8:

2. Use a weather generation algorithm to add fog, rain, and snow to the sunny insulator dataset to construct the corresponding complex weather insulator dataset. Use the labeled sunny insulator dataset as the source domain and the unlabeled complex weather insulator dataset as the target domain. S2. construct a domain adaptation module, wherein the domain adaptation module includes a domain classifier and a channel attention submodule; S3, use the source domain image and the corresponding target domain image to train the YOLO model, use the Backbone part of YOLO to extract image features of three different scales and send them to three domain adaptation modules respectively; S4. Calculate the attention alignment loss to evaluate and constrain the difference between the attention maps of the source domain and the target domain at the same spatial position; S5. Calculate the detection loss of YOLO using the sunny image and its labeled data. S6. Add YOLO's detection loss, domain classification loss, and attention alignment loss to get the total loss, perform back propagation, and iteratively output the best weight model. S7. Use the trained YOLO model to detect insulator defects under complex weather conditions.

2. The attention-aligned domain adaptive complex weather insulator defect detection method according to claim 1 is characterized in that: The weather generation algorithm in S1 includes the synthesis of fog, rain and snow; The synthesis of the fog adopts the synthetic fog algorithm, and the specific formula is: I(x)=J(x)t(x)+L(1-t(x)) Among them, I(x) represents the synthetic fog image, J(x) represents the original fog-free image, L is the atmospheric brightness, which is between 0 and 1, 0 represents pure black, 1 represents pure white, t(x) is the transmittance, (w c ,w h ) represents the fog center, s represents the fog size, i.e., the square root of the maximum value of the image width and height, and D represents the fog thickness coefficient; The rain synthesis is based on the TPSeNCE framework and introduces triangular probability similarity loss and semantic noise contrast estimation strategy to generate rainy day images, wherein the generation of rainy day images is based on generative adversarial networks and contrastive learning, and the specific formula is: Among them, X is a clear image, Y is a real rainy day image, Z is a generated rainy day image, D represents the output probability matrix of the discriminator, and H and W are the height and width of the matrix; The snow synthesis uses the TPSeNCE framework and introduces triangular probabilistic similarity loss and semantic noise contrast estimation strategy to generate snowy images.

3. The attention-aligned domain-adaptive complex weather insulator defect detection method according to claim 2, characterized in that: The domain classifier in S2 uses statistical information of image features to determine whether the features come from the source domain or the target domain. The domain classifier aims to maximize the distinguishability between domains and optimizes by minimizing the adversarial training loss function. The specific formula of the adversarial training loss function is: in, represents the domain label of the i-th training image, represents the predicted probability of the m-th level domain classifier at position (x, y) in the feature map of the ith image.

4. The attention-aligned domain adaptive complex weather insulator defect detection method according to claim 3 is characterized in that: The channel attention submodule in S2 dynamically adjusts the weight of each channel by integrating the global average pooling information and the global maximum pooling information, normalizes the result through the Sigmoid activation function, outputs the attention weight of each channel, adds the weighted results of the feature maps obtained by the global average pooling and the global maximum pooling, and outputs the final attention map.

5. The attention-aligned domain adaptive complex weather insulator defect detection method according to claim 4, characterized in that: The specific content of S4 is: introducing a channel attention submodule, generating attention maps for the source domain and the target domain respectively, and using mean square error to quantify the difference in attention maps between the two domains. The specific formula of the loss function is: in, represents the kth attention map generated by the source domain mth level domain classifier for the ith image, represents the attention map of the corresponding i-th image in the target domain, d m,k represents the total number of elements in the k-th attention map of the m-th domain classifier.

6. The attention-aligned domain-adaptive complex weather insulator defect detection method according to claim 5, characterized in that: The detection loss of the YOLO model in S5 includes bounding box loss, confidence loss and classification loss.

7. The attention-aligned domain adaptive complex weather insulator defect detection method according to claim 6, characterized in that: The total loss in S6 is expressed as: in, is the detection loss of the YOLO model, λ1 and λ2 represent the weights of the domain adversarial loss and the attention alignment loss, respectively.

8. The attention-aligned domain-adaptive complex weather insulator defect detection method according to claim 7, characterized in that: The domain adaptation module is only connected to YOLO during the training phase, ensuring that the model maintains the original YOLO reasoning speed while adapting to complex weather.