CN115953371A - Insulator defect detection method, device, equipment and storage medium - Google Patents

Insulator defect detection method, device, equipment and storage medium Download PDF

Info

Publication number
CN115953371A
CN115953371A CN202211656533.6A CN202211656533A CN115953371A CN 115953371 A CN115953371 A CN 115953371A CN 202211656533 A CN202211656533 A CN 202211656533A CN 115953371 A CN115953371 A CN 115953371A
Authority
CN
China
Prior art keywords
insulator
defect detection
detection model
image
sample
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211656533.6A
Other languages
Chinese (zh)
Inventor
王楷
王天军
郭江涛
肖靖峰
曹澍
孟欣欣
王平
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
State Grid Xinjiang Electric Power CorporationInformation & Telecommunication Co ltd
Original Assignee
State Grid Xinjiang Electric Power CorporationInformation & Telecommunication Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by State Grid Xinjiang Electric Power CorporationInformation & Telecommunication Co ltd filed Critical State Grid Xinjiang Electric Power CorporationInformation & Telecommunication Co ltd
Priority to CN202211656533.6A priority Critical patent/CN115953371A/en
Publication of CN115953371A publication Critical patent/CN115953371A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y04INFORMATION OR COMMUNICATION TECHNOLOGIES HAVING AN IMPACT ON OTHER TECHNOLOGY AREAS
    • Y04SSYSTEMS INTEGRATING TECHNOLOGIES RELATED TO POWER NETWORK OPERATION, COMMUNICATION OR INFORMATION TECHNOLOGIES FOR IMPROVING THE ELECTRICAL POWER GENERATION, TRANSMISSION, DISTRIBUTION, MANAGEMENT OR USAGE, i.e. SMART GRIDS
    • Y04S10/00Systems supporting electrical power generation, transmission or distribution
    • Y04S10/50Systems or methods supporting the power network operation or management, involving a certain degree of interaction with the load-side end user applications

Landscapes

  • Image Analysis (AREA)

Abstract

The invention discloses a method, a device, equipment and a storage medium for detecting insulator defects. The method comprises the following steps: pre-training an insulator defect detection model adopting an attention mechanism; when detecting the defect of the insulator, acquiring an insulator image; inputting the insulator image into an insulator defect detection model, and detecting whether insulator defects exist in the insulator image through the insulator defect detection model; obtaining a detection result output by the insulator defect detection model; and if the insulator defect is detected in the insulator image, marking an anchor frame in the insulator defect area of the insulator image according to the detection result. The insulator defect detection model adopts an attention mechanism, and the attention mechanism can improve the weight of important neurons and inhibit the important neurons into the weight of the important neurons in training, so that the insulator defect detection is more accurate.

Description

