Power terminal weed detection method, device and equipment and storage medium

By using the weed feature extraction model and Transformer model in the weed detection at power terminals, long residual connection and parallel normalization are performed, the problem of inaccurate detection in the prior art is solved, and higher detection accuracy and robustness are achieved.

CN120375051APending Publication Date: 2025-07-25GUANGZHOU POWER SUPPLY BUREAU GUANGDONG POWER GRID CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510440538.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-09
Publication Date
2025-07-25

AI Technical Summary

Technical Problem

The prior art has the problem of inaccurate detection in the weed detection of power terminals. It is mainly because traditional machine learning methods cannot effectively extract weed image features, resulting in insufficient detection accuracy, and the limitations of residual connection design in the existing Transformer model lead to the loss of key feature information.

Method used

The weed feature extraction model is used for long residual connection and parallel normalization processing, and feature extraction is performed through multiple convolutional layers, normalization layers and path discarding layers. The encoder of the Transformer model is used for long residual connection and parallel normalization processing, ensuring that key features maintain importance and recognition during the processing process.

Benefits of technology

The weed recognition accuracy of the weed feature images is improved, the accuracy of weed detection at the power terminal is enhanced, the risk of overfitting is reduced, and the overall accuracy of the detection is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120375051A_ABST
    Figure CN120375051A_ABST
Patent Text Reader

Abstract

The invention discloses a power terminal weed detection method, device and equipment and a storage medium, and relates to the technical field of power equipment maintenance. According to the method, the feature information in the to-be-recognized weed image is acquired, and then the weed feature image is generated, so that information loss in the feature extraction process of the to-be-recognized weed image is avoided, and the integrity of feature expression is enhanced; according to the method, the importance and the identification degree of key features in the weed feature image can be kept in the processing process in a long residual connection processing mode, and the gradient explosion problem of a weed identification model in the weed feature image processing process is relieved; according to the method, the global mode and the local details can be paid attention to when the weed feature image is processed by the weed recognition model, and the over-fitting risk is reduced, so that the recognition accuracy of the weed recognition model on the weed feature image is improved, and the accuracy of power terminal weed detection is further improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of power equipment maintenance, and particularly relates to a method, device, equipment and storage medium for detecting weeds at a power terminal. Background Art

[0002] Power inspection is an important process to ensure the stable operation of power equipment and the safety of the power grid. In power inspection, the detection of weeds at the power terminal is an environment that cannot be ignored. Power equipment such as poles and lines are usually distributed therein. Weeds have the ability to grow and reproduce rapidly, and have a high dryness level and a low ignition point, making them prone to causing fires. Once a fire occurs near the power terminal site, it may quickly spread to the power equipment, resulting in serious equipment damage and power supply interruption, and even threatening the safety of the entire power system. In addition, the growth of weeds may come into contact with power lines, causing problems such as short circuits and induced currents. This will not only affect the power supply quality and stability of the power system, but may also cause equipment failures and safety accidents. Therefore, it is very necessary to detect the weeds at the power terminal.

[0003] Currently, for the method of detecting weeds at the power terminal, usually technical means such as color sets, wavelet methods, and Fourier descriptors are used to extract features such as the color, texture, and shape of the image, and traditional machine learning methods such as support vector machines (SVM) and K-nearest neighbor (KNN) clustering are combined to classify these features, so as to achieve the detection of weeds at the power terminal. However, due to the wide variety of weed species and their different growth states, simply using support vector machines and the like cannot accurately detect weeds. In addition, in the current existing technologies, the extraction of image characteristics is limited by the limitations of traditional machine learning methods and cannot extract the corresponding features well, thereby resulting in inaccurate detection of weeds. Therefore, there is an urgent need for a method, device, equipment and storage medium for detecting weeds at the power terminal to solve the defects of the existing technologies. Summary of the Invention

[0004] The present invention aims to provide a method, device, equipment and storage medium for detecting weeds at the power terminal to solve the above technical problems. By generating a weed feature image and performing long residual connection processing and parallel normalization processing on the weed feature image, the accuracy of detecting weeds at the power terminal is improved.

[0005] To solve the above technical problems, an embodiment of the present invention provides a method for detecting weeds at the power terminal, including:

[0006] Obtain an image of weeds to be recognized, a weed feature extraction model, and a weed recognition model;

[0007] Input the to-be-identified weed image into the weed feature extraction model, so that the weed feature extraction model extracts features from the to-be-identified weed image and generates an initial weed feature image;

[0008] Generate a weed feature image based on the initial weed feature image and the to-be-identified weed image;

[0009] Input the weed feature image into the weed recognition model, so that the weed recognition model performs long residual connection processing and parallel normalization processing on the weed feature image to obtain the detection result of the weeds on the power terminal.

[0010] It can be understood that, compared with the prior art, the present invention extracts features from the to-be-identified weed image through the weed feature extraction model, so as to obtain the feature information in the to-be-identified weed image. Then, a weed feature image is generated based on the initial weed feature image and the to-be-identified weed image, which can alleviate the vanishing gradient of the initial weed feature image, avoid information loss in the process of feature extraction of the to-be-identified weed image, enhance the integrity of feature expression, and thus improve the detection accuracy of the subsequent weed recognition model; the present invention performs long residual connection processing and parallel normalization processing on the weed feature image through the weed recognition model. The long residual connection processing ensures that the key features in the weed feature image can maintain their importance and recognition during the processing, alleviates the gradient explosion problem in the process of the weed recognition model processing the weed feature image. In the form of parallel normalization processing, when the weed recognition model processes the weed feature image, it can simultaneously pay attention to the global pattern and local details, reduce the risk of overfitting, and thus improve the recognition accuracy of the weed recognition model for the weed feature image, and further improve the accuracy of detecting weeds on the power terminal.

[0011] As a preferred solution, the step of inputting the to-be-identified weed image into the weed feature extraction model, so that the weed feature extraction model extracts features from the to-be-identified weed image and generates an initial weed feature image specifically includes:

[0012] The weed feature extraction model includes: a first convolutional layer, a grouped convolutional layer, a normalization layer, a first point convolutional layer, a second point convolutional layer, a path dropout layer, and a second convolutional layer;

[0013] Based on the first convolutional layer, convert the number of channels of the to-be-identified weed image and fix the spatial dimension of the to-be-identified weed image to generate a first weed feature image corresponding to the to-be-identified weed image;

[0014] Based on the grouped convolutional layer, perform depthwise separable convolution on the first weed feature image to generate a second weed feature image corresponding to the first weed feature image;

[0015] Arrange the second weed feature image and input the arranged second weed feature image into the normalization layer so that the normalization layer performs normalization processing on the arranged second weed feature image to generate a third weed feature image;

[0016] Based on the first point convolutional layer, perform feature dimension elevation and transformation on the third weed feature image to generate a fourth weed feature image;

[0017] Process the fourth weed feature image according to a preset activation function and input the fourth weed feature image processed by the preset activation function into the second point convolutional layer so that the second point convolutional layer converts the number of channels of the fourth weed feature image to generate a fifth weed feature image;

[0018] Arrange the fifth weed feature image and input the arranged fifth weed feature image into the path dropout layer so that the path dropout layer performs regularization processing on the fifth weed feature image to generate a sixth weed feature image;

[0019] Based on the second convolutional layer, convert the number of channels of the sixth weed feature image to generate an initial weed feature image.

[0020] This preferred solution realizes efficient and accurate feature extraction and transformation of the weed image to be recognized through multiple convolutional layers, normalization layers, and path dropout layers. Through the conversion of the number of channels and in the form of combining feature dimension elevation and transformation, it can accurately capture the features in the weed image to be recognized, thereby providing an accurate data basis for the subsequent weed recognition and detection of the weed recognition model, improving the recognition accuracy of the weed recognition model for the weed feature image, and further improving the accuracy of weed detection for power terminals.

