Electrical equipment defect detection and identification method based on improved YOLOv8

By improving the YOLOv8 network, using the Swin Transformer, depthwise separable convolution and Ghost modules, combined with the SimAM parameter-free attention and CausalDyConv modules, the detection problem of small target defects in electrical equipment in complex backgrounds was solved, and efficient and accurate defect recognition was achieved.

CN120672686APending Publication Date: 2025-09-19CHANGZHOU UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510737746.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-04
Publication Date
2025-09-19

AI Technical Summary

Technical Problem

Existing technologies have difficulty in efficiently identifying small target defects of electrical equipment, such as cracks, dirt, and damage, in complex backgrounds. Traditional methods also have poor robustness and are significantly affected by changes in lighting and oxidation of the equipment surface.

Method used

An improved YOLOv8 network is adopted. By replacing the backbone network with Swin Transformer, combining depthwise separable convolution and Ghost modules, introducing the SimAM parameter-free attention mechanism and decoupled detection head, and embedding the CausalDyConv module, the small target detection accuracy and model efficiency are optimized.

Benefits of technology

It significantly improves the accuracy and speed of electrical equipment defect detection, adapts to small target recognition in complex backgrounds, reduces computing costs, and improves the applicability and accuracy of detection models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120672686A_ABST
    Figure CN120672686A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of electrical equipment visual defect detection, in particular to an improved YOLOv8-based electrical equipment defect detection and identification method, which comprises the following steps of: replacing a backbone network with a Swin Transform, and optimizing small target detail feature extraction by combining a shallow high-resolution feature layer and expansion convolution; ordinary convolution in the backbone network is replaced by deep separable convolution and a Ghost module to realize lightweight design, and a new backbone network is formed; meanwhile, a SimAM non-parameter attention mechanism is introduced, and defect area feature response is dynamically enhanced through airspace and channel combined weight; a decoupling detection head is designed at a detection head part, classification and regression branches are separated to relieve task conflicts, and a CaualDyConv module is introduced at the head part to enhance the causal reasoning capability of feature expression. Aiming at challenges of dense small targets, special forms, complex backgrounds and the like in electrical equipment and power transmission line defect detection tasks, the invention improves the detection precision while keeping the detection speed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of visual defect detection of electrical equipment, and in particular to an electrical equipment defect detection and identification method based on improved YOLOv8. Background Art

[0002] As the scale of power systems continues to expand, the safe operation of electrical equipment and transmission lines has become critical to ensuring grid reliability. However, electrical equipment defect detection faces challenges such as densely packed small objects, unusual shapes, and complex backgrounds. Traditional manual inspection methods suffer from inherent drawbacks such as low efficiency and high risk. Intelligent detection technologies based on computer vision have gradually become a research hotspot. Traditional image defect detection methods rely on manually designed features, such as edge extraction and texture analysis. Their robustness is significantly affected by factors such as lighting variations and surface oxidation, making them difficult to adapt to multi-scale defect detection in complex backgrounds. For example, defects such as broken insulators and rusted hardware typically occupy only 0.1%-1% of the image area and exhibit irregular geometric shapes. In transmission line scenes, metal components exhibit strong reflections and high similarity interference with the natural environment. Furthermore, the complex surface textures and variable lighting conditions of some equipment make feature extraction difficult. These technical bottlenecks severely restrict the engineering applicability of existing detection models.

[0003] In recent years, the rapid development of deep learning technology, particularly the application of convolutional neural networks, has significantly improved the accuracy and efficiency of defect detection. In research on defect and damage detection models for electrical equipment, finding methods to improve detection accuracy while maintaining speed and processing defect images with densely packed small objects, unusual shapes, and complex backgrounds has become a key research direction and challenge. Summary of the Invention

[0004] The technical problem to be solved by the present invention is: In order to overcome the above technical problems, the present invention provides an electrical equipment defect detection and identification method based on improved YOLOv8, which is suitable for defect detection of electrical equipment, especially for the accurate identification and positioning of small target defects, such as cracks, dirt, damage and other small target defects.

[0005] The technical solution adopted by the present invention to solve the technical problem is: a method for detecting and identifying defects in electrical equipment based on an improved YOLOv8, comprising the following steps:

