Pavement collapse automatic identification method and equipment based on YOLOv5-CS
Through the YOLOv5-CS model, the problem of poor automation and real-time performance in road collapse identification is solved, and high-accuracy automatic identification of road collapse is achieved, which is suitable for real-time monitoring of road collapse disasters.
Patent Information
- Application Number
- CN202410809701.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-21
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2044-06-21
AI Technical Summary
The existing technology has a low degree of automation and poor real-time performance in identifying road collapse, and the remote sensing data is easily affected by occlusion, resulting in missed detection and misjudgment, making it difficult to achieve real-time identification.
The YOLOv5-CS model is used to crawl road collapse images through a web crawler, and adaptive anchor frame calculation, image scaling and Mosaic data enhancement are used to build a road collapse recognition model, which is combined with the backbone network, neck network and output network for training and real-time Identify.
It achieves a high degree of automation and real-time performance, and has high recognition accuracy. It can automatically detect the location and type of road collapse in real time, improve the recognition efficiency, and meet the needs for automatic real-time monitoring of road collapse disasters.
Smart Images

Figure CN118657998A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence and geological disasters, and in particular to a method and device for automatically identifying road collapse based on YOLOv5-CS Background Art
[0002] Pavement collapse is a geological disaster in which part or all of a road or its upper structure sinks, collapses or dents. Generally, pavement collapse may cause traffic jams, underground pipeline ruptures, vehicle damage, and casualties. In severe cases, untimely emergency response may even cause unpredictable losses to people's lives and property. Therefore, real-time monitoring of the road surface, timely warning and reporting of pavement collapse disasters can effectively protect people's lives and safety, avoid or reduce huge economic losses, and have very important research significance and application value.
[0003] For a long time, the identification of road collapse disasters mainly relied on manual inspections. This method has low recognition efficiency, requires a lot of manpower and material resources, and has problems such as poor real-time performance. Later, with the development of image processing technology, methods for detecting road collapse features based on remote sensing images have gradually been applied. This method can automatically detect the location of road collapse, and the recognition efficiency has been significantly improved. However, this method has a low degree of automation, and remote sensing data is easily affected by the obstruction of the photographic center by other objects, so that the complete road image cannot be obtained, resulting in missed detection and misjudgment. Therefore, it is still difficult to achieve real-time recognition of road collapse. Summary of the invention
[0004] In view of the problems existing in the prior art, the purpose of the present invention is to provide a method and device for automatic identification of road collapse based on YOLOv5-CS, which has high automation and real-time performance.
[0005] In order to achieve the above-mentioned object of the invention, the present invention provides the following technical solutions:
[0006] A method for automatically identifying road collapse based on YOLOv5-CS, comprising the following steps:
[0007] (1) Use web crawlers to crawl road subsidence disaster pictures from relevant websites;
[0008] (2) All crawled road collapse disaster images are stored in the sample library, and the collapse types of the images in the sample library are marked;
[0009] (3) Adaptive anchor box calculation, adaptive image scaling, and Mosaic data enhancement are performed on all images in the sample library in turn;
[0010] (4) A road collapse recognition model is constructed using YOLOv5-CS, wherein YOLOv5-CS includes a backbone network Backbone, a neck network Neck, and an output network Output connected in sequence;
[0011] (5) Inputting the image processed in step (3) into the road collapse recognition model for training;
[0012] (6) Extract video frames from road surveillance videos and input them into the trained road collapse recognition model to obtain the real-time situation of road collapse types.
[0013] Furthermore, step (1) comprises:
[0014] (1-1) Obtain the initial URL of the web page to be crawled, use a web crawler to initiate a request to the target site where the initial URL of the web page is located, and save the returned web page source code data;
[0015] (1-2) Parse the web page source code data and save it as an HTML format file;
[0016] (1-3) Perform regular expression screening on HTML format files, select road subsidence related keywords to match road subsidence disaster pictures;
[0017] (1-4) Save the screened road collapse disaster images as JPEG format files.
[0018] Furthermore, step (2) includes:
[0019] (2-1) All crawled road collapse disaster images are stored in the sample library;
[0020] (2-2) Extract any image p from the sample library i ;
[0021] (2-3) When the picture p i When there are people or vehicles in the collapsed pit, i Select the location of the collapse pit in the middle box and mark the type of collapse pit as dangerous collapse; when there are no people or vehicles in the collapse pit, i Select the location of the collapse pit in the middle frame and mark the collapse pit type as ordinary collapse;
[0022] (2-4) Execute (2-2) to (2-3) repeatedly until all images in the sample library are labeled;
[0023] (2-5) Randomly extract the images in the sample library in a ratio of 7:2:1 and store them in the training set, validation set and test set respectively to complete the construction of the sample library.
[0024] Furthermore, in step (2-3), if the image p i If there are people or vehicles in the map, the vehicles or people will be marked as well.
[0025] Furthermore, the backbone network Backbone includes a Focus module, several Conv-C2f modules, an SPP module, and an attention mechanism module SE connected in sequence, and each Conv-C2f module includes a connected convolution module Conv and a C2f module.
[0026] Furthermore, the neck network Neck includes a first C2f module, a first convolution module Conv, a first upsampling module Upsample, a first splicing module CONCAT, a second C2f module, a second convolution module Conv, a second upsampling module Upsample, a second splicing module CONCAT, a third C2f module, a third convolution module Conv, a third splicing module CONCAT, a fourth C2f module, a fourth convolution module Conv, and a fourth splicing module CONCAT, which are connected in sequence. The first C2f module is connected to the output of the attention mechanism module SE, the second splicing module CONCAT is also connected to the output of any C2f module in the Conv-C2f module, the third splicing module CONCAT is also connected to the output of the second convolution module Conv, and the fourth splicing module CONCAT is also connected to the output of the first convolution module Conv.
[0027] Furthermore, the output network Output includes a first convolution module Conv, a second convolution module Conv, a third convolution module Conv, a first detection head module Head1, a second detection head module Head2, and a third detection head module Head3, wherein the input of the first convolution module Conv of the output network Output is connected to the output of the third C2f module of the neck network Neck, and the output is connected to the third detection head module Head3, the input of the second convolution module Conv of the output network Output is connected to the output of the fourth C2f module of the neck network Neck, and the output is connected to the second detection head module Head2, the input of the third convolution module Conv of the output network Output is connected to the output of the fourth concatenation module CONCAT of the neck network Neck, and the output is connected to the first detection head module Head1.
[0028] Furthermore, each detection head module includes a K-means clustering layer, a first fully connected layer, a Softmax function, and a second fully connected layer which are connected in sequence.
[0029] Further, step (6) comprises:
[0030] (6-1) At a preset time interval t, video frames are obtained from road monitoring videos of different monitoring cameras and stored as JPEG format images pl i , store in the picture queue Plist;
[0031] (6-2) Each picture in the picture queue Plist is pl i According to step (3) preprocessing, the processed image spl i ;
[0032] (6-3) Split the image i Input the trained road collapse recognition model to obtain the real-time situation of the road collapse type. If the recognized type is a dangerous collapse type, the picture and its camera position and picture time information are sent to the early warning system.
[0033] (6-4) According to the camera's field of view, shooting height and shooting angle, calculate the ground area corresponding to the image:
[0034]
[0035] Where S is the ground area corresponding to the image, λ is the field of view of the camera, h is the shooting height, θ is the shooting angle, and is the angle between the top view and the ground.
[0036] (6-5) Output the prediction frame coordinates, calculate the rough actual area of the collapse pit based on the percentage of the area of the entire image occupied by the collapse pit prediction frame, and send it to the early warning system.
[0037] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the above method.
[0038] Compared with the prior art, the present invention has the following beneficial effects: the present invention provides a method and device for automatic identification of road subsidence based on YOLOv5-CS, which has high automation, high real-time performance and high identification accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 A flowchart of a method for automatically identifying road subsidence based on YOLOv5-CS provided in an embodiment of the present invention;
[0040] Figure 2 This is the YOLOv5-CS network structure diagram;
[0041] Figure 3 For example, dangerous collapse;
[0042] Figure 4 This is an example of a normal collapse;
[0043] Figure 5 Label examples of dangerous collapses;
[0044] Figure 6 Label examples for common collapse;
[0045] Figure 7 This is the accuracy result graph;
[0046] Figure 8 This is the recall result graph;
[0047] Fig. 9 This is a schematic diagram of the simulated camera position;
[0048] Fig.10 This is the identification result example 1;
[0049] Fig.11 This is the second example of identification result;
[0050] Fig.12 A schematic diagram of the structure of a computer device provided in an embodiment of the present invention DETAILED DESCRIPTION
[0051] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0052] Embodiment 1
[0053] The embodiment of the present invention provides a method for automatically identifying road collapse based on YOLOv5-CS. Figure 1 As shown, the following steps are included:
[0054] (1) Use web crawlers to crawl road subsidence disaster pictures from relevant websites.
[0055] This step includes:
[0056] (1-1) Get the initial URL of the web page to be crawled, use the web crawler to initiate a request to the target site where the initial URL of the web page is located through the Request library, and save the returned web page source code data;
[0057] (1-2) Use the BeautifulSoup library to parse the web page source data and save it as an HTML format file;
[0058] (1-3) Perform regular expression screening on the HTML format file, select road collapse related keywords to match the road collapse disaster pictures; in this embodiment, the keyword is "road collapse";
[0059] (1-4) Save the screened road collapse disaster images as JPEG format files.
[0060] (2) All crawled road collapse disaster images are stored in the sample library, and the collapse types of the images in the sample library are marked.
[0061] This step includes:
[0062] (2-1) All crawled road collapse disaster images are stored in the sample library; in this embodiment, the number of images in the sample library is PI=600;
[0063] (2-2) Extract any image pi from the sample library;
[0064] (2-3) When there are people or vehicles in the collapsed pit in the image pi, the location of the collapsed pit is selected in the image pi, and the type of the collapsed pit is marked as dangerous collapse, such as Figure 3 , 5 As shown; when there are no people or vehicles in the collapse pit, in the picture p i Select the location of the collapse pit in the middle box and mark the collapse pit type as ordinary collapse, such as Figure 4 , 6 As shown; the labeling can be done using the image labeling tool LabelImg; if the image p i If there are people or vehicles in the image, the vehicles or people will be marked together;
[0065] (2-4) Execute (2-2) to (2-3) repeatedly until all images in the sample library are labeled;
[0066] (2-5) Randomly extract the pictures in the sample library in a ratio of 7:2:1 and store them in the training set, validation set and test set respectively to complete the construction of the sample library. In this embodiment, the number of training sets is 420, the number of validation sets is 120, and the number of test sets is 60.
[0067] (3) Adaptive anchor box calculation, adaptive image scaling and Mosaic data enhancement are performed on all images in the sample library in turn.
[0068] Adaptive anchor box calculation and adaptive image scaling can scale the image to the network input size, and Mosaic data enhancement can improve the training efficiency and network accuracy of the model. In this embodiment, the network input image size is 640×640×3.
[0069] (4) A road collapse recognition model is constructed using YOLOv5-CS, wherein YOLOv5-CS includes a backbone network Backbone, a neck network Neck, and an output network Output which are connected in sequence.
[0070] like Figure 2As shown, the backbone network Backbone includes Focus modules, several Conv-C2f modules, SPP modules, and attention mechanism modules SE connected in sequence, and each Conv-C2f module includes connected convolution modules Conv and C2f modules. The Focus module is used to sample the image pixel values, and the image is expanded from the x channel to the y channel, and then convolution is performed to obtain a feature map of L×W×H, where x, y, L, W, and H are specified by the user; in this embodiment, x=3, y=12, L=320, W=320, and H=32. The convolution module Conv extracts local spatial information through convolution operations to obtain feature information, and normalizes the feature value distribution. Finally, the nonlinear transformation capability is introduced through the activation function, thereby realizing the conversion and extraction of input features. The C2f module has the function of increasing the network depth and receptive field, and can better perform feature extraction. The C2f module is a combination of the C3 module in YOLOv5 and the ELAN module in YOLOv7, which can perform more gradient flow branches and obtain richer gradient information. In the SPP module, the input feature map is first pooled at different sizes to obtain a set of feature maps of different sizes. These feature maps are then connected together and reduced in dimension through a fully connected layer to finally obtain a feature vector of fixed size. The attention mechanism module SE compresses the input feature map into a vector through global average pooling, and then generates the importance weight of each channel through two fully connected layers and an activation function. Through the SE attention mechanism module, the model can adaptively learn the importance of each channel, thereby improving the performance of the model.
[0071] The neck network Neck includes a first C2f module, a first convolution module Conv, a first upsampling module Upsample, a first splicing module CONCAT, a second C2f module, a second convolution module Conv, a second upsampling module Upsample, a second splicing module CONCAT, a third C2f module, a third convolution module Conv, a third splicing module CONCAT, a fourth C2f module, a fourth convolution module Conv, and a fourth splicing module CONCAT, which are connected in sequence. The first C2f module is connected to the output of the attention mechanism module SE, the second splicing module CONCAT is also connected to the output of any C2f module in the Conv-C2f module, the third splicing module CONCAT is also connected to the output of the second convolution module Conv, and the fourth splicing module CONCAT is also connected to the output of the first convolution module Conv.
[0072] The output network Output includes a first convolution module Conv, a second convolution module Conv, a third convolution module Conv, a first detection head module Head1, a second detection head module Head2, and a third detection head module Head3, wherein the input of the first convolution module Conv of the output network Output is connected to the output of the third C2f module of the neck network Neck, and the output is connected to the third detection head module Head3, the input of the second convolution module Conv of the output network Output is connected to the output of the fourth C2f module of the neck network Neck, and the output is connected to the second detection head module Head2, the input of the third convolution module Conv of the output network Output is connected to the output of the fourth concatenation module CONCAT of the neck network Neck, and the output is connected to the first detection head module Head1. Each detection head module includes a K-means clustering layer, a first fully connected layer, a Softmax function, and a second fully connected layer connected in sequence. K-means clustering is used to cluster the target boxes marked in the training set to obtain the initial prediction box; the first fully connected layer plus the Softmax function is used to classify the features to obtain the target detection object category; the second fully connected layer is used to regress the feature information to obtain the position and size of the detection box.
[0073] (5) Input the image processed in step (3) into the road collapse recognition model for training.
[0074] According to the prediction results of the samples in the validation set, the precision and recall of the recognition results are calculated. The precision (Formula 1) represents the ratio of the number of correctly detected targets to the number of all detected targets, and the recall (Formula 2) represents the ratio of the number of correctly detected targets to the number of all targets in the data set. In this embodiment, the calculation result of the precision is between 0.6 and 0.8, and the calculation result of the recall is between 0.5 and 0.7. The specific relationship with the training round is as follows: Figure 7 , Figure 8 shown.
[0075]
[0076] Among them, TP means that the true category is a positive example, and the result predicted by the model is also a positive example, and the number of samples predicted correctly; FP means that the true category is a negative example, but the model predicts it as a positive example, and the number of samples predicted incorrectly; FN means that the true category is a positive example, but the model predicts it as a negative example, and the number of samples predicted incorrectly.
[0077] (6) Extract video frames from road surveillance videos and input them into the trained road collapse recognition model to obtain the real-time situation of road collapse types.
[0078] This step specifically includes:
[0079] (6-1) At a preset time interval t, video frames are obtained from road monitoring videos of different monitoring cameras and stored as JPEG format images pl i , stored in the picture queue Plist; in this embodiment t = 1;
[0080] (6-2) Each picture in the picture queue Plist is pl i According to step (3) preprocessing, the processed image spl i ;
[0081] (6-3) Split the image i Input the trained road collapse recognition model to obtain the real-time situation of the road collapse type. If the recognized type is a dangerous collapse type, the picture and its camera position and picture time information are sent to the early warning system.
[0082] (6-4) According to the camera's field of view, shooting height and shooting angle, calculate the ground area corresponding to the image:
[0083]
[0084] Where S is the ground area corresponding to the image, λ is the field of view of the camera, h is the shooting height, θ is the shooting angle, which is the angle between the top view and the ground. The camera position diagram is shown in Fig. 9 As shown;
[0085] (6-5) Output the prediction frame coordinates, calculate the rough actual area of the collapse pit based on the percentage of the area of the entire image occupied by the collapse pit prediction frame, and send it to the early warning system.
[0086] In this embodiment, the test set recognition results are as follows: Fig.10 , Fig.11 In this embodiment, the estimated scale of the collapse pit is shown in Table 1.
[0087] Table 1 Estimation of the size of the collapse pit
[0088]
[0089] Experiments based on the embodiments show that the method of the present invention can automatically detect the location and type of road collapse in real time with high recognition accuracy. Among the 60 pictures in the test set, 54 obtained correct recognition results and 4 were recognized incorrectly. The model recognition accuracy rate reached 94%, which can meet the needs of automatic real-time monitoring of road collapse disasters.
[0090] Table 2 Comparison of recognition results of YOLOv5 and YOLOv5-CS
[0091] Model YOLOv5 YOLOv5-CS mAP@.5 0.56 0.61 mAP@.5:.95 0.31 0.33 Recognition accuracy 90% 94%
[0092] The embodiment of the present invention only provides processing operations for the automatic identification of road subsidence disasters. The method of the present invention is also applicable to the automatic identification of other geological disasters such as ground fissures and landslides.
[0093] Embodiment 2
[0094] The embodiment of the present invention provides a computer device, and the embodiment of the present invention provides services for implementing the method of the above-mentioned embodiment 1 of the present invention. Fig.12 As shown, the device may include: a memory 301 storing a computer executable program; a processor 302 coupled to the memory 301; the processor 302 calls the computer executable program stored in the memory 301 to execute the steps in the method described in the first embodiment.
[0095] The memory 301 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) and / or cache memory. The device may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the memory 301 may be used to read and write non-removable, non-volatile magnetic media (commonly referred to as "hard drives"). A program / utility having a set (at least one) of program modules may be stored in, for example, the memory 301, such program modules including but not limited to an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include the implementation of a network environment. The computer executable program of the program module typically performs the functions and / or methods in the embodiments described in the present invention.
[0096] The processor 302 executes various functional applications and data processing by running the program stored in the memory 301, such as implementing the method provided in the first embodiment of the present invention.
[0097] The code of the computer executable program can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" language or similar programming languages.
[0098] It should be understood that the above embodiments and descriptions only describe the principles, main features and advantages of the present invention. Without departing from the spirit and scope of the present invention, the present invention may be subject to various changes and improvements, and these changes and improvements all fall within the scope of protection of the present invention.
Claims
1. A method for automatic identification of road collapse based on YOLOv5-CS, characterized in that: The steps include: (1) Use web crawlers to crawl road subsidence disaster pictures from relevant websites; (2) All crawled road collapse disaster images are stored in the sample library, and the collapse types of the images in the sample library are marked; (3) Adaptive anchor box calculation, adaptive image scaling, and Mosaic data enhancement are performed on all images in the sample library in turn; (4) A road collapse recognition model is constructed using YOLOv5-CS, wherein YOLOv5-CS includes a backbone network Backbone, a neck network Neck, and an output network Output connected in sequence; (5) Inputting the image processed in step (3) into the road collapse recognition model for training; (6) Extract video frames from road surveillance videos and input them into the trained road collapse recognition model to obtain the real-time situation of road collapse types.
2. The method for automatic identification of road subsidence based on YOLOv5-CS according to claim 1, characterized in that: Step (1) comprises: (1-1) Obtain the initial URL of the web page to be crawled, use a web crawler to initiate a request to the target site where the initial URL of the web page is located, and save the returned web page source code data; (1-2) Parse the web page source code data and save it as an HTML format file; (1-3) Perform regular expression screening on HTML format files, select road subsidence related keywords to match road subsidence disaster pictures; (1-4) Save the screened road collapse disaster images as JPEG format files.
3. The method for automatic identification of road subsidence based on YOLOv5-CS according to claim 1, characterized in that: Step (2) comprises: (2-1) All crawled road collapse disaster images are stored in the sample library; (2-2) Extract any image p from the sample library i ; (2-3) When the picture p i When there are people or vehicles in the collapsed pit, i Select the location of the collapse pit in the middle box and mark the type of collapse pit as dangerous collapse; when there are no people or vehicles in the collapse pit, i Select the location of the collapse pit in the middle frame and mark the collapse pit type as ordinary collapse; (2-4) Execute (2-2) to (2-3) repeatedly until all images in the sample library are labeled; (2-5) Randomly extract the images in the sample library in a ratio of 7:2:1 and store them in the training set, validation set and test set respectively to complete the construction of the sample library.
4. The method for automatic identification of road subsidence based on YOLOv5-CS according to claim 3 is characterized in that: In step (2-3), if the image p i If there are people or vehicles in the map, the vehicles or people will be marked as well.
5. The method for automatic identification of road subsidence based on YOLOv5-CS according to claim 1, characterized in that: The backbone network Backbone includes a Focus module, several Conv-C2f modules, an SPP module, and an attention mechanism module SE connected in sequence, and each Conv-C2f module includes a connected convolution module Conv and a C2f module.
6. The method for automatic identification of road subsidence based on YOLOv5-CS according to claim 5, characterized in that: The neck network Neck includes a first C2f module, a first convolution module Conv, a first upsampling module Upsample, a first splicing module CONCAT, a second C2f module, a second convolution module Conv, a second upsampling module Upsample, a second splicing module CONCAT, a third C2f module, a third convolution module Conv, a third splicing module CONCAT, a fourth C2f module, a fourth convolution module Conv, and a fourth splicing module CONCAT, which are connected in sequence. The first C2f module is connected to the output of the attention mechanism module SE, the second splicing module CONCAT is also connected to the output of any C2f module in the Conv-C2f module, the third splicing module CONCAT is also connected to the output of the second convolution module Conv, and the fourth splicing module CONCAT is also connected to the output of the first convolution module Conv.
7. The method for automatic identification of road subsidence based on YOLOv5-CS according to claim 6, characterized in that: The output network Output includes a first convolution module Conv, a second convolution module Conv, a third convolution module Conv, a first detection head module Head1, a second detection head module Head2, and a third detection head module Head3, wherein the input of the first convolution module Conv of the output network Output is connected to the output of the third C2f module of the neck network Neck, and the output is connected to the third detection head module Head3, the input of the second convolution module Conv of the output network Output is connected to the output of the fourth C2f module of the neck network Neck, and the output is connected to the second detection head module Head2, the input of the third convolution module Conv of the output network Output is connected to the output of the fourth concatenation module CONCAT of the neck network Neck, and the output is connected to the first detection head module Head1.
8. The method for automatic identification of road subsidence based on YOLOv5-CS according to claim 7, characterized in that: Each detection head module includes a K-means clustering layer, a first fully connected layer, a Softmax function, and a second fully connected layer which are connected in sequence.
9. The method for automatic identification of road subsidence based on YOLOv5-CS according to claim 1, characterized in that: Step (6) comprises: (6-1) At a preset time interval t, video frames are obtained from road monitoring videos of different monitoring cameras and stored as JPEG format images pl i , store in the picture queue Plist; (6-2) Each picture in the picture queue Plist is pl i According to step (3) preprocessing, the processed image spl i ; (6-3) Split the image i Input the trained road collapse recognition model to obtain the real-time situation of the road collapse type. If the recognized type is a dangerous collapse type, the picture and its camera position and picture time information are sent to the early warning system. (6-4) According to the camera's field of view, shooting height and shooting angle, calculate the ground area corresponding to the image: Where S is the ground area corresponding to the image, λ is the field of view of the camera, h is the shooting height, θ is the shooting angle, and is the angle between the top view and the ground. (6-5) Output the prediction frame coordinates, calculate the rough actual area of the collapse pit based on the percentage of the area of the entire image occupied by the collapse pit prediction frame, and send it to the early warning system.
10. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: The processor executes the computer program to implement the method according to any one of claims 1 to 9.