[0021] As a preferred solution, generating a weed feature image according to the initial weed feature image and the weed image to be recognized specifically includes:

[0022] Perform residual connection on the initial weed feature image and the weed image to be recognized to generate a weed feature image corresponding to the initial weed feature image.

[0023] This preferred solution can alleviate the problem of gradient disappearance in the process of feature extraction of the weed feature extraction model for the weed image to be recognized by performing residual connection on the initial weed feature image and the weed image to be recognized, thereby avoiding information loss in the process of feature extraction of the weed image to be recognized, enhancing the integrity of feature expression, improving the detection accuracy of the subsequent weed recognition model, and further improving the accuracy of weed detection for power terminals.

[0024] As a preferred solution, inputting the weed feature image into the weed recognition model, so that the weed recognition model performs long residual connection processing and parallel normalization processing on the weed feature image to obtain the detection result of weeds on the power terminal, specifically including:

[0025] The weed recognition model includes: an input layer, an encoder, and a fully connected classification head;

[0026] Input the weed feature image into the input layer, so that the input layer preprocesses the weed feature image to generate an initial weed feature image block;

[0027] Input the initial weed feature image block into the encoder, and through the encoder perform long residual connection processing and parallel normalization processing on the initial weed feature image block to generate a weed feature vector;

[0028] Input the weed feature vector into the fully connected classification head, so that the fully connected classification head generates a weed classification result according to the weed feature vector;

[0029] Determine the detection result of weeds on the power terminal according to the weed classification result.

[0030] In this preferred solution, the input layer preprocesses the weed feature image, which can enhance the local features of the weed feature image and avoid misjudgment of the subsequent encoder caused by blurred global information; through long residual connection processing, the key features in the initial weed feature image block can still maintain their importance and recognition after multiple non-linear transformations, providing a longer return path for the gradient in the form of long residual connection, avoiding the problem of gradient disappearance or explosion of the weed recognition model; in the form of parallel normalization processing, when the weed recognition model processes the weed feature image, it can simultaneously focus on the global pattern and local details, reducing the risk of overfitting, thereby improving the recognition accuracy of the weed recognition model for the weed feature image, and further improving the accuracy of detecting weeds on the power terminal.

[0031] As a preferred solution, through the encoder performing long residual connection processing and parallel normalization processing on the initial weed feature image block to generate a weed feature vector, specifically including:

[0032] The encoder includes: a first parallel normalization layer, a multi-head self-attention layer, a second parallel normalization layer, and a feed-forward neural network layer;

[0033] Input the initial weed feature image block into the first parallel normalization layer, and based on the first parallel normalization layer perform parallel normalization processing on the initial weed feature image block to obtain a first weed feature image block;

[0034] Input the first weed feature image patch into the multi-head self-attention layer, and process the first weed feature image patch through the multi-head self-attention layer to obtain a second weed feature image patch;

[0035] Perform a residual connection process on the second weed feature image patch and the initial weed feature image patch to generate a third weed feature image patch;

[0036] Input the third weed feature image patch into the second parallel normalization layer, and perform parallel normalization processing on the third weed feature image patch based on the second parallel normalization layer to obtain a fourth weed feature image patch;

[0037] Input the fourth weed feature image patch into the feed-forward neural network layer, and process the fourth weed feature image patch through the feed-forward neural network layer to generate a fifth weed feature image patch;

[0038] Perform a long residual connection process on the fifth weed feature image patch, the third weed feature image patch, and the initial weed feature image patch according to a preset long residual connection processing method to generate a weed feature vector.

[0039] This preferred solution can enable the key features in the initial weed feature image patch to still maintain their importance and distinctiveness after multiple non-linear transformations through long residual connection processing, provide a longer reflux path for the gradient in the form of long residual connection, and avoid the problem of gradient disappearance or explosion of the weed recognition model; in the form of parallel normalization processing, when the weed recognition model processes the weed feature image, it can simultaneously focus on the global pattern and local details, reduce the risk of overfitting, thereby improving the recognition accuracy of the weed recognition model for the weed feature image, and further improving the accuracy of power terminal weed detection.

[0040] As a preferred solution, the parallel normalization processing of the initial weed feature image patch based on the first parallel normalization layer to obtain a first weed feature image patch specifically includes:

[0041] The first parallel normalization layer includes: a first layer normalization unit and a first instance normalization unit;

[0042] Input the initial weed feature image patch into the first layer normalization unit to enable the first layer normalization unit to perform normalization processing on the initial weed feature image patch to generate a sixth weed feature image patch;

[0043] Input the initial weed feature image patch into the first instance normalization unit to enable the first instance normalization unit to perform normalization processing on the initial weed feature image patch to generate a seventh weed feature image patch;

[0044] Perform residual connection processing on the sixth weed feature image block and the seventh weed feature image block to generate a first weed feature image block.

[0045] In this preferred solution, normalization processing is performed through two different normalization layers, and then residual connection is performed on the processing results, enabling the weed recognition model to capture both global sequence information and better handle the specificity of individual samples, thereby improving the recognition accuracy of weed recognition and further enhancing the accuracy of detecting weeds on power terminals.

[0046] As a preferred solution, performing long residual connection processing on the fifth weed feature image block, the third weed feature image block, and the initial weed feature image block according to the preset long residual connection processing method to generate a weed feature vector specifically includes:

[0047] Perform residual connection on the fifth weed feature image block, the third weed feature image block, and the initial weed feature image block to generate a weed feature vector.

[0048] In this preferred solution, by performing residual connection on the fifth weed feature image block, the third weed feature image block, and the initial weed feature image block, the information flow between different weed feature image blocks can be enhanced, and a longer return path for gradients can be provided, effectively alleviating the problem of gradient disappearance or explosion, thereby improving the robustness and accuracy of the weed recognition model and further enhancing the accuracy of detecting weeds on power terminals.

[0049] Correspondingly, an embodiment of the present invention provides a power terminal weed detection device, including: a data acquisition module, an initial weed feature image acquisition module, a weed feature image generation module, and a weed detection module;

[0050] Among them, the data acquisition module is used to acquire a weed image to be recognized, a weed feature extraction model, and a weed recognition model;

[0051] The initial weed feature image acquisition module is used to input the weed image to be recognized into the weed feature extraction model, so that the weed feature extraction model performs feature extraction on the weed image to be recognized and generates an initial weed feature image;

[0052] The weed feature image generation module is used to generate a weed feature image according to the initial weed feature image and the weed image to be recognized;

[0053] The weed detection module is used to input the weed feature image into the weed recognition model, so that the weed recognition model performs long residual connection processing and parallel normalization processing on the weed feature image to obtain a detection result of weeds on the power terminal.

[0054] It can be understood that, compared with the prior art, the present device extracts features from the to-be-recognized weed image through a weed feature extraction model, so as to obtain the feature information in the to-be-recognized weed image. Then, a weed feature image is generated based on the initial weed feature image and the to-be-recognized weed image, which can alleviate the vanishing gradient of the initial weed feature image, avoid information loss in the process of feature extraction of the to-be-recognized weed image, enhance the integrity of feature expression, and thus improve the detection accuracy of the subsequent weed recognition model. The device performs long residual connection processing and parallel normalization processing on the weed feature image through a weed recognition model. The long residual connection processing ensures that the key features in the weed feature image can maintain their importance and distinguishability during the processing, alleviating the gradient explosion problem in the process of the weed recognition model processing the weed feature image. In the form of parallel normalization processing, when the weed recognition model processes the weed feature image, it can simultaneously focus on the global pattern and local details, reducing the risk of overfitting, thereby improving the recognition accuracy of the weed recognition model for the weed feature image, and further improving the accuracy of detecting weeds on the power terminal.