Insulator defect detection method, device, equipment and storage medium
Technical Field
The invention relates to the technical field of intelligent electric power, in particular to a method, a device, equipment and a storage medium for detecting insulator defects.
Background
In an electric power system, the power transmission lines are distributed in an environment with complex terrain and bad climate, which brings great difficulty to the power transmission line inspection. The insulator arranged in the power transmission line runs in complex environments such as a strong electric field, high-temperature sunshine, high mechanical stress, high humidity and the like for a long time, and when the insulator is degraded to a certain degree, the insulating property of the insulator is reduced, so that potential safety hazards appear on the power transmission line. Especially on high voltage transmission lines, deterioration of the insulator directly threatens the safe operation of the power system.
In order to avoid safety problems due to deterioration of the insulator, defect detection may be performed on the insulator.
The appearance of the insulator is mostly identified by adopting an edge identification mode in the traditional detection mode, and whether the insulator is lost or not is analyzed. However, the debugging difficulty of the method is high, repeated parameter adjustment is needed under the condition of unstable detection, more false detections are needed when complex defects occur, and the compatibility is poor.
Disclosure of Invention
The invention mainly aims to provide a method, a device, equipment and a storage medium for detecting insulator defects, and aims to solve the problem of low detection precision of the existing insulator defect detection mode.
In order to realize the technical problem, the invention is realized by the following technical scheme:
the embodiment of the invention provides an insulator defect detection method, which comprises the following steps: pre-training an insulator defect detection model adopting an attention mechanism; when detecting the defect of the insulator, acquiring an insulator image; inputting the insulator image into the insulator defect detection model, and detecting whether an insulator defect exists in the insulator image through the insulator defect detection model; obtaining a detection result output by the insulator defect detection model; and if the insulator defect is detected in the insulator image, marking an anchor frame in the insulator defect area of the insulator image according to the detection result.
Wherein, set up in the neural network of the defect detection model of the said insulator: a first attention unit and a second attention unit; wherein, in the process of training the insulator defect detection model, the first attention unit and the second attention unit are both used for adjusting the weight of the neuron in the neural network.
Wherein, before the pre-training of the insulator defect detection model adopting the attention mechanism, the method further comprises the following steps: acquiring a sample insulator image from a preset sample insulator image data set; performing data enhancement processing on the sample insulator image; wherein the data enhancement processing is used for amplifying a plurality of sample insulator images based on the sample insulator images; adding the amplified sample insulator images to the sample insulator image dataset so as to train the insulator defect detection model based on the sample insulator image dataset.
Wherein, the insulator defect detection model adopting an attention mechanism is trained in advance, and comprises: inputting sample insulator images into the insulator defect detection model in sequence; marking a real anchor frame of a real position of the insulator defect in the sample insulator image; generating a plurality of candidate anchor frames with different sizes in the sample insulator image by the insulator defect detection model by using a k-means clustering algorithm; the candidate anchor frames are used for identifying the positions of the insulator defects; selecting one candidate anchor frame closest to the real anchor frame from the candidate anchor frames by a neural network in the insulator defect detection model, and outputting the candidate anchor frame as a prediction anchor frame; and determining a loss value by a loss function in the insulator defect detection model according to the prediction anchor frame and the real anchor frame, and adjusting the insulator defect detection model according to the loss value.
The embodiment of the invention also provides an insulator defect detection device, which comprises: the training module is used for training an insulator defect detection model adopting an attention mechanism in advance; the acquisition module is used for acquiring an insulator image when detecting the defect of the insulator; the detection module is used for inputting the insulator image into the insulator defect detection model and detecting whether insulator defects exist in the insulator image or not through the insulator defect detection model; obtaining a detection result output by the insulator defect detection model; and if the insulator defect is detected in the insulator image, marking an anchor frame in the insulator defect area of the insulator image according to the detection result.
Wherein, set up in the neural network of the defect detection model of the said insulator: a first attention unit and a second attention unit; wherein, in the process of training the insulator defect detection model, the first attention unit and the second attention unit are both used for adjusting the weight of the neuron in the neural network.
Wherein the training module is further configured to: before the insulator defect detection model adopting an attention mechanism is trained in advance, acquiring a sample insulator image from a preset sample insulator image data set; performing data enhancement processing on the sample insulator image; wherein the data enhancement processing is used for amplifying a plurality of sample insulator images based on the sample insulator images; adding the amplified plurality of sample insulator images to the sample insulator image dataset so as to train the insulator defect detection model based on the sample insulator image dataset.
Wherein the training module is configured to: inputting sample insulator images into the insulator defect detection model in sequence; marking a real anchor frame of a real position of the insulator defect in the sample insulator image; generating a plurality of candidate anchor frames with different sizes in the sample insulator image by the insulator defect detection model by using a k-means clustering algorithm; the candidate anchor frames are used for identifying the positions of the insulator defects; selecting one candidate anchor frame closest to the real anchor frame from the candidate anchor frames by a neural network in the insulator defect detection model, and outputting the candidate anchor frame as a prediction anchor frame; and determining a loss value by a loss function in the insulator defect detection model according to the prediction anchor frame and the real anchor frame, and adjusting the insulator defect detection model according to the loss value.
The embodiment of the invention also provides insulator defect detection equipment, which comprises a processor and a memory; the processor is configured to execute the insulator defect detection program stored in the memory, so as to implement any one of the above-described insulator defect detection methods.
An embodiment of the present invention further provides a computer-readable storage medium, where one or more programs are stored, and the one or more programs are executable by one or more processors to implement any one of the insulator defect detection methods described above.
The invention has the following beneficial effects:
in the embodiment of the invention, an insulator defect detection model adopting an attention mechanism is trained, whether insulator defects exist in an insulator image is detected by using the model, and if the insulator defects exist, an anchor frame is marked. Because the insulator defect detection model adopts an attention mechanism, the attention mechanism can improve the weight of important neurons in training and inhibit the important neurons into the weight of the important neurons, so that the insulator defect detection is more accurate.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
fig. 1 is a flow chart of a method of insulator defect detection according to an embodiment of the invention;
FIG. 2 is a flowchart illustrating steps of a data enhancement process according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of an insulator defect detection model according to an embodiment of the invention;
FIG. 4 is a schematic diagram of a channel attention subunit according to an embodiment of the invention;
FIG. 5 is a schematic diagram of a spatial attention subunit according to an embodiment of the present invention;
FIG. 6 is a flow chart of a training process of an insulator defect detection model according to an embodiment of the present invention;
fig. 7 is a structural view of an insulator defect detecting apparatus according to an embodiment of the present invention;
fig. 8 is a structural diagram of an insulator defect detecting apparatus according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in further detail below with reference to the accompanying drawings and specific embodiments.
According to an embodiment of the invention, a method for detecting insulator defects is provided. Fig. 1 is a flowchart illustrating a method for detecting insulator defects according to an embodiment of the present invention.
And step S110, pre-training an insulator defect detection model adopting an attention mechanism.
And the insulator defect detection module is used for identifying whether the insulator defect exists in the insulator image and marking the position of the insulator defect (a prediction anchor frame) by using the anchor frame when the insulator defect is identified.
The training process of the insulator defect detection module will be described later, and therefore, the details are not described herein.
In the training process, the attention mechanism can be used for increasing the neuron linear separability of a neural network in the insulator defect detection model, increasing the weight of important neurons and inhibiting the weight of non-important neurons. The important neuron is a neuron which is significant in identifying the insulator defect.
And step S120, acquiring an insulator image when detecting the insulator defect.
An unmanned aerial vehicle can be used to collect the insulator image. For example: a large amount of inspection videos are shot through a high-definition camera carried by an unmanned aerial vehicle, and insulator images are obtained from the inspection videos.
Step S130, inputting the insulator image into the insulator defect detection model, and detecting whether insulator defects exist in the insulator image through the insulator defect detection model.
Step S140, obtaining a detection result output by the insulator defect detection model; and if the insulator defect is detected in the insulator image, marking an anchor frame in the insulator defect area of the insulator image according to the detection result.
In the embodiment of the invention, an insulator defect detection model adopting an attention mechanism is trained, whether insulator defects exist in an insulator image is detected by using the model, and if the insulator defects exist, the anchor frame is marked. Because the insulator defect detection model adopts an attention mechanism, the attention mechanism can improve the weight of important neurons in training and inhibit the important neurons into the weight of the important neurons, so that the insulator defect detection is more accurate.
According to the embodiment of the invention, the insulator defect detection is automatically carried out after the electric power system collects the images, the occurrence position of the insulator defect is determined, the manual inspection cost is reduced, and the problems of low insulator positioning speed and low precision in the conventional electric power inspection are solved. The invention has higher stability, improves the controllability of detection quality, can integrate and store information and is convenient for personnel to trace.
In the embodiment of the present invention, the insulator defect detection model may adopt a YOLO model. The following description takes the YOLO model as an example.
The YOLO series algorithm is a deep learning neural network image recognition algorithm. The YOLOv5 algorithm is a representative single-stage detection algorithm, has the advantages of small code amount, simple program, high detection speed, high detection accuracy and the like, and becomes the closest image recognition algorithm used by the engineering technology at present.
In the embodiment of the invention, the insulator defect detection model comprises an input end, a reference network, a neck network and an output end. Before training the insulator defect detection model, a sample insulator image data set used for training the insulator defect detection model is collected.
In the embodiment of the invention, a large amount of inspection videos can be shot through the high-definition camera carried by the unmanned aerial vehicle, and a large amount of sample insulator images are obtained from the inspection videos. The sample insulator image may be an image of a defective insulator. Labeling the sample insulator image by using a graphic image interpretation tool LabelImg, drawing a picture frame (a real anchor frame) of a defective part in the sample insulator image and marking a defined label (an insulator or a defective insulator). The label can use the PASCAL VOC format (format used by ImageNet) to save the insulator image marked with the real anchor frame and the label as an XML file. In addition, the PASCAL VOC format needs to be converted to the YOLO format for use together in the process of making the sample insulator image data set. In order to train the insulator defect detection model better, a sample insulator image data set is divided into a training set and a test set, 20% of the training set and 80% of the test set are selected as the training set.
In order to prevent the sample size of the insulator defect detection model from being small, data enhancement processing can be performed on the sample insulator images in the sample insulator image data set so as to increase the number of the sample insulator images, so that the data size of model training is richer, and further the model detection accuracy is higher.
FIG. 2 is a flowchart illustrating steps of a data enhancement process according to an embodiment of the present invention.
Step S210, before the insulator defect detection model adopting the attention mechanism is trained in advance, a sample insulator image is obtained from a preset sample insulator image data set.
Step S220, performing data enhancement processing on the sample insulator image; wherein the data enhancement processing is used to amplify a plurality of sample insulator images based on the sample insulator image.
Step S230, adding the multiple amplified sample insulator images into the sample insulator image dataset, so as to train the insulator defect detection model based on the sample insulator image dataset.
In the embodiment of the invention, a plurality of data enhancement modes can be used for respectively enhancing the data of the insulator image.
Conventional data enhancement may be employed. For example: rotating the image, adding gaussian noise to the image, changing image brightness, cropping the image, translating the image, and the like. The rotation angle used when rotating the image includes, but is not limited to: 60 °,90 °,120 °,150 °,180 °,270 °. The information quantity of the XML file of the new image obtained by adding Gaussian noise into the image and changing the image brightness is the same as that of the original image, and the original image content in the original image cannot be changed.
Mosaic data enhancement may also be employed. And randomly cutting four sample insulator images, randomly rotating and randomly arranging and splicing the four sample insulator images into a new image, and enriching the data volume. Of course, the area of the real anchor frame may not be removed at the time of clipping. Further, a batch of sample insulator images may be removed from the sample insulator image dataset, 4 sample insulator images are randomly taken from the remaining sample insulator images each time, and the new image is synthesized by performing random position cropping and stitching.
Both the new map obtained by the conventional data enhancement method and the new map obtained by the mosaic data enhancement method are stored in the sample insulator image dataset as sample insulator images.
In an embodiment of the present invention, the data enhancement process may be performed by an input terminal of the insulator defect detection model.
In the embodiment of the present invention, in order to increase the detection accuracy of the insulator defect detection model, the neural network (the reference network and the neck network) of the insulator defect detection model is provided with: a first attention unit and a second attention unit; wherein, in the process of training the insulator defect detection model, the first attention unit and the second attention unit are both used for adjusting the weight of the neuron in the neural network.
Further, a first attention unit may be provided in the reference network. A first attention unit and a second attention unit are disposed in the neck network. Wherein the first Attention unit may be a non-Attention SimAM (A Simple Parameter-Free Attention Module for relational Neural Networks). The second Attention unit may be a normalized-based Attention NAM (normalized-based Attention Module) without additional parameters. The SimAM is a simple and very effective attention unit. Unlike the conventional channel/spatial attention module, this unit derives 3D attention weights for feature maps without additional parameters. Specifically, this unit proposes to optimize the energy function to exploit the importance of neurons based on well-known neuroscience theory Compared with other attention mechanisms, the NAM directly uses the scaling in the BN to calculate the attention weight without additional full concatenation, convolution and other additional calculations and parameters, and further suppresses insignificant features by adding the regularization term.
Fig. 3 is a schematic diagram of an insulator defect detection model according to an embodiment of the invention.
In fig. 3, the backhaul represents a reference network, and elements in the reference network are below the backhaul. Neck denotes the Neck network, below which are the elements in the Neck network. Head denotes the output, below which is the cell in the output. Wherein Input represents Input; conv denotes the basic convolution module (in which three functions are encapsulated, including convolution (Conv 2 d), BN normalization, and the SiLU activation function); c3 represents a triple convolution (only three convolutional layers are named as C3, which includes 3 standard convolutional layers and a plurality of bottleeck modules, the role of which is to deepen the network); SIMAM is the first attention unit; SPPF represents a Spatial Pyramid Pooling module (Spatial Pyramid Pooling); concat represents a fusion feature; upsample represents upsampling; NAM denotes a second attention unit; detect represents the output layer of the network.
The embodiment of the invention is to add a first attention unit (SimAM unit) and a second attention unit (NAM unit) in the YOLO model, the added types and the optimal positions are as shown in fig. 3, the SimAM unit is arranged before the SPPF unit of the reference network, the SimAM unit is arranged before the first Conv unit of the neck network, and the NAM unit is arranged after the second, third and fourth C3 units.
The following description is first made with respect to the SIMAM cell.
The SimAM unit is different from the existing channel/spatial attention module, and provides a method for unifying weights. The SimAM cell derives 3D attention weights for the feature map without additional parameters. The operation of the SimAM unit is based essentially on energy function selection, avoiding excessive structural adjustments.
To achieve better attention, the importance of each neuron needs to be assessed. In neuroscience, information-rich neurons often exhibit different firing patterns than peripheral neurons. Moreover, activation of neurons generally inhibits peripheral neurons, i.e., spatial domain inhibition. In other words, neurons with spatial domain inhibitory effects are given greater importance. The method for determining the important neurons is to measure the linear separability between the neurons. Thus, the following energy function e is defined t
Figure BDA0004011695740000081
Wherein the content of the first and second substances,
Figure BDA0004011695740000082
is t and x i Linear transformation of (1), t and x i Is a characteristic of input
Figure BDA0004011695740000083
Target neurons and other neurons in (a). i is the index in the spatial dimension, M = H × W is the number of neurons on one channel. w is a t And b t Are the weights and offsets of the linear transformation. All values in equation (1) are scalar. When in use
Figure BDA0004011695740000084
And has ^ on all other neurons>
Figure BDA0004011695740000085
Equation (1) yields the minimum value. Wherein, y t And y 0 Are two different values. Minimizing equation (1) is equivalent to finding the linear separability of the target neuron t and other neurons in the same channel. The SimAM unit adopts a binary label and adds a regular term. The final energy function is shown in equation (2):
Figure BDA0004011695740000086
each channel has an energy function. The computational overhead can be significant if all of these equations are solved by some iterative solver like SGD (statistical gradient device). However, in equation (2) for w t And b t The analytical solution can be rapidly obtained as shown in the following formula:
Figure BDA0004011695740000087
Figure BDA0004011695740000088
wherein the content of the first and second substances,
Figure BDA0004011695740000089
and &>
Figure BDA00040116957400000810
Is the mean and variance of all neurons in the corresponding channel after the neuron t has been removed. λ is a coefficient. w is a 0 Is the initial weight of the linear transformation.
It can be seen from the formulas (3) and (4) that the solutions are obtained on a single channel, and therefore, it can be reasonably assumed that other neurons of the same channel also satisfy the same distribution. Based on this assumption, the mean and variance can be computed over all neurons, and can be multiplexed over all neurons on the same channel. The overhead of repeatedly calculating μ and σ at each location can be greatly reduced, and finally the minimum energy at each location can be obtained by equation (5):
Figure BDA00040116957400000811
wherein the content of the first and second substances,
Figure BDA00040116957400000812
and &>
Figure BDA00040116957400000813
Equation (5) illustrates energy
Figure BDA0004011695740000091
The lower, the more distinct the neuron t and the peripheral neurons, the more important in the visual processing. Thus, the SimAM cell passes ≦>
Figure BDA0004011695740000092
To indicate the importance of each neuron.
The first attention unit uses scaling operators instead of addition for feature refinement. The whole refinement stage of the SimAM unit is:
Figure BDA0004011695740000093
wherein E is
Figure BDA0004011695740000094
In the summary of all channels and spatial dimensions, sigmoid is used to constrain too large a value, without affecting the relative size of each neuron, and sigmoid is a monotonic function. />
Figure BDA0004011695740000095
Representing an energy function. An indicator indicates a zoom operator. X denotes an input feature.
The calculation of attention weights can be accelerated by deriving the analytic solution of the energy function through the formula, the initial initialization weights are randomly generated, the subsequent weights are updated in training, and the weights are continuously adjusted through continuous training.
Next, description is made on NAM units.
The NAM unit is a new normalization-based attention module, and is an efficient and lightweight attention mechanism. The NAM unit adopts CBAM (plug and play Attention Module) and redesigns the channel and space Attention sub-modules, using the scaling factor in batch normalization, as shown in equation (7), which measures the variance of the channels and indicates their importance.
Figure BDA0004011695740000096
/>
Wherein, B out Denotes the channel output, BN (B) in ) Represents the batch normalized channel input, μ β And σ β Respectively, the mean and variance of the small batch beta. Gamma and beta are trainable affine transformation parameters (scale sum)Displacement).
M c =sigmoid(W γ (BN(F1))) (8)
The channel attention subunit in the NAM unit is shown in fig. 4 and equation (8). Wherein M is c Representing the output characteristics. Gamma ray i And gamma j Is a scaling factor for each channel with a weight of W γ =γ i /∑ j=0 γ j . The scale factor of BN is applied to the spatial dimension to measure the importance of the pixel. It may be named pixel normalization.
M S =sigmoid(W λ (BN S (F2))) (9)
The spatial attention subunit in the NAM cell is shown in fig. 5 and equation (9), where the output is expressed as M s . Weight of W λ =λ i /∑ j=0 λ j 。λ i And λ j Are all scaling factors. F2 denotes an input feature.
To suppress the less significant weights, a regularization term is added to the loss function, as shown in equation (10). Wherein l (f (x, W), y) represents a loss function without a penalty term, and x represents an input; y is the output; w represents the network weight, l (-) is a loss function; g (-) is l 1 Norm penalty function, p is the penalty for balancing g (γ) and g (λ). The Loss value Loss is expressed as:
Loss=∑ (x,y )l(f(x,W),y)+p∑g(γ)+p∑9(λ) (10)
the following describes a training process of the insulator defect detection model. Fig. 6 is a flowchart illustrating a training process of an insulator defect inspection model according to an embodiment of the invention.
Step S610, inputting sample insulator images into the insulator defect detection model in sequence; and marking a real anchor frame of the real position of the insulator defect in the sample insulator image.
Step S620, the insulator defect detection model generates a plurality of candidate anchor frames with different sizes in the sample insulator image by using a k-means clustering algorithm; and the candidate anchor frames are used for identifying the positions of the insulator defects.
In YOLOv5, a sample insulator image is divided into a plurality of regions, and then a plurality of anchor frames are generated at the center of each grid (region) in a set aspect ratio, the anchor frames having different sizes. And taking the anchor frames as possible candidate anchor frames, predicting whether the candidate anchor frames contain the insulators by the insulator defect detection model, and if so, further predicting whether the insulator belongs to the category of the defective insulator or the defect-free insulator. Further, the k-means clustering algorithm performs the following steps:
step 1, randomly selecting a plurality of frames (box) as initial anchor frames (anchors). Step 2, distributing each frame to an anchor frame closest to the frame by using a preset IOU (Intersection over Union) measurement; step 3, calculating the average value of the width and the height of all frames in each cluster, and updating the anchor frame; and (4) repeating the steps 2 and 3 until the anchor frame is not changed any more or the preset maximum iteration number is reached.
In this embodiment, further, since the position of the candidate anchor frame is fixed, the candidate anchor frame may be overlapped with the boundary frame of the insulator too often, so that fine tuning may be performed on the basis of the candidate anchor frame to form a prediction anchor frame capable of accurately describing the position of the insulator, and in the process of training the insulator defect detection model, the insulator defect detection model may be trained to adjust the position of the candidate anchor frame, that is, the fine tuning amplitude needs to be predicted.
Step S630, selecting, by the neural network in the insulator defect detection model, one candidate anchor frame closest to the true anchor frame from the candidate anchor frames, and outputting the candidate anchor frame as a prediction anchor frame.
The insulator defect detection model is trained, namely, the insulator defect detection model is trained to identify the position of the defective insulator, and aiming at the identification of the position of the defective insulator, the first attention unit and the second attention unit increase the weight of important neurons and inhibit the weight of non-important neurons, so that the important neurons can more accurately predict a candidate anchor frame (the size and the position of which are close to the real anchor frame) which is most similar to the real anchor frame, and the most similar candidate anchor frame is determined as a prediction anchor frame.
And step S640, determining a loss value by a loss function in the insulator defect detection model according to the prediction anchor frame and the real anchor frame, and adjusting the insulator defect detection model according to the loss value.
YOLOv5 can choose to adopt a GIoU loss function to calculate the regression loss of the insulator defect detection model, the GIoU loss function inherits the advantages of the IoU loss function, and meanwhile the defect that the distance between non-overlapping frames cannot be measured by the IoU loss function is overcome. However, when two predicted anchor frames are present, if the two predicted anchor frames are both contained in the real anchor frame and the area sizes of the two predicted anchor frames are the same, the GIoU loss function has the same effect as the IoU loss function, and the relative positional relationship cannot be distinguished. Based on the problem, after three important geometric factors of the overlap area, the center point distance and the aspect ratio between the predicted anchor frame and the real anchor frame are fully considered, the embodiment adopts the CIoU loss function as the loss function L of the improved YOLOv5 algorithm CIoU
L CIOU =1-IOU+R CIoU +αv (11)
Figure BDA0004011695740000111
In the equations (11) and (12), IOU is the cross-over ratio, R CIOU For the penalty term, α v is an influence factor, where α is a parameter used for weighing, v is a parameter used for measuring the uniformity of the aspect ratio, and b gt A forecast anchor frame indicating that the category is defect, b a forecast anchor frame indicating that the category is insulator, b and b gt Respectively represent b and b gt P is the Euclidean distance; c represents the diagonal distance of the target minimum bounding rectangle. The expressions for the α and v parameters are shown in equations (13) and (14):
Figure BDA0004011695740000112
Figure BDA0004011695740000113
where w and h are the width and height of the predicted anchor frame, respectively, and w gt And h gt Respectively the width and height of the real anchor frame.
The evaluation indexes of whether the insulator defect detection model is trained or not mainly comprise three points: the average Precision average (mAP), the Precision (Precision), and the recall rate (recall) are the first.
Figure BDA0004011695740000114
The mAP shown in equation (15) represents the average accuracy sum of all classes divided by the average accuracy of all classes in the dataset,
Figure BDA0004011695740000121
Figure BDA0004011695740000122
the Precision (Precision) shown in equation (16) represents that the classifier (i.e., the classifier corresponding to the defective insulator) is regarded as the positive class and the portion that is actually the positive class accounts for the proportion of the classifier regarded as the positive class. TP, FP, and FN represent the number of correct, false, and missed detection frames, respectively.
Figure BDA0004011695740000123
The Recall ratio (Recall) shown in equation (17) indicates that the classifier (i.e., the classifier corresponding to the defective insulator) is regarded as the positive class and that the part which is actually the positive class accounts for the proportion of all the parts which are actually the positive classes.
And presetting an average precision mean threshold, a precision threshold and a recall rate threshold. And comparing the average precision mean value obtained by the calculation with an average precision mean value threshold value, comparing the precision with the precision threshold value, comparing the recall rate with a recall rate threshold value, and determining that the insulator defect detection model is converged and training is completed under the condition that the average precision mean value, the precision and the recall rate are all larger than the respective corresponding threshold values.
The embodiment of the invention circularly executes the training steps to obtain the optimal reference network and the optimal neck network.
The invention performs data enhancement based on the YOLOv5_ m model, redefines an anchor frame, adds a non-attention mechanism SimAM and adds an attention NAM mechanism based on normalization without additional parameters, increases the number of samples and increases the accuracy of model detection.
Furthermore, the input end adopts Mosaic data enhancement, adaptive anchor frame calculation and adaptive picture scaling, and finally converts the picture into a tensor of 640 × 3 and inputs the tensor into the network. The reference network is mainly used for extracting the features of an input picture, firstly, slicing operation is carried out, downsampling is carried out through a convolution module, feature extraction is carried out, then, bottleneckCSP and convolution operation are carried out, a feature graph is obtained, finally, the precision is improved through a spatial pyramid pooling module, multi-scale features are fused, and pooled feature graphs are aggregated through Concat. The neck network is typically located intermediate the reference network and the output. By utilizing the neck Network, the features extracted by the reference Network can be better utilized, and the multi-scale prediction realizes the up-sampling and down-sampling processes through a Feature Pyramid Network (FPN) and a PAN (PAN) structure. Therefore, the diversity and robustness of the features are improved, the output layer mainly utilizes the features extracted before to make prediction, and the output of the target detection result is completed.
According to the invention, data enhancement is utilized, and the traditional data enhancement and mosaic data enhancement are combined, so that the number of data sets is enriched, the imbalance of positive and negative samples of data is avoided, the imbalance proportion of the samples is reduced, and the generalization capability of the model is improved.
According to the method, the communication of the characteristic diagrams among the channels is established by adding the attention-free module SimAM and the channel characteristic factors generated based on the normalization without extra parameter attention NAM, so that the model can focus on the characteristic relation of the channel dimension, the importance degree of each channel is modeled, then different channels are enhanced or inhibited according to different defect tasks, the judgment capability of the model is improved, and the robustness of the model on the surface defect detection problem is greatly improved.
The SimAM is non-attention, the NAM is a lightweight module, the overhead of the module can be ignored, and the module can be used in a plug-and-play mode and can be integrated into most CNN architectures. The effectiveness of attention may vary with position, and the depth of the module affects the position of attention insertion. The two modules are deeply fused into a YOLOv5_ m model, the fusion of the channel and the space dimension is better performed through continuous deep training of the network, the channel characteristics and the space position information of the image are reserved, and the network detection precision is favorably improved.
An embodiment of the present invention further provides an insulator defect detecting apparatus, and as shown in fig. 7, the apparatus is a structural diagram of the insulator defect detecting apparatus according to an embodiment of the present invention.
This insulator defect detecting device includes:
and the training module 710 is used for training an insulator defect detection model adopting an attention mechanism in advance.
And the acquisition module 720 is used for acquiring the insulator image when the insulator defect is detected.
The detection module 730 is configured to input the insulator image into the insulator defect detection model, and detect whether an insulator defect exists in the insulator image through the insulator defect detection model; obtaining a detection result output by the insulator defect detection model; and if the insulator defect is detected in the insulator image, marking an anchor frame in the insulator defect area of the insulator image according to the detection result.
Wherein, set up in the neural network of the defect detection model of the said insulator: a first attention unit and a second attention unit; wherein, in the process of training the insulator defect detection model, the first attention unit and the second attention unit are both used for adjusting the weight of the neuron in the neural network.
Wherein the training module 710 is further configured to: before the insulator defect detection model adopting an attention mechanism is trained in advance, acquiring a sample insulator image from a preset sample insulator image data set; performing data enhancement processing on the sample insulator image; wherein the data enhancement processing is used for amplifying a plurality of sample insulator images based on the sample insulator images; adding the amplified plurality of sample insulator images to the sample insulator image dataset so as to train the insulator defect detection model based on the sample insulator image dataset.
Wherein the training module 710 is configured to: inputting sample insulator images into the insulator defect detection model in sequence; marking a real anchor frame of a real position of the insulator defect in the sample insulator image; generating a plurality of candidate anchor frames with different sizes in the sample insulator image by the insulator defect detection model by using a k-means clustering algorithm; the candidate anchor frames are used for identifying the positions of the insulator defects; selecting one candidate anchor frame closest to the real anchor frame from the candidate anchor frames by a neural network in the insulator defect detection model, and outputting the candidate anchor frame as a prediction anchor frame; and determining a loss value by a loss function in the insulator defect detection model according to the prediction anchor frame and the real anchor frame, and adjusting the insulator defect detection model according to the loss value.
The functions of the apparatus according to the embodiments of the present invention have been described in the above method embodiments, so that reference may be made to the related descriptions in the foregoing embodiments for details which are not described in the present embodiment, and further details are not described herein.
The embodiment provides an insulator defect detection device. Fig. 8 is a block diagram of an insulator defect detecting apparatus according to an embodiment of the present invention.
In this embodiment, the insulator defect detecting apparatus includes, but is not limited to: a processor 810, a memory 820.
The processor 810 is configured to execute the insulator defect detection program stored in the memory 820, so as to implement the insulator defect detection method.
Specifically, the processor 810 is configured to execute the insulator defect detection program stored in the memory 820, so as to implement the following steps: pre-training an insulator defect detection model adopting an attention mechanism; when detecting the defect of the insulator, acquiring an insulator image; inputting the insulator image into the insulator defect detection model, and detecting whether insulator defects exist in the insulator image through the insulator defect detection model; obtaining a detection result output by the insulator defect detection model; and if the insulator defect is detected in the insulator image, marking an anchor frame in the insulator defect area of the insulator image according to the detection result.
Wherein, set up in the neural network of the defect detection model of the said insulator: a first attention unit and a second attention unit; wherein, in the process of training the insulator defect detection model, the first attention unit and the second attention unit are both used for adjusting the weight of the neuron in the neural network.
Wherein, before the pre-training of the insulator defect detection model adopting the attention mechanism, the method further comprises the following steps: acquiring a sample insulator image from a preset sample insulator image data set; performing data enhancement processing on the sample insulator image; wherein the data enhancement processing is used for amplifying a plurality of sample insulator images based on the sample insulator images; adding the amplified plurality of sample insulator images to the sample insulator image dataset so as to train the insulator defect detection model based on the sample insulator image dataset.
Wherein, the insulator defect detection model adopting an attention mechanism is trained in advance, and comprises: inputting sample insulator images into the insulator defect detection model in sequence; marking a real anchor frame of a real position of the insulator defect in the sample insulator image; generating a plurality of candidate anchor frames with different sizes in the sample insulator image by the insulator defect detection model by using a k-means clustering algorithm; the candidate anchor frames are used for identifying the positions of the insulator defects; selecting one candidate anchor frame closest to the real anchor frame from the candidate anchor frames by a neural network in the insulator defect detection model, and outputting the candidate anchor frame as a prediction anchor frame; and determining a loss value by a loss function in the insulator defect detection model according to the prediction anchor frame and the real anchor frame, and adjusting the insulator defect detection model according to the loss value.
The embodiment of the invention also provides a computer readable storage medium. The computer-readable storage medium herein stores one or more programs. Among other things, computer-readable storage media may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as read-only memory, flash memory, a hard disk, or a solid state disk; the memory may also comprise a combination of memories of the kind described above.
When the one or more programs in the computer readable storage medium are executable by the one or more processors, the method for detecting insulator defects as described above is implemented.
Specifically, the processor is configured to execute an insulator defect detection program stored in the memory to implement the following steps: pre-training an insulator defect detection model adopting an attention mechanism; when detecting the defect of the insulator, acquiring an insulator image; inputting the insulator image into the insulator defect detection model, and detecting whether insulator defects exist in the insulator image through the insulator defect detection model; obtaining a detection result output by the insulator defect detection model; and if the insulator defect is detected in the insulator image, marking an anchor frame in the insulator defect area of the insulator image according to the detection result.
Wherein, set up in the neural network of the defect detection model of the said insulator: a first attention unit and a second attention unit; wherein, in the process of training the insulator defect detection model, the first attention unit and the second attention unit are both used for adjusting the weight of the neuron in the neural network.
Wherein, before the pre-training of the insulator defect detection model adopting the attention mechanism, the method further comprises the following steps: acquiring a sample insulator image from a preset sample insulator image data set; performing data enhancement processing on the sample insulator image; wherein the data enhancement process is used to amplify a plurality of sample insulator images based on the sample insulator images; adding the amplified plurality of sample insulator images to the sample insulator image dataset so as to train the insulator defect detection model based on the sample insulator image dataset.
Wherein, the insulator defect detection model adopting an attention mechanism is trained in advance, and comprises: inputting sample insulator images into the insulator defect detection model in sequence; marking a real anchor frame of a real position of the insulator defect in the sample insulator image; generating a plurality of candidate anchor frames with different sizes in the sample insulator image by the insulator defect detection model by using a k-means clustering algorithm; the candidate anchor frames are used for identifying the positions of the insulator defects; selecting one candidate anchor frame closest to the real anchor frame from the candidate anchor frames by a neural network in the insulator defect detection model, and outputting the candidate anchor frame as a prediction anchor frame; and determining a loss value by a loss function in the insulator defect detection model according to the prediction anchor frame and the real anchor frame, and adjusting the insulator defect detection model according to the loss value.
The above description is only an example of the present invention, and is not intended to limit the present invention, and it is obvious to those skilled in the art that various modifications and variations can be made in the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the scope of the claims of the present invention.