[0006] Step 1: Construct an electrical equipment defect dataset: Collect defect image data of electrical equipment, including surface damage, cracks, corrosion, looseness, and other defects. Store the data and classify and annotate it to provide training and test data for subsequent processing;

[0007] Step 2: Dataset Analysis and Partitioning: Analyze the distribution of the dataset and check whether the samples of different types of defects are balanced. Based on training needs, divide the dataset into training, validation, and test sets for training, validation, and evaluation of the model, respectively.

[0008] Step 3: Build an improved model based on the YOLOv8n network model: First, by replacing the backbone network with Swin Transformer, integrating shallow high-resolution features and dilated convolution to enhance the capture of small target details, and replacing the ordinary convolution with depthwise separable convolution and Ghost module, a lightweight design is achieved to form a new backbone network; secondly, the SimAM parameter-free attention mechanism is added to the backbone network; finally, a decoupled detection head is designed in the detection head to separate the classification and regression tasks, and the CausalDyConv module (causal dynamic convolution module) is embedded to enhance feature causal reasoning, effectively solving the problems of missed detection of small targets, complex background interference and low model calculation efficiency, and significantly improving detection accuracy and deployment applicability;

[0009] Step 4: Train the model;

[0010] Step 5: Use the trained model to perform defect detection on the test set images and output the detection results.

[0011] In step 2, the ratio of training set, validation set and test set is 7:2:1.

[0012] In step 3, the overall network architecture of Swin Transformer is composed of multiple stacked Swin Transformer Blocks; in addition, Swin Transformer divides the image into multiple non-overlapping local windows, and self-attention is calculated independently in each window.

[0013] In step 3, the depth-wise separable convolution considers channels and spatial regions separately, decomposing the standard convolution into two independent steps: depth-wise convolution and point-wise convolution.

[0014] In step three, the SimAM parameter-free attention mechanism uses the statistical characteristics of the input features themselves to calculate the difference energy between each position and its neighborhood and generate adaptive attention weights.

[0015] The decoupled detection head achieves task separation through the following methods: first, independent branch design, where the classification branch and regression branch have their own independent convolutional layers or fully connected layers, respectively optimizing task-related features; second, feature adaptation, where the classification branch expands the receptive field to capture global semantic information, and the regression branch adapts to the deformation and scale changes of the target through refined convolution.

[0016] In the convolution operation, the CausalDyConv module limits the receptive field of the convolution kernel to only cover the current and past time steps or spatial positions.

[0017] In the convolution operation of the CausalDyConv module, the weight W of the convolution kernel is dynamically generated according to the input features through a neural network.

[0018] The pre-trained model is fine-tuned using electrical equipment defect data, and the model weights are adjusted to make it more suitable for detecting specific defect categories. After selecting the optimal model, the training process ends.

[0019] Finally, it also includes step six: If the detection results of step five meet the requirements, the model can be put into practical application; if the detection effect of step five does not meet the requirements, the data set is re-optimized or the model structure is adjusted, and iterative updates are performed to improve the detection effect and ensure that the model achieves optimal performance.

[0020] The beneficial effect of the present invention is that the present invention is a method for detecting and identifying defects in electrical equipment based on improved YOLOv8, which aims to improve detection accuracy while maintaining detection speed in the task of defect detection of electrical equipment and transmission lines, such as dense small targets, special shapes, and complex backgrounds. By replacing the backbone network with Swin Transformer, its layered window attention mechanism is used to enhance the long-distance dependency modeling capability, and combining the shallow high-resolution feature layer with the dilated convolution to optimize the extraction of small target detail features, in order to further reduce the computational cost, the ordinary convolution in the backbone network is replaced with the depth-wise separable convolution and the Ghost module to achieve a lightweight design, forming a new backbone network; at the same time, the SimAM parameter-free attention mechanism is introduced to dynamically enhance the feature response of the defect area through the joint weighting of the spatial domain and the channel; a decoupled detection head is designed in the detection head part, separating the classification and regression branches to alleviate task conflicts, and the CausalDyConv module is introduced in the head to enhance the causal reasoning ability of feature expression. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The present invention will be further described below with reference to the accompanying drawings and examples.