[0055] Correspondingly, an embodiment of the present invention provides a terminal device, including:

[0056] One or more processors;

[0057] A memory, coupled to the processor, for storing one or more programs;

[0058] When the one or more programs are executed by the one or more processors, the one or more processors implement a method for detecting weeds on a power terminal as described above.

[0059] Correspondingly, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, and the computer program is executed by a processor to implement a method for detecting weeds on a power terminal as described above. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] Figure 1 : A flowchart of the steps of a method for detecting weeds on a power terminal provided by an embodiment of the present invention;

[0061] Figure 2 : A schematic diagram of the network architecture of an existing weed detection model provided by an embodiment of the present invention;

[0062] Figure 3 : A schematic diagram of the connection structure between a weed feature extraction model and a weed recognition model provided by an embodiment of the present invention;

[0063] Figure 4 : A schematic diagram of the specific structure of a weed feature extraction model provided by an embodiment of the present invention;

[0064] Figure 5 : A comparison chart of the average accuracy rate curves before and after model improvement provided by an embodiment of the present invention;

[0065] Figure 6 : A comparison chart of the training loss rate curves before and after model improvement provided by an embodiment of the present invention;

[0066] Figure 7 : A schematic structural diagram of a weed detection device for a power terminal provided by an embodiment of the present invention;

[0067] Among them, 201: Data acquisition module; 202: Initial weed feature image acquisition module; 203: Weed feature image generation module; 204: Weed detection module. Detailed implementation manners

[0068] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

[0069] Power inspection is an important link to ensure the stable operation of power equipment and the safety of the power grid. In power inspection, weed detection in the terminal field is an important link that cannot be ignored. Power terminal equipment such as poles and lines are usually distributed therein, and weeds have the ability to grow and reproduce rapidly, with a high degree of dryness and a low ignition point, making it easy to cause fires. Once a fire occurs near a power terminal, it may quickly spread to power equipment, resulting in serious equipment damage and power supply interruption, and even threatening the safety of the entire power system. In addition, the growth of weeds may come into contact with power lines, resulting in problems such as short circuits and induced currents. This will not only affect the power supply quality and stability of the power system, but may also cause equipment failures and safety accidents. By detecting weeds, the risk of damage to power equipment can be reduced and the reliability of the equipment can be improved. Traditional inspection methods mainly rely on manual labor, but with the continuous expansion of the power grid and the gradual expansion of the inspection scope, the workload of manual inspection has increased sharply, and the efficiency is difficult to improve. The rapid development of unmanned aerial vehicle (UAV) technology has brought new solutions to power inspection. UAVs have the advantages of strong terrain adaptability, fast response speed, and high inspection efficiency. They can easily cross complex terrains and quickly reach inspection targets. By carrying high-definition cameras and various sensors, UAVs can capture detailed image data of power equipment and provide accurate and real-time equipment status information for inspection personnel.

[0070] Therefore, based on the situation where such drones capture image data, those skilled in the prior art would also conduct research on weed identification through traditional algorithms. For example, they would use technical means such as color sets, wavelet methods, and Fourier descriptors to extract features such as the color, texture, and shape of the image, and classify these features by combining methods such as support vector machine (SVM) and K-nearest neighbor (KNN) clustering. Specifically, some technicians proposed combining Gabor wavelet (GW) and gradient field distribution (GFD) to extract the feature vectors of weed images. During the feature extraction process, this method first uses GW to enhance the directional features of the image, then executes GFD to generate the histogram gradient direction angle, and then generates the histogram envelope through other steps. Finally, a single-layer perceptron (SLP) model is used to train and classify the newly generated set of feature vectors. In order to overcome the problems of low accuracy and efficiency of traditional weed identification methods, some technicians also proposed a KNN weed identification method based on Haar wavelet transform. There are also technicians who use the gray-level co-occurrence matrix (GLCM) to extract the texture features of weeds, combine the principal component analysis method (PCA) to reduce the features to a 2D feature space, and finally complete the classification task by the support vector machine (SVM).

