Lightweight visual processing method and system for insulator defect detection
Patent Information
- Application Number
- CN202610943784.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-29
- Publication Date
- 2026-09-29
AI Technical Summary
[0004]但是类似的现有技术方案均存在以下共有的不足之处:(1)虽然在准确性上有较高的表现,但其模型复杂、推理速度慢,不适合在计算资源有限的无人机边缘平台上使用
[0007]本发明的有益效果在于,与现有技术相比,
Smart Images

Figure CN122841916A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of power equipment testing technology, specifically relating to a lightweight visual processing method and system for insulator defect detection. Background Technology
[0002] Using drones equipped with image acquisition devices for aerial inspection of insulators has become a widely used technique in power grid operation and maintenance departments. Given the small size and diverse shapes of insulator defects, as well as the blurring caused by environmental interference in the images, current technologies have proposed many constructive optimization solutions.
[0003] For lightweight improvements to small object detection, existing techniques replace the C2F (CSP bottleneck with 2 convolutions) module in YOLOv8 with the C3Ghost (CSP bottleneck with 3ghost convolutions) module. Other techniques, building upon YOLOv8, introduce multi-scale large-kernel attention modules and improve the C2F module using lightweight GSConv convolutions.
[0004] However, similar existing technical solutions all have the following common shortcomings: (1) Although they have high accuracy, their models are complex and their inference speed is slow, making them unsuitable for use on UAV edge platforms with limited computing resources. (2) Existing lightweight models still have limited performance in complex backgrounds and small target recognition, and are prone to false detections and missed detections, affecting the accuracy of operation and maintenance decisions. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention provides a lightweight visual processing method and system for insulator defect detection. Multi-layer fusion features are extracted using a dual-path variance gating module, and high-level semantic information is enhanced by combining SPPF and multi-scale feature pyramids. The downsampling branch in the detection head is adjusted to improve resolution. A dynamic EIoU loss function is introduced to achieve adaptive adjustment between the predicted and ground truth bounding boxes, significantly improving detection accuracy and robustness.
[0006] This application discloses a lightweight visual processing method for insulator defect detection, employing the following technical solution: A dual-path variance gating module for structure and detail is constructed in the backbone network of YOLOv8n; the insulator image is sequentially passed through the CBS module and the GhostConv module to extract the input feature map, which is then input into the dual-path variance gating module to output multi-layer multi-path fusion features; an SPPF module is connected after the dual-path variance gating module to obtain high-level semantic features; A multi-scale feature pyramid is designed in the neck network of YOLOv8n; the multi-path fusion features of each layer are concatenated with the upsampled high-level semantic features and fused in the GC3 module; the fusion process is repeated layer by layer, and finally the high-resolution fusion features are input into the convolutional block attention module to obtain attention-enhanced features; In the YOLOv8n detection head, a feature map resolution is designed; corresponding to the resolution of the insulator image, the detection branch corresponding to the first downsampling factor in the detection head is replaced with a detection branch of the fourth downsampling factor, and the first downsampling factor branch is deleted; the fourth downsampling factor is less than the first sampling factor. In the loss function of YOLOv8n, a dynamic loss function is designed; EIoU is used as the basic loss function, and a scale factor that decays over time is introduced during training to perform isocentric scaling transformation on the predicted box and the ground truth box, thereby constructing a dynamically adjusted intersection-union ratio.
[0007] The beneficial effects of this invention are that, compared with the prior art, 1. This invention sets up a structure-detail dual-path variance-gated module in the backbone network, which feeds the input features into a fidelity branch, a directional structure branch, and a defect detail branch for processing. The fidelity branch preserves the original feature information, the directional structure branch enhances the slender, continuous, and oriented structural features of the insulator string, and the defect detail branch highlights local high-frequency anomalies such as damage, cracks, flashover edges, and gaps. Simultaneously, the variance-gated fusion module adaptively adjusts the contributions of the structure and detail branches based on the mean and variance of the feature responses, enabling the model to dynamically enhance key features according to the complexity of the image texture, thereby improving the representation ability of insulator defects in complex backgrounds.
[0008] 2. This invention uses the GC3 lightweight feature fusion module in the neck network, replacing the original heavy convolutional structure with the Ghost convolutional structure. While maintaining the cross-stage feature fusion capability, it reduces redundant feature calculations, reduces the number of model parameters and computational load, and makes the improved detection model more suitable for deployment on platforms with limited computing resources, such as drones, inspection robots or edge computing terminals.
[0009] 3. This invention introduces an attention enhancement module composed of channel attention and spatial attention after neck feature fusion. The fused features processed by the backbone network and neck network are weighted twice in terms of channel and spatial dimensions, enabling the model to suppress interference from complex backgrounds such as sky, conductors, towers, and vegetation, and highlight the area where insulator defects are located, thereby improving the recognition accuracy of small target defects.
[0010] 4. This invention replaces the original large target detection layer with a small target detection layer, enabling the detection head to receive high-resolution feature maps containing more shallow texture and edge information, thereby reducing the loss of small defect information caused by downsampling and improving the detection capability of small-scale defects such as aging, missing, and dirt; at the same time, redundant large target detection layers are removed, further reducing the computational burden of the model.
[0011] 5. This invention employs an improved EIoU bounding box loss function. Through width and height error constraints, isocentric scaling, scale factor decay, and quality reweighting mechanisms, the regression contribution of prediction boxes of different quality is dynamically adjusted, making it easier to complete coarse target localization in the early stage of training and further enhancing the fine regression of high-quality prediction boxes in the later stage of training, thereby improving the localization accuracy and robustness of bounding boxes under high IoU threshold.
[0012] 6. Based on the experimental results, the improved model of this invention can achieve higher detection accuracy in insulator defect detection tasks with lower parameter and computational requirements, taking into account the requirements of detection accuracy, real-time performance and lightweight deployment, and is suitable for automatic identification of insulator defects in power inspection scenarios. Attached Figure Description
[0013] Figure 1 An improved YOLOv8n network structure diagram is provided for this embodiment; Figure 2 The SDVG module structure provided for this embodiment; Figure 3 The GC3 module structure diagram provided for this embodiment; Figure 4 A CBAM structure diagram provided for an embodiment; Figure 5 CAM structure diagram provided for the embodiment; Figure 6 SAM structure diagram provided for the embodiment; Figure 7 Sample images of three types of insulator defects provided for the embodiments; Figure 8 A visual heatmap provided for an example. Detailed Implementation
[0014] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of this invention. The embodiments described in this application are merely some embodiments of this invention, and not all embodiments. Based on the spirit of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the protection scope of this invention.
[0015] Example 1 As an embodiment of this application, a specific implementation of a lightweight visual processing method for insulator defect detection is disclosed.
[0016] This application's method is based on the YOLOv8n framework. The YOLOv8n model consists of a backbone network, a neck network, and a head. The backbone network is responsible for feature extraction, and its design focuses on how to efficiently extract important features for subsequent processing. The neck network is mainly responsible for fusing features of different scales extracted by the backbone network. The head is responsible for transforming the fused feature map into the final target location and category.
[0017] YOLOv8n, through its lightweight design that reduces convolutional layers and optimizes network structure, maintains high-precision object detection capabilities while significantly reducing computational and memory consumption, giving it a significant advantage in edge deployments and real-time detection tasks. This invention further optimizes the structure of YOLOv8n, as shown in the improved YOLOv8n network structure. Figure 1 As shown.
[0018] like Figure 1 As shown, the improved YOLOv8n network consists of three parts: the backbone network, the neck network, and the head network. Figure 1 The "Input 640×640" on the left indicates that the size of the insulator inspection image input into the network is 640×640.
[0019] The backbone network is used for layer-by-layer feature extraction from the input image. It consists of the CBS module, GhostConv module, SDVG module (Structure-Detail Variance-Gated Module, SDVG), and SPPF module. The CBS module in the diagram is composed of Conv, BN, and SiLU connected sequentially. Conv represents a convolutional layer used to extract local features; BN represents a batch normalization layer used to improve training stability; and SiLU represents an activation function used to enhance the network's non-linear expressive power. GhostConv represents the Ghost convolutional module, used to generate effective feature maps while reducing the number of parameters and computational cost. SDVG represents the Structure-Detail Variance Gated Module, used to enhance the directional structural information and local defect details of the insulator string. SPPF represents the Fast Spatial Pyramid Pooling Module, used to expand the feature receptive field and enhance the high-level semantic feature expressive power.
[0020] Specifically, the input image first undergoes initial feature extraction via the CBS module, then sequentially passes through the GhostConv module and multiple SDVG modules for hierarchical feature extraction, and finally obtains high-level semantic features via the SPPF module and outputs them to the neck network. The different levels of features output from the backbone network are then fed into the neck network for further fusion.
[0021] The neck network is used to fuse multi-scale features output from the backbone network, mainly including upsampling, Concat, GC3, GhostConv, and CBAM modules. In the diagram, "upsampling" refers to enlarging the size of high-level low-resolution features to fuse them with shallow high-resolution features; Concat represents concatenating feature maps from different layers along the channel dimension; GC3 is a lightweight feature fusion module used to fuse and compress the concatenated features; and CBAM is a convolutional block attention module used to weight the fused features along both channel and spatial dimensions, enhancing the response of key defect regions and suppressing interference from complex backgrounds.
[0022] Specifically, the high-level features output by SPPF are first upsampled and concatenated with shallow features, then fused by the GC3 module. Subsequently, they are upsampled again and concatenated with even shallower features, then processed by the GC3 and CBAM modules to obtain high-resolution fused features. Afterwards, GhostConv downsamples the high-resolution fused features and concatenates them with features of corresponding scales, then fuses them again by the GC3 module, thus forming a bidirectional feature fusion structure from top to bottom and bottom to top.
[0023] The detection head is used for target classification and bounding box regression based on the multi-scale fusion features output by the neck network. In the figure, 160×160, 80×80, and 40×40 represent three detection feature maps at different resolutions. Specifically, the 160×160 detection head is used to improve the detection capability of small defects, the 80×80 detection head is used to detect smaller-scale targets, and the 40×40 detection head is used to detect medium-scale targets. Compared with the original YOLOv8n network, this application adds a 160×160 detection head and removes the 20×20 detection head, making the network more suitable for application scenarios where small targets account for a high proportion of insulator defect detection, while retaining detailed information and reducing redundant computation.
[0024] This embodiment describes in detail, through S1-S4, the specific implementation of the method proposed in this application.
[0025] S1: In one implementation, to simultaneously meet the multiple requirements of lightweight deployment performance, overall insulator string profile representation, and local defect detail enhancement, this application proposes a Structure-Detail Variance-Gated Module (SDVG) to replace the C2F module in the YOLOv8n backbone network. The SDVG module consists of a fidelity branch, a directional structure branch, a defect detail branch, and a variance-gated fusion module, see [link to relevant documentation]. Figure 2 .
[0026] like Figure 2 As shown, the SDVG module takes the input feature map as input. For input, Figure 2 In this context, "Start" and "End" represent the data input and output terminals of the module, respectively. (Input Feature Map) Firstly, after The intermediate feature map is obtained by processing with LeakyReLU. .in, Indicates the kernel size as The convolution operation, LeakyReLU represents the linear unit activation function with leakage correction. Subsequently, The input is divided into fidelity branches along the channel dimension using a Split operation. Directional structure branch input and defect detail branch input .
[0027] Figure 2 In the middle, the fidelity branch route Combined with LeakyReLU, it is used to obtain high-fidelity features. ; directional structural branches include , PWConv, Concat, And LeakyReLU, among which and They are used to extract horizontal and vertical stripe features respectively. PWConv represents pointwise convolution, and Concat represents channel concatenation. The defect detail branch includes... Difference calculation , , PWConv and LeakyReLU, among which Indicates the pooling window size is Average pooling operation, Represents local difference features. This indicates the detailed characteristics of the defect.
[0028] Figure 2The right side is the variance-gated fusion module, which is based on the intermediate feature map. Calculate the mean statistic and variance statistics and will and After concatenation using Concat, the gated weights are generated sequentially through Linear, ReLU, Linear, and Sigmoid. Here, Linear represents a linear mapping layer, ReLU represents a modified linear unit activation function, and Sigmoid represents a Sigmoid activation function. Figure 2 The term "weighted" in this context refers to multiplying the gating weights by the corresponding branch features channel by channel to adaptively adjust the contributions of directional structural features and defect detail features. Finally, the fidelity features are... Weighted directional structural features and weighted defect details By concatenating with Concat, and then... The output is processed by LeakyReLU.
[0029] In a further implementation, let the input feature map of the current SDVG module be... ,in, , and These represent the number of channels, height, and width of the input feature map, respectively. It should be noted that the input feature map... This is not the original, unprocessed inspection image, but rather an intermediate feature map obtained after processing the original insulator inspection image through a preceding network layer.
[0030] For the input feature map Channel compression is performed to obtain intermediate features The number of channels is , ; It is a 1×1 convolution; This is the LeakyReLU activation function.
[0031] Will Based on the channel, it is divided into three parts: Fidelity branch input characteristics directional structural branch input characteristics Defect details of branch input features ; The channel allocation is based on a preset ratio according to the functional requirements of each branch. In a preferred embodiment, the ratio of the number of channels for fidelity branches, directional structure branches, and defect detail branches is set as follows:
[0032] That is, when the intermediate feature map Number of channels If it is divisible by 4, let:
[0033] when If the value is not divisible by 4, it can be rounded down according to the above ratio, and the remaining channels can be allocated to directional structure branches or defect detail branches to ensure:
[0034] Among them, the fidelity branch is mainly used to preserve basic feature information, and its number of channels is relatively small; the directional structure branch needs to extract both transverse and longitudinal strip features to model the continuous arrangement structure of the insulator string, so it is allocated more channels; the defect detail branch is used to extract local differential features to enhance details such as damage, cracks, flashover edges, and gaps. Through the above channel allocation method, it is possible to control the amount of computation while ensuring the preservation of basic features, the enhancement of structural information, and the extraction of defect details.
[0035] 1.1: In a further implementation, in the fidelity branch, for Lightweight channel mapping and nonlinear activation processing are performed:
[0036] To preserve feature fidelity. The role of fidelity-preserving branches is to retain as much original feature information as possible, reduce information loss caused by excessive transformation, and maintain stable gradient propagation.
[0037] 1.2: In a further embodiment, in the directional structural branch, for Perform horizontal and vertical stripe feature extraction separately; represented as: ; ; In the formula, and The feature maps are obtained by extracting horizontal and vertical strip features, respectively. Use the LeakyReLU activation function; For a depth-separable transverse strip convolution with size 1×k, For depth-separable longitudinal strip convolution with size k×1; It is a 1×1 pointwise convolution.
[0038] The horizontal and vertical stripe feature maps are fused to obtain the directional structural features: ; It is a directional structural feature. The LeakyReLU activation function is used. The directional structure branch is used to extract the slender, continuous, and oriented arrangement features of the insulator string. Considering that the insulator string often exhibits a longitudinal or lateral extension structure in the image, strip convolution is used for modeling.
[0039] 1.3: In a further implementation, in the defect detail branch, for After smoothing, construct the difference features; ; To perform average pooling The input features are then smoothed; subsequently, local difference features are constructed using the difference between the input features and the local mean (smoothed features). : ; Local difference features Perform lightweight coding: ; In the formula: This represents the detailed defect features output after encoding. The defect detail branch is used to highlight local high-frequency anomalies, such as damage, cracks, flashover edges, and gaps.
[0040] 1.4: In a further implementation, in the variance-gated fusion module, the contributions of the directional structure branch and the defect detail branch are adaptively adjusted based on the texture complexity and response distribution of the input features. Specifically: First, regarding intermediate features Perform global average pooling Get the mean , Indicates global average pooling; Then, the global variance pooling is defined and calculated as follows: ; In the formula: This represents the variance obtained from global variance pooling; Indicate intermediate features The channel is Height is Width is Element.
[0041] This variance-gated fusion module borrows the ideas of "global statistical compression and weighted incentives" from the SE attention mechanism. Specifically, the mean... Used to characterize intermediate features Overall response strength, variance Used to characterize intermediate features The response dispersion and texture complexity are considered. For insulator inspection images, when the main outline of the insulator string is continuous and the arrangement direction is obvious, the intermediate features usually show a more stable structural response. In this case, the directional structural branches contribute more to the detection results. When there are damages, gaps, flashover edges, cracks, or complex background interference in the image, the local response differences of the intermediate features increase, and the variance statistics can reflect such local abnormal changes. In this case, the defect detail branches contribute more to the detection results.
[0042] Therefore, this application will average With variance Concatenating to form a statistical vector Furthermore, by learning a nonlinear mapping relationship from statistical distribution to branch weights through a two-layer perceptron, the model can dynamically adjust the contributions of directional structure branches and defect detail branches in the fused features based on the structural saliency and texture complexity of different input features. Specifically, this involves... With variance By concatenating the data, we obtain a statistical vector. ; Statistical vector The data is fed into a two-layer perceptron to generate the weights of the structural and detail branches: ; In the formula, The weights of the structural branches; The weight of the detailed branch. , These are learnable parameters; It is the ReLU activation function; This is the Sigmoid function.
[0043] Furthermore, the directional structural features and defect detail features are respectively multiplied channel-by-channel with weighted sums to obtain the weighted directional structural features. and weighted defect details ; Finally, the fidelity features Weighted directional structural features and weighted defect details The components are stitched together using a 1×1 convolution to achieve fusion. ; Indicates multi-pathway fusion characteristics, This is the LeakyReLU activation function.
[0044] Starting from the target structural characteristics and defect manifestations, the SDVG module can suppress irrelevant background interference in advance at the backbone network stage while maintaining low computational complexity, and enhance the characterization ability of small defects in insulators, providing more discriminative basic features for subsequent multi-scale feature fusion and detection head regression classification.
[0045] S2: In one embodiment, in order to reduce the computational complexity of the YOLOv8n neck network and improve the neck network's ability to handle splicing features in a lightweight manner, this application further improves its neck network.
[0046] like Figure 1 As shown, the input to the neck network comes from feature maps of different scales output by the backbone network, including multi-path fusion features from multiple SDVG modules and high-level semantic features from the SPPF module. The multi-path fusion features output by the SDVG modules contain the fusion results of fidelity features, directional structure features, and defect detail features, providing the neck network with overall insulator string structural information and local defect detail information.
[0047] First, the C2F module in the neck network of YOLOv8n is replaced with the GC3 module. The GC3 module improves computational efficiency by replacing all standard convolutions in the C3 module with Ghost convolutions, reducing computational load and memory usage. (See reference...) Figure 3 The GC3 module includes two CBS modules, one GBottleneck module, one Concat splicing unit, and one output CBS module. Figure 3 In this context, CBS represents the basic convolutional module, which consists of a Convolutional layer (Conv), a Batch Normalization layer (BN), and a SiLU activation function, used to perform convolutional transformations, normalization, and non-linear activations on the input features; GBottleneck represents a lightweight bottleneck structure that introduces Ghost convolutions, used to generate effective features while reducing the computational cost of standard convolutions; and Concat represents the channel concatenation operation, used to fuse the features output from different branches along the channel dimension.
[0048] Specifically, the input features of the GC3 module are divided into two branches after entering the module: the first branch passes through the CBS module and the GBottleneck module in sequence to obtain the main branch features after lightweight transformation; the second branch passes through another CBS module to obtain the bypass branch features, which are used to retain the basic information in the input features. Subsequently, the main branch features and the bypass branch features are concatenated through a Concat operation to obtain the concatenated features; finally, the concatenated features are integrated through the output CBS module to obtain the output features of the GC3 module.
[0049] Through the above structure, the GC3 module retains the cross-stage branching and feature concatenation ideas of the C3 module, while utilizing Ghost convolutions in GBottleneck to reduce redundant convolutional computations and intermediate feature storage overhead. Therefore, the GC3 module is mainly used to perform lightweight fusion processing on the concat features in the neck network, thereby reducing the number of model parameters and computational cost, and improving the model's adaptability for deployment on UAV inspection equipment or edge computing terminals.
[0050] The GC3 module is used to perform lightweight processing on the features concatenated by the Concat operation in the neck network. Its core function is to reduce the number of parameters, computational cost, and intermediate feature storage overhead of the neck network.
[0051] Specifically, such as Figure 1 As shown, the neck network contains multiple concat nodes where features from upsampling, downsampling, and the corresponding layers of the backbone network are concatenated. The concatenated features are then input to the GC3 module, where they undergo feature fusion and channel compression. Building upon the cross-stage connection structure of the C3 module, the GC3 module replaces standard convolutions with Ghost convolutions, generating effective features with lower computational cost, thereby reducing redundant convolution computations and memory usage.
[0052] Therefore, this application incorporates a GC3 module in the neck network as a lightweight feature processing module to replace the computationally intensive C2F module in the original neck network. This approach reduces model complexity while maintaining the basic feature fusion functionality of the neck network, making the improved detection network more suitable for deployment on platforms with limited computing resources, such as UAV inspection equipment and edge computing terminals.
[0053] Then, to address the issue of blurred or incomplete images of power distribution line insulators due to complex environmental backgrounds, and to improve the accuracy of small target detection by enabling the model to focus on key areas, this invention further introduces a CBAM attention mechanism module (convolutional block attention module) into the neck network, referring to... Figure 4 The CBAM module includes a channel attention mechanism (CAM) and a spatial attention mechanism (SAM). The input to the CBAM module is the high-resolution fused features obtained from the neck network after upsampling, concat stitching, and fusion by the GC3 module. This high-resolution fusion feature It also includes insulator structure information, defect details, and semantic information after neck network fusion from the backbone network SDVG module. The features are processed sequentially using the channel attention mechanism (CAM) and the spatial attention mechanism (SAM) to perform channel-dimensional weighting and spatial-dimensional weighting, respectively, resulting in attention-enhanced features. The attention enhancement feature Used to input subsequent 160×160 inspection heads to enhance the detection capability of small defect targets.
[0054] like Figure 5 As shown, CAM uses feature maps As input, respectively for Max pooling and average pooling are performed to obtain global response information across different channels. Max pooling is used to highlight significant responses within a channel, while average pooling characterizes the overall response of the channel. The results of max pooling and average pooling are then fed into a shared fully connected layer (MLP) for mapping, and the two outputs are summed before being input into a sigmoid function to obtain the channel weights. Figure 5 In this context, "max pooling" and "average pooling" represent two global pooling operations in channel attention, respectively. "Shared fully connected layer" or MLP represents a shared mapping network used to generate channel weights. "Sigmoid" represents an activation function used to limit the weights to the range of 0 to 1. "Channel weight" represents the importance of each channel to the insulator defect detection task.
[0055] The channel weights generated by CAM are compared with the input features. Multiplying yields the channel enhancement features. In this application, channel weights can enhance the effective channel response associated with insulator defects and suppress irrelevant channel responses caused by background factors such as sky, conductors, towers, and vegetation.
[0056] like Figure 6 As shown, SAM uses channel enhancement features As input, max pooling and average pooling are performed on the channel dimension to obtain two spatial description maps. Then, the two spatial description maps are concatenated and convolved, and finally, the position weights are generated by the Sigmoid function. Figure 6 In this context, "channel weights" refers to the channel attention weights of the CAM output. This represents the feature map after channel attention weighting. "Max pooling" and "average pooling" represent channel-dimensional pooling operations in spatial attention. "Convolution" is used to fuse the pooled spatial description map. "Sigmoid" is used to generate position weights in the range of 0 to 1. "Position weights" represent the importance of different spatial regions in the feature map for defect detection.
[0057] The location weights generated by SAM are combined with channel enhancement features. Multiply to obtain attention-enhancing features ,like Figure 4 As shown. This feature, compared to the original high-resolution fused feature... This can better highlight the area where the insulator defect is located and suppress interference from complex background areas.
[0058] The overall data flow of the neck network is as follows: like Figure 1 As shown, the input to the neck network comes from feature maps of different scales output by the backbone network, including multi-path fusion features from multiple SDVG modules and high-level semantic features from the SPPF module. The multi-path fusion features output by the SDVG modules contain the fusion results of fidelity features, directional structure features, and defect detail features, providing the neck network with overall insulator string structural information and local defect detail information.
[0059] In the Neck network, the high-level semantic features output by the SPPF module are first upsampled to make their spatial size consistent with the feature maps output by the adjacent shallow SDVG modules. Then, the upsampled high-level semantic features are concatenated with the SDVG output features of the corresponding scale in the channel dimension through the Concat operation to obtain the concatenated features. The concatenated features are then input into the GC3 module for lightweight feature fusion.
[0060] Furthermore, the features fused by the GC3 module are upsampled and concatenated with the shallower SDVG output features via a Concat operation, and then further fused by the GC3 module. Through this top-down feature fusion process, deep semantic information can be combined with shallow detail information, thereby enhancing the neck network's ability to express small-scale defects in insulators.
[0061] After obtaining the high-resolution fusion feature, it is input into the CBAM attention module. The CBAM module sequentially weights the fusion feature through channel attention and spatial attention mechanisms to obtain the attention-enhanced high-resolution fusion feature. This feature is output to the 160×160 detector head to improve the detection capability of small defect targets; on the other hand, after being downsampled by GhostConv, it is further concatenated with the neck feature of the corresponding scale and fused through the GC3 module to obtain the medium-resolution fusion feature (third fusion feature) corresponding to the 80×80 detector head.
[0062] Subsequently, the medium-resolution fusion features (SPPF output features) are further downsampled by GhostConv and concatenated with deeper neck features, then fused by the GC3 module to obtain the low-resolution fusion features (second fusion features) corresponding to the 40×40 detector head. Thus, the input to the neck network is the multi-scale feature map output by the backbone network, and the calculations involved include upsampling, concatenation, GC3 lightweight fusion, CBAM attention enhancement, and GhostConv downsampling. The output consists of three sets of fusion feature maps with different resolutions, which are fed into the 160×160, 80×80, and 40×40 detector heads, respectively.
[0063] S3: In one embodiment, in order to improve the problem that small defect features are easily lost during multiple downsampling processes in YOLOv8n, this application improves the scale branch of the detection head, replacing the 20×20 detection head (corresponding to the first downsampling factor) used for large target detection in the original YOLOv8n with a 160×160 detection head (corresponding to the fourth downsampling factor) used for small target detection.
[0064] In one example, the input image resolution is 640×640. The first downsampling factor corresponds to 32x downsampling and a feature map of 20×20. The fourth downsampling factor corresponds to 4x downsampling and a feature map of 160×160. The second and third downsampling factors correspond to 16x and 8x downsampling respectively (40×40 and 80×80).
[0065] It should be noted that this implementation method does not simply replace the size of the detection head, but rather, taking into account the characteristics of small defect target size, weak edge details, and strong background interference in insulator defect detection tasks, it reconfigures the data flow between the output features of the detection head and the neck network. For example... Figure 1 As shown, the neck network, after upsampling, concat concatenation, GC3 lightweight fusion, and CBAM attention enhancement, outputs a feature map with a spatial resolution of 160×160. This feature map is denoted as... The aforementioned The input features of the 160×160 detector head are used for classification prediction and bounding box regression of micro insulator defect targets.
[0066] Compared to a 20×20 detection head, a 160×160 detection head has a smaller feature map downsampling factor, which preserves more shallow texture information, edge information, and local detail information. For defects such as insulator aging, missing parts, dirt, and breakage, these typically appear as small local areas with subtle morphological changes and indistinct boundaries in inspection images. If the lower-resolution 20×20 detection head is continued, these minute defects are easily compressed or submerged after multiple downsampling, leading to missed detections or inaccurate localization. Therefore, this application introduces a 160×160 detection head, enabling the model to perform detection based on higher-resolution feature maps, thereby enhancing the response capability to minute defect targets.
[0067] Meanwhile, this application removes the original 20×20 detection head. The reason is that the 20×20 detection head is mainly used for detecting larger-scale targets, while in the insulator defect inspection scenario of this application, the detection objects are mainly local defects in the insulator, with relatively small target scales. Therefore, the contribution of the larger target detection branch to this task is limited. Removing the 20×20 detection head reduces the convolution calculations, the number of prediction boxes, and the intermediate feature storage overhead in the detection branch, thereby reducing the model's computational complexity and memory usage.
[0068] With the above configuration, the detection head includes three detection branches: 160×160, 80×80, and 40×40. The 160×160 detection head is used to detect minute defects, the 80×80 head for smaller-scale defects, and the 40×40 head for medium-scale defects. This head configuration matches the scale distribution of insulator defects, improving the detection capability for minute targets while avoiding redundant calculations caused by large-target detection heads. This makes it more suitable for UAV inspections and real-time deployment scenarios for edge devices.
[0069] S4: In one implementation, the bounding box loss function of the YOLOv8n model is improved to dynamically adjust the regression contribution of different quality prediction boxes, thereby improving the positioning accuracy and robustness of power line defects under high IoU thresholds.
[0070] It should be noted that the bounding box loss function described in S4 mainly applies during the model training phase and does not change the bounding box loss function. Figure 1The improved YOLOv8n network's forward structure during the inference phase is shown. Specifically, after processing by three detection heads (160×160, 80×80, and 40×40) in S3, the model outputs prediction results at different scales, including the predicted category, prediction confidence, and predicted bounding boxes. During training, the predicted bounding boxes output by the detection heads are matched with the ground truth bounding boxes in the labeled data, and the bounding box regression loss is calculated based on the matched predicted and ground truth boxes. The improved EIoU loss function replaces the bounding box regression loss term in the original YOLOv8n to constrain the regression errors of the predicted box position, width, and height. This loss value participates in the calculation of the total training loss and updates the learnable parameters in the backbone network, neck network, and detection heads through backpropagation, thereby improving the model's accuracy in locating insulator defects.
[0071] In power line insulator defect scenarios with small target sizes and complex backgrounds, low-quality predicted boxes often dominate gradient updates during training, limiting localization performance at high IoU thresholds. The YOLOv8n model uses CIoU as the loss function for bounding boxes, comprehensively considering the overlap between predicted and ground truth boxes, the distance between center points, and aspect ratio differences. However, the aspect ratio term in CIoU primarily focuses on the proportional consistency of the boxes. When the proportions are consistent, the model is prone to degradation and struggles to effectively describe actual width and height errors, potentially limiting optimization effectiveness.
[0072] Therefore, this application uses EIoU as the basic loss function, and improves the optimization efficiency by constraining the width and height errors of the bounding box. Loss Function The expression is as follows: ; In the formula: IoU is the intersection-union ratio of the predicted bounding box and the ground truth bounding box; Euclidean distance; , , These are the coordinates of the center point, width, and height of the prediction box, respectively. , , , where are the center point coordinates, width, and height of the ground truth bounding box, respectively; c is the diagonal length of the minimum bounding rectangle enclosed by the predicted bounding box and the ground truth bounding box; cw and ch are the width constant and height constant, respectively.
[0073] Furthermore, based on the EIoU loss function, improvements are made by designing isocenter scaling, scale factor decay, and quality reweighting strategies to dynamically adjust the regression contribution of different quality prediction boxes.
[0074] First, the predicted bounding box and the ground truth bounding box are scaled isocentrically, and the new intersection-over-union ratio is calculated, denoted as . And a scale factor attenuation is introduced, as shown in the following equation:
[0075]
[0076]
[0077] In the formula: For scaling operation; B is the bounding box; x, y, w, and h are the x-coordinate, y-coordinate, width, and height of the bounding box center point, respectively; r(t) is the scaling factor that changes with the training epoch t. For intersection, union, and ratio operations; and These are the predicted bounding box and the ground truth bounding box, respectively. t represents the current training iteration. and These are the initial and final values of the scaling factor, respectively. is the decay function; T is the total number of training rounds.
[0078] It should be noted that this invention decays the scale factor r(t), reducing it by a larger value in the early stages of training. The penalty is initially applied to allow the target box to be located; in the later stages of training, r(t) is gradually reduced, mainly to increase the penalty for high-quality samples. This is intended to enhance the precise localization of the target bounding box.
[0079] In summary, the improved EIoU regression loss proposed in this application is:
[0080] This design is based on EIoU and optimizes the IoU loss of the scaling domain by adjusting the scaling factor, which can enhance the accurate regression of high-quality prediction boxes, thereby improving the positioning accuracy and robustness of power line defects under high IoU thresholds.
[0081] Example 2 This embodiment provides a case study using a publicly available dataset of power insulators as the experimental dataset. This dataset contains 6050 images, covering normal insulators and three defect categories: aging, missing, and contaminated. The images are randomly divided into training, validation, and test sets in an 8:1:1 ratio. Figure 7 The dataset shows partial samples of three types of insulator defects.
[0082] 2.1: The experimental hardware environment and hyperparameter settings in this embodiment are shown in Table 1 and Table 2. All experiments were conducted under the same configuration.
[0083] Table 1 Experimental Hardware Environment
[0084] Table 2 Experimental hyperparameter settings
[0085] 2.2 Regarding model accuracy, this embodiment uses precision (P), recall (R), and mean precision. (mean average precision) is used as an evaluation index, and its calculation formula is shown in the following formula:
[0086]
[0087]
[0088]
[0089] In the formula: , , These represent the number of positive examples predicted by the model and actually positive examples, the number of positive examples predicted by the model but actually negative examples, and the number of negative examples predicted by the model but actually positive examples; No. The average precision of the class; P(R) is the precision-recall curve; N is the total number of classes in the dataset.
[0090] For indicators This embodiment adopts @0.50 and It reflects the detection performance under different positioning accuracies. @0.50 indicates that the IoU threshold is 0.50. ; This represents the average IoU threshold when it is between 0.50 and 0.95 (in steps of 0.05). It can comprehensively measure the model's precise localization capability at high IoU thresholds.
[0091] To evaluate the lightweight nature of the model, the number of parameters (Params) and the computational cost (FLOPs) are used as evaluation metrics, and the calculation formulas are as follows:
[0092]
[0093] In the formula: The number of input feature maps; , ,and These represent the height, width, and number of channels of the input feature map, respectively. , , These represent the number, height, and width of the convolutional kernels, respectively.
[0094] 2.3: To verify the effectiveness of each improvement scheme in the proposed improved YOLOv8n object detection model, this embodiment designs an ablation experiment based on the original YOLOv8n. Under the same training process, environment, and hyperparameters, the small object detection layer, GC2F module, GC3 module, CBAM attention mechanism, and improved EIoU loss function are added sequentially by controlling variables to quantitatively evaluate the contribution of each improvement point to the model performance. After multiple training iterations, the experimental results are shown in Table 3.
[0095] Table 3 Ablation Experiment Results 1
[0096] Based on Table 3, the following conclusions can be drawn: First, by adding a 160×160 small target detection layer and removing the original 20×20 large target detection layer, the model's precision (P) and recall (R) increased by 0.8% and 1.5%, respectively, and mAP@0.50 increased to 88.5%, while the number of parameters was significantly reduced to 0.99 M.
[0097] Next, by replacing the C2F module in the backbone network with the SDVG module and replacing the standard convolution with Ghost convolution, the number of parameters and computational cost of the model were reduced by 0.23M and 1.5G, respectively. The SDVG module optimizes the feature extraction process by introducing lightweight Ghost convolution, while the model accuracy remains basically unchanged, with mAP@0.50 maintained at 88.4%.
[0098] When further optimizing the neck network, the addition of the GC3 module further reduced the number of parameters and computational cost of the feature fusion part, reducing the number of parameters to 0.62 M and the computational cost to 8.0 G. At the same time, the improvement of multi-scale feature fusion capability increased mAP@0.50 to 89.6%.
[0099] After introducing the CBAM attention mechanism, the precision (P) increased by 1.7%, the recall (R) increased by 0.9%, and the mAP@0.50 increased by 1.9%. It can be seen that the CBAM attention mechanism can significantly enhance the detection capability of small targets in complex backgrounds.
[0100] Finally, after introducing the improved EIoU loss function, mAP@0.50:0.95 increased from 61.3% to 67.5% (an increase of 6.2%), significantly enhancing the bounding box regression and precise localization capabilities under high IoU thresholds.
[0101] In summary, the various optimization modules introduced step by step improved the model's accuracy and efficiency performance in different dimensions.
[0102] 2.4: To verify the superiority of the method in this embodiment, comparative experiments were conducted with several mainstream target detection algorithms based on the constructed insulator defect dataset. The comparison methods included Faster R-CNN, YOLOv5n, YOLOv8n, YOLOv8s, YOLOv10n, and YOLOv11n. The experimental results are shown in Table 4.
[0103] Table 4 Comparison of experimental results
[0104] As shown in Table 4, in terms of model accuracy performance, the improved YOLOv8n model in this embodiment achieves an mAP@0.50 value of 93.2%, significantly higher than other comparative models. In particular, compared with the YOLOv10n and YOLOv11n proposed in recent years, mAP@0.50 is improved by 9% and 7.9%, respectively. This improvement demonstrates that the proposed model possesses superior detection performance for problems with complex backgrounds and small target scales, such as insulator defect detection.
[0105] In terms of model efficiency and performance, the improved YOLOv8n model excels in both parameter count and computational cost, with only 0.62 M parameters, significantly lower than other models. This means that the improved model maintains high accuracy while greatly reducing computational resource consumption, making it suitable for deployment on resource-constrained edge computing devices such as drones.
[0106] In summary, the improved YOLOv8n model demonstrates significant advantages in both accuracy and efficiency, and can meet the accuracy and efficiency requirements of power grid distribution line insulator defect detection engineering practice.
[0107] 2.5: This embodiment uses heatmaps for visualization, comparing the key areas of interest between the improved model and the original YOLOv8n model, such as... Figure 8 As shown in the image, the highlighted areas in the heatmap represent the target regions of interest to the model.
[0108] Depend on Figure 8It can be seen that, compared to the traditional YOLOv8n model, the improved model, by introducing the CBAM attention mechanism, can more effectively focus on defect targets in small targets and complex backgrounds. The original YOLOv8n model, however, not only focuses on the target region but also on the background region, resulting in a decrease in its feature capture capability.
[0109] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the specific implementation of the present invention. Any modifications or equivalent substitutions that do not depart from the spirit and scope of the present invention should be covered within the protection scope of the claims of the present invention.
Claims
1. A lightweight visual processing method for insulator defect detection, characterized in that, include: Construct a dual-path variance gating module for structure and detail in the YOLOv8n backbone network; The insulator image is sequentially passed through the CBS module and the GhostConv module to extract the input feature map, which is then input into the dual-path variance gating module to output multi-layer multi-path fusion features; the SPPF module is then connected to the end of the dual-path variance gating module to obtain high-level semantic features; A multi-scale feature pyramid is designed in the neck network of YOLOv8n; the multi-path fusion features of each layer are concatenated with the upsampled high-level semantic features and fused in the GC3 module; the fusion process is repeated layer by layer, and finally the high-resolution fusion features are input into the convolutional block attention module to obtain attention-enhanced features; Design the feature map resolution in the YOLOv8n detection head; Corresponding to the resolution of the insulator image, the detection branch in the detection head corresponding to the first downsampling factor is replaced with the detection branch of the fourth downsampling factor, and the first downsampling factor branch is deleted; The fourth downsampling factor is less than the first downsampling factor; In the loss function of YOLOv8n, a dynamic loss function is designed; EIoU is used as the basic loss function, and a scale factor that decays over time is introduced during training to perform isocentric scaling transformation on the predicted box and the ground truth box, thereby constructing a dynamically adjusted intersection-union ratio.
2. The lightweight visual processing method for insulator defect detection according to claim 1, characterized in that, The dual-channel gated variance gated module includes a fidelity branch, a directional structure branch, a defect detail branch, and a variance gated fusion module, including: After channel compression of the input feature map, an intermediate feature map is obtained. The intermediate feature map is then divided into three branches according to the channel: fidelity branch input features, directional structure branch input features, and defect detail branch input features. In the fidelity branch, lightweight channel mapping and nonlinear activation processing are performed on the input features of the fidelity branch to obtain fidelity features; In the directional structure branch, the input features of the directional structure branch are subjected to horizontal strip feature extraction and vertical strip feature extraction respectively. The horizontal strip feature map and the vertical strip feature map are fused to obtain the directional structure features. In the defect detail branch, after the input features of the defect detail branch are smoothed by average pooling, local difference features are constructed by using the difference between the input features of the defect detail branch and the smoothed features; the local difference features are then lightly encoded to output the defect detail features.
3. A lightweight visual processing method for insulator defect detection according to claim 2, characterized in that, The variance-gated fusion module includes: The global mean and global variance of the intermediate feature map are obtained and concatenated into a statistical vector; the statistical vector is input into a two-layer perceptron to generate structural branch weights and detail branch weights. The directional structural features are weighted with the structural branch weights, and the defect detail features are weighted with the detail branch weights, respectively, to obtain the weighted directional structural features and the weighted defect detail features. The high-fidelity features, weighted directional structural features, and weighted defect detail features are concatenated and fused through convolution to output multi-path fusion features.
4. A lightweight visual processing method for insulator defect detection according to claim 1, characterized in that, The multi-scale feature pyramid includes: The high-level semantic features are upsampled to match the spatial size of the multi-channel fusion features, and the upsampled semantic features are concatenated with the multi-channel fusion features in the channel dimension. The concatenated features are then input into the GC3 module for fusion. The features fused by the GC3 module are further upsampled and spliced with the multi-channel fused features of the next layer, and then fused again by the GC3 module. High-resolution fusion features are obtained through layer-by-layer fusion.
5. A lightweight visual processing method for insulator defect detection according to claim 1, characterized in that, The convolutional block attention module includes: Channel attention mechanism and spatial attention mechanism; The channel attention mechanism performs max pooling and average pooling on the high-resolution fused features respectively, and maps the results of the two pooling operations through a shared fully connected layer; the two mapped outputs are added together and then input into the activation function to obtain the channel weights; The channel weights are multiplied by the high-resolution fusion features to obtain the channel enhancement features.
6. A lightweight visual processing method for insulator defect detection according to claim 5, characterized in that, The spatial attention mechanism includes: The channel enhancement features are subjected to max pooling and average pooling in the channel dimension to obtain two spatial description maps. The two spatial description maps are then concatenated and convolved, and then the location weights are generated by an activation function. Multiplying the location weights by the channel enhancement features yields the attention enhancement features.
7. A lightweight visual processing method for insulator defect detection according to claim 1, characterized in that, The feature map resolution in the detection head includes: Based on the resolution of the insulator image, replace the detection branch corresponding to the first downsampling factor in the detection head with the detection branch corresponding to the fourth downsampling factor, and delete the first downsampling factor detection branch; The resolution of the attention enhancement feature is consistent with that of the fourth sampling multiple detection branch; The attention enhancement features are input into the fourth downsampling factor detection branch. The attention enhancement feature is downsampled by GhostConv and concatenated with the fusion feature output by the corresponding scale GC3 module to form a third fusion feature, which is then sent to the third downsampling factor detection branch. The third fusion feature is downsampled by GhostConv and concatenated with the fusion feature output by the corresponding scale GC3 module to form the second fusion feature, which is then sent to the second downsampling factor detection branch.
8. A lightweight visual processing method for insulator defect detection according to claim 1, characterized in that, Constructing a dynamically adjusted crossover-union ratio includes: Design a decay function for the scaling factor so that the scaling factor changes with the training rounds; Based on the scaling factor that decays over time, the predicted bounding box and the ground truth bounding box are scaled isocentrically and a new intersection-union ratio is calculated. Substitute the difference between 1 and the new crossover ratio into EIoU to form the dynamic loss function.
9. A lightweight vision processing system for insulator defect detection, comprising performing the lightweight vision processing method as described in any one of claims 1-8, characterized in that, The system includes: Backbone network improvement module; used to construct a structure and detail dual-path variance gating module in the YOLOv8n backbone network; the insulator image is sequentially passed through the CBS module and GhostConv module to extract the input feature map, which is then input to the dual-path variance gating module to output multi-layer multi-path fusion features; the SPPF module is connected after the dual-path variance gating module to obtain high-level semantic features; The neck network improvement module is used to design a multi-scale feature pyramid in the neck network of YOLOv8n. The multi-path fusion features of each layer are concatenated with the upsampled high-level semantic features and fused in the GC3 module. The fusion process is repeated layer by layer, and finally the high-resolution fusion features are input into the convolutional block attention module to obtain attention-enhanced features. An improved detection head module is used to design the feature map resolution in the YOLOv8n detection head. Corresponding to the resolution of the insulator image, the detection branch corresponding to the first downsampling factor in the detection head is replaced with a detection branch corresponding to the fourth downsampling factor, and the first downsampling factor branch is deleted. The fourth downsampling factor is less than the first downsampling factor. The loss function improvement module is used to design a dynamic loss function in the YOLOv8n loss function. It adopts EIoU as the basic loss function and introduces a scale factor that decays over time during training to perform isocentric scaling transformation on the predicted boxes and ground truth boxes, thereby constructing a dynamically adjusted intersection-union ratio.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the computer program is loaded into the processor, it implements the lightweight visual processing method according to any one of claims 1-8.
11. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the lightweight visual processing method according to any one of claims 1-8.