[0022] Figure 1 It is a basic flow chart of the present invention.

[0023] Figure 2 This is the existing YOLOv8n structure diagram.

[0024] Figure 3 This is the improved YOLOv8n structure diagram of the present invention.

[0025] Figure 4 This is an overview diagram of the depth-wise separable convolution of the present invention.

[0026] Figure 5 : (a) is a conventional convolution operation structure diagram, and (b) is a Ghost convolution operation structure diagram of the present invention.

[0027] Figure 6 This is the principle diagram of the SimAM attention mechanism of the present invention. DETAILED DESCRIPTION

[0028] The present invention will now be described in further detail with reference to the accompanying drawings, which are simplified schematic diagrams that illustrate the basic structure of the present invention in a schematic manner.

[0029] like Figure 1 As shown, the present invention provides an electrical equipment defect detection and identification method based on improved YOLOv8, comprising the following steps:

[0030] Step 1: Build an electrical equipment defect dataset: Collect defect image data of electrical equipment, including surface damage, cracks, corrosion, looseness, and other defects. Store and classify the data to provide training and test data for subsequent processing.

[0031] Step 2: Dataset Analysis and Division: Analyze the distribution of the dataset and check whether the samples of various defects are balanced. Based on training needs, divide the dataset into training set, validation set, and test set in a ratio of 7:2:1, which are used for training, validation, and evaluation of the model, respectively.

[0032] Step 3. Build an improved model based on the YOLOv8n network model: First, by replacing the backbone network with Swin Transformer, integrating shallow high-resolution features and dilated convolution to enhance the capture of small target details, and replacing the ordinary convolution with depthwise separable convolution and Ghost module, a lightweight design is achieved to form a new backbone network; secondly, the SimAM parameter-free attention mechanism is added to the backbone network; finally, a decoupled detection head is designed in the detection head to separate the classification and regression tasks, and the CausalDyConv module is embedded to enhance feature causal reasoning, effectively solving the problems of missed detection of small targets, complex background interference and low model calculation efficiency, and significantly improving detection accuracy and deployment applicability.

[0033] The existing YOLOv8n model mainly consists of a backbone network, a neck network, and a detection head, such as Figure 2As shown. The backbone network is mainly responsible for extracting multi-scale features from the input image layer by layer. Its core is based on the improved CSPDarknet architecture, which reduces computational redundancy and enhances gradient flow by partially connecting modules across stages. The shallow network captures detailed features, while the deep network extracts more abstract semantic information. At the same time, the SPPF module is introduced to accelerate the fusion of multi-scale features. The neck network connects the backbone network and the detection head. Its core task is to integrate multi-scale features and enhance contextual information. YOLOv8n usually adopts an improved version of PANet, which fuses shallow detail features with deep semantic features through bidirectional cross-layer connections, and uses lightweight design to reduce computational costs, helping the model to better handle targets of different scales. The detection head is the final prediction part, responsible for outputting bounding box coordinates, categories, and confidence. The overall structure balances speed and accuracy through lightweight design and module optimization, making it suitable for real-time detection scenarios.

[0034] like Figure 3 As shown, the present invention improves on the basis of the existing YOLOv8n network, and the specific improvement steps are as follows:

[0035] Step 3.1: Replace the backbone network with Swin Transformer, and replace the ordinary convolution in the backbone network with depth-wise separable convolution and Ghost module.

[0036] (1) Swin Transformer is a hierarchical visual Transformer architecture. Its core idea is to significantly reduce the computational complexity while maintaining the global modeling capability of Transformer by combining local window self-attention with hierarchical feature pyramid. It is particularly suitable for complex scenarios such as dense small object detection.

[0037] The overall architecture of the Swin Transformer network is composed of multiple Swin Transformer Blocks stacked together. The Swin Transformer divides the image into multiple non-overlapping local windows, and calculates self-attention independently in each window. Compared with the global attention of traditional ViT, the computational complexity is reduced from O(H 2 W 2 C) reduced to O(M 2 HWC), achieving linearly growing computational load, where M is the window size, H, W, and C are the height, width, and number of channels of the feature map respectively.