Claims (10)

1. An insulator defect detection method is characterized by comprising the following steps:
pre-training an insulator defect detection model adopting an attention mechanism;
when detecting the defect of the insulator, acquiring an insulator image;
inputting the insulator image into the insulator defect detection model, and detecting whether insulator defects exist in the insulator image through the insulator defect detection model;
obtaining a detection result output by the insulator defect detection model; and if the insulator defect is detected in the insulator image, marking an anchor frame in the insulator defect area of the insulator image according to the detection result.
2. The method of claim 1,
setting in the neural network of the insulator defect detection model: a first attention unit and a second attention unit; wherein, in the process of training the insulator defect detection model, the first attention unit and the second attention unit are both used for adjusting the weight of the neurons in the neural network.
3. The method of claim 1, wherein prior to the pre-training the insulator defect inspection model using attention mechanism, further comprising:
acquiring a sample insulator image from a preset sample insulator image data set;
performing data enhancement processing on the sample insulator image; wherein the data enhancement processing is used for amplifying a plurality of sample insulator images based on the sample insulator images;
adding the amplified sample insulator images to the sample insulator image dataset so as to train the insulator defect detection model based on the sample insulator image dataset.
4. The method of claim 1, wherein the pre-training an insulator defect detection model using an attention mechanism comprises:
inputting sample insulator images into the insulator defect detection model in sequence; marking a real anchor frame of a real position of the insulator defect in the sample insulator image;
generating a plurality of candidate anchor frames with different sizes in the sample insulator image by the insulator defect detection model by using a k-means clustering algorithm; the candidate anchor frames are used for identifying the positions of the insulator defects;
selecting one candidate anchor frame closest to the real anchor frame from the candidate anchor frames by a neural network in the insulator defect detection model, and outputting the candidate anchor frame as a prediction anchor frame;
and determining a loss value by a loss function in the insulator defect detection model according to the prediction anchor frame and the real anchor frame, and adjusting the insulator defect detection model according to the loss value.
5. An insulator defect detecting device, comprising:
the training module is used for training an insulator defect detection model adopting an attention mechanism in advance;
the acquisition module is used for acquiring an insulator image when detecting the defect of the insulator;
the detection module is used for inputting the insulator image into the insulator defect detection model and detecting whether insulator defects exist in the insulator image or not through the insulator defect detection model; obtaining a detection result output by the insulator defect detection model; and if the insulator defect is detected in the insulator image, marking an anchor frame in the insulator defect area of the insulator image according to the detection result.
6. The apparatus of claim 5,
setting in the neural network of the insulator defect detection model: a first attention unit and a second attention unit; wherein, in the process of training the insulator defect detection model, the first attention unit and the second attention unit are both used for adjusting the weight of the neuron in the neural network.
7. The apparatus of claim 5, wherein the training module is further configured to:
before the insulator defect detection model adopting an attention mechanism is trained in advance, acquiring a sample insulator image from a preset sample insulator image data set;
performing data enhancement processing on the sample insulator image; wherein the data enhancement process is used to amplify a plurality of sample insulator images based on the sample insulator images;
adding the amplified plurality of sample insulator images to the sample insulator image dataset so as to train the insulator defect detection model based on the sample insulator image dataset.
8. The apparatus of claim 5, wherein the training module is configured to:
inputting sample insulator images into the insulator defect detection model in sequence; marking a real anchor frame of a real position of the insulator defect in the sample insulator image;
the insulator defect detection model generates a plurality of candidate anchor frames with different sizes in the sample insulator image by using a k-means clustering algorithm; the candidate anchor frames are used for identifying the positions of the insulator defects;
selecting one candidate anchor frame closest to the real anchor frame from the candidate anchor frames by a neural network in the insulator defect detection model, and outputting the candidate anchor frame as a prediction anchor frame;
and determining a loss value by a loss function in the insulator defect detection model according to the prediction anchor frame and the real anchor frame, and adjusting the insulator defect detection model according to the loss value.
9. The insulator defect detection equipment is characterized by comprising a processor and a memory; the processor is configured to execute the insulator defect detection program stored in the memory to implement the insulator defect detection method according to any one of claims 1 to 4.
10. A computer-readable storage medium, wherein the computer-readable storage medium stores one or more programs, which are executable by one or more processors to implement the insulator defect detection method according to any one of claims 1 to 4.
CN202211656533.6A 2022-12-22 2022-12-22 Insulator defect detection method, device, equipment and storage medium Pending CN115953371A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211656533.6A CN115953371A (en) 2022-12-22 2022-12-22 Insulator defect detection method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211656533.6A CN115953371A (en) 2022-12-22 2022-12-22 Insulator defect detection method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115953371A true CN115953371A (en) 2023-04-11

