Lightweight method for detecting dangerous cracks in dam bodies based on edge computing
By improving the YOLOv8 model, the problem of high computational complexity of target detection algorithms on edge devices has been solved, and efficient identification of dangerous dam cracks in the reservoir area has been achieved, reducing computing energy consumption and storage space requirements, and ensuring detection accuracy and efficiency. .
Patent Information
- Application Number
- CN202411029342.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-07-30
AI Technical Summary
Existing target detection algorithms based on deep learning have high computational complexity when running on edge devices, resulting in high computing energy consumption. They are difficult to be widely promoted and applied in reservoir areas, and cannot be effectively deployed on edge devices to achieve real-time monitoring of dangerous conditions in dams. and timely warning.
Using the improved YOLOv8 model, by reconstructing the splitting and splicing module, improving the pyramid splitting attention module and the cross-stage local feature fusion module, we reduce the number of model parameters and build a lightweight feature fusion network, which is suitable for edge device deployment and reduces computing energy consumption. .
Without affecting the detection accuracy, it reduces the amount of calculation parameters by 41.4%, reduces the storage space requirements of the algorithm model for deployment devices, achieves efficient deployment and execution on resource-constrained edge devices, and achieves a smaller volume. A small and more efficient algorithm model for identifying dangerous cracks in dam bodies.
Smart Images