[0038] Window self-attention mechanism formula:

[0039]

[0040] Where Q, K, and V are query, key, and value matrices, and B is a learnable parameter encoding the relative positions of pixels within the encoding window, such as the relative position encoding of pixels i and j, and B ij =W pos [i-j+Δ], Δ is the offset, W pos is the location parameter matrix. k is the vector dimension of query (Q) and key (K).

[0041] And through the shifted window strategy, regular windows and offset windows can be used alternately in adjacent Transformer layers, allowing information to flow between different windows and avoiding local receptive field limitations.

[0042] (2) Depthwise separable convolution is a lightweight convolution operation. In the standard convolution process, all channels in the corresponding image area are considered simultaneously. However, the depthwise separable convolution of the present invention breaks this bottleneck, considers channels and spatial regions separately, and decomposes the standard convolution into two independent steps: depthwise convolution and point-by-point convolution. Figure 4 shown.

[0043] Depthwise convolution: A filter is applied to each input channel, performing convolution only in the spatial dimension. The number of output channels is the same as the number of input channels. Pointwise convolution: A 1×1 convolution kernel is used to combine the output channels of depthwise convolution to adjust the number of output channels to the target number. This feature significantly reduces the number of model parameters and computational complexity in applications.

[0044] (3) The Ghost module is an innovative design for convolutional neural networks, which is particularly suitable for embedded devices. It uses existing feature maps to generate more "ghost" feature maps through low-cost linear transformation, thereby improving the computational efficiency of the network.

[0045] Ghost convolution uses a small amount of standard convolution to generate some basic feature maps, and performs cheap linear operations on the basic feature maps, such as channel-by-channel translation, scaling, pooling, etc., to generate the remaining feature maps, which are then merged to obtain the complete output. Figure 5 As shown, Figure 5 (a) is a conventional convolution operation, and (b) is the Ghost convolution operation of the present invention.

[0046] The advantage of the Ghost module is that it significantly reduces the amount of computation and captures feature diversity through linear transformation to avoid information loss. In addition, it can directly replace the standard convolutional layer without adjusting the network structure.

[0047] Step 3.2: Add SimAM parameter-free attention mechanism to the backbone network:

[0048] SimAM is an attention mechanism that does not require the introduction of trainable parameters. It aims to automatically enhance the response of important areas by dynamically calculating the spatial and inter-channel relationships of feature maps. Its core is to generate attention weights using the statistical properties of the input features themselves through self-calibration mechanism and instance perception without relying on additional parameters. The principle diagram of SimAM attention mechanism is shown in the figure below. Figure 6 As shown in Figure 2, SimAM treats each neuron in the feature map as a sample and automatically infers attention weights by maximizing its separability from surrounding neurons. This process requires no learnable parameters and is accomplished solely through mathematical optimization.

[0049] SimAM defines the energy function e for each neuron t as follows:

[0050]

[0051] in and is a linear transformation, t and x i is the input feature X∈R C×H×W The target neuron and other neurons in a single channel. i is the index in the spatial dimension, and M = H × W is the number of neurons in the channel. ω t and b t are the weights and biases of the linear transformation. t is the optimized response value of the target neuron, representing the enhanced features of the defect region. y0 is the optimized response value of the other neurons, representing the suppressed features of the background or non-salient regions. C is the number of channels, H and W are the height and width of the feature map, respectively. y represents the optimized response value of the neuron.

[0052] Minimizing the above formula is equivalent to training the linear separability between neuron t and other neurons in the same channel. Using binary labels and adding regularization terms, the final energy function e t The definition is as follows:

[0053]

[0054] The analysis is:

[0055]

[0056] where μ t and σ t are the mean and variance, and λ is the regularization parameter.

[0057] Since all neurons on each channel follow the same distribution, we can first calculate the mean and variance of the input features in the two dimensions H and W to avoid repeated calculations and obtain the minimum energy calculation formula:

[0058]

[0059] This process can be expressed as:

[0060]

[0061] E means The result after summing over all channels and spatial dimensions, X is the original input feature map, The feature map after attention weight adjustment. The Sigmoid function is the threshold function of the neural network.