Family

ID=87281833

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211656533.6A Pending CN115953371A (en) 2022-12-22 2022-12-22 Insulator defect detection method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115953371A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117115640A (en) * 2023-07-04 2023-11-24 北京市农林科学院 Improved YOLOv 8-based pest and disease damage target detection method, device and equipment

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117115640A (en) * 2023-07-04 2023-11-24 北京市农林科学院 Improved YOLOv 8-based pest and disease damage target detection method, device and equipment

Similar Documents

Publication Publication Date Title
CN108961235B (en) Defective insulator identification method based on YOLOv3 network and particle filter algorithm
CN110298298B (en) Target detection and target detection network training method, device and equipment
CN113705478B (en) Mangrove single wood target detection method based on improved YOLOv5
WO2023155069A1 (en) Deep-learning-based surface defect detection method for mobile phone battery
CN108564085B (en) Method for automatically reading of pointer type instrument
CN111291826B (en) Pixel-by-pixel classification method of multisource remote sensing image based on correlation fusion network
CN113112519B (en) Key frame screening method based on interested target distribution
CN110598613A (en) Expressway agglomerate fog monitoring method
CN110827312A (en) Learning method based on cooperative visual attention neural network
CN111259808A (en) Detection and identification method of traffic identification based on improved SSD algorithm
CN115661569A (en) High-precision fine-grained SAR target detection method
CN116385911A (en) Lightweight target detection method for unmanned aerial vehicle inspection insulator
CN115147418A (en) Compression training method and device for defect detection model
CN116740758A (en) Bird image recognition method and system for preventing misjudgment
CN115953371A (en) Insulator defect detection method, device, equipment and storage medium
CN113628180A (en) Semantic segmentation network-based remote sensing building detection method and system
CN111079807B (en) Ground object classification method and device
CN116403071B (en) Method and device for detecting few-sample concrete defects based on feature reconstruction
US20230386023A1 (en) Method for detecting medical images, electronic device, and storage medium
CN112084941A (en) Target detection and identification method based on remote sensing image
CN116363532A (en) Unmanned aerial vehicle image traffic target detection method based on attention mechanism and re-parameterization
CN113269171B (en) Lane line detection method, electronic device and vehicle
CN113139540B (en) Backboard detection method and equipment
CN113313678A (en) Automatic sperm morphology analysis method based on multi-scale feature fusion
CN112419310A (en) Target detection method based on intersection and fusion frame optimization

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination