A method for aerial insulator orientation identification based on improved yolov5
Through the improved Yolov5 network and CBAM attention mechanism, combined with the adaptive anchor frame and feature fusion module, the problem of background interference and video stream recognition in aerial insulator recognition is solved, and high-precision and efficient insulator recognition is achieved, which is suitable for embedded Equipment and power system applications.
Patent Information
- Application Number
- CN202211369709.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-03
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2042-11-03
AI Technical Summary
When the existing deep learning method based on horizontal anchor boxes identifies insulators in aerial images, it is easy to label background information as the target, resulting in a decrease in recognition accuracy, and cannot effectively process video streams, making it difficult to promote in real application scenarios.
Using the improved Yolov5 network, by introducing directional boxes with angle parameters for labeling and training, combined with CBAM lightweight attention mechanism and adaptive anchor box calculation, the robustness and feature extraction capabilities of the model are enhanced, and Mosaic data enhancement and SPP are used The +FPN module performs feature fusion and optimizes the prediction head module to improve recognition accuracy and speed.
It has improved the accuracy and speed of insulator identification, can identify insulators in video streams, and is suitable for embedded devices with edge-cloud collaborative architecture in power systems, meeting the requirements of real-time and efficiency.
Smart Images

Figure CN115690542B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of computer vision image recognition, and in particular relates to an aerial photography insulator directional recognition method based on improved YOLOv5. Background Art
[0002] Insulators are an important part of the power transmission and distribution network. They are devices installed between conductors of different potentials, or between conductors and ground potential components. They can withstand voltage and mechanical stress, and are a special type of insulation control that can play an important role in overhead transmission and distribution lines. Damage to insulators usually leads to abnormal use of the entire line and shortened lifespan, so the detection of insulators is particularly important. Since insulators are widely used in overhead transmission and distribution lines, manual detection is difficult. They are generally photographed and analyzed with the help of aerial photography equipment such as drones. Accurate and rapid identification of insulators during image capture is a difficult task. Existing deep learning methods for target recognition are mainly divided into anchor frame-based algorithms such as Fast R-cnn, Yolo series networks, and non-anchor frame-based algorithms such as Mask R-cnn, among which the mainstream algorithm is still the horizontal anchor frame-based algorithm. However, aerial photos are mostly taken from a bird's-eye view, and each photo usually contains multiple insulators. In addition, the appearance and shape of the insulator itself is characterized by a large aspect ratio. When using the traditional recognition model based on horizontal anchor frames for recognition, a large amount of background information will be marked as insulators, causing it to learn non-target information, ultimately reducing the recognition accuracy. In addition, the identified insulators also contain a certain amount of background information in the picture, which means that the positioning is not accurate enough. Patent 202111431311.X, an insulator detection and positioning method based on a rotating frame recognition network, improves the problem of horizontal frame recognition being interfered by background information by adding the angle information of the recognition frame during the training phase. However, this method does not take into account the speed and efficiency of recognition, does not make adaptive improvements in recognition accuracy, cannot use video streams to detect insulators, and is difficult to promote in real application scenarios. Summary of the invention
[0003] Technical problems solved: In response to the above technical problems, the present invention discloses an aerial photography insulator directional identification method based on improved YOLOv5, which realizes the identification of insulators using directional frames, reduces the identification range of insulators, improves the identification accuracy of insulators, and has excellent identification speed performance. It can also be extended to the identification of insulators in video streams and applied to embedded devices in the edge-cloud collaborative architecture of power systems.
[0004] The technical solution adopted by the present invention is:
[0005] An aerial photography insulator orientation identification method based on improved Yolov5 includes the following steps:
[0006] S1, obtain the insulator image set used for training, annotate the obtained image set using an oriented frame with angle parameters, generate the data set required by the deep learning model, and divide the data set into a training set and a test set;
[0007] S2, construct an insulator orientation recognition model based on the yolov5 network, which includes an image input module, a feature extraction BackBone module, which is the backbone network of yolov5, a feature fusion Neck module, which is the neck of yolov5, and a prediction head module, which is the head of yolov5;
[0008] The image input module performs rotation, brightness change, random cropping, and random splicing operations on batch insulator images to enhance the robustness of the model;
[0009] The feature extraction BackBone module performs convolution feature extraction on the insulator image processed by the image input module to generate feature maps of different scales;
[0010] The feature fusion Neck module performs up- and down-sampling on the feature maps of different scales processed by the feature extraction BackBone module, so as to output a feature map with complete feature information;
[0011] The prediction head module fits and identifies the insulator on the feature graph processed by the feature fusion Neck module;
[0012] S3, use the training set to train the insulator recognition model. After the training is completed, use the divided test set to evaluate the performance of the insulator recognition model and calculate the average precision AP indicator.
[0013] Further:
[0014] In S1, the roLabelImg data annotation tool is used to annotate the acquired aerial insulator images to generate label data, and then the label data is converted to generate dota format data, namely the coordinates of the center point of the rectangle (x, y) and the length and width of the rectangle, as well as the angle parameter information between the rectangle and the x-axis.
[0015] For the added angle parameters, the long edge definition method and CLS strategy are used during the back-propagation gradient descent. When defining the angle of the oriented box, the angle between the longer side and the horizontal direction is selected as the angle of the oriented box. CLS converts the angle regression problem into a classification problem, and adds 180 angle parameters defined by the long edge definition method to do the classification problem.
[0016] The image input module described in S2 first uses the traditional Mosaic data enhancement method of the Yolo series to randomly scale, randomly crop, and randomly arrange the training data for splicing; secondly, it uses the adaptive anchor frame calculation method to pre-calculate the approximate anchor frame size for the object to be detected; finally, it uses the adaptive image scaling operation to adjust images of different resolutions to the same resolution.
[0017] The feature extraction BackBone module described in S2 adds Focus or slicing operation on the basis of CSPDarknet commonly used in the yolo series to increase the number of channels of the extracted features; in the BackBone stage after the Focus operation, yolov5 first uses the CSP convolution module to extract the initial feature map from the third-level feature map to the second-level feature map, and then uses the CSP convolution module and the CBAM lightweight attention mechanism module to extract the second-level feature map to the first-level feature map; the CBAM lightweight attention mechanism module first uses the channel attention mechanism module CAM, ChannelAttention Module, which first undergoes global maximum pooling and global average pooling based on width and height, and then passes through three layers of fully connected perceptrons to add its output at the pixel scale and then activate it by the sigmoid function; the output feature map is multiplied with the initial feature map at the pixel scale to obtain the output of the CAM module; the output of the CAM module is used as SAM, Spatial Attention The input of the module first performs global maximum pooling and global average pooling based on the channel scale, and the results are tensor spliced at the channel scale; then the dimension is reduced to a single channel feature map through a channel-scale convolution operation, and finally the obtained feature map is multiplied with the input of SAM to obtain a feature map with rich spatial information.
[0018] The feature fusion Neck module described in S2 adopts the SPP module and the FPN+PAN module for upsampling and downsampling. Specifically: the SPP module concatenates the tensors of the three-level feature maps after maximum pooling to obtain a feature map with more complete feature information, upsamples through FPN to fuse the richer field of view information of the upper-level feature map to the next-level feature map, and downsamples through the PAN module to fuse more accurate positioning information to the upper-level feature map; after fusion, feature maps of different sizes and levels will be obtained.
[0019] The prediction head module described in S2 is to use the three-level feature map obtained by the feature fusion Neck module to draw on the idea of SSD, that is, the strategy of fitting small targets with large feature maps and fitting large targets with small feature maps is used to identify targets of different sizes; specifically, the pre-selected box size set for the first-level feature map is [(116,90), (156,98), (373,326)], the pre-selected box size set for the second-level feature map is [(30,61), (62,45), (59,119)], and the pre-selected box size set for the third-level feature map is [(10,13), (16,30), (33,23)].
[0020] The specific steps for calculating the AP index in S3 to evaluate the model performance are: save the weight file generated by training, use the weight file to identify insulators in the test model, compare it with the annotated real information, and generate the corresponding CSV file; extract the AP information from the CSV file.
[0021] The loss function of directional recognition used in training in S3 is:
[0022]
[0023] In this formula is the overall loss function, is the classification loss, is the rectangular box position loss, is the confidence loss, is the rectangular box angle loss; the classification loss, confidence loss and rectangular box angle loss are calculated using the BCEWithlogitsloss function, and the rectangular box position loss is calculated by the CIOU_Loss function.
[0024] Beneficial effects of the present invention:
[0025] First, the present invention inherits the advantages of Yolov5 such as fast single-stage network recognition speed, which meets the high real-time requirements of the power transmission and distribution network. In addition, the lightweight network structure has low requirements for hardware performance and can be deployed on embedded devices such as drones, which is more practical.
[0026] Second, the present invention can be applied to the field of video recognition. After practice, its speed can reach 22FPS, which meets the speed requirement of video recognition and has been verified in practice.
[0027] Third, the present invention adds a lightweight attention mechanism module CBAM on the basis of the original yolov5 network. The introduction of this module significantly improves the network feature extraction capability without increasing the detection time overhead, which further improves the practicality of the improved model.
[0028] Fourth, the present invention uses the CLS method and the long side definition method to solve the boundary problem when regressing the angle parameters. Then, the insulator image set can be annotated using an oriented frame with an angle, avoiding the problem that the model learns background information irrelevant to model training because a large amount of background information is annotated as insulators when annotating the horizontal frame. The loss function adds the rectangular frame angle loss calculated by the BCEWithlogitsloss function on the basis of the original yolov5 loss function. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 is a flow chart of the present invention;
[0030] Figure 2 This is a schematic diagram of the effect of the tool for labeling angle parameter datasets (RoLabelImg) in the present invention;
[0031] Figure 3 Schematic diagram of the improved yolov5 network model structure used in the present invention;
[0032] Figure 4 Comparison chart of model convergence degree before and after adding the attention mechanism to the present invention;
[0033] Figure 5 Comparison chart of map indicators before and after adding the attention mechanism to the present invention;
[0034] Figure 6 Schematic diagram of the structure of the CBAM lightweight attention mechanism module used in the present invention;
[0035] Figure 7 Schematic diagram of the long side definition method used in the present invention;
[0036] Figure 8 It is a schematic diagram of parameters corresponding to each level of characteristic graph in the present invention;
[0037] Fig. 9 The AP index and PR curve verified by the training model in the present invention;
[0038] Fig.10 It is a schematic diagram of various parameters obtained in the training of the present invention;
[0039] Fig.11 A schematic diagram of using the trained model to identify aerial insulator images in the present invention;
[0040] Fig.12 This is a schematic diagram of the capture of the aerial insulator video using the trained model in the present invention. DETAILED DESCRIPTION
[0041] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. Those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should belong to the protection scope of the present invention.
[0042] See also Figure 1 , an aerial photography insulator directional identification method based on improved yolov5, comprising the following steps:
[0043] S1, obtain the insulator image set used for training, use the oriented frame with angle parameters to annotate the obtained image set, generate the data set required by the deep learning model, and divide the data set into training set and test set.
[0044] Further: In S1, the roLabelImg data annotation tool is used to annotate the acquired aerial insulator images to generate label data, and then the label data is converted to generate dota format data, namely, the coordinates of the center point of the rectangle (x, y) and the length and width of the rectangle, as well as the angle parameter information between the rectangle and the x-axis.
[0045] For the added angle parameters, the long side definition method and CLS strategy are used during the back-propagation gradient descent. When defining the angle of the oriented box, the angle between the longer side and the horizontal direction is selected as the angle of the oriented box. CLS converts the angle regression problem into a classification problem, and adds 180 angle parameters defined by the long side definition method to the classification problem. This effectively avoids the boundary oscillation problem during angle regression. This strategy can effectively enable angle information to participate in the model training process, solving the problem that angle information is difficult to train through regression problems.
[0046] S2, based on the yolov5 network, an insulator directional recognition model is constructed. The insulator recognition model mainly includes an image input module, a feature extraction BackBone module, which is the backbone network of yolov5, a feature fusion Neck module, which is the "neck" of yolov5, and a prediction head module, which is the "head" of yolov5. The image input module first uses the traditional Mosaic data enhancement method of the yolo series to splice the training data in a random scaling, random cropping, and random arrangement manner; secondly, the adaptive anchor frame calculation method is used to pre-calculate the approximate anchor frame size for the object to be detected, so as to speed up the training and detection time; finally, the adaptive image scaling operation is used to adjust the images of different resolutions to the same resolution, which also improves the reasoning ability of yolov5.
[0047] In the feature extraction BackBone module, this module adds Focus or slicing operation on the basis of CSPDarknet commonly used in the yolo series to increase the number of channels of extracted features. CSPDarknet is a common feature extraction network in the yolo series used since yolov4. It adds CSP or Cross Stage Partial structure on the basis of Darknet, a feature extraction network before yolov4. This structure borrows the idea of residual connection to reduce the amount of calculation and enhance gradient representation. The CSPDarknet network mainly includes CBL module and CSP module. The CBL module consists of convolution layer, batch normalization BN layer, and Leakyrelu activation function. The CSP module borrows the idea of Resnet to connect multiple CBL modules together through residual connection, which effectively deepens the network structure. Then batch normalization and Leaky relu function activation are performed through tensor splicing.
[0048] In the remaining BackBone stage, yolov5 first uses the CSP convolution module to extract the initial feature map from the third-level feature map to the second-level feature map, and then uses the CSP convolution module and the CBAM lightweight attention mechanism module to extract the second-level feature map into the first-level feature map. The CBAM lightweight attention mechanism module further extracts features from the channel dimension and spatial dimension of the extracted features, so that the final feature map contains rich spatial information without increasing the time overhead.
[0049] Figure 6 The schematic diagram of the structure of the CBAM lightweight attention mechanism module used in the present invention includes a CAM module and a SAM module. The CAM (Channel Attention Module) module is a channel attention mechanism module, and the SAM (Spatial Attention Module) module is a spatial attention mechanism module. The feature map obtained by convolution is first subjected to global maximum pooling and global average pooling based on width and height by the channel attention mechanism module CAM, and then respectively outputted by the three-layer fully connected perceptron to add and activate the sigmoid function at the pixel scale, so that the feature map has channel feature information. The output feature map is multiplied with the initial feature map at the pixel scale to obtain the output of the CAM module. The output of the CAM module is used as the input of the spatial attention mechanism module SAM, and global maximum pooling and global average pooling based on the channel scale are first performed, and the obtained results are tensor spliced at the channel scale. Then the convolution operation at the channel scale is reduced to a single channel feature map, and finally the obtained feature map is multiplied with the input of SAM to obtain a feature map with rich spatial information.
[0050] In the feature fusion Neck module, the SPP module and the FPN+PAN module are used for upsampling and downsampling. Specifically:
[0051] The SPP module performs maximum pooling of different scales on the three-level feature maps, converts them to the same size, and then performs tensor splicing with the feature map after the second feature extraction after input, and fuses them into a feature map with rich and multi-level feature information. The specific kernel size in the maximum pooling process is {1*1, 5*5, 9*9, 13*13}.
[0052] The FPN structure uses interpolation to enlarge the size of the first-level feature map to the size of the second-level feature map during the upsampling process, and then performs tensor splicing with it. The second-level feature map is spliced with the third-level feature map in the same way to achieve the purpose of passing the strong semantic information of the upper-level feature map downward. Upsampling through FPN fuses the richer "field of view" information of the upper-level feature map into the next-level feature map.
[0053] The PAN structure is similar to the FPN concept, which is to transform the third-level feature map into a size similar to the second-level feature map through a convolution operation. Figure 1 After the tensors are concatenated, the second-level feature map is concatenated with the first-level feature map in the same way to achieve the purpose of passing the strong positioning information of the lower-level feature map upward. The more accurate positioning information is fused to the upper-level feature map through downsampling of the PAN module. The feature maps of different sizes and levels obtained after fusion are sent to the prediction head module.
[0054] The prediction head module uses the idea of SSD to obtain the three-level feature map obtained by the feature fusion Neck module, and adopts the strategy of fitting large feature maps to small targets and small feature maps to large targets to identify targets of different sizes; specifically, the pre-selected box size set for the first-level feature map is [(116,90), (156,98), (373,326)], the pre-selected box size set for the second-level feature map is [(30,61), (62,45), (59,119)], and the pre-selected box size set for the third-level feature map is [(10,13), (16,30), (33,23)].
[0055] S3, use the training set to train the insulator recognition model, and after the training is completed, use the divided test set to evaluate the performance of the insulator recognition model and calculate the average precision AP index. The specific steps of calculating the AP index to evaluate the model performance are: save the weight file generated by the training, use the weight file to identify the insulator in the test model, compare it with the annotated real information, and generate the corresponding CSV file. Extract the AP information from the CSV file.
[0056] The present invention will be further described below through specific implementation methods and effects.
[0057] A method for identifying the orientation of aerial insulators based on improved yolov5 is as follows:
[0058] Step 1: Obtain a set of insulator images, annotate the insulator images, and generate the data set required for the deep learning model.
[0059] Exemplarily, the insulator in the insulator picture is the only target to be recognized by the recognition model. It should be understood that insulators of different sizes indicate that the recognition model needs to have multi-scale recognition capabilities. The method of the present invention can be extended to more equipment recognition tasks in aerial pictures with similar appearance features to insulators. Figure 2 This is a schematic diagram of the effect of one of the tools for manually labeling angle parameter datasets (RoLabelImg). The figure shows two insulator labeling boxes of different sizes and neither of them is placed horizontally. The position information, size information, and angle information of the directional labeling box containing the insulator are the labeling information concerned by the present invention. Figure 2 The other characters in are the inherent parameters of the marking tool and have nothing to do with the technical solution of this embodiment.
[0060] Get more aerial insulator datasets from open source datasets, use the labeling tool RoLabelImg to label them, and label them as Insulators. The dataset labeled by RoLabelImg is in VOC format, which cannot be used directly by the yolov5 network, so it needs to be converted into a txt file in dota format. The dataset converted into txt format is divided into a training set: test set: validation set with a ratio of 7:2:1.
[0061] Step 2: Construct an insulator directional identification model
[0062] The insulator identification model of this embodiment is implemented based on the yolov5 network. In order to better meet the application scenarios faced by this embodiment, this embodiment improves the original yolov5 network model. Figure 3 This is a schematic diagram of the improved yolov5 network model structure used in this embodiment.
[0063] Specifically, this embodiment improves the original yolov5 model from the following aspects:
[0064] First: In order to introduce the angle information of the annotation box into the yolov5 network, the present invention draws on the CLS idea to transform the regression problem into a classification problem, and then combines the long side definition method to define the angle between the longer side of the oriented box and the horizontal direction as the angle of the oriented box. Figure 7This is a diagram of the long edge definition method. The label dimension is changed from the original yolov5 network ( , , , ) is the coordinate information of the upper left corner and the lower right corner of the annotation box, and is changed to (X, Y, W, H, θ) is the coordinate information of the center point of the annotation box, the length and width information, and the angle information. The data enhancement technology involved in the data loading part of the original yolov5 network contains a large number of normalization and denormalization operations. Therefore, the improved yolov5 network model of the present invention requires that the input image must be padded in the format of Width=Height to avoid the long side definition method. The long side and the short side have no strict correspondence with the length and width of the picture, which leads to confusion in positioning information.
[0065] See also Figure 3 In the feature extraction BackBone module, the CBAM lightweight attention mechanism module is added to the basic structure of the CSPDarknet network, while the feature fusion Neck module retains the original structure of yolov5:
[0066] The data enhanced by the image input module is first sliced and spliced by the Focus module, changing the original 608*608*3 feature map to a 304*304*12 feature map, and then undergoing a convolution to a 304*304*32 feature map, which increases the number of feature channels and expands the spatial information of the feature while basically retaining the original image features. After that, the feature extraction BackBone module extracts features from the input by the CBL convolution module and the CSP convolution module: first, the second-level feature map is obtained by two combined convolutions of the CBL module and CSP1_X, with a size of 38*38. Then, the first-level feature map is obtained by a combined convolution of the CBL module and CSP1_X and the CBAM attention mechanism module, with a size of 19*19. Figure 4 Comparison of model convergence before and after adding the attention mechanism in this invention, Figure 5The map index comparison chart before and after the attention mechanism is added to the present invention. After the introduction of the CBAM attention mechanism, the model has a significant improvement in convergence compared to the model without adding the attention mechanism, and the map index has also been improved by nearly 4 percentage points. It can be seen that the introduction of the CBAM attention mechanism has greatly improved the improvement effect of the present invention. After the feature extraction module is completed, the Neck module performs feature fusion with the SPP module and up and down sampling as the main means. Specifically: First, the SPP module performs a Maxpooling operation that is adapted to the size of the three-level feature map and the original feature map, and then performs tensor splicing to synthesize a feature map with multi-scale feature information. The feature map is obtained by combining the CSP2_X convolution module and the CBL convolution module, and then the upsampling operation is performed to perform tensor splicing with the first-level feature map. The feature map obtained by this step operation is then subjected to a combined convolution of the CSP2_X and CBL modules, and after upsampling, it is tensor spliced with the second-level feature map. Finally, a CSP2_X module and a conv module are used to obtain the final third-level feature map with a size of 76*76. Similarly, the second-level feature map with a final size of 38*38 is obtained by concatenating the feature map before the second upsampling in the Neck module and the final third-level feature map tensor, and then convolving it with the CSP2_X and conv modules. The first-level feature map with a final size of 19*19 is obtained by concatenating the feature map before the first upsampling in the Neck module and the final second-level feature map tensor, and then convolving it with the CSP2_X and conv modules. At this point, the feature extraction BackBone module and the feature fusion Neck module have completed all the work.
[0067] Second: The main improvement in the prediction Head module is to add the angle information of the annotation box. Specifically: 180 angle classification channels are added to the Detect constructor. See Figure 8 Three anchor boxes of different sizes are constructed with each pixel of each level of feature map as the center point, so the parameters corresponding to the pixels on each level of feature map are 3*(4+1+1+180), 3 is the number of anchor boxes, 4 is the anchor box size and position information parameter, the two 1s are the category parameter and confidence parameter respectively, and 180 is the angle classification parameter.
[0068] Third: Make adaptive improvements in the loss function. The loss function of the original yolov5 network is:
[0069] After the angle classification parameter is introduced, the loss function also adds the angle classification loss, and the loss function of directional target recognition is obtained as follows:
[0070] In this formula is the overall loss function, is the classification loss, is the rectangular box position loss, is the confidence loss, is the rectangular frame angle loss. The classification loss, confidence loss and rectangular frame angle loss are calculated using the BCEWithlogitsloss function, and the rectangular frame position loss is calculated using the CIOU_Loss function. Compared with GIOU_Loss, CIOU_Loss takes the aspect ratio of the anchor frame into consideration, which is more in line with the characteristics of the large aspect ratio of the insulator.
[0071]
[0072] In the formula is the sigmoid function,
[0073]
[0074] In the formula The intersection of the candidate box and the real box. is a parameter used to weigh v, is a parameter to measure the consistency of aspect ratio. is the Euclidean distance between the two center points of A and B, and c is the Euclidean distance between the diagonals of the minimum enclosing rectangles of box A and box B. is the width of the real frame, is the height of the real box, W is the width of the pre-selected box, and H is the height of the pre-selected box.
[0075] Fourth: parameter adjustment, different hyperparameter combinations of the network will have different effects on the performance of the improved yolov5 directional identification insulator of the present invention. Therefore, the present invention adjusts different hyperparameter combinations of the improved yolov5 model until the evaluation performance of the network is optimal, and the hyperparameter combinations are shown in Table 1.
[0076] Table
[0077] Hyperparameters Hyperparameter selected values Iteration rounds 500 Learning Rate 0.0032 Batch size 4
[0078] For the model trained under this hyperparameter combination, the prediction accuracy Precision and recall Recall saved in the CSV file during the training process are taken out to draw the PR curve and calculate the AP indicator.
[0079]
[0080]
[0081] TP stands for true positive, FP stands for false positive, and FN stands for false negative. The AP index can be calculated by calculating the area under the PR curve. Fig. 9, the AP index of the model obtained by training in this embodiment is 0.95. Fig.10 , all training indicators tend to converge after 500 iterations, and all indicators have reached a good level. Fig.11 , the model trained by the embodiment of the present invention can be used to perform directional and rapid recognition of aerial insulator images with high recognition accuracy. Fig.12 The model trained by the embodiment of the present invention can also perform directional recognition on aerial insulator videos with good results.
[0082] Fifth: Time performance comparison, the present invention basically retains the fast recognition performance of the original yolov5 network, and compares the average recognition speed of a single picture. As shown in Table 2, the average single-picture time of the directional YOLOv5+CBAM attention mechanism in the present invention is only 0.006 seconds longer than that of the original YOLOv5 network, and it has a significant speed advantage compared with other mainstream recognition network representatives, the Faster R-cnn network, which shows that the recognition speed performance of the method in this paper is excellent.
[0083] Table
[0084] Identification Model Average time for single image recognition Faster R-cnn 0.37s YOLOv5 0.045s Directed YOLOv5 0.047s The present invention 0.051s
Claims
1. A method for identifying the orientation of an aerial insulator based on improved Yolov5, characterized in that: The following steps are involved: S1, obtain the insulator image set used for training, annotate the obtained image set using an oriented frame with angle parameters, generate the data set required by the deep learning model, and divide the data set into a training set and a test set; S2, construct an insulator orientation recognition model based on the yolov5 network, which includes an image input module, a feature extraction BackBone module, which is the backbone network of yolov5, a feature fusion Neck module, which is the neck of yolov5, and a prediction head module, which is the head of yolov5; The image input module performs rotation, brightness change, random cropping, and random splicing operations on batch insulator images to enhance the robustness of the model; The feature extraction BackBone module performs convolution feature extraction on the insulator image processed by the image input module to generate feature maps of different scales; The feature fusion Neck module performs up- and down-sampling on the feature maps of different scales processed by the feature extraction BackBone module, so as to output a feature map with complete feature information; The prediction head module fits and identifies the insulator on the feature graph processed by the feature fusion Neck module; The feature extraction BackBone module adds Focus or slicing operation on the basis of CSPDarknet commonly used in the yolo series to increase the number of channels of the extracted features; in the BackBone stage after the Focus operation, yolov5 first uses the CSP convolution module to extract the initial feature map from the third-level feature map to the second-level feature map, and then uses the CSP convolution module and the CBAM lightweight attention mechanism module to extract the second-level feature map to the first-level feature map; the CBAM lightweight attention mechanism module first uses the channel attention mechanism module CAM, Channel Attention Module, which first undergoes global maximum pooling and global average pooling based on width and height, and then passes through three layers of fully connected perceptrons to add its output at the pixel scale and then activate it by the sigmoid function; the output feature map is multiplied by the initial feature map at the pixel scale to obtain the output of the CAM module; The output of the CAM module is used as the input of the SAM, Spatial Attention Module. First, global maximum pooling and global average pooling based on the channel scale are performed, and the obtained results are tensor spliced at the channel scale. Then, the convolution operation at the channel scale is performed to reduce the dimension to a single-channel feature map, and finally the obtained feature map is multiplied with the input of SAM to obtain a feature map with rich spatial information; S3, use the training set to train the insulator recognition model. After the training is completed, use the divided test set to evaluate the performance of the insulator recognition model and calculate the average precision AP indicator.
2. The method for identifying the orientation of an aerial insulator based on improved yolov5 according to claim 1 is characterized in that: In S1, the roLabelImg data annotation tool is used to annotate the acquired aerial insulator images to generate label data, and then the label data is converted to generate dota format data, namely the coordinates of the center point of the rectangle (x, y) and the length and width of the rectangle, as well as the angle parameter information between the rectangle and the x-axis.
3. The method for identifying the orientation of an aerial insulator based on improved yolov5 according to claim 2 is characterized in that: For the added angle parameters, the long edge definition method and CLS strategy are used during the back-propagation gradient descent. When defining the angle of the oriented box, the angle between the longer side and the horizontal direction is selected as the angle of the oriented box. CLS converts the angle regression problem into a classification problem, and adds 180 angle parameters defined by the long edge definition method to do the classification problem.
4. The method for identifying the orientation of an aerial insulator based on improved yolov5 according to claim 1 is characterized in that: The image input module described in S2 first uses the traditional Mosaic data enhancement method of the Yolo series to randomly scale, randomly crop, and randomly arrange the training data for splicing; secondly, it uses the adaptive anchor frame calculation method to pre-calculate the approximate anchor frame size for the object to be detected; finally, it uses the adaptive image scaling operation to adjust images of different resolutions to the same resolution.
5. The method for identifying the orientation of an aerial insulator based on improved yolov5 according to claim 1 is characterized in that: The feature fusion Neck module described in S2 adopts the SPP module and the FPN+PAN module for upsampling and downsampling. Specifically: the SPP module concatenates the tensors of the three-level feature maps after maximum pooling to obtain a feature map with more complete feature information, upsamples through FPN to fuse the richer field of view information of the upper-level feature map to the next-level feature map, and downsamples through the PAN module to fuse more accurate positioning information to the upper-level feature map; after fusion, feature maps of different sizes and levels will be obtained.
6. The method for identifying the orientation of an aerial insulator based on improved yolov5 according to claim 1, characterized in that: The prediction head module described in S2 is to use the three-level feature map obtained by the feature fusion Neck module to draw on the idea of SSD, that is, the strategy of fitting small targets with large feature maps and fitting large targets with small feature maps is used to identify targets of different sizes; specifically, the pre-selected box size set for the first-level feature map is [(116,90), (156,98), (373,326)], the pre-selected box size set for the second-level feature map is [(30,61), (62,45), (59,119)], and the pre-selected box size set for the third-level feature map is [(10,13), (16,30), (33,23)].
7. According to the method for identifying the orientation of an insulator by aerial photography based on improved yolov5 as described in claim 1, it is characterized in that: The specific steps for calculating the AP index in S3 to evaluate the model performance are as follows: save the weight file generated by training, use the weight file to identify insulators in the test model, compare it with the annotated real information, and generate the corresponding CSV file; Extract the AP information from this CSV file.
8. According to the method for identifying the orientation of insulators by aerial photography based on improved yolov5 mentioned in claim 7, it is characterized in that: The loss function of directional recognition used in training in S3 is: In this formula is the overall loss function, is the classification loss, is the rectangular box position loss, is the confidence loss, is the rectangular box angle loss; the classification loss, confidence loss and rectangular box angle loss are calculated using the BCEWithlogitsloss function, and the rectangular box position loss is calculated by the CIOU_Loss function.
Citation Information
Patent Citations
Insulator detecting and positioning method based on rotating frame recognition network
CN114299354A
Lightweight power distribution assembly defect identification method based on improved YOLOv5-LITE
CN114862768A
