A method and device for detecting safety control of power distribution network projects
By adding the CBAM convolutional attention mechanism and Bi-FPN network to the YOLOv5 neural network model, combined with the improved CIoU loss function, the speed and accuracy of distribution network engineering detection are improved, and the slow detection speed and accuracy of the existing technology are solved. It solves the problem of low accuracy and realizes real-time and accurate safety problem detection on distribution network engineering sites.
Patent Information
- Application Number
- CN202210255317.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-15
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2042-03-15
AI Technical Summary
Existing distribution network engineering inspection methods have slow detection speed and low accuracy, making it difficult to meet the actual needs of the site, especially when the project scale is large and the supervision force is insufficient.
A distribution network engineering safety control detection method based on the YOLOv5 neural network model is adopted, by adding an improved CBAM convolutional attention mechanism module and Bi-FPN network to the backbone feature extraction network for feature fusion, and using an improved CIoU loss function. Improve detection speed and accuracy.
It achieves real-time and accurate detection of safety issues on the distribution network engineering site, improves detection capabilities and identification accuracy, meets the real-time needs of the site, and solves the problem of insufficient supervision in project management.
Smart Images

Figure CN114758288B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of machine image recognition, and in particular to a method and device for detecting safety management and control of a power distribution network project. Background Art
[0002] Distribution network projects have the characteristics of many construction sites, wide coverage, and great difficulty in safety risk prevention and control and on-site supervision. At present, the investment scale of distribution network projects is relatively large, with provincial companies averaging more than 3,000 projects per year and tens of thousands of on-site workers. Compared with the above scale, there are few project management personnel and insufficient supervision, which can easily lead to problems such as irregular on-site operations, many safety accidents, and poor quality of project completion. Therefore, it is urgent to strengthen the safety and quality control of distribution network projects by strengthening artificial intelligence means such as machine vision.
[0003] Deep learning is widely used in the field of image recognition due to its strong feature extraction capability, high recognition accuracy, and fast real-time performance. Currently, the main object detection algorithms based on machine vision are: traditional detection technology based on input image features and edge detection, and detection technology based on deep learning.
[0004] Traditional detection technology selects target candidate areas, extracts image sample features such as HOG features, SVM features, etc., and sends image features to classifiers such as iterative algorithms for classification and output results. Traditional detection algorithms follow four stages: image preprocessing, target positioning, target segmentation, and target recognition. Design errors in each stage will affect subsequent results, and the use of a large number of manually extracted features leads to poor robustness and is difficult to apply to distribution network engineering detection tasks with complex scenarios. Image recognition methods based on deep learning are mostly based on convolutional neural network models, with more stable recognition rates and wider applicability, but the neural network model is large and difficult to meet the requirements of embedded devices on distribution network engineering sites. In addition, the recognition speed is poor and cannot meet real-time detection requirements. Summary of the invention
[0005] In view of the above analysis, the embodiments of the present invention aim to provide a distribution network engineering safety management and control detection method and device to solve the problems that the existing detection methods have slow detection speed, low accuracy and poor applicability, and are difficult to meet the actual use needs of distribution network engineering sites.
[0006] On the one hand, an embodiment of the present invention provides a distribution network engineering safety management and control detection method, comprising the following steps:
[0007] Collect distribution network project site pictures and obtain sample sets after preprocessing;
[0008] A security control detection model is built based on the YOLOv5 neural network model. An improved CBAM convolutional attention mechanism module is added to the backbone feature extraction network. The spatial attention module in the improved CBAM convolves the input feature map along the horizontal and vertical channels to obtain the CBAM output feature map. The Bi-FPN network is used in the neck network to fuse the feature map output by the backbone feature extraction network.
[0009] Based on the sample set, a trained security control and detection model is obtained;
[0010] The real-time collected distribution network engineering images are passed into the trained safety control detection model to obtain the target detection results in the image.
[0011] Based on the further improvement of the above method, the improved CBAM convolutional attention mechanism module includes a channel attention module and a spatial attention module; the feature map output by the channel attention module is used as the input feature map of the spatial attention module. In the spatial attention module, the input feature map is convolved twice along the horizontal and vertical channels, and finally the CBAM output feature map is weighted.
[0012] Based on the further improvement of the above method, the spatial attention module performs two convolutions on the input feature map along the horizontal and vertical channels, and finally obtains the weighted CBAM output feature map, including:
[0013] For the input feature map, use the average pooling kernel to encode each channel in the horizontal and vertical directions respectively, and obtain two first feature maps in the horizontal and vertical directions;
[0014] Convolution is performed on the two first feature maps respectively to obtain two intermediate feature maps in the horizontal and vertical directions, and then the intermediate feature weights in the horizontal and vertical directions are obtained through a nonlinear activation function;
[0015] After convolving the two intermediate feature weights again, the channel weights in the horizontal and vertical directions are obtained through the activation function;
[0016] The input feature map is multiplied by the channel weights in the horizontal and vertical directions respectively to obtain the CBAM output feature map.
[0017] Based on the further improvement of the above method, the backbone feature extraction network is based on the CSPDarknet53 network, and the C3 module is used to replace the original CSP module; the C3 module divides the input feature map into two branches for processing. One branch is first convolved through the first convolution block CBS, and then the gradient is propagated through multiple residual units; the other branch is directly convolved through the second convolution block CBS, and then the two branches are spliced and convolved through the third convolution block CBS to obtain the C3 output feature map;
[0018] The logical operations in the first convolution block CBS, the second convolution block CBS and the third convolution block CBS are the same, including: convolution operation Conv, batch normalization BN and Silu activation function in sequence.
[0019] Based on the further improvement of the above method, an improved CBAM convolutional attention mechanism module is added to the backbone feature extraction network. That is, after the third convolution block CBS in each C3 module, an improved CBAM convolutional attention mechanism module is added as the C3' module. After the C3 output feature map of the C3 module passes through the CBAM convolutional attention mechanism module, the CBAM output feature map obtained is used as the C3' output feature map.
[0020] Based on the further improvement of the above method, the backbone feature extraction network processes the input image through the Focus module, the fourth convolution block CBS, the first C3' module, the fifth convolution block CBS, the second C3' module, the sixth convolution block CBS, the third C3' module, the seventh convolution block CBS, and the SPP module in sequence to extract the input image features and output 5 feature maps of different scales, including:
[0021] Feature map P1 processed by the Focus module, feature maps P2, P3 and P4 processed by the first, second and third C3' modules respectively, and feature map P5 processed by the SPP module.
[0022] Based on the further improvement of the above method, the Bi-FPN network is used to perform feature fusion on the feature maps output by the backbone feature extraction network. The feature maps of 5 different scales are fused at three network levels using the Bi-FPN network to obtain feature maps of 3 different sizes.
[0023] Based on the further improvement of the above method, a trained security control and detection model is obtained based on the sample set, including:
[0024] Based on the sample set, the security control detection model is trained, and the redundant target boxes are eliminated through the non-maximum suppression algorithm to obtain the predicted box of the sample image;
[0025] The loss function is used to calculate the error between the prediction box and the target box, and the model parameters are updated based on the error. The training is repeated until the value of the loss function is less than the threshold to obtain a trained security control detection model.
[0026] Based on the further improvement of the above method, the loss function is based on the CIoU loss function, with the width and height of the predicted box as the penalty term, and the calculation formula is:
[0027]
[0028]
[0029]
[0030] Among them, IoU is the intersection over union ratio of the predicted box and the standard box, d is the distance between the center points of the predicted box and the target box, c is the diagonal distance of the smallest rectangle that can cover both the predicted box and the target box, α is the weight function, and v is used to measure the consistency of the aspect ratio between the target box and the predicted box; ω is the width of the target box, ω p is the prediction box width, ω' is the width of the smallest rectangle that can cover both the prediction box and the target box, h is the target box height, and h p is the height of the prediction box, and h' is the height of the smallest rectangle that can cover both the prediction box and the target box.
[0031] On the other hand, an embodiment of the present invention provides a distribution network engineering safety management and control detection device, including: an image acquisition and preprocessing module, which is used to acquire images of the distribution network engineering site and obtain a sample set after preprocessing;
[0032] The model generation module is used to build a security control detection model based on the YOLOv5 neural network model. In the backbone feature extraction network, a CBAM convolutional attention mechanism module is added. In the spatial attention module in the CBAM, the input feature map is convolved along the horizontal and vertical channels to obtain the CBAM output feature map. In the neck network, the Bi-FPN network is used to perform feature fusion on the feature map output by the backbone feature extraction network.
[0033] Model training module, used to obtain a trained security control and detection model based on the sample set;
[0034] The project site image detection module is used to pass the real-time collected distribution network project images into the trained safety management and control detection model to obtain the target detection results in the image, including: target bounding box and target category.
[0035] Compared with the prior art, the present invention can achieve at least one of the following beneficial effects:
[0036] 1. Improve the existing backbone extraction network CSPDarknet53 of YOLOv5 and add an improved CBAM structure with attention mechanism, so that the features cover more parts of the object to be identified, increase the probability of final object identification, and improve the detection capability of the network without increasing other overhead.
[0037] 2. Structural improvements are made to the existing YOLOv5 feature extraction network, and the improved Bi-FPN is used to replace PANET. The stacking of different features is increased in the feature extraction process, which strengthens the fusion of image features and improves the accuracy of network recognition.
[0038] 3. Improve the existing CIoU loss function to solve the problem that the height and width gradients of the predicted box in the CIoU loss function are opposite, and the additional penalty term is 0 when the height and width ratio of the predicted box are equal to those of the target box. Directly use the predicted box width and height as penalty terms to improve the convergence speed.
[0039] 4. In response to the safety issues existing at the distribution network engineering site, an improved neural network model is proposed to meet the real-time requirements of on-site use, accurately and quickly complete the detection of safety issues, and realize the identification of safety issues such as the wearing of safety helmets, whether the drop-out fuse is disconnected, and whether the equipment bottom plate is blocked. It solves the problems of the existing distribution network on-site engineering management, such as the small number of engineering management personnel and insufficient supervision force, and improves the reliability of safety management and control at the distribution network engineering site.
[0040] In the present invention, the above-mentioned technical solutions can also be combined with each other to achieve more preferred combination solutions. Other features and advantages of the present invention will be described in the subsequent description, and some advantages can become obvious from the description, or can be understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained through the contents particularly pointed out in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The drawings are only for the purpose of illustrating specific embodiments and are not to be considered limiting of the present invention. Like reference symbols denote like components throughout the drawings.
[0042] Figure 1 This is a flow chart of the safety management and control detection method for distribution network engineering in Example 1 of the present invention;
[0043] Figure 2 is a schematic diagram of the improved CBAM structure in Example 1 of the present invention;
[0044] Figure 3 This is a schematic diagram of the improved CSPDarknet53 structure in Example 1 of the present invention;
[0045] Figure 4 This is a schematic diagram of improved Bi-FPN network feature fusion in Example 1 of the present invention;
[0046] Figure 5 A graph showing changes in the loss function, precision, recall and average precision during the training process in Example 3 of the present invention;
[0047] Figure 6 This is a PR curve diagram in Example 3 of the present invention. DETAILED DESCRIPTION
[0048] The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings, wherein the accompanying drawings constitute a part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not used to limit the scope of the present invention.
[0049] Embodiment 1,
[0050] A specific embodiment of the present invention discloses a distribution network engineering safety management and detection method, such as Figure 1 As shown, the following steps are included:
[0051] S11: Collect pictures of the distribution network project site and obtain a sample set after preprocessing;
[0052] It should be noted that the collected distribution network project site pictures are classified according to different types of safety, quality, and process problems, and image processing technology is used to flip, rotate, and add noise to the samples to expand the number of sample sets; labelimg is used to annotate the objects in the samples, organize them into .txt format, and put them into the sample set folder.
[0053] S12: A security control detection model is constructed based on the YOLOv5 neural network model. An improved CBAM convolutional attention mechanism module is added to the backbone feature extraction network. The spatial attention module in the improved CBAM convolves the input feature map along the horizontal and vertical channels to obtain the CBAM output feature map. The Bi-FPN network is used in the neck network to perform feature fusion on the feature map output by the backbone feature extraction network.
[0054] It should be noted that the YOLOv5 neural network model is divided into three parts. The first part is the backbone feature extraction network, which is used to extract the features of the input image. The second part is the neck network, which is used to enhance the features extracted by the backbone feature extraction network. The third part is the head network, which is used to make predictions based on the enhanced features and obtain detection results.
[0055] S121: Based on the YOLOv5 neural network model, an improved backbone feature extraction network is constructed.
[0056] Specifically, the backbone feature extraction network is based on the CSPDarknet53 network, and the C3 module is used to replace the original CSP module; the C3 module divides the input feature map into two branches for processing. One branch first passes through the first convolution block CBS for convolution, and then propagates the gradient through multiple residual units; the other branch directly passes through the second convolution block CBS for convolution, and then the two branches are spliced and passed through the third convolution block CBS for convolution to obtain the C3 output feature map. The logical operations in the first convolution block CBS, the second convolution block CBS, and the third convolution block CBS are the same, including: convolution operation Conv, batch normalization BN, and Silu activation function.
[0057] Compared with the CSP module, the C3 module reduces a 1х1 convolution operation and removes a BN layer and activation function. This simplifies the network structure, reduces the amount of calculation, and reduces the model's inference time, while ensuring that the model's performance does not decrease.
[0058] Furthermore, an improved CBAM convolutional attention mechanism module is added to the C3 module, such as Figure 2 As shown in the figure. The CBAM (Convolutional Block Attention Module) convolutional attention mechanism module includes a channel attention module and a spatial attention module. It can calculate the attention weights from two different dimensions, channel and space, respectively, and then multiply the obtained attention weights with the input feature map to perform adaptive feature refinement. Moreover, CBAM is a lightweight module that can improve the model detection effect without additional overhead.
[0059] The channel attention module can learn the weights of different channels, thereby generating channel-domain attention. By changing the weights of the original channels in the feature map through the channel attention module, a more obvious performance improvement is achieved with a small increase in the amount of computation. Figure 2 In the channel attention module, the input feature map X has a dimension of C×H×W, where C is the number of channels, H and W are the height and width of the feature map, respectively. After global maximum pooling and global average pooling, two C×1×1 weight vectors are obtained, which are sent to a two-layer neural network MLP. After addition, the sigmoid function is used for activation to obtain the channel weight. The obtained channel weight is multiplied by the original feature map X by channel to obtain the feature map X' output by the channel attention module.
[0060] The spatial attention module can highlight the information-rich parts of the feature map, complementing the channel attention. In the prior art, the YOLOv5 neural network model easily loses the feature information of small targets when performing convolution sampling, and the detection effect of small targets is not ideal. The introduction of the spatial attention mechanism in this embodiment can make the model pay more attention to the information-rich positions in the feature map. For small targets and dense targets, feature information can be effectively extracted to improve the detection accuracy.
[0061] In the improved CBAM spatial attention module, the feature map X' output by the channel attention module is used as the input feature map of the spatial attention module. The input feature map X' is convolved twice along the horizontal and vertical channels. The first convolution reduces the dimension of the vector, improves the extraction of effective information, and reduces the amount of calculation. Convolve again, transform the number of channels of the intermediate feature vector back to the same number of channels as the input feature X', and Sigmoid activation is used to obtain the final weight, and finally the CBAM output feature map is weighted. Specifically, it includes the following processes:
[0062] ① Use the average pooling kernel of size (H, 1) and (1, W) to encode each channel in the horizontal and vertical directions respectively, and obtain the two first feature maps in the horizontal and vertical directions. The formula is as follows:
[0063]
[0064]
[0065] Among them, z w (w) is the first feature map in the horizontal direction, z h (h) is the first feature map in the vertical direction, and X'(i,w) and X'(h,j) are pixels on the feature map X'.
[0066] ② After convolving the two first feature maps respectively to obtain the two intermediate feature maps in the horizontal and vertical directions, the intermediate feature weights in the horizontal and vertical directions are obtained through the nonlinear activation function. The formula is as follows:
[0067] f w =δ[F w1 (z w (w))] Formula (3)
[0068] f h =δ[F h1 (z h (h))] Formula (4)
[0069] Among them, δ is a nonlinear activation function, F w1 、F h1 are the convolutions performed on the two intermediate feature maps in the horizontal and vertical directions, respectively,w 、f h They are the intermediate feature weights in the horizontal and vertical directions, and their dimensions are C / r w ×W、C / r h ×H,r w 、r h are the dimension reduction coefficients of the number of channels in the horizontal and vertical directions, respectively.
[0070] ③ Weight the two intermediate features f respectively w and f h After convolution again, the channel weights in the horizontal and vertical directions are obtained through Sigmoid function activation. The formula is as follows:
[0071] g w =σ(F w2 (f w )) Formula (5)
[0072] g h =σ(F h2 (f h )) Formula (6)
[0073] Among them, σ is the Sigmoid function, F w2 、F h2 are the convolutions of the intermediate feature weights in the horizontal and vertical directions, g w , g h are the channel weights in the horizontal and vertical directions respectively.
[0074] ④ Multiply the input feature map by the channel weights in the horizontal and vertical directions respectively to obtain the CBAM output feature map Y. The formula is as follows:
[0075] Y(i,j)=X'(i,j)×g h (i)×g w (j) Formula (7)
[0076] The improved CBAM modifies the spatial attention module in CBAM and decomposes the features along the height and width directions and convolves them to generate weights respectively. This solves the problem of position information loss caused by two-dimensional global pooling in the CBAM spatial attention module, generates features that are sensitive to both channels and coordinate positions, and improves the detection accuracy.
[0077] After building the improved CBAM convolutional attention mechanism module, add the improved CBAM convolutional attention mechanism module after the third convolution block CBS in each C3 module as the C3' module. After the C3 output feature map of the C3 module passes through the CBAM convolutional attention mechanism module, the obtained CBAM output feature map is used as the C3' output feature map.
[0078] The final improved CSPDarknet53 network is as follows Figure 3 As shown, C3_1_n' represents an improved C3' module with n residual units, and CBAM' represents an improved CBAM convolutional attention mechanism module.
[0079] exist Figure 3 In the figure, the backbone feature extraction network processes the input image through the Focus module, the fourth convolution block CBS, the first C3' module, the fifth convolution block CBS, the second C3' module, the sixth convolution block CBS, the third C3' module, the seventh convolution block CBS, and the SPP module in sequence to extract the input image features and output 5 feature maps of different scales, including:
[0080] Feature map P1 processed by the Focus module, feature maps P2, P3 and P4 processed by the first, second and third C3' modules respectively, and feature map P5 processed by the SPP module.
[0081] For example, the five different scales are: [19×19], [38×38], [76×76], [152×152], and [304×304].
[0082] Compared with the prior art, this embodiment improves the existing backbone extraction network CSPDarknet53 of YOLOv5, adds an improved CBAM structure with an attention mechanism, so that the features cover more parts of the object to be identified, increases the probability of finally distinguishing the object, and improves the detection capability of the network without increasing other overhead.
[0083] S122: An improved Bi-FPN network is used in the neck network to perform feature fusion on the feature map output by the backbone feature extraction network.
[0084] Specifically, the five feature maps of different scales obtained in step S121 are fused with the features of three network layers using the Bi-FPN network to obtain three feature maps of different sizes, such as Figure 4 shown.
[0085] 1) In the first network level and the second network level of the Bi-FPN network, k represents the network level, k = 1, 2, P t =P t 1in , P t 1out =P t 2in , t=1,2,3,4,5; perform the following feature fusion:
[0086] ① For P5 kin Upsampling, with P4kin Stacking is performed to obtain the intermediate feature P4 ktd , the formula is as follows:
[0087]
[0088] Among them, conv() represents the convolution operation, revise() represents the feature map resolution matching operation after up / down sampling, ω k4 is the weight of the 4th level input feature fused to the 4th level intermediate feature in the kth network layer, ω k5 It is the weight of the 5th level input feature fused to the 4th level intermediate feature in the kth network layer. Preferably, ε=0.00001 is taken to avoid numerical instability.
[0089] ② For P t+1 ktd Upsampling, with P t kin Stack and obtain the intermediate feature P t ktd , the formula is as follows:
[0090]
[0091] Among them, ω kt is the weight of the t-th level input feature fused to the t-th level intermediate feature in the k-th network layer, ω k(t+1) It is the weight of the intermediate features of level t+1 in the k-th network layer fused to the intermediate features of level t.
[0092] ③For P1 kin Downsampling, with P2 ktd Stack and get the output feature P1 kout , the formula is as follows:
[0093]
[0094] Among them, ω k1 ' is the weight of the first-level input feature fused to the first-level output feature in the k-th network layer, ω k2 ' is the weight of the fusion of the second-level intermediate features to the first-level output features in the k-th network layer.
[0095] ④ P t-1 kout Downsampling, with P t kin , P t ktd Stack and get the output feature P t kout , the formula is as follows:
[0096]
[0097] Among them, ω kt ' is the weight of the t-th level input feature fused to the t-th level output feature in the k-th network layer, ω kt ” is the weight of the t-th level intermediate feature fused to the t-th level output feature in the k-th network layer, ω k(t-1) ' is the weight of the fusion of the t-1th level output feature to the tth level output feature in the kth network layer.
[0098] ⑤ For P4 kout Downsampling, with P5 kin Stack and get output feature P5 kout , the formula is as follows:
[0099]
[0100] Among them, ω k5 ' is the weight of the 5th level input feature fused to the 5th level output feature in the kth network layer, ω k4 ' is the weight of the fusion of the 4th level output features to the 5th level output features in the kth network layer.
[0101] 2) In the third network layer of the Bi-FPN network, P t 2out =P t 3in , t=1,2,3,4,5, perform the following feature fusion:
[0102] ① For P5 3in Upsampling, with P4 3in Stacking is performed to obtain the intermediate feature P4 3td , the formula is as follows:
[0103]
[0104] Among them, ω 34 is the weight of the 4th level input feature fused to the 4th level intermediate feature in the 3rd network layer, ω 35 It is the weight of the 5th level input feature fused to the 4th level intermediate feature in the 3rd network layer.
[0105] ② For P t+1 3td Upsampling, with P t 3in Stack and obtain the intermediate feature P t 3td , the formula is as follows:
[0106]
[0107] Among them, ω 3t is the weight of the t-th level input feature fused to the t-th level intermediate feature in the third network layer, ω 3(t+1) It is the weight of the t+1th level intermediate feature fused to the tth level intermediate feature in the third network layer.
[0108] ③For P1 3in Downsampling, with P2 3td 、P2 3in Stack and get the output feature P2 out , the formula is as follows:
[0109]
[0110] Among them, ω 31 ' is the weight of the fusion of the first-level input features to the first-level output features in the third network layer, ω 32 ” is the weight of the fusion of the second-level intermediate features to the second-level output features in the third network layer, ω 32 ' is the weight of the fusion of the second-level input features to the second-level output features in the third network layer.
[0111] ④ P t-1 3out Downsampling, with P t 3in , P t 3td Stack and get the output feature P t out , the formula is as follows:
[0112]
[0113] Among them, ω 3t ' is the weight of the t-th level input feature fused to the t-th level output feature in the third network layer, ω 3t ” is the weight of the t-th level intermediate feature fused to the t-th level output feature in the third network layer, ω 3(t-1) ' is the weight of the fusion of the t-1th level output feature to the tth level output feature in the third network layer.
[0114] For example, the three different sizes are: [38×38], [76×76], and [152×152].
[0115] Compared with the prior art, this embodiment uses an improved Bi-FPN to replace the PANET network in the YOLOv5 model. Bi-FPN uses fast normalization fusion, normalizes the weight by dividing it by the sum of all weights, and normalizes the weight to between [0,1] to improve the calculation speed. The improved Bi-FPN network deletes the node with only one input, which has no feature fusion and has a small contribution. After deleting the node, the network is simplified; an edge is added between the original input node and the output node, and the stacking of different features is increased without consuming more costs, which strengthens the fusion of image features and improves the accuracy of network recognition. Moreover, compared with the existing three-scale feature fusion network, the improved Bi-FPN simultaneously fuses the features of five scales extracted by the backbone network, increases the fusion of large-scale features, and improves the detection effect of large-scale targets.
[0116] S123: Input the three feature maps of different sizes output from the improved Bi-FPN feature fusion network into the prediction layer of the head network, eliminate redundant target frames through the non-maximum suppression algorithm, and obtain the target prediction frame and target category in the original image.
[0117] Specifically, the prediction results of the prediction layer are ranked by scores, and the DIoU-NMS non-maximum suppression algorithm is used to eliminate redundant target boxes. The algorithm considers the intersection-over-union ratio and the distance between the center points of the prediction box and the target box at the same time, which improves the detection of similar targets. The algorithm formula is as follows:
[0118]
[0119] Among them, IoU is the intersection over union of the prediction box and the target box, d is the distance between the center points of the prediction box and the target box, and c is the diagonal distance of the minimum rectangle that can cover both the prediction box and the target box.
[0120] S13: Based on the sample set, a trained security control and detection model is obtained;
[0121] It should be noted that when training the constructed security control detection model, the loss function is used to calculate the error between the prediction box and the target box, and the model parameters are updated based on the error. The training is repeated until the value of the loss function is less than the threshold, and a trained security control detection model is obtained, so that the network achieves optimal performance.
[0122] It should be noted that when the height and width gradients of the predicted box are opposite, and the height and width ratios of the predicted box are equal to those of the target box, using the existing CIoU loss function will result in the additional penalty term being 0. Therefore, the loss function of this embodiment directly uses the width and height of the predicted box as penalty terms based on the CIoU loss function to improve the convergence speed. The calculation formula is:
[0123]
[0124]
[0125]
[0126] Among them, IoU is the intersection over union ratio of the predicted box and the standard box, d is the distance between the center points of the predicted box and the target box, c is the diagonal distance of the smallest rectangle that can cover both the predicted box and the target box, α is the weight function, and v is used to measure the consistency of the aspect ratio between the target box and the predicted box; ω is the width of the target box, ω p is the prediction box width, ω' is the width of the smallest rectangle that can cover both the prediction box and the target box, h is the target box height, and h p is the height of the prediction box, and h' is the height of the smallest rectangle that can cover both the prediction box and the target box.
[0127] It should be noted that during training, whether the training is completed can also be identified based on the maximum number of training times.
[0128] S14: The real-time collected distribution network engineering image is transmitted to the trained safety control detection model to obtain the target detection result in the image.
[0129] It should be noted that the target detection result includes: a target bounding box and a target category. During implementation, the bounding box with the highest confidence level of the target category is selected as the target bounding box. Preferably, the target categories are distinguished by bounding boxes of different colors.
[0130] Compared with the prior art, the distribution network engineering safety management and control detection method provided in this embodiment improves the existing backbone extraction network CSPDarknet53 of YOLOv5, adds an improved CBAM structure containing an attention mechanism, so that the features cover more parts of the object to be identified, increases the probability of finally distinguishing the object, and improves the detection capability of the network without increasing other overheads; replaces PANET with an improved Bi-FPN, adds stacking of different features in the feature extraction process, strengthens the fusion of image features, and improves the accuracy of network recognition; improves the existing CIoU loss function, solves the problem that the additional penalty term is 0 when the height and width gradients of the predicted box in the CIoU loss function are opposite, and the height and width ratio of the predicted box are equal to the target box, directly uses the predicted box width and height as the penalty term, and improves the convergence speed; meets the real-time requirements of on-site use, accurately and quickly completes the detection of safety issues, realizes the identification of safety issues such as wearing of safety helmets, whether the drop-out fuse is disconnected, and whether the bottom plate of the equipment is blocked, solves the problems of insufficient engineering management personnel and insufficient supervision force in the existing distribution network on-site engineering management, and improves the reliability of on-site safety management and control of distribution network engineering.
[0131] Embodiment 2,
[0132] A specific embodiment 2 of the present invention discloses a distribution network engineering safety control detection device, thereby realizing the safety control detection method in embodiment 1. The specific implementation of each module refers to the corresponding description in embodiment 1. The device includes:
[0133] Image acquisition and preprocessing module, used to collect pictures of distribution network project sites and obtain sample sets after preprocessing;
[0134] The model generation module is used to build a security control detection model based on the YOLOv5 neural network model. In the backbone feature extraction network, a CBAM convolutional attention mechanism module is added. In the spatial attention module in the CBAM, the input feature map is convolved along the horizontal and vertical channels to obtain the CBAM output feature map. In the neck network, the Bi-FPN network is used to perform feature fusion on the feature map output by the backbone feature extraction network.
[0135] Model training module, used to obtain a trained security control and detection model based on the sample set;
[0136] The project site image detection module is used to transfer the real-time collected distribution network project images into the trained safety management and detection model to obtain the target detection results in the image.
[0137] It should be noted that when building the security control detection model in the model generation module, based on the Yolov5 neural network model, the improved CSPDarknet53 is used in the backbone feature extraction network to extract the features of the input image, wherein the C3 module is used to replace the original CSP module, and the improved CBAM convolution attention mechanism module is added after the last convolution block CBS in each C3 module; the improved Bi-FPN network is used in the neck network to enhance the features extracted by the backbone feature extraction network; DIoU-NMS is used as a non-maximum suppression algorithm in the head network to eliminate redundant target boxes; the improved CIoU is used as the loss function during training, and the width and height of the predicted box are used as penalty terms to improve the convergence speed.
[0138] The improved CBAM convolutional attention mechanism module includes a channel attention module and a spatial attention module. The feature map output by the channel attention module is used as the input feature map of the spatial attention module. In the spatial attention module, the input feature map is convolved along the horizontal and vertical channels to obtain the CBAM output feature map, including:
[0139] The dimension of the input feature map is C×H×W, where C is the channel, H is the height, and W is the width. The average pooling kernels of size (H, 1) and (1, W) are used to encode each channel in the horizontal and vertical directions respectively, and two first feature maps in the horizontal and vertical directions are obtained;
[0140] Convolution is performed on the two first feature maps respectively to obtain two intermediate feature maps in the horizontal and vertical directions, and then the intermediate feature weights in the horizontal and vertical directions are obtained through a nonlinear activation function;
[0141] After convolving the two intermediate feature weights again, they are activated by the Sigmoid function to obtain the channel weights in the horizontal and vertical directions;
[0142] The input feature map is multiplied by the channel weights in the horizontal and vertical directions respectively to obtain the CBAM output feature map.
[0143] It should be noted that since the distribution network engineering safety control detection device of this embodiment and the above-mentioned distribution network engineering safety control detection method can refer to each other, this is a repeated description, so it will not be repeated here. Since the principle of this device embodiment is the same as that of the above-mentioned method embodiment, this device also has the corresponding technical effects of the above-mentioned method embodiment.
[0144] Embodiment 3,
[0145] A specific embodiment 3 of the present invention, based on the security control detection method of embodiment 1 of the present invention, built a security control detection device of embodiment 2, and set the training process running parameters: batch size is 32, the initial learning rate is set to 0.001, and the total number of iterations is 500 times.
[0146] Considering the applicability of the present invention, in this embodiment, three safety issues existing in the engineering site are selected, namely, whether the safety helmet is worn correctly, whether the drop-out fuse is disconnected, and whether the bottom plate of the equipment is blocked.
[0147] This example uses the Ubuntu 18.04 operating system, selects the TensorFlow architecture to build a security control and detection model, and uses a GeForce RTX 2070 graphics card for calculations. The specific experimental configuration is shown in Table 1.
[0148] Table 1 Experimental environment configuration
[0149] parameter Configuration CPU Intel(R)Core(TM)i5-10400F CPU@2.90GHz GPU GeForce RTX 2070 language Python 3.8 Memory 16G Accelerated Environment CUDA 10.1 System environment Ubuntu 18.04
[0150] During the model training process, the mean average precision (mAP), recall rate (Recall), improved loss function (CIoU_loss), and precision rate (Precision) are used to evaluate the performance of the model. Figure 5It can be seen that the recall rate (Recall) stabilizes at around 0.93 after the model is iterated 100 times; the precision rate (Precision) is greater than 0.9 after the model is iterated 80 times; the mean average precision (mAP) reaches 0.97 when the model is iterated 100 times; the improved loss function (CIoU_loss) is stable when the model is iterated 500 times, which is approximately equal to 0.1.
[0151] When different thresholds are set, multiple sets of Precision-Recall values can be obtained. Using Precision and Recall values as coordinates, a PR curve can be drawn, such as Figure 6 shown.
[0152] The convolutional neural network model is optimized based on the loss function, and the network model parameters are updated through continuous iterations of gradient descent and back propagation to achieve optimal performance of the network and obtain a trained security control and detection model.
[0153] Taking the detection of whether the safety helmet is worn, whether the bottom plate of the equipment is blocked, and whether the drop-out fuse is disconnected as an example, the on-site image of the distribution network project to be detected is input into the trained safety management and detection model to obtain the target detection results in the image, including: target bounding box, target category, and category confidence.
[0154] For example, regarding whether a helmet is worn, in the target detection result, a target that wears a helmet correctly is marked with a green bounding box, a target that does not wear a helmet correctly is marked with a red bounding box, and the category confidence is displayed on the bounding box.
[0155] In order to measure the actual effect of the algorithm, the target recognition in the actual test samples was statistically analyzed, and the detection accuracy is shown in Table 2. As can be seen from Table 2, the algorithm recognizes good results in engineering site image recognition.
[0156] Table 2 Recognition accuracy of samples of different categories
[0157] Engineering safety types Recognition accuracy Is the helmet worn correctly? 98.87% Is the bottom plate of the equipment blocked? 98.20% Is the drop-out fuse disconnected? 99.52%
[0158] Those skilled in the art will appreciate that all or part of the processes of the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, wherein the computer-readable storage medium is a disk, an optical disk, a read-only storage memory, or a random access memory, etc.
[0159] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by any technician familiar with the technical field within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention.
Claims
1. A distribution network engineering safety management and control detection method, characterized in that: The steps include: Collect distribution network project site pictures and obtain sample sets after preprocessing; A security control detection model is constructed based on the YOLOv5 neural network model, wherein an improved CBAM convolutional attention mechanism module is added to the backbone feature extraction network, and the spatial attention module in the improved CBAM convolves the input feature map along the horizontal and vertical channels to obtain the CBAM output feature map; a Bi-FPN network is used in the neck network to perform feature fusion on the feature map output by the backbone feature extraction network; The backbone feature extraction network is based on the CSPDarknet53 network, and the C3 module is used to replace the original CSP module; the C3 module divides the input feature map into two branches for processing, one branch is first convolved through the first convolution block CBS, and then the gradient is propagated through multiple residual units; the other branch is directly convolved through the second convolution block CBS, and then the two branches are spliced and convolved through the third convolution block CBS to obtain the C3 output feature map; the logical operations in the first convolution block CBS, the second convolution block CBS and the third convolution block CBS are the same, including: convolution operation Conv, batch normalization BN and Silu activation function in sequence; An improved CBAM convolutional attention mechanism module is added to the backbone feature extraction network. After the third convolutional block CBS in each C3 module, an improved CBAM convolutional attention mechanism module is added as the C3' module. After the C3 output feature map of the C3 module passes through the CBAM convolutional attention mechanism module, the CBAM output feature map is obtained as the C3' output feature map; Based on the sample set, a trained security control detection model is obtained, including: based on the sample set, the security control detection model is trained, and redundant target frames are eliminated by a non-maximum suppression algorithm to obtain a predicted frame of the sample image; the error between the predicted frame and the target frame is calculated by a loss function, and the model parameters are updated based on the error, and the training is repeated until the value of the loss function is less than a threshold, so as to obtain a trained security control detection model; the loss function is based on the CIoU loss function, and the width and height of the predicted frame are used as penalty terms, and the calculation formula is: ; ; ; in, IoU is the intersection-over-union ratio of the predicted box and the standard box, d is the distance between the center point of the prediction box and the target box, c is the diagonal distance of the minimum rectangle that can cover both the prediction box and the target box, α is the weight function, v Used to measure the consistency of the aspect ratio between the target box and the predicted box; ω is the target box width, is the prediction box width, is the width of the smallest rectangle that can cover both the prediction box and the target box. h is the target frame height, is the predicted box height, is the height of the minimum rectangle that can cover both the prediction box and the target box; The real-time collected distribution network engineering images are passed into the trained safety control detection model to obtain the target detection results in the image.
2. The distribution network engineering safety management and control detection method according to claim 1 is characterized in that: The improved CBAM convolutional attention mechanism module includes a channel attention module and a spatial attention module; the feature map output by the channel attention module is used as the input feature map of the spatial attention module. In the spatial attention module, the input feature map is convolved twice along the horizontal and vertical channels, and finally the CBAM output feature map is weighted.
3. The distribution network engineering safety management and control detection method according to claim 2 is characterized in that: In the spatial attention module, the input feature map is convolved twice along the horizontal and vertical channels, and finally the CBAM output feature map is weighted, including: For the input feature map, use an average pooling kernel to encode each channel in the horizontal direction and the vertical direction respectively to obtain two first feature maps in the horizontal direction and the vertical direction; Convolution is performed on the two first feature maps respectively to obtain two intermediate feature maps in the horizontal and vertical directions, and then the intermediate feature weights in the horizontal and vertical directions are obtained through a nonlinear activation function; After convolving the two intermediate feature weights again, the channel weights in the horizontal and vertical directions are obtained through the activation function; The input feature map is multiplied by the channel weights in the horizontal and vertical directions respectively to obtain a CBAM output feature map.
4. The distribution network engineering safety management and control detection method according to claim 3 is characterized in that: The backbone feature extraction network processes the input image sequentially through the Focus module, the fourth convolution block CBS, the first C3' module, the fifth convolution block CBS, the second C3' module, the sixth convolution block CBS, the third C3' module, the seventh convolution block CBS, and the SPP module to extract the input image features and output 5 feature maps of different scales, including: Feature map P1 processed by the Focus module, feature maps P2, P3 and P4 processed by the first, second and third C3' modules respectively, and feature map P5 processed by the SPP module.
5. The distribution network engineering safety management and control detection method according to claim 4 is characterized in that: The Bi-FPN network is used to perform feature fusion on the feature maps output by the backbone feature extraction network, and the feature maps of the five different scales are fused at three network levels using the Bi-FPN network to obtain feature maps of three different sizes.
6. A distribution network engineering safety control and detection device, characterized in that: include: Image acquisition and preprocessing module, used to collect pictures of distribution network project sites and obtain sample sets after preprocessing; The model generation module is used to build a security control detection model based on the YOLOv5 neural network model, wherein an improved CBAM convolutional attention mechanism module is added to the backbone feature extraction network, and the spatial attention module in the improved CBAM convolves the input feature map along the horizontal and vertical channels to obtain the CBAM output feature map; the Bi-FPN network is used in the neck network to perform feature fusion on the feature map output by the backbone feature extraction network; the backbone feature extraction network is based on the CSPDarknet53 network, and the C3 module is used to replace the original CSP module; the C3 module divides the input feature map into two branches for processing, one branch is first convolved through the first convolution block CBS, and then propagated through multiple residual units. degree; the other branch is directly convolved through the second convolution block CBS, and then the two branches are spliced and convolved through the third convolution block CBS to obtain a C3 output feature map; the logical operations in the first convolution block CBS, the second convolution block CBS and the third convolution block CBS are the same, including: convolution operation Conv, batch normalization BN and Silu activation function in sequence; an improved CBAM convolution attention mechanism module is added to the backbone feature extraction network, that is, after the third convolution block CBS in each C3 module, an improved CBAM convolution attention mechanism module is added as a C3' module, and the C3 output feature map of the C3 module passes through the CBAM convolution attention mechanism module, and the CBAM output feature map obtained is used as the C3' output feature map; The model training module is used to obtain a trained security control detection model based on the sample set, including: training the security control detection model based on the sample set, eliminating redundant target frames through a non-maximum suppression algorithm, and obtaining a predicted frame of the sample image; using a loss function to calculate the error between the predicted frame and the target frame, updating the model parameters based on the error, and repeating the training until the value of the loss function is less than a threshold, thereby obtaining a trained security control detection model; the loss function is based on the CIoU loss function, and uses the width and height of the predicted frame as penalty terms. The calculation formula is: ; ; ; in, IoU is the intersection-over-union ratio of the predicted box and the standard box, d is the distance between the center point of the prediction box and the target box, c is the diagonal distance of the minimum rectangle that can cover both the prediction box and the target box, α is the weight function, v Used to measure the consistency of the aspect ratio between the target box and the predicted box; ω is the target box width, is the prediction box width, is the width of the smallest rectangle that can cover both the prediction box and the target box. h is the target frame height, is the predicted box height, is the height of the minimum rectangle that can cover both the prediction box and the target box; The project site image detection module is used to transfer the real-time collected distribution network project images into the trained safety management and detection model to obtain the target detection results in the image.
