Lightning arrester external defect detection method and device based on improved YOLOv8
By improving the YOLOv8 algorithm and CBAM attention mechanism, combined with the fusion of feature pyramids, the problems of insufficient detection accuracy and high missed detection error rate in traditional lightning arrester detection methods are solved, efficient and accurate detection of external defects of lightning arrester are achieved, and intelligent operation and maintenance of the power grid is supported.
Patent Information
- Application Number
- CN202510230131.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-28
- Publication Date
- 2025-05-30
AI Technical Summary
The traditional external defect detection methods of lightning arresters have problems such as insufficient detection accuracy, high missed detection error rate, and low detection efficiency, which are difficult to meet the requirements of intelligent operation and maintenance of the power grid.
Using improved YOLOv8 object detection algorithm and visible light imaging, the detection accuracy of external defects of the lightning arrester is improved by optimizing and improving the structure of the YOLOv8 model, combined with the CBAM attention mechanism and feature pyramid fusion.
It significantly improves the detection accuracy of external defects of lightning arresters, can accurately identify subtle defects such as surface cracks, corrosion, and deformation, reduces the rate of leakage detection and error detection, realizes fast and accurate defect detection, and supports grid equipment status evaluation and preventive maintenance.
Smart Images

Figure CN120071012A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of arrester fault detection methods, and particularly relates to an external defect detection method and device for arresters based on improved YOLOv8. Background Technique
[0002] As an important overvoltage protection device in the power system, the operating state of the arrester is directly related to the safe and stable operation of the entire power grid. During long-term outdoor operation, the arrester is affected by various factors such as bad weather, environmental pollution, and lightning strikes, resulting in external defects such as cracks, breakages, and dirt deposits on the external insulation. These defects not only reduce the insulation performance of the arrester but may also cause serious accidents such as insulation breakdown and explosion, resulting in system power outages and equipment damage. Traditional manual inspection methods have problems such as low efficiency, high missed inspection rate, and strong subjectivity of inspection results, making it difficult to meet the requirements of intelligent operation and maintenance of the power grid. Therefore, developing an efficient and accurate external defect detection technology for arresters is of great significance for timely discovering and handling arrester hidden dangers, preventing accidents, and ensuring the safe operation of the power grid; at the same time, with the rapid development of artificial intelligence and image processing technology, new technical means and development opportunities have been provided for the intelligent detection of external defects of arresters.
[0003] Currently, some studies have combined infrared technology with methods such as computer vision and fault characteristics to achieve the detection of external defects of lightning arresters, including: U-Net, leakage current and its resistive component, YOLOv3, etc. During the operation of lightning arresters, problems such as partial discharge and pollution corrosion caused by external defects will generate abnormal heat generation. Infrared thermal imagers detect the infrared radiation emitted by the surface of an object and convert the thermal energy information into a visible temperature distribution image. Different types of defects will form characteristic temperature distribution patterns, such as abnormal temperature gradients at cracks and hot spot distributions in polluted areas. By designing a reasonable deep learning network, the temperature distribution images formed by different defects are recognized to achieve the detection of external defects of lightning arresters. Although infrared technology has been widely used in the detection of external defects of lightning arresters, there are still some inherent limitations: First, the cost of infrared detection equipment is relatively high, and the detection process is easily affected by external factors such as ambient temperature and solar radiation, reducing the reliability of the detection results; Second, the spatial resolution of infrared images is relatively low, making it difficult to capture subtle surface defect features; Third, infrared detection mainly judges defects based on temperature anomalies, and the detection sensitivity is insufficient for early defects that have not caused obvious heating, such as micro-cracks and mild pollution. In contrast, the defect detection technology based on visible light images has obvious advantages: visible light cameras are inexpensive, easy to deploy, and have high image resolution and rich texture details, which can clearly reflect the tiny defects on the surface of lightning arresters; At the same time, visible light images are not affected by changes in ambient temperature and can work stably under different weather conditions; In addition, with the development of deep learning technology, visible light image processing algorithms have become increasingly mature, and can achieve precise recognition and positioning of various surface defects, providing more comprehensive and reliable technical support for the condition assessment and preventive maintenance of lightning arresters.
[0004] To address the above problems, an automatic detection method for external defects of lightning arresters based on an improved YOLOv8 object detection algorithm and visible light imaging is proposed. By using technical means such as network structure optimization and multi-modal fusion, it can significantly improve the detection accuracy of various defects on parts such as the lightning arrester shell while maintaining the fast detection ability, providing timely and reliable decision-making support for grid operation and maintenance personnel, reducing the cost and risk of manual inspection, and is of great significance for improving the efficiency and safety of grid operation and maintenance. Summary of the Invention
[0005] To solve the problems existing in the background technology, the purpose of the present invention is to propose an external defect detection method for lightning arresters based on improved YOLOv8, aiming at the problems of insufficient detection accuracy, high false omission and misdetection rates, and low detection efficiency in the traditional external defect detection methods of lightning arresters. By optimizing and improving the YOLOv8 model structure, this method improves the detection ability for subtle defects such as cracks, corrosion, and deformation on the surface of lightning arresters, realizes the rapid and accurate identification of external defects of lightning arresters, and thus provides reliable technical support for the state assessment and preventive maintenance of power system equipment.
[0006] The present invention adopts the following technical solutions:
[0007] An external defect detection method for lightning arresters based on improved YOLOv8, the method comprising the following steps:
[0008] Improve the YOLOv8 network and use the training data set for network training to obtain a trained improved YOLOv8 network;
[0009] Use the trained improved YOLOv8 network to detect the external defects of the lightning arrester and obtain the detection results;
[0010] Among them, the method of improving the YOLOv8 network and using the training data set for network training to obtain a trained improved YOLOv8 network is as follows:
[0011] Obtain the lightning arrester image sample data set, preprocess it, and finally perform a convolution operation to obtain the input feature map I norm ;
[0012] Backbone network feature extraction: Use CSPDarknet53 as the backbone network. The backbone network feature extraction inputs Inorm into the improved CSPDarknet53 backbone network and passes through 5 CSP stages in sequence:
[0013] F 1 = CSP(I norm )(1)
[0014] F 2 = CSP(F 1 )(2)
[0015] F 3 = CSP(F 2 )(3)
[0016] F 4 = CSP(F 3 )(4)
[0017] F 5 = CSP(F 4)(5)
[0018] Among them, each CSP stage includes the CBAM attention mechanism, and the processing of the i-th input feature F i includes channel attention calculation and spatial attention calculation;
[0019] Feature pyramid fusion: Perform top-down and bottom-up feature fusion on the features F 3 、F 4 and F 5 output by the backbone network;
[0020] Detection head prediction: Predict the fused features respectively;
[0021] Predicted box decoding;
[0022] Soft-NMS post-optimization processing: After merging the predicted boxes on all feature maps and arranging them in descending order of confidence, for the position box of each detection box i , first calculate its intersection over union IoU with other detection boxes, and then update the confidence score of other detection boxes according to the IoU j , the process is as follows:
[0023]
[0024] In the formula, γ is the update rate and η is the limit threshold.
[0025] Furthermore, the channel attention calculation process is as follows:
[0026]
[0027] In the formula, F i is the i-th input feature map, σ is the sigmoid activation function, MLP is a two-layer perceptron, AvgPool is the average pooling operation, MaxPool is the max pooling operation, is the output of the i-th channel attention, is the matrix multiplication operator.
[0028] The spatial attention calculation process is as follows:
[0029]
[0030]
[0031] In the formula, Conv represents the convolution operator, F i out is the output of the CBAM module.
[0032] Further, after the optimization process of Soft-NMS, multi-scale result fusion is also required: for each detected target, if there are detection boxes on multiple feature maps, first group the detection boxes belonging to the same target according to the intersection over union (IoU) size, and perform average weighting on each group of detection boxes:
[0033]
[0034] In the formula, B i is the detection box on the i-th feature map, and B f is the position of the output bounding box.
[0035] Further, after multi-scale result fusion, loss function optimization is also required: B f is used as the position of the final output bounding box, the category with the highest confidence among all boxes is used as the final output category, and the confidence after weighted average is used as the final confidence, and it is optimized through the following loss function:
[0036] L = λ 1 L cls + λ 2 L box + λ 3 L obj (30)
[0037] In the formula, L cls is the classification loss, using Focal Loss; L box is the regression loss, using CIoU Loss; L obj is the objectness loss, using BCE Loss; λ is the balance coefficient.
[0038] Further, the feature pyramid fusion process is expressed as follows:
[0039] P 5 = Conv(F 5 )(10)
[0040] P 4 = Conv(F 4 ) + Upsample(P 5 )(11)
[0041] P 3 = Conv(F 3 ) + Upsample(P 4 )(12)
[0042] N 3 = P 3 (13)
[0043] N 4 = P4 + Downsample(N 3 )(14)
[0044] N 5 = P 5 + Downsample(N 4 )(15)
[0045] Wherein, Upsample and Downsample are upsampling and downsampling operations respectively, and N 3 , N 4 and N 5 are the outputs of the feature fusion module;
[0046] Furthermore, the method for respectively predicting the fused features N 3 , N 4 and N 5 is as follows:
[0047] C i = σ(Conv(N i ))(16)
[0048] Δ i = Conv(N i )(17)
[0049] Δ i = (Δx i , Δy i , Δw i , Δh i )(18)
[0050] O i = σ(Conv(N i ))(19)
[0051] Wherein, C i , Δ i and O i are the output values of class prediction, bounding box prediction and objectness prediction respectively. C i and O i perform the same convolution operation, but the kernel sizes of the two are different; Δx i , Δy i , Δw i and Δh i are the x-axis deviation, y-axis deviation, width deviation and height deviation respectively;
[0052] Furthermore, the prediction box decoding process is as follows:
[0053] For each prior position (x i , y c ), yc ) Calculate the actual bounding box coordinates and convert the expression form. The process is as follows:
[0054] x i = (x c + Δx i ) × s i (20)
[0055] y i = (y c + Δy i ) × s i (21)
[0056]
[0057] box i = [x i - w i / 2, y i - h i / 2, x i + w i / 2, y i + h i / 2](24)
[0058] score i = O i × max(C i )(25)
[0059] In the formula, s i is the stride of the corresponding feature map, p w and p h are the width and height of the prior box respectively, box i is the position of the detection box, and score i is the corresponding confidence.
[0060] An arrester external defect detection device based on improved YOLOv8, comprising:
[0061] An improved YOLOv8 network acquisition module, used to improve the YOLOv8 network and train the network using a training data set to obtain a trained improved YOLOv8 network;
[0062] An arrester external defect detection module, used to detect the external defects of the arrester using the trained improved YOLOv8 network and obtain the detection result;
[0063] Among them, the method for improving the YOLOv8 network and training the network using a training data set to obtain a trained improved YOLOv8 network is:
[0064] Obtain the lightning arrester image sample dataset, preprocess it, and finally perform a convolution operation to obtain the input feature map I norm ;
[0065] Backbone network feature extraction: Use CSPDarknet53 as the backbone network. The backbone network feature extraction inputs Inorm into the improved CSPDarknet53 backbone network and passes through 5 CSP stages in sequence:
[0066] F 1 = CSP(I norm )(1)
[0067] F 2 = CSP(F 1 )(2)
[0068] F 3 = CSP(F 2 )(3)
[0069] F 4 = CSP(F 3 )(4)
[0070] F 5 = CSP(F 4 )(5)
[0071] Among them, each CSP stage contains the CBAM attention mechanism. The processing process of the i-th input feature F i includes channel attention calculation and spatial attention calculation;
[0072] Feature pyramid fusion: Perform top-down and bottom-up feature fusion on the features F 3 , F 4 and F 5 output by the backbone network;
[0073] Detection head prediction: Perform predictions on the fused features respectively;
[0074] Prediction box decoding;
[0075] Soft-NMS post-optimization processing: After merging the prediction boxes on all feature maps and sorting them in descending order of confidence, for the position box i of each detection box, first calculate its intersection over union IoU with other detection boxes, and then update the confidence score j of other detection boxes according to IoU. The process is as follows:
[0076]
[0077] In the formula, γ is the update rate and η is the limit threshold.
[0078] A non - transitory computer - readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements an external defect detection method for lightning arresters based on improved YOLOv8 as described above.
[0079] An electronic device, including a memory, a processor, and a computer program stored on the memory and operable on the processor. When the processor executes the program, it implements an external defect detection method for lightning arresters based on improved YOLOv8 as described above.
[0080] The beneficial technical effects of the present invention are as follows:
[0081] 1. Through the optimization and improvement of the YOLOv8 model structure, the present invention significantly improves the detection accuracy of external defects of lightning arresters, can accurately identify subtle defects such as surface cracks, corrosion, and deformation, effectively reduces the missed detection and false detection rates; at the same time, it has the characteristics of fast detection speed and strong real - time performance, realizes the intelligence and automation of external defect detection of lightning arresters, and can provide reliable technical support for the condition assessment and preventive maintenance of power system equipment, having good application value;
[0082] 2. The present invention introduces the CBAM attention mechanism on the basis of the original YOLOv8 to enhance the feature extraction ability. CBAM combines channel attention and spatial attention, enabling the network to focus on key defect areas and suppress background noise, thereby improving the detection accuracy; in addition, the present invention improves the feature pyramid structure. The top - down feature transfer enhances the detection ability of small targets, while the bottom - up feature feedback further optimizes the feature interaction from the bottom layer to the top layer, enabling high - level features to more effectively guide the decision - making of low - level features; these improvements cooperate with each other, enabling the model to achieve higher detection accuracy and stronger robustness in the task of external defect detection of lightning arresters. BRIEF DESCRIPTION OF THE DRAWINGS
[0083] Figure 1 It is a schematic flowchart of the method for obtaining a trained improved YOLOv8 network in an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0084] Embodiment 1
[0085] The following further clearly and completely describes an external defect detection method and device for lightning arresters based on improved YOLOv8 provided by the present invention with reference to the accompanying drawings:
[0086] An external defect detection method for lightning arresters based on improved YOLOv8, the method comprising the following steps:
[0087] Improve the YOLOv8 network and use the training dataset to train the network to obtain a trained improved YOLOv8 network;
[0088] Use the trained improved YOLOv8 network to detect external defects of arresters and obtain the detection results;
[0089] Among them, as Figure 1 shown, the method for improving the YOLOv8 network and using the training dataset to train the network to obtain a trained improved YOLOv8 network is as follows:
[0090] Obtain the arrester image sample dataset, preprocess it, and finally perform a convolution operation to obtain the input feature map I norm ; Among them, the method for obtaining the arrester image sample dataset and preprocessing it is: collect arrester image samples, including normal samples and various external defect samples (such as cracks, corrosion, deformation, etc.), use professional annotation tools to annotate the images, and the annotation information includes the defect category and the position bounding box; unify the image size to 640×640, perform operations such as random flipping, rotation, adjusting brightness and contrast on the images, perform data normalization processing, and finally perform a convolution operation to obtain the input feature map I norm ;
[0091] Backbone network feature extraction: Use CSPDarknet53 as the backbone network. The backbone network feature extraction inputs Inorm into the improved CSPDarknet53 backbone network and goes through 5 CSP stages in sequence:
[0092] F 1 = CSP(I norm )(1)
[0093] F 2 = CSP(F 1 )(2)
[0094] F 3 = CSP(F 2 )(3)
[0095] F 4 = CSP(F 3 )(4)
[0096] F 5 = CSP(F 4 )(5)
[0097] Among them, each CSP stage includes the CBAM attention mechanism. The processing process of the i-th input feature F i includes channel attention calculation and spatial attention calculation; the channel attention calculation process is as follows:
[0098]
[0099] In the formula, F i is the i-th input feature map, σ is the sigmoid activation function, MLP is a two-layer perceptron, AvgPool is the average pooling operation, MaxPool is the max pooling operation, is the output of the i-channel attention, is the matrix multiplication operator.
[0100] The spatial attention calculation process is as follows:
[0101]
[0102] In the formula, Conv represents the convolution operator, F i out is the output of the CBAM module;
[0103] Feature pyramid fusion: The features F 3 , F 4 and F 5 output by the backbone network are subjected to top-down and bottom-up feature fusion; the process is shown as follows:
[0104] P 5 = Conv(F 5 )(10)
[0105] P 4 = Conv(F 4 ) + Upsample(P 5 )(11)
[0106] P 3 = Conv(F 3 ) + Upsample(P 4 )(12)
[0107] N 3 = P 3 (13)
[0108] N 4 = P 4 + Downsample(N 3 )(14)
[0109] N 5 = P 5 + Downsample(N 4 )(15)
[0110] In the formula, Upsample and Downsample are the upsampling and downsampling operations respectively, N 3 , N4 and N 5 is the output of the feature fusion module;
[0111] Detection head prediction: predicting the fused features respectively; the predicting of the fused feature N 3 , N 4 and N 5 The methods for predicting respectively are as follows:
[0112] C i =σ(Conv(N i ))(16)
[0113] Δ i =Conv(N i )(17)
[0114] Δ i =(Δx i , Δy i , Δw i , Δh i )(18)
[0115] O i =σ(Conv(N i ))(19)
[0116] In the formula, C i , Δ i and O i are the output values of class prediction, bounding box prediction and objectness prediction respectively. C i and O i perform the same convolution operation, but the kernel sizes of the two are different; Δx i , Δy i , Δw i and Δh i are the x-axis deviation, y-axis deviation, width deviation and height deviation respectively;
[0117] Predicting box decoding; the predicting box decoding process is as follows:
[0118] For each prior position (x i , y c ) on the feature map N c , calculate the actual bounding box coordinates and convert the expression form. The process is as follows:
[0119] x i =(x c +Δx i )×s i (20)
[0120] y i =(y c +Δy i)×s i (21)
[0121]
[0122] box i =[x i -w i / 2,y i -h i / 2,x i +w i / 2,y i +h i / 2](24)
[0123] score i =O i ×max(C i )(25)
[0124] In the formula, s i is the stride of the corresponding feature map, p w and p h are the width and height of the prior box respectively, box i is the position of the detection box, and score i is the corresponding confidence level;
[0125] Optimization processing after Soft-NMS: After merging the prediction boxes on all feature maps and sorting them in descending order of confidence, for the position box i of each detection box, first calculate its intersection over union IoU with other detection boxes, and then update the confidence score j of other detection boxes according to the IoU. The process is as follows:
[0126]
[0127] In the formula, γ is the update rate and η is the limit threshold;
[0128] Multi-scale result fusion: For each detected target, if there are detection boxes on multiple feature maps, first group the detection boxes belonging to the same target according to the size of the intersection over union IoU, and perform average weighting on each group of detection boxes:
[0129]
[0130] In the formula, B i is the detection box on the i-th feature map, and B f is the position of the output bounding box;
[0131] Loss function optimization: B fAs the final output bounding box position, the class with the highest confidence among all boxes is used as the final output class, the confidence after weighted average is used as the final confidence, and it is optimized through the following loss function:
[0132] L = λ 1 L cls + λ 2 L box + λ 3 L obj (30)
[0133] In the formula, L cls is the classification loss, using Focal Loss; L box is the regression loss, using CIoU Loss; L obj is the objectness loss, using BCE Loss; λ is the balance coefficient.
[0134] The evaluation of object detection performance is mainly carried out through several key indicators evaluated on the test dataset: Precision (P), Recall (R), Frames Per Second (FPS), and mean Average Precision (mAP). Precision and Recall are common indicators for evaluating binary classification models. Precision represents the proportion of correctly identified positive instances among all instances predicted as positive by the model. Recall represents the proportion of actual positive examples successfully identified by the model among all positive examples. These indicators reflect the performance of the model from different perspectives. Precision focuses on the accuracy of positive predictions, while Recall emphasizes the comprehensive coverage of all positive instances. Average Precision (AP) is calculated as the area under the Precision-Recall curve, and an excellent classifier produces a higher AP value. mAP represents the average of the AP values for all classes, and this value is restricted to the interval [0, 1]; this indicator is considered the most critical indicator in object detection algorithms. mAP@0.5 is the mAP when the IoU threshold is 0.5, and the higher the mAP value, the better the detection performance; the mathematical formulas for P, R, FPS, and mAP are shown as follows.
[0135]
[0136] In the formula, T P represents the number of correctly identified positive samples, F P represents the number of misclassified positive samples, F N represents the positive samples that the model fails to detect; in addition, N represents the total number of frames processed by the model, T represents the total processing time, C represents the number of classes, and AP i represents the average precision of the i-th class.
[0137] Evaluate different models on the test set and quantify various evaluation metrics. The results are shown in Table 1.
[0138] Table 1 Performance comparison of various models
[0139] Table 1Performance comparison of various models
[0140] model P R FPS mAP@0.5 Improved YOLOv8 0.8592 0.7376 84.20 0.8212 YOLOv8 0.8596 0.7073 89.65 0.7745 YOLOv7 0.8427 0.6942 80.65 0.7556 RT-DETR 0.8905 0.4764 75.66 0.6372
[0141] Among them, the mAP@0.5 value of the improved YOLOv8 is 0.8212, which is 4.67%, 6.56%, and 18.4% higher than YOLOv8, YOLOv7, and RT-DETR respectively, indicating that the model proposed in the present invention achieves the best performance in the task of detecting external defects of lightning arresters. The P value and R value of CSL-YOLOv8 are 0.8592 and 0.7376 respectively, both at a relatively high level, indicating that the proposed model balances the contradiction between false positives and false negatives well. The FPS of the improved YOLOv8 is 84.20, second only to 89.65 of YOLOv8, indicating that while achieving improved detection accuracy, the proposed model does not increase excessive computational burden, thus ensuring the timeliness of the model and improving the detection ability in practical applications.
[0142] Specifically, the process of using the trained improved YOLOv8 network to detect external defects of lightning arresters and obtaining the detection results is as follows:
[0143] 1. Image normalization preprocessing: Normalize the pixel values of the input original image to the range [0, 1] to obtain the normalized image.
[0144] 2. Multi-scale feature extraction: Input the preprocessed image into the improved CSPDarknet53 backbone network, and extract features layer by layer through 5 cascaded CSP modules to generate 5 feature maps F 1 to F 5 ;
[0145] 3. Attention mechanism enhancement: Apply the CBAM dual attention mechanism to the extracted feature maps, and calculate the channel attention weight M c and the spatial attention weight M s in sequence to obtain the attention-enhanced feature map F out ;
[0146] 4. Feature pyramid fusion: Adopt the improved feature pyramid network, and upsample and downsample the high-level feature maps from top to bottom and from bottom to top, and fuse them with the same-level feature maps to generate the fused features N 3 、N 4 、N 5 ;
[0147] 5. Defect Detection and Prediction: Perform a convolution operation on the fused feature map to predict the defect category probability and location information;
[0148] 6. Result Optimization and Output: Use the improved Soft-NMS algorithm for post-processing to remove overlapping detection boxes and output the category, location, and confidence of the surface defects of the lightning arrester;
[0149] 7. Multi-scale Feature Fusion: For each detected target, group the boxes belonging to the same target according to the IoU size, perform average weighting on each group of boxes, and finally output the detection results.
[0150] Embodiment 2
[0151] This embodiment provides an external defect detection device for a lightning arrester based on the improved YOLOv8, including:
[0152] An improved YOLOv8 network acquisition module, which is used to improve the YOLOv8 network and train the network using the training data set to obtain a trained improved YOLOv8 network;
[0153] An external defect detection module for the lightning arrester, which is used to detect the external defects of the lightning arrester using the trained improved YOLOv8 network and obtain the detection results;
[0154] Among them, the method for improving the YOLOv8 network and training the network using the training data set to obtain a trained improved YOLOv8 network is as follows:
[0155] Obtain the lightning arrester image sample data set, preprocess it, and finally perform a convolution operation to obtain the input feature map I norm ;
[0156] Backbone Network Feature Extraction: Use CSPDarknet53 as the backbone network. The backbone network feature extraction inputs Inorm into the improved CSPDarknet53 backbone network and goes through 5 CSP stages in sequence:
[0157] F 1 = CSP(I norm )(1)
[0158] F 2 = CSP(F 1 )(2)
[0159] F 3 = CSP(F 2 )(3)
[0160] F 4 = CSP(F 3 )(4)
[0161] F 5 = CSP(F 4 )(5)
[0162] Among them, each CSP stage includes the CBAM attention mechanism, and the processing of the i-th input feature F i includes channel attention calculation and spatial attention calculation;
[0163] Feature pyramid fusion: Perform top-down and bottom-up feature fusion on the features F 3 , F 4 and F 5 output by the backbone network;
[0164] Detector head prediction: Predict the fused features respectively;
[0165] Predicted box decoding;
[0166] Soft-NMS post-optimization processing: After merging the predicted boxes on all feature maps, sort them in descending order of confidence. For the position box i of each detection box, first calculate its intersection over union IoU with other detection boxes, and then update the confidence score j of other detection boxes according to the IoU. The process is as follows:
[0167]
[0168] In the formula, γ is the update rate and η is the limit threshold.
[0169] A non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements an external defect detection method for lightning arresters based on the improved YOLOv8 as described above.
[0170] Furthermore, the present invention adopts the following technical solutions:
[0171] An electronic device includes a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, it implements an external defect detection method for lightning arresters based on the improved YOLOv8 as described above.
[0172] Through the description of the above embodiments, those skilled in the art can clearly understand that the facilities of the present invention can be implemented by means of software plus a necessary general hardware platform. The embodiments of the present invention can be implemented using existing processors, or by dedicated processors used for this purpose or other purposes in a suitable system, or by a hardwired system. The embodiments of the present invention also include non-transitory computer-readable storage media, which include machine-readable media for carrying or having machine-executable instructions or data structures stored thereon; such machine-readable media can be any available media accessible by a general or special-purpose computer or other machine with a processor. For example, such machine-readable media can include RAM, ROM, EPROM, EEPROM, CD-ROM or other optical disc storage, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to carry or store the required program code in the form of machine-executable instructions or data structures and can be accessed by a general or special-purpose computer or other machine with a processor. When information is transmitted or provided to a machine through a network or other communication connection (hardwired, wireless, or a combination of hardwired and wireless), the connection is also regarded as a machine-readable medium.
[0173] So far, the technical solutions of the present invention have been described in conjunction with the preferred embodiments shown in the drawings. However, it is easy for those skilled in the art to understand that the protection scope of the present invention is obviously not limited to these specific embodiments. Without departing from the principle of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will all fall within the protection scope of the present invention.
Claims
1. A lightning arrester external defect detection method based on improved YOLOv8, characterized in that: The method comprises the following steps: Improve the YOLOv8 network and use the training data set to train the network to obtain a trained improved YOLOv8 network; Use the trained improved YOLOv8 network to detect the external defects of the arrester and obtain the detection results; Among them, the method of improving the YOLOv8 network and using the training data set to train the network to obtain the trained improved YOLOv8 network is: Obtain the arrester image sample dataset, preprocess it, and finally perform convolution operation to obtain the input feature map I norm ; Backbone network feature extraction: CSPDarknet53 is used as the backbone network. Backbone network feature extraction inputs Inorm into the improved CSPDarknet53 backbone network and goes through 5 CSP stages in sequence: F1=CSP(I norm ) (1) F2=CSP(F1) (2) F3=CSP(F2) (3) F4=CSP(F3) (4) F5=CSP(F4) (5) Each CSP stage contains a CBAM (Convolutional Block Attention Module) attention mechanism for the i-th input feature F i The processing process includes channel attention calculation and spatial attention calculation; Feature pyramid fusion: Top-down and bottom-up feature fusion of features F3, F4 and F5 output by the backbone network; Detection head prediction: predict the fusion features separately; Prediction box decoding; Soft-NMS post-optimization processing: After merging the prediction boxes on all feature maps, arrange them in descending order of confidence, and calculate the position box of each detection box. i First, calculate the intersection over union (IoU) with other detection boxes, and then update the confidence scores of other detection boxes based on IoU. j , the process is as follows: Where γ is the update rate and η is the limit threshold.
2. According to claim 1, a lightning arrester external defect detection method based on improved YOLOv8 is characterized in that: The channel attention calculation process is as follows: In the formula, F i is the i-th input feature map, σ is the sigmoid activation function, MLP is a two-layer perceptron, AvgPool is the average pooling operation, MaxPool is the maximum pooling operation, F i c is the attention output of the i-th channel, is the matrix multiplication operator. The spatial attention calculation process is as follows: Where Conv represents the convolution operator, F i out Output of CBAM module.
3. According to a method for detecting external defects of a lightning arrester based on improved YOLOv8 according to claim 1, it is characterized in that: After the Soft-NMS optimization process, multi-scale result fusion is required: for each detected target, if there are detection frames on multiple feature maps, first group the detection frames belonging to the same target according to the size of the intersection over union (IoU), and average the weights of each group of detection frames: In the formula, B i is the detection box on the i-th feature map, B f is the output bounding box position.
4. According to claim 3, a lightning arrester external defect detection method based on improved YOLOv8 is characterized in that: After the multi-scale results are fused, the loss function needs to be optimized: B f As the final output bounding box position, the category with the highest confidence in all boxes is taken as the final output category, and the weighted average confidence is taken as the final confidence, which is optimized by the following loss function: L=λ1L cls +λ2L box +λ3L obj (30) Where, L cls For classification loss, Focal Loss is used; L box CIoU Loss is used as the regression loss; L obj is the target loss, using BCE Loss; λ is the balance coefficient.
5. According to a method for detecting external defects of a lightning arrester based on improved YOLOv8 according to claim 1, it is characterized in that: The feature pyramid fusion process is expressed as follows: P5=Conv(F5) (10) P4=Conv(F4)+Upsample(P5) (11) P3=Conv(F3)+Upsample(P4) (12) N3=P3 (13) N4=P4+Downsample(N3) (14) N5=P5+Downsample(N4) (15) Where Upsample and Downsample are upsampling and downsampling operations respectively, and N3, N4 and N5 are the outputs of the feature fusion module.
6. The method for detecting external defects of a lightning arrester based on improved YOLOv8 according to claim 1, characterized in that: The method for predicting the fusion features N3, N4 and N5 respectively is: C i =σ(Conv(N i )) (16) D i =Conv(N i ) (17) D i =(Δx i ,Dy i ,Δw i ,Dh i ) (18) THE i =σ(Conv(N i )) (19) In the formula, C i , Δ i and O i are the output values of category prediction, bounding box prediction and object degree prediction, respectively. i and O i The same convolution operation is performed, but the convolution kernel size is different; Δx i , Δy i , Δw i and Δh i They are x-axis deviation, y-axis deviation, width deviation and height deviation respectively.
7. The method for detecting external defects of a lightning arrester based on improved YOLOv8 according to claim 6 is characterized in that: The prediction frame decoding process is: For feature map N i Each prior position (x c ,y c ), calculate the actual bounding box coordinates, and convert the expression form. The process is as follows: x i =(x c +Δx i )×s i (20) y i =(y c +Δy i )×s i (21) box i =[x i -w i / 2,y i -h i / 2,x i +w i / 2,y i +h i / 2] (24) score i =O i ×max(C i ) (25) In the formula, s i is the step size of the corresponding feature map, p w and p h are the width and height of the prior box, box i is the position of the detection box, score i is the corresponding confidence level.
8. A lightning arrester external defect detection device based on improved YOLOv8, characterized in that: include: Improve the YOLOv8 network acquisition module, which is used to improve the YOLOv8 network and use the training data set to train the network to obtain the trained improved YOLOv8 network; The arrester external defect detection module is used to detect the arrester external defects using the trained improved YOLOv8 network and obtain the detection results; Among them, the method of improving the YOLOv8 network and using the training data set to train the network to obtain the trained improved YOLOv8 network is: Obtain the arrester image sample dataset, preprocess it, and finally perform convolution operation to obtain the input feature map I norm ; Backbone network feature extraction: CSPDarknet53 is used as the backbone network. Backbone network feature extraction inputs Inorm into the improved CSPDarknet53 backbone network and goes through 5 CSP stages in sequence: F1=CSP(I norm ) (1) F2=CSP(F1) (2) F3=CSP(F2) (3) F4=CSP(F3) (4) F5=CSP(F4) (5) Among them, each CSP stage contains the CBAM attention mechanism, which takes the i-th input feature F i The processing process includes channel attention calculation and spatial attention calculation; Feature pyramid fusion: Top-down and bottom-up feature fusion of features F3, F4 and F5 output by the backbone network; Detection head prediction: predict the fusion features separately; Prediction box decoding; Soft-NMS post-optimization processing: After merging the prediction boxes on all feature maps, arrange them in descending order of confidence, and calculate the position box of each detection box. i First, calculate the intersection over union (IoU) with other detection boxes, and then update the confidence scores of other detection boxes based on IoU. j , the process is as follows: Where γ is the update rate and η is the limit threshold.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, it implements a method for detecting external defects of a lightning arrester based on improved YOLOv8 as described in any one of claims 1 to 7.
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 processor executes the program, it implements a method for detecting external defects of a lightning arrester based on improved YOLOv8 as described in any one of claims 1 to 7.
Citation Information
Cited By
Intelligent detection and evaluation method and system for underground pipeline diseases
CN121505359A
An underground pipeline disease intelligent detection and evaluation method and system
CN121505359B
Knee meniscus injury detection method and system fusing multiple sequences and contrast learning
CN121767758A