[0071] In addition, there are technicians who use the Transformer (Vision Transformer, VIT) model for weed detection. Please refer to Figure 2 , which is the schematic diagram of the network architecture of the existing weed detection model provided by the embodiments of the present invention. The existing weed detection model is usually the Transformer (Vision Transformer, VIT) model. As Figure 2 shown, the existing weed detection usually decomposes the image (i.e., Picture) into multiple sub-images (i.e., Figure 2 picture1, picture2, picture3... picture9 in), and inputs the sub-images into the image patch and embedding layer (i.e., the input layer, Figure 2 Linear Projection of Flattened Pathes in) of the Transformer model for image segmentation, embedding, and position encoding (i.e., Figure 2(Patch + Position Embedding) to obtain Embedded Patches. Then, the Embedded Patches are processed through the encoder of the Transformer model (i.e., the Transformer Encoder). Specifically, they are processed through the LN layer (Layer Normalization), the Multi-Head-Attention layer, the LN layer (Layer Normalization), and the MLP (feed-forward neural network layer). After that, the classification detection result is obtained through the fully-connected classification head (i.e., the MLP Head). However, in the existing weed detection models, the image is directly input into the Transformer model, and the design of the residual connection in the existing Transformer model has limitations, mainly limited after the Multi-Head-Attention and the MLP, which leads to the loss of key feature information of the input image. In addition, the existing single normalization method cannot well ensure the recognition and detection accuracy of the model. Therefore, the embodiments of the present invention provide a method, device, equipment, and storage medium for detecting weeds in power terminals to solve the above technical problems.

[0072] Embodiment 1

[0073] Please refer to Figure 1 which is the flowchart of the steps of a method for detecting weeds in power terminals provided by the embodiments of the present invention, including steps S101 to S104.

[0074] Step S101: Obtain the weed image to be recognized, the weed feature extraction model, and the weed recognition model.

[0075] Step S102: Input the weed image to be recognized into the weed feature extraction model so that the weed feature extraction model extracts features from the weed image to be recognized and generates an initial weed feature image.

[0076] In this embodiment, the step of inputting the weed image to be recognized into the weed feature extraction model so that the weed feature extraction model extracts features from the weed image to be recognized and generates an initial weed feature image specifically includes:

[0077] The weed feature extraction model includes: the first convolutional layer, the grouped convolutional layer, the normalization layer, the first point convolutional layer, the second point convolutional layer, the path dropout layer, and the second convolutional layer;

[0078] Convert the number of channels of the to-be-recognized weed image based on the first convolutional layer, and fix the spatial dimension of the to-be-recognized weed image to generate the first weed feature image corresponding to the to-be-recognized weed image;

[0079] Perform depthwise separable convolution on the first weed feature image based on the grouped convolutional layer to generate the second weed feature image corresponding to the first weed feature image;

[0080] Arrange the second weed feature image, and input the arranged second weed feature image into the normalization layer so that the normalization layer performs standardization processing on the arranged second weed feature image to generate the third weed feature image;

[0081] Perform feature dimension elevation and transformation on the third weed feature image based on the first point convolutional layer to generate the fourth weed feature image;

[0082] Process the fourth weed feature image according to a preset activation function, and input the fourth weed feature image processed by the preset activation function into the second point convolutional layer so that the second point convolutional layer converts the number of channels of the fourth weed feature image to generate the fifth weed feature image;

[0083] Arrange the fifth weed feature image, and input the arranged fifth weed feature image into the path dropout layer so that the path dropout layer performs regularization processing on the fifth weed feature image to generate the sixth weed feature image;

[0084] Convert the number of channels of the sixth weed feature image based on the second convolutional layer to generate the initial weed feature image.

[0085] In this embodiment, efficient and accurate feature extraction and transformation of the to-be-recognized weed image are realized through multiple convolutional layers, normalization layers, and path dropout layers. Through the conversion of the number of channels and in the form of combining feature dimension elevation and transformation, the features in the to-be-recognized weed image can be accurately captured, thereby providing an accurate data basis for the weed recognition detection of the subsequent weed recognition model, improving the recognition accuracy of the weed recognition model for the weed feature image, and further improving the accuracy of the weed detection for the power terminal.

[0086] Step S103: Generate a weed feature image according to the initial weed feature image and the to-be-recognized weed image.

[0087] In this embodiment, the generating a weed feature image according to the initial weed feature image and the to-be-recognized weed image specifically includes:

[0088] Perform residual connection on the initial weed feature image and the weed image to be recognized to generate a weed feature image corresponding to the initial weed feature image.

[0089] In this embodiment, by performing residual connection on the initial weed feature image and the weed image to be recognized, the problem of gradient disappearance in the process of feature extraction of the weed feature extraction model for the weed image to be recognized can be alleviated, thereby avoiding information loss in the process of feature extraction of the weed image to be recognized, enhancing the integrity of feature expression, thus improving the detection accuracy of the subsequent weed recognition model, and further improving the accuracy of weed detection for power terminals.

[0090] Please refer to Figure 3 , which is a schematic connection structure diagram of the weed feature extraction model and the weed recognition model provided by the embodiment of the present invention; Figure 4 , which is a schematic specific structure diagram of the weed feature extraction model provided by the embodiment of the present invention.

[0091] In an alternative embodiment, as Figure 3 and Figure 4 shown, the weed feature extraction model described in this embodiment is a CNN model. In the CNN model of this embodiment, multiple identical convolutional modules can be included, or only one convolutional module can be included. In this embodiment, the convolutional module is defined as a CBlock module. The weed feature extraction model of this embodiment will be described in detail by taking the example of including only one CBlock module.

[0092] As Figure 3 shown, the weed feature extraction model includes: a first convolutional layer (the first Conv), a depthwise convolutional layer (DWConv), a normalization layer (LN, LayerNorm layer), a first pointwise convolutional layer (the first PWConv), a second pointwise convolutional layer (the second PWConv), a path dropout layer (Drop_path), and a second convolutional layer (the second Conv);

[0093] Input the weed image to be recognized (Weed Image) into the first convolutional layer (the first Conv). The first convolutional layer is a two-dimensional convolutional layer that uses a 7×7 convolutional kernel and padding (i.e., padding = 3). Through the first convolutional layer, the number of channels (dim) of the weed image to be recognized is increased from 3 to 64, while keeping its spatial dimensions (i.e., height and width) unchanged, thereby generating the first weed feature image. Input the first weed feature image into the depthwise separable convolution layer (DWConv) for depthwise separable convolution. The number of groups of the grouped convolutional layer is set to the number of channels of the first weed feature image. Then, perform permutation (i.e., permute operation) on the second weed feature image, and then input it into the normalization layer (LN, LayerNorm layer) for normalization processing. Then, perform feature dimension increase and transformation through the first pointwise convolutional layer (the first PWConv). Then, process the fourth weed feature image through the GELU activation function (i.e., the preset activation function, Figure 4 the Act operation in

[0094] In an optional embodiment, as Figure 3 and Figure 4 shown, perform residual connection between the initial weed feature image (i.e., the output of the CNN model, which can also be understood as the output of the second convolutional layer) and the weed image to be recognized (Weed Image) to generate the weed feature image corresponding to the initial weed feature image.

[0095] In the above optional embodiments, the CBlock module realizes efficient feature extraction and transformation of the weed image to be recognized through its unique convolutional layer design (including the first convolutional layer, grouped convolutional layer, first point convolutional layer, second point convolutional layer, second convolutional layer), residual connection, LayerNorm normalization (normalization layer), GELU activation function, and DropPath mechanism. The CBlock module not only enhances the network's ability to capture local details of the image but also effectively alleviates the problems of gradient disappearance and overfitting in the training of deep networks through strategies such as residual connection. Specifically, the first convolutional layer aims to extract deep features of the weed image to be recognized. The grouped convolutional layer can maintain the depth of the first weed feature image unchanged while reducing the computational complexity of the CBlock module through depthwise separable convolution, further capturing the spatial features of the first weed feature image. The arrangement and normalization layer can maintain the stability and performance of the CBlock module. Introducing non-linearity through the GELU activation function can enhance the expressive ability of features. Subsequently, through the second point convolutional layer, dropout layer, and second convolutional layer, the initial feature image can be transformed to have the same shape as the weed image to be recognized. Then, through the residual connection between the initial weed feature image and the weed image to be recognized, the problem of gradient disappearance in the CNN model can be alleviated, improving the training efficiency and performance of the network.

[0096] It should be noted that the weed recognition model used in this embodiment is a Transformer model, as described above, and Figure 2 as shown, the limitations of the residual connection design in the existing Transformer models, that is, the residual connection is mainly limited after the Multi-Head Attention and MLP layers, and its "short-distance" characteristic may lead to the loss of key feature information in the original input image. Moreover, the normalization layers in the encoders of the existing Transformer models are mostly single normalization layers, which cannot further improve the expressive power and generalization ability of the Transformer model. Therefore, this embodiment solves these defects through the long residual connection processing and parallel normalization processing in step S104.

[0097] Step S104: Input the weed feature image into the weed recognition model so that the weed recognition model performs long residual connection processing and parallel normalization processing on the weed feature image to obtain the detection result of the weeds on the power terminal.

[0098] It should be noted that the prototype of the weed recognition model in this embodiment is a Transformer model. In this embodiment, by improving the encoder of the Transformer model, the long residual connection processing and parallel normalization processing are realized.

[0099] In this embodiment, inputting the weed feature image into the weed recognition model to enable the weed recognition model to perform long residual connection processing and parallel normalization processing on the weed feature image, and obtain the detection result of the weed on the power terminal, specifically including:

[0100] The weed recognition model includes: an input layer, an encoder, and a fully connected classification head;

[0101] Input the weed feature image into the input layer to enable the input layer to preprocess the weed feature image and generate an initial weed feature image block;

[0102] Input the initial weed feature image block into the encoder, and through the encoder, perform long residual connection processing and parallel normalization processing on the initial weed feature image block to generate a weed feature vector;

[0103] Input the weed feature vector into the fully connected classification head to enable the fully connected classification head to generate a weed classification result according to the weed feature vector;

[0104] Determine the detection result of the weed on the power terminal according to the weed classification result.

[0105] In this embodiment, the input layer preprocesses the weed feature image, which can enhance the local features of the weed feature image and avoid misjudgment of the subsequent encoder caused by blurred global information; through long residual connection processing, the key features in the initial weed feature image block can still maintain their importance and recognition after multiple non-linear transformations, providing a longer return path for the gradient in the form of long residual connection, avoiding the problem of gradient disappearance or explosion of the weed recognition model; in the form of parallel normalization processing, when the weed recognition model processes the weed feature image, it can simultaneously focus on the global pattern and local details, reducing the risk of overfitting, thereby improving the recognition accuracy of the weed recognition model for the weed feature image, and further improving the accuracy of detecting the weed on the power terminal.

[0106] In an alternative embodiment, in order to further improve the recognition accuracy of the Transformer model (i.e., the weed recognition model), as Figure 3 shown, the embodiment of the present invention can also cut the initial weed feature image before inputting it into the input layer (i.e., Figure 3 the weed image1-9 in it, which means 9 images, including weedimage1, weed image2, weed image3... weed image9).

[0107] In an alternative embodiment, the initial weed feature image (weed image1-9) is input into the input layer of the Transformer model (i.e., the Linear Projection of Flattened Patches) for preprocessing. This preprocessing process includes image patching, flattening, linear projection, and position embedding, etc., to generate the initial weed feature image patches as shown in Figure 3 the initial weed feature image patches (i.e., the color patches numbered with numbers at Patch+PositionEmbedding, also known as Embedded Patches).

[0108] It should be noted that the working principle of the input layer of the Transformer model is currently relatively common. This embodiment also follows the input layer of the existing Transformer model, so the specific process will not be elaborated.

[0109] In this embodiment, the encoder performs long residual connection processing and parallel normalization processing on the initial weed feature image patches to generate weed feature vectors, specifically including:

[0110] The encoder includes: a first parallel normalization layer, a multi-head self-attention layer, a second parallel normalization layer, and a feed-forward neural network layer;

[0111] Input the initial weed feature image patches into the first parallel normalization layer, and perform parallel normalization processing on the initial weed feature image patches based on the first parallel normalization layer to obtain the first weed feature image patches;

[0112] Input the first weed feature image patches into the multi-head self-attention layer, and process the first weed feature image patches through the multi-head self-attention layer to obtain the second weed feature image patches;

[0113] Perform residual connection processing on the second weed feature image patches and the initial weed feature image patches to generate the third weed feature image patches;

[0114] Input the third weed feature image patches into the second parallel normalization layer, and perform parallel normalization processing on the third weed feature image patches based on the second parallel normalization layer to obtain the fourth weed feature image patches;

[0115] Input the fourth weed feature image patches into the feed-forward neural network layer, and process the fourth weed feature image patches through the feed-forward neural network layer to generate the fifth weed feature image patches;

[0116] Perform long residual connection processing on the fifth weed feature image block, the third weed feature image block, and the initial weed feature image block according to the preset long residual connection processing method to generate a weed feature vector.

[0117] In this embodiment, through long residual connection processing, the key features in the initial weed feature image block can still maintain their importance and recognition after multiple non-linear transformations. In the form of long residual connection, a longer backflow path is provided for the gradient, avoiding the problem of gradient disappearance or explosion in the weed recognition model. In the form of parallel normalization processing, when the weed recognition model processes the weed feature image, it can simultaneously focus on the global pattern and local details, reducing the risk of overfitting, thereby improving the recognition accuracy of the weed recognition model for the weed feature image, and further improving the accuracy of weed detection for power terminals.

[0118] In this embodiment, the parallel normalization processing of the initial weed feature image block based on the first parallel normalization layer to obtain the first weed feature image block specifically includes:

[0119] The first parallel normalization layer includes: a first layer normalization unit and a first instance normalization unit;

[0120] Input the initial weed feature image block into the first layer normalization unit so that the first layer normalization unit performs normalization processing on the initial weed feature image block to generate a sixth weed feature image block;

[0121] Input the initial weed feature image block into the first instance normalization unit so that the first instance normalization unit performs normalization processing on the initial weed feature image block to generate a seventh weed feature image block;

[0122] Perform residual connection processing on the sixth weed feature image block and the seventh weed feature image block to generate a first weed feature image block.

[0123] In this embodiment, the parallel normalization processing of the third weed feature image block based on the second parallel normalization layer to obtain the fourth weed feature image block specifically includes:

[0124] The second parallel normalization layer includes: a second layer normalization unit and a second instance normalization unit;

[0125] Input the third weed feature image block into the second layer normalization unit so that the second layer normalization unit performs normalization processing on the third weed feature image block to generate an eighth weed feature image block;

[0126] Input the third weed feature image block into the second instance normalization unit, so that the second instance normalization unit normalizes the third weed feature image block to generate a ninth weed feature image block;

[0127] Perform residual connection processing on the eighth weed feature image block and the ninth weed feature image block to generate a fourth weed feature image block.

[0128] In this embodiment, normalization processing is performed through two different normalization layers, and then residual connection is performed on the processing results, so that the weed recognition model can capture both global sequence information and better handle the specificity of individual samples, thereby improving the recognition accuracy of weed recognition, and further improving the accuracy of weed detection for power terminals.

[0129] In this embodiment, the long residual connection processing of the fifth weed feature image block, the third weed feature image block, and the initial weed feature image block according to the preset long residual connection processing method to generate a weed feature vector specifically includes:

[0130] Perform residual connection on the fifth weed feature image block, the third weed feature image block, and the initial weed feature image block to generate a weed feature vector.

[0131] In this embodiment, by performing residual connection on the fifth weed feature image block, the third weed feature image block, and the initial weed feature image block, the information flow between different weed feature image blocks can be enhanced, and a longer return path for gradients can be provided, effectively alleviating the problem of gradient disappearance or explosion, thereby improving the robustness and accuracy of the weed recognition model, and further improving the accuracy of weed detection for power terminals.

[0132] In an alternative embodiment, as Figure 3 shown, based on Figure 3For the Opt-Transformer Encoder part, a more specific expansion of step S104 in this embodiment is given. First, the initial weed feature image patches (EmbeddedPatches) are input into the first parallel normalization layer, where the first parallel normalization layer includes a first layer normalization unit (LN, Layer Normalization) and a first instance normalization unit (IN, Instance Normalization); by inputting the initial weed feature image patches into the first layer normalization unit, the initial weed feature image patches are normalized to generate the sixth weed feature image patches; by inputting the initial weed feature images into the first instance normalization unit, the initial weed feature image patches are normalized to generate the seventh weed feature image patches; a residual connection process is performed on the sixth weed feature image patches and the seventh weed feature image patches to generate the first weed feature image patches; then the first weed feature image patches are input into the multi-head self-attention layer (Multi-Head Attention), and through the processing of the multi-head self-attention layer, the second weed feature image patches are obtained; then a residual connection process is performed on the second weed feature image patches and the initial weed feature image patches to generate the third weed feature image patches; then the third weed feature image patches are input into the second parallel normalization layer (which is between the Multi-Head Attention and the MLP), and the second parallel normalization layer includes: a second layer normalization unit (LN, Layer Normalization) and a second instance normalization unit (IN, Instance Normalization); the third weed feature image patches are input into the second layer normalization unit to normalize the third weed feature image patches to generate the eighth weed feature image patches; the third weed feature image patches are input into the second instance normalization unit to normalize the third weed feature image patches to generate the ninth weed feature image patches; a residual connection process is performed on the eighth weed feature image patches and the ninth weed feature image patches to generate the fourth weed feature image patches; then the fourth weed feature image patches are input into the feed-forward neural network layer (MLP) for processing to generate the fifth weed feature image patches; then a residual connection is made among the fifth weed feature image patches, the third weed feature image patches, and the initial weed feature image patches, thus realizing the long residual connection process to generate the weed feature vectors.

[0133] In an alternative embodiment, after generating the weed feature vector, it is input into the fully connected classification head (MLP Head) of the Transformer model, and the weed classification result is generated through the fully connected classification head, and then the detection result of the weed on the power terminal is determined based on the weed classification result. It should be noted that this embodiment still uses the fully connected classification head (MLP Head) of the current common Transformer model, so the specific classification and recognition process thereof will not be described in this embodiment.

[0134] It should be noted that since the weed images on the power terminal often contain complex background information (such as power facilities like utility poles and transformers), as well as diverse weed species and growth states, this requires the Transformer model to accurately capture and distinguish the subtle differences between weeds and the background, while maintaining an effective representation of the internal features of the weeds. Therefore, in this alternative embodiment, a long residual connection is achieved by performing residual connections on the fifth weed feature image block, the third weed feature image block, and the initial weed feature image block. By introducing the long residual connection, the feature information of the initial weed feature image block can be more deeply integrated into each layer of the Transformer model, ensuring that the key features can still maintain their importance and distinctiveness after multiple non-linear transformations; in addition, since the image acquisition on the power terminal is often affected by various factors such as illumination changes, occlusion, and perspective changes, the long residual connection in this embodiment enables the Transformer model to more stably extract and represent features when facing these challenges by enhancing the circulation of the original input information, thereby improving the robustness and generalization ability of the Transformer model. At the same time, a longer backflow path for the gradient is provided in the form of a long residual connection, effectively alleviating the problem of gradient disappearance or explosion during the use of the Transformer model, facilitating the effective transfer and optimization of the gradient between the layers of the Transformer model, so that the Transformer model enhances its ability to extract, represent, and optimize features in the task of detecting weeds on the power terminal, and improves the accuracy of detecting weeds on the power terminal.

[0135] It should be noted that in this embodiment, through the parallel normalization processing of two parallel normalization layers, the layer normalization layer (LN) focuses on the feature stability at different positions within the same image feature block, which helps the Transformer model capture sequence-level dependencies; while the instance normalization layer focuses on the standardization of features within each sample, enhancing the ability of the Transformer model to handle individual sample variations. Applying and integrating the two in parallel can combine the advantages of both, enabling the Transformer model to capture both global sequence information and better handle the specificities of individual samples, thereby improving the overall performance of the Transformer model. In addition, by integrating two different normalization layers in this embodiment, the Transformer model can adaptively adjust the degree of dependence on global information and individual information in the weed detection tasks for different types of power terminals, thus making the Transformer model have a wider applicability and accuracy. Parallel normalization can avoid the risk of overfitting caused by the Transformer model relying too much on a specific feature processing method due to single normalization. By introducing diverse feature processing methods in a parallel normalization manner, the generalization ability of the Transformer model is increased. By fusing features from different normalization layers, a richer and more diverse feature representation is provided for the Transformer model, thereby improving the recognition accuracy of the Transformer model.

[0136] In the embodiment of the present invention, by designing the structures of the CNN model (i.e., the weed feature extraction model) and the Transformer model (the weed recognition model), the CNN model captures the local spatial features in the weed image to be recognized, and the Transformer model captures the global context information. The combination of the two realizes the complementarity of features and provides the weed recognition model with the comprehensive understanding ability of the image content; by combining the efficient feature extraction ability of the CNN model and the global modeling ability of the Transformer model, it has a higher classification accuracy and stronger robustness, and thus improves the recognition accuracy of the weed recognition model.

[0137] In this embodiment, the weed feature extraction model is used to extract features from the to-be-recognized weed image, so as to obtain the feature information in the to-be-recognized weed image. Then, the weed feature image is generated based on the initial weed feature image and the to-be-recognized weed image, which can alleviate the vanishing gradient of the initial weed feature image, avoid information loss in the feature extraction process of the to-be-recognized weed image, enhance the integrity of feature expression, and thus improve the detection accuracy of the subsequent weed recognition model. In this embodiment, the weed recognition model performs long residual connection processing and parallel normalization processing on the weed feature image. The long residual connection processing ensures that the key features in the weed feature image can maintain their importance and recognition in the processing process, alleviates the gradient explosion problem in the process of the weed recognition model processing the weed feature image. In the form of parallel normalization processing, when the weed recognition model processes the weed feature image, it can pay attention to the global pattern and local details at the same time, reduce the risk of overfitting, and thus improve the recognition accuracy of the weed recognition model for the weed feature image, and further improve the accuracy of detecting weeds on the power terminal.

[0138] Embodiment 2

[0139] Based on the power terminal weed detection method described in Embodiment 1, as well as the involved weed feature extraction model (CNN model) and weed recognition model (Transformer model), this embodiment will compare their related performances with those of a single Transformer model.

[0140] Specifically, please refer to Figure 5 , which is a comparison chart of the average accuracy curves before and after model improvement provided by the embodiment of the present invention. As Figure 5 shown, this average accuracy curve comparison chart refers to the comparison chart of the average accuracy during the training process of the CNN model + Transformer model (i.e., the weed feature extraction model + the weed recognition model) in Embodiment 1 and a single Transformer model. Figure 5 The abscissa of Figure 5 is epoch (training progress), and the ordinate is train_acc (Training Accuracy, training accuracy, that is, average accuracy). As

[0141] In addition, please refer to Table 1, which is a comparison table of the classification accuracy before and after the model improvement provided in the embodiments of the present invention. The accuracy of the CNN model + Transformer model (i.e., the weed feature extraction model + the weed recognition model) is 81.3%, while the classification accuracy of the single Transformer model is only 77.8%.

[0142] Table 1

[0143]

[0144] Please refer to Figure 6 , which is a comparison graph of the training loss rate curves before and after the model improvement provided in the embodiments of the present invention; as Figure 6 shown, this average accuracy curve comparison graph refers to the comparison graph of the training loss rate between the CNN model + Transformer model (i.e., the weed feature extraction model + the weed recognition model) of Embodiment 1 and the single Transformer model during the training process. Figure 5 The abscissa of Figure 5 is epoch (training progress), and the ordinate is train_loss (Training Loss, that is, the training loss rate). As

[0145] shown, the training loss rate of the CNN model + Transformer model (i.e., the weed feature extraction model + the weed recognition model) is lower than that of the single Transformer model, indicating that the CNN model + Transformer model (i.e., the weed feature extraction model + the weed recognition model) has a smaller error and higher accuracy in the weed detection of power terminals. Figure 5 and Figure 6 Based on the curve graphs of

[0146] , the CNN model + Transformer model (i.e., the weed feature extraction model + the weed recognition model) of this embodiment always has a better average accuracy index than the single Transformer model during the training process, and has a lower loss value. Moreover, as the training progresses, its loss value drops rapidly and finally stabilizes at a lower level, which verifies that the CNN model + Transformer model has more accurate performance in the weed detection task of power terminals.

[0147] Table 2

[0148]

[0149] As described in Table 2 above, a series of ablation experiments were conducted based on the existing Transformer model. Using parallel normalization (A), long residual connection (B), and CNN model + Transformer model (C) alone can all improve the accuracy (ACC, %) of the original Transformer model, reaching 79.6%, 78.1%, and 79.7% respectively, that is, each single optimization can improve the accuracy of the original Transformer model. Further, these single optimizations were combined respectively. As shown in Table 2, the accuracy of the combination of A + B (parallel normalization + long residual connection) is 77.3%, and the accuracies of the combinations of A + C (parallel normalization + CNN model + Transformer model) and B + C (long residual connection + CNN model + Transformer model) are 81.2% and 80.1% respectively. This shows that the combination of the CNN + Transformer structure with parallel normalization or long residual connection can more effectively improve the recognition accuracy. And if the combination of A + B + C is made, the accuracy reaches 81.3%, which proves that parallel normalization + long residual connection + CNN model + Transformer model can have better recognition accuracy.

[0150] In summary, in this embodiment, by comparing the accuracies corresponding to different models and different structural optimizations, it is verified that the combination of the CNN model, Transformer model, parallel normalization, and long residual connection proposed in the embodiments of the present invention has high accuracy in the detection of weeds on power terminals.

[0151] Embodiment 3

[0152] Please refer to Figure 7 , which is a schematic structural diagram of a weed detection device for power terminals provided by an embodiment of the present invention, including: a data acquisition module 201, an initial weed feature image acquisition module 202, a weed feature image generation module 203, and a weed detection module 204.

[0153] Among them, the data acquisition module 201 is used to acquire the weed image to be recognized, the weed feature extraction model, and the weed recognition model.

[0154] The initial weed feature image acquisition module 202 is used to input the weed image to be recognized into the weed feature extraction model, so that the weed feature extraction model extracts features from the weed image to be recognized and generates an initial weed feature image.

[0155] In this embodiment, the initial weed feature image acquisition module 202 includes: an initial weed feature image acquisition unit;

[0156] In the initial weed feature image acquisition unit, the weed feature extraction model includes: a first convolutional layer, a grouped convolutional layer, a normalization layer, a first point convolutional layer, a second point convolutional layer, a path dropout layer, and a second convolutional layer;

[0157] The initial weed feature image acquisition unit is configured to convert the number of channels of the weed image to be recognized based on the first convolutional layer, and fix the spatial dimension of the weed image to be recognized, generating a first weed feature image corresponding to the weed image to be recognized;

[0158] Perform depthwise separable convolution on the first weed feature image based on the grouped convolutional layer, generating a second weed feature image corresponding to the first weed feature image;

[0159] Arrange the second weed feature image, and input the arranged second weed feature image into the normalization layer, so that the normalization layer performs standardization processing on the arranged second weed feature image, generating a third weed feature image;

[0160] Perform feature upsampling and transformation on the third weed feature image based on the first point convolutional layer, generating a fourth weed feature image;

[0161] Process the fourth weed feature image according to a preset activation function, and input the fourth weed feature image processed by the preset activation function into the second point convolutional layer, so that the second point convolutional layer converts the number of channels of the fourth weed feature image, generating a fifth weed feature image;

[0162] Arrange the fifth weed feature image, and input the arranged fifth weed feature image into the path dropout layer, so that the path dropout layer performs regularization processing on the fifth weed feature image, generating a sixth weed feature image;

[0163] Convert the number of channels of the sixth weed feature image based on the second convolutional layer, generating an initial weed feature image.

[0164] The weed feature image generation module 203 is configured to generate a weed feature image according to the initial weed feature image and the weed image to be recognized.

[0165] In this embodiment, the weed feature image generation module 203 includes: a weed feature image generation unit;

[0166] The weed feature image generation unit is configured to perform residual connection on the initial weed feature image and the weed image to be recognized, generating a weed feature image corresponding to the initial weed feature image.

[0167] The weed detection module 204 is configured to input the weed feature image into the weed recognition model, so that the weed recognition model performs long residual connection processing and parallel normalization processing on the weed feature image to obtain the detection result of the weeds on the power terminal.

[0168] In this embodiment, the weed detection module 204 includes: a weed detection unit;

[0169] In the weed detection unit, the weed recognition model includes: an input layer, an encoder, and a fully connected classification head;

[0170] The weed detection unit is configured to input the weed feature image into the input layer, so that the input layer preprocesses the weed feature image to generate an initial weed feature image block;

[0171] Input the initial weed feature image block into the encoder, and perform long residual connection processing and parallel normalization processing on the initial weed feature image block through the encoder to generate a weed feature vector;

[0172] Input the weed feature vector into the fully connected classification head, so that the fully connected classification head generates a weed classification result according to the weed feature vector;

[0173] Determine the detection result of the weeds on the power terminal according to the weed classification result.

[0174] In this embodiment, the weed detection unit includes: a weed feature vector generation sub-unit;

[0175] In the weed feature vector generation sub-unit, the encoder includes: a first parallel normalization layer, a multi-head self-attention layer, a second parallel normalization layer, and a feed-forward neural network layer;

[0176] The weed feature vector generation sub-unit is configured to input the initial weed feature image block into the first parallel normalization layer, and perform parallel normalization processing on the initial weed feature image block based on the first parallel normalization layer to obtain a first weed feature image block;

[0177] Input the first weed feature image block into the multi-head self-attention layer, and process the first weed feature image block through the multi-head self-attention layer to obtain a second weed feature image block;

[0178] Perform residual connection processing on the second weed feature image block and the initial weed feature image block to generate a third weed feature image block;

[0179] Input the third weed feature image block into the second parallel normalization layer, and perform parallel normalization processing on the third weed feature image block based on the second parallel normalization layer to obtain a fourth weed feature image block;

[0180] Input the fourth weed feature image block into the feed-forward neural network layer, and process the fourth weed feature image block through the feed-forward neural network layer to generate a fifth weed feature image block;

[0181] Perform long residual connection processing on the fifth weed feature image block, the third weed feature image block, and the initial weed feature image block according to a preset long residual connection processing method to generate a weed feature vector.

[0182] In this embodiment, the weed feature vector generation subunit includes: a first parallel normalization processing component;

[0183] In the first parallel normalization processing component, the first parallel normalization layer includes: a first layer normalization unit and a first instance normalization unit;

[0184] The first parallel normalization processing component is used to input the initial weed feature image block into the first layer normalization unit, so that the first layer normalization unit performs normalization processing on the initial weed feature image block to generate a sixth weed feature image block;

[0185] Input the initial weed feature image block into the first instance normalization unit, so that the first instance normalization unit performs normalization processing on the initial weed feature image block to generate a seventh weed feature image block;

[0186] Perform residual connection processing on the sixth weed feature image block and the seventh weed feature image block to generate a first weed feature image block.

[0187] In this embodiment, the weed feature vector generation subunit includes: a long residual connection processing component;

[0188] The long residual connection processing component is used to perform residual connection on the fifth weed feature image block, the third weed feature image block, and the initial weed feature image block to generate a weed feature vector.

[0189] In this embodiment, the weed feature extraction model is used to extract features from the to-be-identified weed image, so as to obtain the feature information in the to-be-identified weed image. Then, according to the initial weed feature image and the to-be-identified weed image, a weed feature image is generated, which can alleviate the gradient disappearance of the initial weed feature image, avoid information loss in the process of extracting features from the to-be-identified weed image, enhance the integrity of feature expression, and thus improve the detection accuracy of the subsequent weed recognition model. In this embodiment, the weed recognition model performs long residual connection processing and parallel normalization processing on the weed feature image. The long residual connection processing ensures that the key features in the weed feature image can maintain their importance and distinguishability during the processing, alleviates the gradient explosion problem in the process of the weed recognition model processing the weed feature image. In the form of parallel normalization processing, when the weed recognition model processes the weed feature image, it can simultaneously focus on the global pattern and local details, reduce the risk of overfitting, and thus improve the recognition accuracy of the weed recognition model for the weed feature image, and further improve the accuracy of detecting weeds on the power terminal.

[0190] Embodiment 4

[0191] An embodiment of the present invention provides a terminal device, including:

[0192] One or more processors;

[0193] A memory, coupled to the processor, for storing one or more programs;

[0194] When the one or more programs are executed by the one or more processors, the one or more processors implement a method for detecting weeds on a power terminal as described in Embodiment 1 above.

[0195] An embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, and the computer program is executed by a processor to implement a method for detecting weeds on a power terminal as described in Embodiment 1 above.

[0196] In summary, in the embodiment of the present invention, the weed feature extraction model is used to extract features from the to-be-recognized weed image, so as to obtain the feature information in the to-be-recognized weed image. Then, according to the initial weed feature image and the to-be-recognized weed image, a weed feature image is generated, which can alleviate the gradient disappearance of the initial weed feature image, avoid information loss in the process of feature extraction of the to-be-recognized weed image, enhance the integrity of feature expression, and thus improve the detection accuracy of the subsequent weed recognition model; in the embodiment of the present invention, the weed recognition model performs long residual connection processing and parallel normalization processing on the weed feature image. In the way of long residual connection processing, it is ensured that the key features in the weed feature image can maintain their importance and recognition during the processing, alleviating the problem of gradient explosion in the process of the weed recognition model processing the weed feature image. In the form of parallel normalization processing, when the weed recognition model processes the weed feature image, it can simultaneously focus on the global pattern and local details, reducing the risk of overfitting, thereby improving the recognition accuracy of the weed recognition model for the weed feature image, and further improving the accuracy of detecting weeds on the power terminal.

[0197] In the specific embodiments described above, the purpose, technical solutions, and beneficial effects of the present invention have been further described in detail. It should be understood that the above description is only for the specific embodiments of the present invention and is not used to limit the protection scope of the present invention. In particular, it is pointed out that for those skilled in the art, any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for detecting weeds in a power terminal, characterized in that, Including: Obtain a weed image to be recognized, a weed feature extraction model, and a weed recognition model; Input the weed image to be recognized into the weed feature extraction model, so that the weed feature extraction model extracts features from the weed image to be recognized and generates an initial weed feature image; Generate a weed feature image based on the initial weed feature image and the weed image to be recognized; Input the weed feature image into the weed recognition model, so that the weed recognition model performs long residual connection processing and parallel normalization processing on the weed feature image to obtain a detection result of weeds in the power terminal.

2. The power terminal weed detection method according to claim 1, characterized in that The step of inputting the weed image to be recognized into the weed feature extraction model, so that the weed feature extraction model extracts features from the weed image to be recognized and generates an initial weed feature image specifically includes: The weed feature extraction model includes: a first convolutional layer, a grouped convolutional layer, a normalization layer, a first point convolutional layer, a second point convolutional layer, a path dropout layer, and a second convolutional layer; Based on the first convolutional layer, convert the number of channels of the weed image to be recognized and fix the spatial dimension of the weed image to be recognized to generate a first weed feature image corresponding to the weed image to be recognized; Based on the grouped convolutional layer, perform depthwise separable convolution on the first weed feature image to generate a second weed feature image corresponding to the first weed feature image; Arrange the second weed feature image and input the arranged second weed feature image into the normalization layer, so that the normalization layer performs normalization processing on the arranged second weed feature image to generate a third weed feature image; Based on the first point convolutional layer, perform feature dimension elevation and transformation on the third weed feature image to generate a fourth weed feature image; Process the fourth weed feature image according to a preset activation function and input the fourth weed feature image processed by the preset activation function into the second point convolutional layer, so that the second point convolutional layer converts the number of channels of the fourth weed feature image to generate a fifth weed feature image; Arrange the fifth weed feature image and input the arranged fifth weed feature image into the path dropout layer, so that the path dropout layer performs regularization processing on the fifth weed feature image to generate a sixth weed feature image; Based on the second convolutional layer, convert the number of channels of the sixth weed feature image to generate an initial weed feature image.

3. The weed detection method for a power terminal according to claim 1 or 2, characterized in that, The step of generating a weed feature image based on the initial weed feature image and the weed image to be recognized specifically includes: Perform residual connection on the initial weed feature image and the weed image to be recognized to generate a weed feature image corresponding to the initial weed feature image.

4. The method for detecting weeds in a power terminal according to claim 1, wherein, The step of inputting the weed feature image into the weed recognition model, so that the weed recognition model performs long residual connection processing and parallel normalization processing on the weed feature image to obtain a detection result of weeds in the power terminal specifically includes: The weed recognition model includes: an input layer, an encoder, and a fully connected classification head; Input the weed feature image into the input layer so that the input layer preprocesses the weed feature image to generate an initial weed feature image block; Input the initial weed feature image block into the encoder, and perform long residual connection processing and parallel normalization processing on the initial weed feature image block through the encoder to generate a weed feature vector; Input the weed feature vector into the fully connected classification head so that the fully connected classification head generates a weed classification result according to the weed feature vector; Determine the detection result of the weeds on the power terminal according to the weed classification result.

5. The weed detection method for a power terminal according to claim 4, characterized in that, The step of performing long residual connection processing and parallel normalization processing on the initial weed feature image block through the encoder to generate a weed feature vector specifically includes: The encoder includes: a first parallel normalization layer, a multi-head self-attention layer, a second parallel normalization layer, and a feed-forward neural network layer; Input the initial weed feature image block into the first parallel normalization layer, and perform parallel normalization processing on the initial weed feature image block based on the first parallel normalization layer to obtain a first weed feature image block; Input the first weed feature image block into the multi-head self-attention layer, and process the first weed feature image block through the multi-head self-attention layer to obtain a second weed feature image block; Perform residual connection processing on the second weed feature image block and the initial weed feature image block to generate a third weed feature image block; Input the third weed feature image block into the second parallel normalization layer, and perform parallel normalization processing on the third weed feature image block based on the second parallel normalization layer to obtain a fourth weed feature image block; Input the fourth weed feature image block into the feed-forward neural network layer, and process the fourth weed feature image block through the feed-forward neural network layer to generate a fifth weed feature image block; Perform long residual connection processing on the fifth weed feature image block, the third weed feature image block, and the initial weed feature image block according to a preset long residual connection processing method to generate a weed feature vector.

6. The power terminal weed detection method according to claim 5, wherein The step of performing parallel normalization processing on the initial weed feature image block based on the first parallel normalization layer to obtain a first weed feature image block specifically includes: The first parallel normalization layer includes: a first layer normalization unit and a first instance normalization unit; Input the initial weed feature image block into the first layer normalization unit so that the first layer normalization unit performs normalization processing on the initial weed feature image block to generate a sixth weed feature image block; Input the initial weed feature image block into the first instance normalization unit so that the first instance normalization unit performs normalization processing on the initial weed feature image block to generate a seventh weed feature image block; Perform residual connection processing on the sixth weed feature image block and the seventh weed feature image block to generate a first weed feature image block.

7. A method for detecting weeds in a power terminal according to any one of claims 5 to 6, characterized in that, Performing long residual connection processing on the fifth weed feature image block, the third weed feature image block, and the initial weed feature image block according to the preset long residual connection processing method to generate a weed feature vector, specifically including: Performing residual connection on the fifth weed feature image block, the third weed feature image block, and the initial weed feature image block to generate a weed feature vector.

8. A weed detection device for a power terminal, characterized in that, Including: A data acquisition module, an initial weed feature image acquisition module, a weed feature image generation module, and a weed detection module; Wherein, the data acquisition module is used to acquire a weed image to be recognized, a weed feature extraction model, and a weed recognition model; The initial weed feature image acquisition module is used to input the weed image to be recognized into the weed feature extraction model, so that the weed feature extraction model performs feature extraction on the weed image to be recognized to generate an initial weed feature image; The weed feature image generation module is used to generate a weed feature image according to the initial weed feature image and the weed image to be recognized; The weed detection module is used to input the weed feature image into the weed recognition model, so that the weed recognition model performs long residual connection processing and parallel normalization processing on the weed feature image to obtain a detection result of weeds on the power terminal.

9. A terminal device, characterized in that, Including: One or more processors; A memory, coupled to the processor, for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement a method for detecting weeds on a power terminal according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, The computer program is executed by a processor to implement a method for detecting weeds on a power terminal according to any one of claims 1 to 7.