[0062] The core benefit of adding the SimAM parameter-free attention mechanism to the backbone network is that it significantly enhances the characteristics of defect areas in small objects and complex backgrounds by dynamically capturing local feature contrast, without introducing additional parameters, making it perfectly suitable for lightweight model design. This mechanism uses the statistical properties of the input features, such as mean and standard deviation, to calculate the difference energy between each location and its neighbors, generating adaptive attention weights. This method highlights high-contrast defect areas such as insulator cracks and surface corrosion on electrical equipment, while suppressing interference from smooth backgrounds.

[0063] Step 3.3: Design a decoupled detection head to separate the classification and regression tasks in the detection head part, and embed the CausalDyConv module.

[0064] (1) The core idea of ​​the decoupled detection head is to separate the two core tasks of target detection: classification and regression, into independent network branches, thereby reducing the interference between tasks and improving detection accuracy.

[0065] Traditional detection heads typically couple classification and regression tasks within the same network structure, sharing feature extraction layers and parameters. Decoupled detection heads achieve task separation through the following methods: First, independent branch design: the classification branch and regression branch each have their own convolutional or fully connected layers, each optimizing task-specific features. Second, feature adaptation: the classification branch typically employs a larger receptive field to capture global semantic information. The regression branch may adapt to object deformation and scale changes through refined convolution.

[0066] (2)CausalDyConv is a convolutional neural network module that combines causal constraints with a dynamic convolution mechanism. Its core design goals include maintaining causal relationships and dynamically adjusting convolution kernels.

[0067] In convolution operations, the receptive field of the convolution kernel is restricted to cover only the current and past time steps or spatial positions. For example, in a one-dimensional convolution of a time series, a unidirectional convolution kernel is used to ensure that the output is only affected by the left input.

[0068] For the output sequence X=[x1,x2,...,xT ], the output y of causal convolution m for Where K is the convolution kernel size, and when mk<1, x m-k = 0. T is the total length of the sequence, ω k is the weight parameter of the convolution kernel at the kth position, m represents the time step of the current processing, k is the offset index of the convolution kernel, x m-k is the input feature of the current time step mk.

[0069] The weight W of the convolution kernel is not fixed, but is dynamically generated according to the input features through a small neural network:

[0070] W dynamic is the convolution kernel weight dynamically generated at time step m, x m Represents the value of the input sequence in the causal dynamic convolution at time step m.

[0071] This invention employs a decoupled design within the detection head, separating the classification and regression tasks. This allows the classification branch to focus on target category identification, while the regression branch focuses on bounding box localization, thus avoiding task interference and improving detection accuracy. Furthermore, the CausalDyConv module is embedded. By dynamically adjusting convolution kernel parameters and strictly adhering to causal constraints, it strengthens the logical connections between features, making the model more stable in complex scenarios such as occlusion and deformation. This combination simplifies the model structure and enhances the ability to reason about temporal or spatial logic, enabling efficient and accurate target detection.

[0072] Step 4: Train the model.

[0073] The code debugging and testing experimental environment is based on Python 3.8. The server operating system used is Windows 11; the CPU is Intel i9-14900HX; the RAM is 16GB; the computing resource is one NVIDIA RTX 4060, GPU driver version 522.06; the deep learning framework is PyTorch 1.13.1, the CUDA version is 11.8, and the pre-trained model is yolov8s.pt; the parameter settings during training are shown in Table 1.

[0074] Table 1

[0075]

[0076] To describe the accuracy of the model's predictions and true labels during training, mAP50 (mean average precision) is used as a model evaluation metric. This is the mAP (mean average precision) at an intersection-over-union (iou) ratio of 50%. For n samples in a given category, assume there are k positive examples. Each positive example corresponds to a recall rate R value (1 / m, 2 / m, ..., 1). For each recall rate, the maximum precision P is calculated, and then these k P values ​​are averaged. A larger mAP value indicates a smaller deviation from the true value. If the mAP value changes significantly or decreases after multiple rounds of training, fine-tuning the parameters (such as the initial learning rate and number of iterations) is necessary. Repeated parameter tuning can improve the model's performance.

[0077] Step 5: Use the trained model to perform defect detection on the test set images and output the detection results.