Figure CN118552830B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision and target detection technology, and in particular to a lightweight method for detecting dangerous cracks in a dam body oriented to edge computing. Background Art
[0002] Dam cracks are a common safety hazard of dams, so it is crucial to detect and take corresponding measures in time to ensure the safety of the dams. Although the current target recognition algorithm provides a certain solution, the high computational complexity of the algorithm leads to high communication and maintenance costs when deploying recognition on the cloud platform, and it cannot be effectively deployed on edge devices, making it difficult to widely promote and apply in reservoir areas.
[0003] However, due to the limited computing resources and storage capacity of edge devices, the current deep learning-based target detection algorithms may face challenges in running on edge devices, because they usually have large model parameters, resulting in a large computational burden and high computing energy consumption. Therefore, it is urgent to establish an efficient and lightweight dam dam danger target detection algorithm suitable for edge setting deployment, to achieve real-time monitoring and timely warning of dam dam danger, and to be suitable for deployment on edge devices to achieve low-energy, low-cost, and high-efficiency dam supervision functions. Summary of the invention
[0004] The present invention provides a lightweight method for detecting dangerous targets of cracks in dam bodies for edge computing. It adopts an improved YOLOv8 model for target detection, reduces the amount of training parameters, maintains detection accuracy, and realizes lightweight algorithm. It is suitable for edge device deployment and effectively reduces computing energy consumption, providing support for the deployment of an efficient and lightweight dam body crack danger identification system at the edge of a reservoir.
[0005] The present invention adopts the following technical solution: a lightweight method for detecting dangerous cracks in dam bodies based on edge computing, comprising the following steps:
[0006] Step S1, image data set collection and production: take pictures of different dam bodies, classify and sort the pictures, and screen out pictures with cracks in the dam bodies; manually annotate the screened pictures, combine the public data sets to form a dam body danger data set, and divide it into training set, verification set and test set;
[0007] Step S2, improve the YOLOv8 target detection algorithm model, and improve the module and network structure as follows:
[0008] Step S21, reconstructing the splitting and splicing module SPC; introducing depthwise separable convolution, using multiple small convolution kernels to stack and reconstruct the splicing module SPC to form a lightweight splitting and splicing module LSPC;
[0009] Step S22, improving the pyramid split attention module PSA; connecting the lightweight split concatenation module LSPC with the input and compression activation module SE in the pyramid split attention module PSA to form an improved lightweight pyramid split attention module DPSA;
[0010] Step S23, improving the cross-stage local feature fusion module C2f; introducing the improved lightweight pyramid split attention module DPSA and the pyramid split attention module PSA, and replacing the bottleneck residual module Bottleneck in the cross-stage local feature fusion module C2f by alternating to obtain a lightweight multi-scale fusion module SudeC2f;
[0011] Step S24, construct a new feature fusion network, and respectively draw a branch in the feature extraction network feat2 layer and the feature extraction network feat3 layer, wherein the branch of the feature extraction network feat2 layer passes through the lightweight multi-scale fusion module SudeC2f with a depth of 3, and is added and spliced with two feature maps of size 40*40*512 in the addition and splicing module AddConcat, and is passed through the lightweight multi-scale fusion module SudeC2f of the next layer and then transmitted to the detection head P4out; the branch of the feature extraction network fe3 layer passes through the lightweight multi-scale fusion module SudeC2f with a depth of 1, and is added and spliced with two feature maps of size 20*20*512 in the addition and splicing module AddConcat, and is passed through the lightweight multi-scale fusion module SudeC2f of the next layer and then transmitted to the detection head P5out; the new feature fusion network constructed reduces the degree of information loss and retains important original feature information; the improvement of the YOLOv8 target detection algorithm model is completed, and the improved YOLOv8 dam crack danger detection lightweight model is obtained;
[0012] Step S3, using the improved YOLOv8 target detection algorithm model to train and obtain the optimal weight: using the prepared dam body danger data set to train the improved YOLOv8 dam body crack danger detection lightweight model, update the weight, and obtain the optimal detection model weight with the highest mAP value;
[0013] Step S4, improving the deployment of the YOLOv8 lightweight model for dam crack hazard detection: exporting the trained optimal detection model weight file with the highest mAP value into ONNX format and deploying it on the edge device;
[0014] Step S5, determine whether hyperparameters need to be adjusted: test the recognition effect, determine whether hyperparameters need to be adjusted for retraining, if yes, adjust the hyperparameters and jump to step S3;
[0015] Step S6, dam body crack hazard detection: The image to be detected is transmitted to the edge device of the deployed improved YOLOv8 dam body crack hazard detection lightweight model, and the dam body is detected using the improved YOLOv8 dam body crack hazard detection lightweight model based on the optimal weight to determine whether there is a crack hazard. If there is a crack hazard, the detection result image is output and the hazard type and confidence level are marked.
[0016] Furthermore, the image data set collection and production in step S1 is specifically performed as follows:
[0017] Step S11, collect pictures of cracks in dams, obtain pictures of target categories appearing in different dams at different angles, screen the collected pictures, remove blurry and low-quality pictures that are difficult for the human eye to distinguish, screen out clear, easy-to-distinguish pictures that meet the requirements, and form a dam body danger data set;
[0018] Step S12, using the same target detection and labeling method as the YOLO format dataset, use the dataset labeling software Labelimg to label the dam body danger dataset obtained in step S11, use a rectangular frame for labeling by default, and label the crack category as "crack"; finally, a YOLO format dataset is obtained in which each jpg image corresponds to a labeled txt file;
[0019] Step S13, divide the labeled data set into training set, validation set and test set in a ratio of 7:2:1, place the corresponding image files in the train, val and test folders under the images directory, and place the label files in the train, val and test folders under the labels directory. Finally, save the file path of the image in a txt file, and let the improved YOLOv8 lightweight model for dam crack hazard detection obtain the image path by reading the txt file for training.
[0020] Furthermore, in step S21, multiple small convolution kernels are stacked to reconstruct the splitting and splicing module SPC to form a lightweight splitting and splicing module LSPC; the details are as follows:
[0021] Step S211, split the input feature map into 4 feature maps of the same size through the splitting module split, and use 4 groups of depth-separable convolution DsConv to connect with the 4 feature maps respectively to complete the splitting and splicing. The convolution kernel sizes of the first 3 groups of depth-separable convolution DsConv are 3*3, 5*5, and 7*7;
[0022] In step S212, combined with the small target features of the reservoir crack danger, the fourth group of deep separable convolution DsConv is composed of a stack of 1 deep separable convolution layers with a kernel size of 5*5 and 2 3*3, and finally added to the input of the lightweight splitting and splicing module LSPC Add and then concatenated with the output of the three groups of deep separable convolution DsConv in step S211 to obtain the lightweight splitting and splicing module LSPC.
[0023] Furthermore, in step S22, an improved lightweight pyramid split attention module DPSA is formed; specifically, as follows:
[0024] The lightweight split concatenation module LSPC is connected to the input and compression activation module SE in the pyramid split attention module PSA, and then a calibration module softmax is used to perform multiply operation on the output of the lightweight split concatenation module LSPC to obtain the lightweight pyramid split attention module DPSA.
[0025] Further, in step S23, the bottleneck residual module Bottleneck is replaced by alternating action in the cross-stage local feature fusion module C2f to obtain a lightweight multi-scale fusion module SudeC2f; specifically as follows:
[0026] On the cross-stage local feature fusion module C2f of the YOLOv8 target detection algorithm model, the bottleneck residual module Bottleneck is removed, and the pyramid split attention module PSA and the lightweight pyramid split attention module DPSA are introduced. The pyramid split attention module PSA is connected after the split module Split and then the pyramid split attention module PSA is connected. This cycle is repeated through alternating effects. The total number of pyramid split attention modules PSA is determined by the hyperparameter as the depth of the module, and finally a lightweight multi-scale fusion module SudeC2f is formed.
[0027] Furthermore, in step S24, a new feature fusion network is constructed, as follows:
[0028] Step S241, a new branch is derived from the feature extraction network feat2 layer of the backbone network with a shape of 40*40*512, and the feature layer featEX1 is obtained through a lightweight multi-scale fusion module SudeC2f with a depth n of 3, and then the feature layer featEX1 and the feature layer of the size of 40*40*512 output by the feature extraction network fe4 layer and the convolution layer Conv are added and concatenated by the AddConcat module to obtain a feature layer of 40*40*1024, and then passed through the lightweight multi-scale fusion module SudeC2f of the next layer and then transmitted to the detection head P4out;
[0029] Step S242, a new branch is derived from the feature extraction network feat3 layer of the backbone network with a shape of 20*20*512, and the feature layer featEX2 is obtained through a lightweight multi-scale fusion module SudeC2f with a depth n of 1, and then the feature layer featEX2 and the feature extraction network feat3 layer and the feature layer of the convolution layer Conv output with a size of 20*20*512 are added and concatenated by the addition and splicing module AddConcat to obtain a feature layer of 20*20*1024, and then passed through the lightweight multi-scale fusion module SudeC2f of the next layer and then transmitted to the detection head P5out;
[0030] Step S243, replacing the cross-stage local feature fusion module C2f in the feature fusion network with the lightweight multi-scale fusion module SudeC2f to finally complete the construction of the new feature fusion network.
[0031] Beneficial effects of the present invention: The present invention introduces an improved lightweight pyramid split attention module DPSA to fuse multi-scale feature information with respect to the original cross-stage local feature fusion module C2f. At the same time, the lightweight split splicing module uses a depth-separable convolution to replace the original convolution block and uses a small convolution kernel for reconstruction, thereby reducing the number of network parameters, forming a new lightweight multi-scale fusion module SudeC2f, which ultimately achieves the effect of being able to better extract target features while reducing redundant information and improving training efficiency. In addition, the two branches added to the effective feature layer of the backbone network are added and spliced through the lightweight multi-scale fusion modules SudeC2f of different depths and the corresponding feature maps through the addition and splicing module AddConcat, which can effectively retain part of the original feature information, reduce the information loss caused by deep feature extraction, and thus ensure the detection accuracy of the target.
[0032] The present invention adopts the improved YOLOv8 lightweight model for dam crack hazard detection for target detection, which reduces the amount of calculation parameters by 41.4% without affecting the detection accuracy, greatly reduces the storage space requirements of the algorithm model for the deployed equipment, facilitates the deployment of the algorithm model on edge devices, and makes the deployment and execution of the model on resource-constrained devices more efficient. A smaller and more efficient algorithm model for identifying dam crack hazard is realized. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 It is the overall flow chart of the present invention. DETAILED DESCRIPTION
[0034] To further illustrate the solution of this application, the technical solution in the embodiment of this application is now described in detail with the above-mentioned figures, and the described embodiment part is part of the embodiment of this application. Based on the embodiment in this application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this application.
[0035] Based on the improved algorithm model, the adopted process includes image data set collection and preprocessing operations, improved algorithm model training, selection of optimal weights, deployment of the model to edge devices and judgment of whether hyperparameters need to be adjusted for retraining, and dam body image detection and recognition. The present invention is suitable for the identification of crack hazards in dam bodies on edge devices. While ensuring high recognition accuracy, it reduces the amount of calculation parameters by 41.4% compared to the original YOLOv8 algorithm model, achieving a high-precision and more lightweight algorithm model, which can be effectively applied to deployment and execution on resource-constrained edge devices, effectively reducing remote communication costs and facilitating application promotion.
[0036] like Figure 1 As shown in the figure, a lightweight method for detecting dangerous cracks in a dam body for edge computing includes the following steps:
[0037] Step S1, image data set collection and production: take pictures of different dam bodies, classify and sort the pictures, and screen out pictures with cracks in the dam bodies; manually annotate the screened pictures, combine the public data sets to form a dam body danger data set, and divide it into training set, verification set and test set;
[0038] Step S2, improve the YOLOv8 target detection algorithm model, and improve the module and network structure as follows:
[0039] Step S21, reconstructing the splitting and splicing module SPC; introducing depthwise separable convolution, using multiple small convolution kernels to stack and reconstruct the splicing module SPC to form a lightweight splitting and splicing module LSPC;
[0040] Step S22, improving the pyramid split attention module PSA; connecting the lightweight split concatenation module LSPC with the input and compression activation module SE in the pyramid split attention module PSA to form an improved lightweight pyramid split attention module DPSA;
[0041] Step S23, improving the cross-stage local feature fusion module C2f; introducing the improved lightweight pyramid split attention module DPSA and the pyramid split attention module PSA, and replacing the bottleneck residual module Bottleneck in the cross-stage local feature fusion module C2f by ABAB-style interlayer placement and alternating action to obtain a lightweight multi-scale fusion module SudeC2f;
[0042] Step S24, construct a new feature fusion network, and respectively draw a branch in the feature extraction network feat2 layer and the feature extraction network feat3 layer, wherein the feat2 branch passes through the lightweight multi-scale fusion module SudeC2f with a depth of 3, and is added and spliced with two feature maps of size 40*40*512 in the addition and splicing module AddConcat, and is passed through the lightweight multi-scale fusion module SudeC2f of the next layer and then transmitted to the detection head P4out; the feat3 branch passes through the lightweight multi-scale fusion module SudeC2f with a depth of 1, and is added and spliced with two feature maps of size 20*20*512 in the addition and splicing module AddConcat, and is passed through the lightweight multi-scale fusion module SudeC2f of the next layer and then transmitted to the detection head P5out; the new feature fusion network thus constructed reduces the degree of information loss and retains important original feature information; the improvement of the YOLOv8 target detection algorithm model is completed, and the improved YOLOv8 dam crack danger detection lightweight model is obtained;
[0043] Step S3, using the improved YOLOv8 target detection algorithm model to train and obtain the optimal weight: using the prepared dam body danger data set to train the improved YOLOv8 dam body crack danger detection lightweight model, update the weight, and obtain the optimal detection model weight with the highest mAP value;
[0044] Step S4, improving the deployment of the YOLOv8 lightweight model for dam crack hazard detection: exporting the trained optimal detection model weight file with the highest mAP value into ONNX format and deploying it on the edge device;
[0045] Step S5, determine whether hyperparameters need to be adjusted: test the recognition effect, determine whether hyperparameters need to be adjusted for retraining, if yes, adjust the hyperparameters and jump to step S3;
[0046] Step S6, dam body crack hazard detection: The image to be detected is transmitted to the edge device where the improved YOLOv8 dam body crack hazard detection lightweight model is deployed, and the dam body is detected using the improved YOLOv8 dam body crack hazard detection lightweight model based on the optimal weight to determine whether there is a crack hazard. If there is a crack hazard, the detection result image is output, and the hazard type and confidence level are marked.
[0047] Furthermore, the image data set collection and production in step S1 is specifically performed as follows:
[0048] Step S11, collect pictures of cracks in dams, obtain pictures of target categories appearing in different dams at different angles, screen the collected pictures, remove blurry and low-quality pictures that are difficult for the human eye to distinguish, screen out clear, easy-to-distinguish pictures that meet the requirements, and form a dam body danger data set;
[0049] Step S12, using the same target detection and labeling method as the YOLO format dataset, use the dataset labeling software Labelimg to label the dam body danger dataset obtained in step S11, use a rectangular frame for labeling by default, and label the crack category as "crack"; finally, a YOLO format dataset is obtained in which each jpg image corresponds to a labeled txt file;
[0050] Step S13, divide the labeled data set into training set, validation set and test set in a ratio of 7:2:1, place the corresponding image files in the train, val and test folders under the images directory, and place the label files in the train, val and test folders under the labels directory. Finally, save the file path of the image in a txt file, and let the improved YOLOv8 lightweight model for dam crack hazard detection obtain the image path by reading the txt file for training.
[0051] Furthermore, in step S21, multiple small convolution kernels are stacked to reconstruct the splitting and splicing module SPC to form a lightweight splitting and splicing module LSPC; the details are as follows:
[0052] Step S211, split the input feature map into 4 feature maps of the same size through the splitting module split, and use 4 groups of depth-separable convolution DsConv to connect with the 4 feature maps respectively to complete the splitting and splicing. The sizes of the first 3 groups of depth-separable DsConv convolution kernels are 3*3, 5*5, and 7*7;
[0053] In step S212, in combination with the small target features of the reservoir crack danger, the fourth group of deep separable convolution DsConv is stacked by one deep separable convolution layer with a kernel size of 5*5 and two 3*3, and finally added to the input of the lightweight splitting and splicing module LSPC by Add, and then concatenated with the output of the three groups of deep separable convolution layers DsConv in step S211 to obtain the lightweight splitting and splicing module LSPC. In this way, the calculation amount of the module is greatly reduced while ensuring that the receptive field is basically consistent with the size of the 9*9 convolution kernel, and the impact of the loss of important information is reduced.
[0054] Furthermore, in step S22, an improved lightweight pyramid split attention module DPSA is formed; specifically, as follows:
[0055] The lightweight split splicing module LSPC is connected to the input and compression activation module SE in the pyramid split attention module PSA, and then a calibration module softmax is multiplied with the output of the lightweight split splicing module LSPC to obtain the lightweight pyramid split attention module DPSA. The purpose is to reduce the number of calculation parameters of the PSA module without significantly affecting the module's performance in identifying crack hazards and reducing redundant information.
[0056] Furthermore, in step S23, an improved lightweight pyramid split attention module DPSA and a pyramid split attention module PSA are introduced into the cross-stage local feature fusion module C2f, and the bottleneck residual module Bottleneck is replaced by the ABAB-style interlayer arrangement in the cross-stage local feature fusion module C2f to obtain a lightweight multi-scale fusion module SudeC2f; specifically as follows:
[0057] In the cross-stage local feature fusion module C2f of the YOLOv8 algorithm model, the bottleneck residual module Bottleneck is removed, and the pyramid split attention module PSA and the lightweight pyramid split attention module DPSA are introduced at the same time. The pyramid split attention module PSA is connected after the split module Split and then connected to the pyramid split attention module PSA. This cycle is repeated through the ABAB-style interlayer placement and the total number of the two is determined by the hyperparameter n as the depth of the module, and finally a lightweight multi-scale fusion module SudeC2f is formed. In this way, the new lightweight multi-scale fusion module SudeC2f can take into account information at multiple scales. At the same time, the pyramid split attention module PSA and the lightweight pyramid split attention module DPSA work together to balance the impact of the reduction in the number of module calculation parameters on the accuracy of crack target detection.
[0058] Furthermore, in step S24, a new feature fusion network is constructed, as follows:
[0059] Step S241, a new branch is derived from the feature extraction network feat2 layer with a main network shape of 40*40*512, and a feature layer featEX1 is obtained through a lightweight multi-scale fusion module SudeC2f with a depth n of 3, and then featEX1 and the fe4 layer and the feature layer with a size of 40*40*512 output by the convolution layer Conv are added and concatenated by the AddConcat module to obtain a feature layer of 40*40*1024, and then the feature layer is passed through the lightweight multi-scale fusion module SudeC2f of the next layer and then transmitted to the detection head P4out; thereby enhancing the learning ability of some important original feature information and improving the detection accuracy of the corresponding category;
[0060] Step S242, a new branch is derived from the feature extraction network feat3 layer with a main network shape of 20*20*512, and a feature layer featEX2 is obtained through a lightweight multi-scale fusion module SudeC2f with a depth n of 1, and then the featEX2 and feat3 layers and the feature layer with a size of 20*20*512 output by the convolution layer Conv are added and concatenated by the AddConcat module to obtain a feature layer of 20*20*1024, and then the feature layer is passed through the lightweight multi-scale fusion module SudeC2f of the next layer and then transmitted to the detection head P5out; thereby reducing the information loss caused by the deep feature extraction and improving the model detection performance;
[0061] Step S243, replace the cross-stage local feature fusion module C2f in the feature fusion network with the lightweight multi-scale fusion module SudeC2f to finally complete the construction of the new feature fusion network, so as to fuse the multi-scale feature information and reduce the amount of calculation parameters of the network model.
[0062] On the one hand, the cross-stage local feature fusion module C2f in the original YOLOv8 network model is a residual structure composed of several bottleneck residual modules Bottleneck and convolution blocks. For the crack targets on the dam body, some shorter cracks appear small and dense in the image, the target frame is relatively wide, and some longer cracks have relatively narrow target frames, which are difficult to distinguish from the background and have unclear features, which limits the fusion extraction ability. Therefore, the improved lightweight multi-scale fusion module SudeC2f adds a pyramid split attention mechanism that can fuse multi-scale features, which can extract and fuse effective information of different receptive field sizes; at the same time, considering that the use of the lightweight multi-scale fusion module SudeC2f leads to an increase in the number of network layers, the 40*40*512 and 20*20*512 branches derived from the backbone network are added to the two input layers of the corresponding feature map addition and splicing module AddConcat. In this way, some important original information is saved, and the loss of important feature information caused by the too deep feature extraction network is prevented, thereby ensuring a better detection effect on the dangerous category of the dam body.
[0063] On the other hand, in order to facilitate real-time monitoring and algorithm model deployment, the number of algorithm model parameters and the size of weight files are very important. The increase in the depth of the network layer brought about by the addition of modules to improve the algorithm is accompanied by an increase in the number of calculation parameters, which is doubled and accompanied by redundant information. Considering the balance between the ability to extract important feature information fusion and the number of algorithm calculation parameters, the improved lightweight pyramid split attention module DPSA in the lightweight multi-scale fusion module SudeC2f uses deep separable convolution and multiple small convolution kernels to reconstruct the split splicing module; adjust the number of output channels of each layer to achieve the effect of reducing redundant information and reducing the number of calculation parameters. Experiments have shown that the improved YOLOv8 dam crack hazard detection lightweight model has a nearly 41.4% reduction in parameters compared to the YOLOv8 target detection model, and the mAP remains basically unchanged, which improves the monitoring efficiency.
[0064] The improved algorithm is now compared with the YOLOv8s network of the YOLOv8 algorithm. The various indicators of the algorithm models before and after the improvement are shown in Table 1. Among them, the mAP50~95 (average recognition accuracy under the LOU threshold of 50% to 95%) of the crack detection category is basically the same, and the improved algorithm has slightly improved by 0.2%. The scores show that the algorithms have achieved a good balance between accuracy and recall before and after the improvement, and the slight increase in the recall rate of the improved algorithm can reduce the possibility of missed targets. In addition, the number of model parameters has been reduced from about 11.16 million in YOLOv8s to 6.54 million in the improved network, with an overall reduction of about 41.4% in the number of parameters. More intuitively, the size of the weight file has been reduced from 22.5MB to 13.4MB, which will greatly reduce the storage space requirements for the algorithm model, facilitate the deployment of the algorithm model on edge devices, and make the deployment and execution of the model on resource-constrained devices more efficient.
[0065] Table 1
[0066]
[0067] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A lightweight method for edge computing-oriented detection of crack hazards in dam bodies, characterized in that: The steps include: Step S1, image data set collection and production: taking pictures of different dam bodies, classifying and sorting the taken pictures, and screening out pictures with cracks in the dam bodies; Manually annotate the screened images, combine them with public datasets to form a dam hazard dataset, and divide them into training set, validation set and test set; Step S2, improve the YOLOv8 target detection algorithm model, and improve the module and network structure as follows: Step S21, reconstructing the splitting and splicing module SPC; introducing depthwise separable convolution, using multiple small convolution kernels to stack and reconstruct the splicing module SPC to form a lightweight splitting and splicing module LSPC; Step S22, improving the pyramid split attention module PSA; connecting the lightweight split concatenation module LSPC with the input and compression activation module SE in the pyramid split attention module PSA to form an improved lightweight pyramid split attention module DPSA; Step S23, improving the cross-stage local feature fusion module C2f; introducing the improved lightweight pyramid split attention module DPSA and the pyramid split attention module PSA, and replacing the bottleneck residual module Bottleneck in the cross-stage local feature fusion module C2f by alternating to obtain a lightweight multi-scale fusion module SudeC2f; Step S24, construct a new feature fusion network, and respectively draw a branch in the feature extraction network feat2 layer and the feature extraction network feat3 layer, wherein the branch of the feature extraction network feat2 layer passes through the lightweight multi-scale fusion module SudeC2f with a depth of 3, and is added and spliced with two feature maps of size 40*40*512 in the addition and splicing module AddConcat, and is passed through the lightweight multi-scale fusion module SudeC2f of the next layer and then transmitted to the detection head P4out; the branch of the feature extraction network fe3 layer passes through the lightweight multi-scale fusion module SudeC2f with a depth of 1, and is added and spliced with two feature maps of size 20*20*512 in the addition and splicing module AddConcat, and is passed through the lightweight multi-scale fusion module SudeC2f of the next layer and then transmitted to the detection head P5out; the new feature fusion network constructed reduces the degree of information loss and retains important original feature information; the improvement of the YOLOv8 target detection algorithm model is completed, and the improved YOLOv8 dam crack danger detection lightweight model is obtained; Step S3, using the improved YOLOv8 target detection algorithm model to train and obtain the optimal weight: using the prepared dam body danger data set to train the improved YOLOv8 dam body crack danger detection lightweight model, update the weight, and obtain the optimal detection model weight with the highest mAP value; Step S4, improving the deployment of the YOLOv8 lightweight model for dam crack hazard detection: exporting the trained optimal detection model weight file with the highest mAP value into ONNX format and deploying it on the edge device; Step S5, determine whether hyperparameters need to be adjusted: test the recognition effect, determine whether hyperparameters need to be adjusted for retraining, if yes, adjust the hyperparameters and jump to step S3; Step S6, dam body crack hazard detection: The image to be detected is transmitted to the edge device of the deployed improved YOLOv8 dam body crack hazard detection lightweight model, and the dam body is detected using the improved YOLOv8 dam body crack hazard detection lightweight model based on the optimal weight to determine whether there is a crack hazard. If there is a crack hazard, the detection result image is output and the hazard type and confidence level are marked.
2. The lightweight method for edge computing-oriented dam body crack danger target detection as claimed in claim 1 is characterized in that: The specific process of collecting and making image data sets in step S1 is as follows: Step S11, collect pictures of cracks in dams, obtain pictures of target categories appearing in different dams at different angles, screen the collected pictures, remove blurry and low-quality pictures that are difficult for the human eye to distinguish, screen out clear, easy-to-distinguish pictures that meet the requirements, and form a dam body danger data set; Step S12, using the same target detection and labeling method as the YOLO format dataset, use the dataset labeling software Labelimg to label the dam body danger dataset obtained in step S11, use a rectangular frame for labeling by default, and label the crack category as "crack"; finally, a YOLO format dataset is obtained in which each jpg image corresponds to a labeled txt file; Step S13, divide the labeled data set into training set, validation set and test set in a ratio of 7:2:1, place the corresponding image files in the train, val and test folders under the images directory, and place the label files in the train, val and test folders under the labels directory. Finally, save the file path of the image in a txt file, and let the improved YOLOv8 lightweight model for dam crack hazard detection obtain the image path by reading the txt file for training.
3. The lightweight method for edge computing-oriented dam body crack danger target detection as claimed in claim 1, characterized in that: In step S21, multiple small convolution kernels are stacked to reconstruct the splitting and splicing module SPC to form a lightweight splitting and splicing module LSPC; the details are as follows: Step S211, split the input feature map into 4 feature maps of the same size through the splitting module split, and use 4 groups of depth-separable convolution DsConv to connect with the 4 feature maps respectively to complete the splitting and splicing. The convolution kernel sizes of the first 3 groups of depth-separable convolution DsConv are 3*3, 5*5, and 7*7; In step S212, combined with the small target features of the reservoir crack danger, the fourth group of deep separable convolution DsConv is composed of a stack of 1 deep separable convolution layers with a kernel size of 5*5 and 2 3*3, and finally added to the input of the lightweight splitting and splicing module LSPC Add and then concatenated with the output of the three groups of deep separable convolution DsConv in step S211 to obtain the lightweight splitting and splicing module LSPC.
4. The lightweight method for edge computing-oriented dam body crack danger target detection according to claim 1 is characterized in that: In step S22, an improved lightweight pyramid split attention module DPSA is formed; specifically, as follows: The lightweight split concatenation module LSPC is connected to the input and compression activation module SE in the pyramid split attention module PSA, and then a calibration module softmax is used to perform multiply operation on the output of the lightweight split concatenation module LSPC to obtain the lightweight pyramid split attention module DPSA.
5. The lightweight method for edge computing-oriented dam body crack danger target detection according to claim 1 is characterized in that: In step S23, the bottleneck residual module Bottleneck is replaced by alternating action in the cross-stage local feature fusion module C2f to obtain a lightweight multi-scale fusion module SudeC2f; the details are as follows: On the cross-stage local feature fusion module C2f of the YOLOv8 target detection algorithm model, the bottleneck residual module Bottleneck is removed, and the pyramid split attention module PSA and the lightweight pyramid split attention module DPSA are introduced. The pyramid split attention module PSA is connected after the split module Split and then the pyramid split attention module PSA is connected. This cycle is repeated through alternating effects. The total number of pyramid split attention modules PSA is determined by the hyperparameter as the depth of the module, and finally a lightweight multi-scale fusion module SudeC2f is formed.
6. The lightweight method for edge computing-oriented dam body crack danger target detection according to claim 1 is characterized in that: In step S24, a new feature fusion network is constructed, as follows: Step S241, a new branch is derived from the feature extraction network feat2 layer of the backbone network with a shape of 40*40*512, and the feature layer featEX1 is obtained through a lightweight multi-scale fusion module SudeC2f with a depth n of 3, and then the feature layer featEX1 and the feature layer of the size of 40*40*512 output by the feature extraction network fe4 layer and the convolution layer Conv are added and concatenated by the AddConcat module to obtain a feature layer of 40*40*1024, and then passed through the lightweight multi-scale fusion module SudeC2f of the next layer and then transmitted to the detection head P4out; Step S242, a new branch is derived from the feature extraction network feat3 layer of the backbone network with a shape of 20*20*512, and the feature layer featEX2 is obtained through a lightweight multi-scale fusion module SudeC2f with a depth n of 1, and then the feature layer featEX2 and the feature extraction network feat3 layer and the feature layer of the convolution layer Conv output with a size of 20*20*512 are added and concatenated by the addition and splicing module AddConcat to obtain a feature layer of 20*20*1024, and then passed through the lightweight multi-scale fusion module SudeC2f of the next layer and then transmitted to the detection head P5out; Step S243, replacing the cross-stage local feature fusion module C2f in the feature fusion network with the lightweight multi-scale fusion module SudeC2f to finally complete the construction of the new feature fusion network.