[0078] Step 6: If the test results meet the requirements, the model can be put into practical application. If the test results do not meet the requirements, the dataset can be optimized or the model structure can be adjusted, and iterative updates can be performed to improve the test results and ensure the model achieves optimal performance.

[0079] With the above-described preferred embodiments of the present invention as a guide, and with reference to the above description, relevant personnel are fully capable of making various changes and modifications without departing from the technical scope of this invention. The technical scope of this invention is not limited to the contents of the specification and must be determined according to the scope of the claims.

Claims

1. A method for detecting and identifying defects in electrical equipment based on improved YOLOv8, characterized in that: The following steps are involved: Step 1: Construct an electrical equipment defect dataset: Collect defect image data of electrical equipment, store the data, and classify and annotate it to provide training and test data for subsequent processing; Step 2: Dataset analysis and partitioning: Analyze the distribution of the dataset and check whether the samples of various defects are balanced; According to training needs, the dataset is divided into training set, validation set and test set, which are used for training, validation and evaluation of the model respectively; Step 3: Build an improved model based on the YOLOv8n network model: First, replace the backbone network with SwinTransformer, fuse shallow high-resolution features with dilated convolution to enhance the capture of small target details, and replace the ordinary convolution with depthwise separable convolution and Ghost module to achieve a lightweight design and form a new backbone network; secondly, add the SimAM parameter-free attention mechanism to the backbone network; finally, design a decoupled detection head in the detection head to separate the classification and regression tasks, and embed the CausalDyConv module; Step 4: Train the model; Step 5: Use the trained model to perform defect detection on the test set images and output the detection results.

2. The electrical equipment defect detection and identification method based on improved YOLOv8 according to claim 1, characterized in that: In step 2, the ratio of training set, validation set and test set is 7:2:

1.

3. The electrical equipment defect detection and identification method based on improved YOLOv8 according to claim 1, characterized in that: In step 3, the overall network architecture of Swin Transformer is composed of multiple stacked Swin Transformer Blocks; in addition, Swin Transformer divides the image into multiple non-overlapping local windows, and self-attention is calculated independently in each window.

4. The electrical equipment defect detection and identification method based on improved YOLOv8 according to claim 3, characterized in that: In step 3, the depth-wise separable convolution considers channels and spatial regions separately, decomposing the standard convolution into two independent steps: depth-wise convolution and point-wise convolution.

5. The electrical equipment defect detection and identification method based on improved YOLOv8 according to claim 4, characterized in that: In step three, the SimAM parameter-free attention mechanism uses the statistical characteristics of the input features themselves to calculate the difference energy between each position and its neighborhood and generate adaptive attention weights.

6. The electrical equipment defect detection and identification method based on improved YOLOv8 according to claim 5, characterized in that: The decoupled detection head achieves task separation through the following methods: first, independent branch design, where the classification branch and regression branch have their own independent convolutional layers or fully connected layers, respectively optimizing task-related features; second, feature adaptation, where the classification branch expands the receptive field to capture global semantic information, and the regression branch adapts to the deformation and scale changes of the target through refined convolution.

7. The electrical equipment defect detection and identification method based on improved YOLOv8 according to claim 6, characterized in that: In the convolution operation, the CausalDyConv module limits the receptive field of the convolution kernel to only cover the current and past time steps or spatial positions.

8. The electrical equipment defect detection and identification method based on improved YOLOv8 according to claim 7, characterized in that: In the convolution operation of the CausalDyConv module, the weight W of the convolution kernel is dynamically generated according to the input features through a neural network.

9. The electrical equipment defect detection and identification method based on improved YOLOv8 according to claim 1, characterized in that: The pre-trained model is fine-tuned using electrical equipment defect data, and the model weights are adjusted to make it more suitable for detecting specific defect categories. After selecting the optimal model, the training process ends.

10. The electrical equipment defect detection and identification method based on improved YOLOv8 according to claim 1, characterized in that: Finally, step six is ​​included: If the detection effect of step five does not meet the requirements, the data set is re-optimized or the model structure is adjusted, and iterative updates are performed to improve the detection effect and ensure that the model achieves optimal performance.