Underground drainage pipe detection method based on improved YOLOv8

By introducing ShuffleNetV2, LSKA attention mechanism and DIoU loss function in YOLOv8, the problem of insufficient detection accuracy and real-time performance in underground drainage pipeline detection is solved, and more efficient and accurate detection effects are achieved.

CN119888364AActive Publication Date: 2025-04-25YANCHENG INST OF TECH +1
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510074469.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-17
Publication Date
2025-04-25
Estimated Expiration
2045-01-17

AI Technical Summary

Technical Problem

The existing YOLOv8 has problems such as limited detection performance for small targets, poor adaptability, and high computing resources in underground drainage pipeline inspection, which makes it difficult to meet the requirements of detection accuracy and real-time.

Method used

By introducing the lightweight network architecture ShuffleNetV2 in YOLOv8, combining the LSKA attention mechanism and DIoU loss function, the model's feature extraction and bounding box regression capabilities are optimized.

Benefits of technology

The efficiency and detection accuracy of the model are significantly improved, the calculation amount and parameter amount are reduced, faster convergence speed and better regression accuracy are achieved, and the efficiency and accuracy of underground drainage pipe defect detection are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119888364A_ABST
    Figure CN119888364A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of underground drainage pipe detection, and particularly discloses an improved YOLOv8-based underground drainage pipe detection method, which comprises the following steps: capturing an underground drainage pipe image, and preprocessing the underground drainage pipe image to obtain a preprocessed underground drainage pipe image; on the basis of a YOLOv8 convolutional neural network fusing ShuffleNetV2 and LSKA attention mechanisms and adopting a DIOU loss function, a defect detection model of the underground drainage pipe is constructed; inputting the preprocessed underground drainage pipeline image into an underground drainage pipeline defect detection model to obtain an underground drainage pipeline defect image; the method is used for lightening a model, reducing the number of parameters, better extracting target features, obtaining higher convergence speed and better regression precision, and further improving the efficiency and precision of underground drainage pipe defect detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of underground drainage pipe detection, and in particular to an underground drainage pipe detection method based on improved YOLOv8. Background Art

[0002] At present, drainage pipe defect detection is a research field that has attracted much attention in recent years, especially in the context of aging and increasing loads of urban infrastructure. During use, drainage pipes are affected by various factors such as soil settlement, water erosion, chemical corrosion, and external loads, and are prone to cracks, disconnections, leakages, and obstruction. These defects not only affect the normal operation of the drainage system, leading to urban waterlogging and environmental pollution, but may also cause serious safety hazards. Traditional defect detection methods work well when dealing with obvious defects, but when faced with tiny cracks and detection images interfered by noise (such as changes in illumination, environmental interference, etc.), they often fail to capture the details and morphological features of the cracks, affecting the accuracy of detection. YOLOv8 is a version in the YOLO (YouOnlyLookOnce) series, which is mainly used for target detection and image segmentation. However, the existing YOLOv8 has the following disadvantages when applied to underground drainage pipe detection:

[0003] (1) The performance of small object detection is limited; YOLOv8 is not as accurate as some other specially optimized small object detection networks (such as FasterR-CNN) in detecting small objects (such as tiny cracks), especially in complex scenes.

[0004] (2) It has poor adaptability to unstructured scenes and limited ability to handle complex backgrounds and obstructions. In particular, low light and water vapor in underground environments will further reduce image quality, limiting the model's ability to recognize targets. In particular, when targets are densely packed or there is a large overlap between targets (such as multiple defects in a pipeline), the model may be disturbed and unable to accurately locate defect location information, resulting in false detection or missed detection. The robustness of the model needs to be improved.

[0005] (3) High computing resource consumption and high computing cost: To improve detection accuracy, YOLOv8 tends to adopt more complex network architectures or higher resolution input data. However, high-resolution images require a large amount of memory to store intermediate calculation results and feature maps during processing, especially when using larger batch sizes for inference, the memory usage will increase dramatically. This resource demand may lead to insufficient video memory, which in turn causes the inference speed to decrease and cannot meet the requirements of real-time detection. To solve this problem, when constructing the underground drainage pipe defect feature extraction network, it is necessary to strike a balance between detection speed and accuracy. Although increasing the number of model parameters can usually improve feature extraction capabilities and performance, an overly large model will bring high computational complexity, increase computational costs, and affect real-time performance. Existing backbone networks such as VGG16 and MobileNetV1, using multi-layer convolution and residual structures, can indeed effectively extract features and improve detection accuracy, but at the same time they are also accompanied by extremely high computational complexity, making it difficult to meet the requirements of real-time performance in practical applications.

[0006] Therefore, the present invention proposes an underground drainage pipe detection method based on improved YOLOv8. Summary of the invention

[0007] The present invention provides an underground drainage pipe detection method based on improved YOLOv8, by introducing a lightweight network architecture-ShuffleNetV2 in YOLOv8. The network significantly reduces the amount of calculation and the amount of parameters through deep separable convolution and channel shuffling technology. Among them, the deep separable convolution decomposes the standard convolution into deep convolution and point-by-point convolution, which greatly reduces the computational complexity; channel shuffling promotes cross-channel information exchange and feature reorganization by rearranging feature channels, and enhances the information interaction between features. These innovations enable ShuffleNetV2 to significantly improve the efficiency of the model while maintaining high detection accuracy. Secondly, the feature extraction capability can be improved by integrating it into YOLOv8. By adding a hybrid attention mechanism within and at the end of the basic model and improving the sampling layer of the neural network, the model can strengthen important feature information, especially for small cracks, while suppressing irrelevant or secondary information. This method not only helps the model better understand the contextual relationship, but also improves the detection accuracy of drainage pipe defects. Secondly, by using the DIoU (Distance-IoU) loss function, the model not only focuses on the overlapping area, but also on the center position of the box, so that the model can better optimize the position of the bounding box and usually converge faster during training, especially when there are many overlapping targets. Based on the above improved YOLOv8 model results, the model is lightweight, the number of parameters is reduced, and the target features can be better extracted, and faster convergence speed and better regression accuracy are obtained, thereby improving the efficiency and accuracy of underground drainage pipe defect detection.

[0008] The present invention provides an underground drainage pipe detection method based on improved YOLOv8, comprising:

[0009] S1: capturing an underground drainage pipe image, and preprocessing the underground drainage pipe image to obtain a preprocessed underground drainage pipe image;

[0010] S2: An underground drainage pipe defect detection model was built based on the YOLOv8 convolutional neural network that integrates ShuffleNetV2 and LSKA attention mechanism and adopts DIoU loss function;

[0011] S3: Input the preprocessed underground drainage pipe image into the underground drainage pipe defect detection model to obtain the underground drainage pipe defect image.

[0012] Preferably, the underground drainage pipe detection method based on the improved YOLOv8, S1: is used to capture the underground drainage pipe image, and preprocess the underground drainage pipe image to obtain the preprocessed underground drainage pipe image, including:

[0013] Use CCTV camera to capture the underground drainage pipeline to be tested to obtain the image of the underground drainage pipeline;

[0014] The underground drainage pipe image is preprocessed to obtain a preprocessed underground drainage pipe image.

[0015] Preferably, based on the underground drainage pipe detection method of improving YOLOv8, the underground drainage pipe image is preprocessed to obtain the preprocessed underground drainage pipe image, including:

[0016] Identify the pipeline outline in the underground drainage pipeline image, divide the underground drainage pipeline image into regions based on the pipeline outline, and obtain a pipeline pure image and a background image of the underground drainage pipeline image;

[0017] Graying the background image of the underground drainage pipe image to obtain a graying background image, and performing contrast compression on the graying background image until the pixel values ​​of all pixels in the graying background image are within a preset gray value, thereby obtaining a preprocessed background image;

[0018] The pixel enhancement is performed on the pure image of the underground drainage pipeline to obtain the preprocessed underground drainage pipeline image.

[0019] Preferably, based on the underground drainage pipe detection method of the improved YOLOv8, pixel enhancement is performed on the pure image of the underground drainage pipe image to obtain the preprocessed underground drainage pipe image, including:

[0020] Get the pixel stretch range step table;

[0021] Based on each pixel stretching range in the stretching range ladder table, multiple contrast stretchings are performed on the pipeline pure image of the underground drainage pipeline image to obtain a pipeline image with strong contrast under each pixel stretching range;

[0022] Grayscale processing is performed on the high-contrast pipeline image under each pixel stretching range to obtain the grayscale pipeline image under each pixel stretching range, and the occurrence frequency of each grayscale value in the grayscale pipeline image under each pixel stretching range is counted;

[0023] Determine the cumulative distribution probability of each gray value in the gray-scale pipeline image under each pixel stretching range based on the occurrence frequency of all gray values ​​in the gray-scale pipeline image under each pixel stretching range;

[0024] Based on the cumulative distribution probability of each gray value in the grayscale pipeline image under each pixel stretching range and the maximum grayscale value of the grayscale pipeline image under each pixel stretching range, the grayscale pipeline image under each pixel stretching range is uniformly stretched to obtain a grayscale balanced pipeline image under each pixel stretching range;

[0025] Based on the grayscale balanced pipeline image under all pixel stretching ranges, the preprocessed underground drainage pipeline image is obtained.

[0026] Preferably, the underground drainage pipe detection method based on the improved YOLOv8 is based on the cumulative distribution probability of each gray value in the grayscale pipe image under each pixel stretching range and the maximum grayscale value of the grayscale pipe image under each pixel stretching range, and the grayscale pipe image under each pixel stretching range is evenly stretched to obtain a grayscale balanced pipe image under each pixel stretching range, including:

[0027] The product of the difference between the maximum grayscale value of the grayscale pipeline image under each pixel stretching range and 1 and the cumulative distribution probability of each grayscale value in the grayscale pipeline image under the corresponding pixel stretching range is regarded as the new grayscale value of each grayscale value in the grayscale balanced pipeline image under the corresponding pixel stretching range;

[0028] Based on the new grayscale values ​​in the grayscale balanced pipeline image under each pixel stretching range of all grayscale values, the grayscale balanced pipeline image under each pixel stretching range is obtained.

[0029] Preferably, based on the underground drainage pipe detection method of the improved YOLOv8, the preprocessed underground drainage pipe image is obtained based on the grayscale balanced pipe image under all pixel stretching ranges, including:

[0030] Calculate the image display effect evaluation value of the grayscale equalization pipeline image under each pixel stretch range:

[0031]

[0032] Where, AM IQ is the image display effect evaluation value of the grayscale equalization pipeline image under the currently calculated pixel stretching range, I max is the maximum grayscale value of the grayscale equalization pipeline image under the currently calculated pixel stretching range, n is the total number of pixels of the grayscale equalization pipeline image under the currently calculated pixel stretching range, I iorg is the gray value of the i-th pixel in the pure image of the underground drainage pipeline, I iproc is the gray value of the i-th pixel in the grayscale equalization pipeline image under the currently calculated pixel stretching range, m is the total number of image display attributes, μ jproc is the attribute mean of the jth graphical attribute of the pure image of the underground drainage pipeline image, μ jproc is the attribute mean of the jth graphic attribute of the grayscale equalization pipeline image under the currently calculated pixel stretching range;

[0033] The grayscale balanced pipeline image corresponding to the maximum image display effect evaluation value in the grayscale balanced pipeline image under all pixel stretching ranges is regarded as the preprocessed underground drainage pipeline image.

[0034] Preferably, an underground drainage pipe detection method based on improved YOLOv8, S2: Based on the YOLOv8 convolutional neural network that integrates ShuffleNetV2 and LSKA attention mechanism and adopts DIoU loss function, an underground drainage pipe defect detection model is built, including:

[0035] The underground drainage pipe images are captured and preprocessed using CCTV cameras to obtain a data set;

[0036] Preprocess the images in the data set and establish corresponding true labels to obtain the preprocessed data set, and divide the preprocessed data set into a training set, a test set, and a validation set;

[0037] The YOLOv8 convolutional neural network that integrates ShuffleNetV2 and LSKA attention mechanism and adopts DIoU loss function is selected as the pre-training model;

[0038] Input the training set into the pre-training model for training to obtain a trained detection model;

[0039] The trained detection model is used to perform defect detection on the test set and the validation set, and the recognition accuracy of the trained detection model is optimized through the algorithm until the underground drainage pipe defect detection model is obtained.

[0040] Preferably, based on the underground drainage pipe detection method of improving YOLOv8, a YOLOv8 convolutional neural network integrating ShuffleNetV2 and LSKA attention mechanism and adopting DIoU loss function is selected as a pre-training model, including:

[0041] Load the pre-trained weights of the YOLOv8 model, replace the feature extraction network in the YOLOv8 model with ShuffleNetV2, introduce the LSKA attention mechanism in the head of the YOLOv8 model, and replace the loss function of the YOLOv8 model with the DIoU loss function to obtain the pre-trained model;

[0042] Among them, the input channels of the basic unit blocks and downsampling units in the pre-trained model are equal and the corresponding output channels are equal.

[0043] Preferably, based on the underground drainage pipe detection method of improving YOLOv8, the feature extraction network in the YOLOv8 model is replaced with ShuffleNetV2, including:

[0044] Integrate ShuffleNetV2 into the YOLOv8 framework; replace the C2f module in the YOLOv8 backbone network with the basic module of ShuffleNetV2.

[0045] Preferably, based on the underground drainage pipe detection method of improved YOLOv8, the formula of DIoU loss function is:

[0046]

[0047] Where IoU is the intersection-over-union ratio of the predicted box and the true box, Area of ​​Intersection is the area of ​​the intersection between the predicted box and the true box, Area of ​​Union is the area of ​​the union between the predicted box and the true box, DIOU is the output value of the DIoU loss function, d is the Euclidean distance between the center point of the predicted box and the center point of the true box, and c is the diagonal length of the minimum circumscribed box between the predicted box and the true box.

[0048] The beneficial effects of the present invention compared with the prior art are as follows: a lightweight network architecture, ShuffleNetV2, is introduced into YOLOv8. The network significantly reduces the amount of calculation and the amount of parameters through deep separable convolution and channel shuffling technology. Among them, deep separable convolution decomposes the standard convolution into deep convolution and point-by-point convolution, which greatly reduces the computational complexity; channel shuffling promotes cross-channel information exchange and feature reorganization by rearranging feature channels, and enhances information interaction between features. These innovations enable ShuffleNetV2 to significantly improve the efficiency of the model while maintaining high detection accuracy. Secondly, the feature extraction capability can be improved by integrating it into YOLOv8. By adding a hybrid attention mechanism within and at the end of the basic model and improving the sampling layer of the neural network, the model can strengthen important feature information, especially for tiny cracks, while suppressing irrelevant or secondary information. This method not only helps the model better understand contextual relationships, but also improves the detection accuracy of drainage pipe defects. Secondly, by using the DIoU (Distance-IoU) loss function, the model not only focuses on the overlapping area, but also on the center position of the box, so that the model can better optimize the position of the bounding box and usually converge faster during training, especially when there are many overlapping targets. Based on the above improved YOLOv8 model results, the model is lightweight, the number of parameters is reduced, and the target features can be better extracted, and faster convergence speed and better regression accuracy are obtained, thereby improving the efficiency and accuracy of underground drainage pipe defect detection.

[0049] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures specifically pointed out in this application document.

[0050] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:

[0052] Figure 1 This is a flow chart of an underground drainage pipe detection method based on improved YOLOv8 in an embodiment of the present invention;

[0053] Figure 2 This is a flowchart for implementing underground drainage pipe detection based on the improved YOLOv8 algorithm in an embodiment of the present invention;

[0054] Figure 3Schematic diagram of the ShuffleNetV2 basic module and downsampling module in an embodiment of the present invention;

[0055] Figure 4 is a schematic diagram of channel rearrangement comparison in an embodiment of the present invention;

[0056] Figure 5 LSKA structure diagram in an embodiment of the present invention. DETAILED DESCRIPTION

[0057] The preferred embodiments of the present invention are described below in conjunction with the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.

[0058] Embodiment 1:

[0059] The present invention provides an underground drainage pipe detection method based on improved YOLOv8. Figure 1 ,include:

[0060] S1: capturing an underground drainage pipe image, and preprocessing the underground drainage pipe image to obtain a preprocessed underground drainage pipe image;

[0061] S2: An underground drainage pipe defect detection model was built based on the YOLOv8 convolutional neural network that integrates ShuffleNetV2 and LSKA attention mechanism and adopts DIoU loss function;

[0062] S3: Input the preprocessed underground drainage pipe image into the underground drainage pipe defect detection model to obtain the underground drainage pipe defect image.

[0063] In this embodiment, reference Figure 2 ,The implementation process of underground drainage pipe detection based on the improved YOLOv8 algorithm is as follows:

[0064] Step 1: Data preparation:

[0065] Using a public dataset, the dataset is divided into three independent subsets: training set, validation set, and test set. The division ratio is 7:2:1. PC is selected as the image recognition processing end, with a processor of i7-12700H CPU, 64-bit Windows 11 operating system, and a GPU of NVIDIA RTX 3050 Ti. At the same time, the experimental environment includes a GPU server, which is equipped with NVIDIA Tesla A40 48GB 300W GPU card.

[0066] Step 2: Data preprocessing:

[0067] The training set is augmented to expand the training data, including random rotation, flipping, dehazing and other operations to increase the generalization ability of the model.

[0068] Standardize or normalize the validation set and test set to ensure that the pixel values ​​of the images are in the same scale range.

[0069] Step 3: Model building:

[0070] Load the pre-trained weights of YOLOv8, replace the feature extraction network with ShuffleNetV2, and introduce the LSKA attention mechanism in the head to build an improved YOLOv8 model.

[0071] Step 4: Training the model:

[0072] Configure the training hyperparameters, set the batch size to 32 and the number of iterations to 300; start training the model using the training set data. In each training iteration, calculate the loss and update the model weights.

[0073] After each training cycle, use the validation set to evaluate the performance of the model. Monitor indicators such as loss and accuracy on the validation set so that training can be stopped in time to prevent overfitting.

[0074] Step 5: Model Evaluation:

[0075] Use the test set to finally evaluate the performance of the model. Calculate the accuracy, F1 score and other indicators of the model on the test set, and draw a confusion matrix to visualize the evaluation results to determine its performance in real situations.

[0076] In this embodiment, underground drainage pipe image: the original image of the underground drainage pipe captured by a specific device (such as a CCTV camera). These images contain various information about the appearance of the pipe and are the basis for subsequent processing and analysis. For example: a clear picture showing the inner wall, interface and surrounding environment of the underground drainage pipe. In this embodiment, underground drainage pipe defect detection model: a model based on the YOLOv8 convolutional neural network that integrates the ShuffleNetV2 and LSKA attention mechanisms and built with the DIoU loss function, which is used to detect whether there are defects in underground drainage pipes. Example: After training and optimization, the model can accurately identify defects such as pipe cracks and corrosion.

[0077] In this embodiment, the underground drainage pipe defect image: after being analyzed and processed by the underground drainage pipe defect detection model, the underground drainage pipe image with defects is marked. For example: an original underground drainage pipe image, the cracked part is framed with a specific color or mark, indicating that this is the defective area.

[0078] The beneficial effects of the above technologies include: by capturing and preprocessing underground drainage pipe images, a clear and effective data basis is provided for subsequent detection. The YOLOv8 convolutional neural network that integrates ShuffleNetV2 and LSKA attention mechanisms improves the model's ability to extract and focus on underground drainage pipe features, and enhances the accuracy of detection. The DIoU loss function is used to optimize the model's training process, allowing the model to converge to better results faster. The underground drainage pipe defect detection model built can efficiently analyze the preprocessed images and accurately detect the defects of underground drainage pipes. This method can effectively improve the efficiency and accuracy of underground drainage pipe detection, help to timely discover and deal with pipeline defects, and ensure the normal operation of the drainage system.

[0079] Embodiment 2:

[0080] On the basis of Example 1, based on the underground drainage pipe detection method of improving YOLOv8, S1: used to capture the underground drainage pipe image, and preprocess the underground drainage pipe image to obtain the preprocessed underground drainage pipe image, including:

[0081] Use CCTV camera to capture the underground drainage pipeline to be tested to obtain the image of the underground drainage pipeline;

[0082] The underground drainage pipe image is preprocessed to obtain a preprocessed underground drainage pipe image.

[0083] The beneficial effects of the above technology are: using CCTV cameras to capture images of underground drainage pipes can intuitively and comprehensively obtain the internal conditions of the pipes. Preprocessing the images helps to eliminate noise, enhance image quality, and provide clearer and more accurate information for subsequent defect detection. This method of capturing first and then preprocessing ensures that the image data input into the detection model has high quality and availability. It can improve the accuracy and efficiency of subsequent detection and reduce the possibility of misjudgment and missed judgment. It lays a good data foundation for the effective detection of underground drainage pipe defects.

[0084] Embodiment 3:

[0085] On the basis of Example 2, based on the underground drainage pipe detection method of improving YOLOv8, the underground drainage pipe image is preprocessed to obtain the preprocessed underground drainage pipe image, including:

[0086] Identify the pipeline outline in the underground drainage pipeline image, divide the underground drainage pipeline image into regions based on the pipeline outline, and obtain a pipeline pure image and a background image of the underground drainage pipeline image;

[0087] Graying the background image of the underground drainage pipe image to obtain a graying background image, and performing contrast compression on the graying background image until the pixel values ​​of all pixels in the graying background image are within a preset gray value, thereby obtaining a preprocessed background image;

[0088] The pixel enhancement is performed on the pure image of the underground drainage pipeline to obtain the preprocessed underground drainage pipeline image.

[0089] In this embodiment, pipeline outline: the line used to define the shape and boundary of the underground drainage pipeline image. It is a key identifier to distinguish the pipeline from the surrounding environment. For example: a continuous line that clearly outlines the edge of the pipeline in the image.

[0090] In this embodiment, the pipeline pure image: after processing, only contains the underground drainage pipeline itself, and removes other irrelevant information. For example: an image only shows a clear pipeline body without background interference.

[0091] In this embodiment, the background image refers to the part of the underground drainage pipeline image other than the pipeline itself, which usually includes the surrounding environment, debris, etc. For example, the image area composed of soil, stones, etc. around the pipeline.

[0092] In this embodiment, the contrast of the grayscale background image is compressed until the pixel values ​​of all pixels in the grayscale background image are within the preset grayscale value, and the preprocessed background image is obtained: the background image is first grayscaled, and then its contrast is reduced so that the pixel value gradually becomes smaller until the pixel value of all pixels does not exceed the preset grayscale value, thereby obtaining a processed background image. For example: the preset grayscale value is 50, and the original background image has a pixel value range of 0-255. After processing, all pixel values ​​are within 50.

[0093] The beneficial effects of the above technology include: by identifying the pipeline outline and dividing the area, the pipeline body can be effectively separated from the background, highlighting the key detection area. Grayscale processing and contrast compression of the background image reduce the interference of background information and reduce the complexity of data processing. The pixel values ​​in the grayscale background image are controlled within the preset grayscale value, making the background more unified and stable, which is convenient for subsequent processing. Pixel enhancement of the pure image of the pipeline can highlight the detailed features of the pipeline and improve the sensitivity of defect detection. This preprocessing method improves the quality and usability of the image, and provides strong support for the accurate detection of defects in underground drainage pipes.

[0094] Embodiment 4:

[0095] On the basis of Example 3, based on the underground drainage pipe detection method improved by YOLOv8, pixel enhancement is performed on the pure image of the underground drainage pipe image to obtain the preprocessed underground drainage pipe image, including:

[0096] Get the pixel stretch range step table;

[0097] Based on each pixel stretching range in the stretching range ladder table, multiple contrast stretchings are performed on the pipeline pure image of the underground drainage pipeline image to obtain a pipeline image with strong contrast under each pixel stretching range;

[0098] Grayscale processing is performed on the high-contrast pipeline image under each pixel stretching range to obtain the grayscale pipeline image under each pixel stretching range, and the occurrence frequency of each grayscale value in the grayscale pipeline image under each pixel stretching range is counted;

[0099] Determine the cumulative distribution probability of each gray value in the gray-scale pipeline image under each pixel stretching range based on the occurrence frequency of all gray values ​​in the gray-scale pipeline image under each pixel stretching range;

[0100] Based on the cumulative distribution probability of each gray value in the grayscale pipeline image under each pixel stretching range and the maximum grayscale value of the grayscale pipeline image under each pixel stretching range, the grayscale pipeline image under each pixel stretching range is uniformly stretched to obtain a grayscale balanced pipeline image under each pixel stretching range;

[0101] Based on the grayscale balanced pipeline image under all pixel stretching ranges, the preprocessed underground drainage pipeline image is obtained.

[0102] In this embodiment, the pixel stretch range ladder table is a table that lists different pixel stretch ranges and is used to guide multiple contrast stretch operations on an image. For example, the table may include a series of pixel value ranges from 0-50, 50-100, 100-150, etc.

[0103] In this embodiment, the pixel stretching range refers to a specific pixel value interval set when processing an image. For example, the interval of 50-100 is a pixel stretching range.

[0104] In this embodiment, based on each pixel stretching range in the stretching range ladder table, the pipeline clean image of the underground drainage pipeline image is subjected to multiple contrast stretching to obtain a pipeline image with a strong contrast in each pixel stretching range: according to each pixel value interval specified in the pixel stretching range ladder table, the pipeline clean image is subjected to contrast enhancement operation respectively, so as to obtain a pipeline image with a strong contrast after processing in each specific interval. For example: a contrast stretch is performed once according to the range of 0-50 in the ladder table to obtain a pipeline image with a strong contrast in this range, and then another stretch is performed according to the range of 50-100, and so on.

[0105] In this embodiment, the frequency of occurrence of each gray value in the grayscale pipeline image in each pixel stretching range is counted: the proportion of the number of occurrences of each gray value in the grayscale pipeline image to the total number of pixels in each specific pixel stretching range is calculated. For example: in a certain pixel stretching range, the gray value of 100 appears 100 times, and the total number of pixels is 1000, then the frequency of occurrence of the gray value 100 in this range is 0.1.

[0106] In this embodiment, the cumulative distribution probability of each gray value in the gray-scale pipeline image in each pixel stretching range is determined based on the frequency of occurrence of all gray values ​​in the gray-scale pipeline image in each pixel stretching range: the cumulative distribution probability of each gray value in each pixel stretching range is obtained by gradually accumulating and calculating according to the frequency of occurrence of each gray value. For example: within a certain pixel stretching range, the frequency of occurrence of gray value 0 is 0.2, and the frequency of occurrence of gray value 1 is 0.003, then the cumulative distribution probability of gray value 1 is 0.2+0.003=0.203.

[0107] The beneficial effects of the above technology include: obtaining a step table of pixel stretching ranges, which provides clear parameters and ranges for multiple contrast stretching. Through multiple contrast stretching and grayscale processing, the detailed features of the pure image of the pipeline can be highlighted within different stretching ranges. Statistical grayscale value occurrence frequency and cumulative distribution probability help to more accurately understand the grayscale distribution of the image. Uniform distribution stretching based on cumulative distribution probability and maximum grayscale value makes the grayscale distribution of the image more balanced, avoiding some areas from being too bright or too dark. Comprehensively combining the grayscale balanced pipeline images under all pixel stretching ranges, the final pre-processed underground drainage pipeline image has higher quality and is more conducive to subsequent defect detection. This sophisticated pixel enhancement processing method can significantly improve the quality and recognizability of pure pipeline images, thereby improving the accuracy and reliability of underground drainage pipe defect detection.

[0108] Embodiment 5:

[0109] On the basis of Example 4, based on the underground drainage pipe detection method improved by YOLOv8, based on the cumulative distribution probability of each gray value in the grayscale pipe image under each pixel stretching range and the maximum grayscale value of the grayscale pipe image under each pixel stretching range, the grayscale pipe image under each pixel stretching range is evenly stretched to obtain a grayscale balanced pipe image under each pixel stretching range, including:

[0110] The product of the difference between the maximum grayscale value of the grayscale pipeline image under each pixel stretching range and 1 and the cumulative distribution probability of each grayscale value in the grayscale pipeline image under the corresponding pixel stretching range is regarded as the new grayscale value of each grayscale value in the grayscale balanced pipeline image under the corresponding pixel stretching range;

[0111] Based on the new grayscale values ​​in the grayscale balanced pipeline image under each pixel stretching range of all grayscale values, the grayscale balanced pipeline image under each pixel stretching range is obtained.

[0112] The beneficial effects of the above technology include: by determining the new grayscale value through a clear calculation method, the distribution uniform stretching of the grayscale pipeline image can be accurately achieved. Based on the calculation of the cumulative distribution probability and the maximum grayscale value, the stretching process is scientific and reasonable. It can effectively balance the grayscale distribution, enhance the contrast and clarity of the image, and highlight the characteristics of the pipeline. The obtained grayscale balanced pipeline image can better show the details of the pipeline and help improve the accuracy of defect detection. This precise grayscale equalization processing method improves the quality and analyzability of the image, and provides a strong guarantee for the accurate detection of underground drainage pipes.

[0113] Embodiment 6:

[0114] On the basis of Example 4, based on the underground drainage pipe detection method improved by YOLOv8, based on the grayscale balanced pipe image under all pixel stretching ranges, a preprocessed underground drainage pipe image is obtained, including:

[0115] Calculate the image display effect evaluation value of the grayscale equalization pipeline image under each pixel stretch range:

[0116]

[0117] Where, AM IQ is the image display effect evaluation value of the grayscale equalization pipeline image under the currently calculated pixel stretching range, I max is the maximum grayscale value of the grayscale equalization pipeline image under the currently calculated pixel stretching range, n is the total number of pixels of the grayscale equalization pipeline image under the currently calculated pixel stretching range, I iorg is the gray value of the i-th pixel in the pure image of the underground drainage pipeline, Iiproc is the gray value of the i-th pixel in the grayscale equalization pipeline image under the currently calculated pixel stretching range, m is the total number of image display attributes, μ jproc is the attribute mean of the jth graphical attribute of the pure image of the underground drainage pipeline image, μ jproc is the attribute mean of the jth graphic attribute of the grayscale equalization pipeline image under the currently calculated pixel stretching range;

[0118] The grayscale balanced pipeline image corresponding to the maximum image display effect evaluation value in the grayscale balanced pipeline image under all pixel stretching ranges is regarded as the preprocessed underground drainage pipeline image.

[0119] In this embodiment, the image display effect evaluation value of the grayscale balanced pipeline image is a quantitative indicator used to evaluate the display effect of the underground drainage pipeline image after grayscale balanced processing. It is calculated by a specific mathematical formula, taking into account factors such as the maximum grayscale value of the image, the total number of pixels, the grayscale value of the pixels in the pure image of the pipeline, and the mean of multiple image display attributes. This evaluation value can reflect the quality of the image after grayscale balanced processing and the quality of the display effect. The larger the value, the better the display effect, indicating that the image has a higher quality after processing, which is more conducive to subsequent defect detection and analysis.

[0120] The beneficial effects of the above technology include: by calculating the graphic display effect evaluation value through a clear mathematical formula, the display effect of the grayscale balanced pipe image under each pixel stretching range can be quantitatively evaluated. The grayscale value, the total number of pixels and the average of multiple graphic display attributes are taken into account to make the evaluation more comprehensive and accurate. The grayscale balanced pipe image corresponding to the maximum graphic display effect evaluation value is selected as the preprocessed underground drainage pipe image to ensure that the final image used for detection has the best display effect and quality. It can improve the accuracy and reliability of subsequent underground drainage pipe defect detection and reduce the possibility of misjudgment. This screening method based on the graphic display effect evaluation value effectively improves the quality and availability of the preprocessed underground drainage pipe image, and provides more favorable conditions for accurate defect detection.

[0121] Embodiment 7:

[0122] On the basis of Example 1, based on the underground drainage pipe detection method of improving YOLOv8, S2: Based on the YOLOv8 convolutional neural network that integrates ShuffleNetV2 and LSKA attention mechanism and adopts DIoU loss function, an underground drainage pipe defect detection model is built, including:

[0123] The underground drainage pipe images are captured and preprocessed using CCTV cameras to obtain a data set;

[0124] Preprocess the images in the data set and establish corresponding true labels to obtain the preprocessed data set, and divide the preprocessed data set into a training set, a test set, and a validation set;

[0125] The YOLOv8 convolutional neural network that integrates ShuffleNetV2 and LSKA attention mechanism and adopts DIoU loss function is selected as the pre-training model;

[0126] Input the training set into the pre-training model for training to obtain a trained detection model;

[0127] The trained detection model is used to perform defect detection on the test set and the validation set, and the recognition accuracy of the trained detection model is optimized through the algorithm until the underground drainage pipe defect detection model is obtained.

[0128] In this embodiment, the data set is a set of underground drainage pipe images captured by CCTV cameras and preprocessed (the preprocessing process is the same as the method for preprocessing the underground drainage pipe images in Embodiments 3-6), which is used for model training and testing. For example, a set of 1,000 images of underground drainage pipes in different states is included.

[0129] In this embodiment, the images in the data set are preprocessed and corresponding real labels are established to obtain a preprocessed data set: a series of processing operations are performed on the original images in the data set, such as denoising, enhancement, etc., and each image is labeled with its real situation, such as whether there is a defect, the type of defect, etc., to form a new data set. For example: the original 1,000 images are preprocessed, and each image is labeled with labels such as "there is a crack defect and its defect location" and "no defect" to obtain a preprocessed data set.

[0130] In this embodiment, the trained detection model is used to detect defects on the test set and the validation set, and the recognition accuracy of the trained detection model is optimized through the algorithm until the underground drainage pipe defect detection model is obtained: the trained model is used to detect defects on the specially divided test set images, and then the parameters of the model are continuously adjusted and improved according to the detection results and related algorithms to improve the accuracy of the model in identifying defects, and finally an underground drainage pipe defect detection model with excellent performance is obtained. For example: 200 test set images are detected using the trained model, and the accuracy is 80% according to the detection results. The model parameters are further optimized through the algorithm, and the detection accuracy is increased to 90% again. This process is repeated until the model reaches the ideal accuracy, and finally the verification set is used to verify whether the detection accuracy of the model finally obtained is 90%. If so, the underground drainage pipe defect detection model is output, otherwise, the above steps are repeated until the detection accuracy of the model finally obtained by the verification set is 90%, and the underground drainage pipe defect detection model is output.

[0131] The beneficial effects of the above technologies include: using CCTV cameras to capture and preprocess the data set, providing a rich source of data for model training. Preprocessing and dividing the data set ensures the rationality and effectiveness of the training set, test set, and validation set. The YOLOv8 convolutional neural network that integrates specific mechanisms and loss functions is selected as the pre-training model, which lays a good foundation for the performance of the model. By inputting the training set into the pre-training model for training, the model parameters can be continuously optimized and the detection capability can be improved. Using the test set for defect detection and accuracy optimization ensures that the final underground drainage pipe defect detection model has high accuracy and reliability. This systematic model building method can effectively build a high-performance underground drainage pipe defect detection model, providing strong support for actual detection work.

[0132] Embodiment 8:

[0133] On the basis of Example 7, based on the underground drainage pipe detection method of improving YOLOv8, a YOLOv8 convolutional neural network integrating ShuffleNetV2 and LSKA attention mechanisms and using DIoU loss function is selected as a pre-training model, including:

[0134] Load the pre-trained weights of the YOLOv8 model, replace the feature extraction network in the YOLOv8 model with ShuffleNetV2, introduce the LSKA attention mechanism in the head of the YOLOv8 model, and replace the loss function of the YOLOv8 model with the DIoU loss function to obtain the pre-trained model;

[0135] Among them, the input channels of the basic unit blocks and downsampling units in the pre-trained model are equal and the corresponding output channels are equal.

[0136] In this embodiment, the feature extraction module C2f can also be replaced according to the technical solution of the present invention. Replacing C2f with C2f_DBB can further enhance the feature extraction and expression capabilities of the model, thereby achieving the effect of improving the target detection accuracy.

[0137] In this embodiment, in order to enhance the feature learning ability of the network without significantly increasing the detection time and ensure the detection accuracy, a lightweight network architecture, ShuffleNetV2, is introduced. This network significantly reduces the amount of calculation and parameters through deep separable convolution and channel shuffling technology. Among them, deep separable convolution decomposes the standard convolution into deep convolution and point-by-point convolution, greatly reducing the computational complexity; channel shuffling promotes cross-channel information exchange and feature reorganization by rearranging feature channels, and enhances information interaction between features. These innovations enable ShuffleNetV2 to significantly improve the efficiency of the model while maintaining high detection accuracy.

[0138] In view of this, this embodiment optimizes the network structure of YOLOv8, integrates ShuffleNetV2 into the YOLOv8 framework, replaces the C2f module in the YOLOv8 backbone network with the basic module of ShuffleNetV2; although the C2f module performs well in feature extraction, the computational complexity is high; while the basic module of ShuffleNetV2 reduces the computational complexity while still having a strong feature extraction capability. Through this replacement, the number of parameters and the amount of computation of the model are effectively controlled, significantly reducing the demand for computing resources. The structure of ShuffleNetV2 is as follows: Figure 3 shown.

[0139] The main reason for introducing the basic module and downsampling module in ShuffleNetV2 is to improve the feature extraction capability and overall performance while keeping the model lightweight. These two modules each have different functions and meet different needs.

[0140] The basic module is used to extract features while keeping the size of the feature map unchanged. It is able to capture detailed information in the shallow layers of the network, which is crucial for tasks such as image classification. Through residual connections, the basic module can effectively transfer information, alleviate the gradient vanishing problem in deep networks, and promote the convergence of the model. The downsampling module is designed to reduce the computational complexity by reducing the spatial size of the feature map while increasing the number of channels to maintain feature expressiveness. This is very important for capturing higher-level features and contextual information. In deep networks, larger feature map sizes may lead to excessive computation, and the downsampling module can effectively reduce the amount of computation while increasing the number of channels to enhance the diversity and expressiveness of features.

[0141] In convolutional neural networks, it is usually necessary to gradually extract features from low layers to high layers. The basic module is suitable for extracting low-level features (such as edges, textures, etc.), while the downsampling module is suitable for extracting higher-level features (such as shapes, objects, etc.). By using different modules at different layers, ShuffleNetV2 can effectively learn features at different levels and improve the overall performance of the model.

[0142] The main idea of ​​ShuffleNetV2 is to reduce computational complexity through effective channel rearrangement and grouped convolution. The core concept is to make the effect of grouped convolution more significant by rearranging the channels of feature maps, thereby improving the ability of information flow and feature fusion; dividing the standard convolution into multiple small grouped convolutions to reduce the amount of calculation and the number of parameters. The convolution operation is decomposed into depth convolution and point-by-point convolution, and the input features are added to the output features through residual connections to enhance the expressiveness of the model, thereby further improving efficiency.

[0143] Image channel width balancing can minimize the memory access cost (MAC). We analyze the point-by-point convolution that bears most of the computational overhead. Assuming the number of input channels C1 and the number of output channels C2, the spatial size of the feature map when passing through each layer of the network is h×ω, then the computational amount (FLOPs) of the convolution kernel is B=hωC1C2. Assuming that there is enough memory, its memory consumption C1C2=hω(C1+C2)+C1C2, then the formula for B is:

[0144] when hour);

[0146] That is, only when C1 = C2, MAC achieves the minimum value. Therefore, the input and output channels of the basic unit block and the downsampling unit of this model are equal.

[0147] Grouped convolution can be expressed by the following formula, where the number of groups is g and the number of input channels is C in , the convolution kernel size is K×K:

[0148]

[0149] Among them, g represents the number of groups, C in is the number of input channels, and K is the size of the convolution kernel.

[0150] Point-wise convolution, also known as 1x1 convolution, is used to linearly combine the information of each channel and can be expressed by the following formula:

[0151]

[0152] Among them, Weight(k) is the 1x1 convolution kernel of point-by-point convolution, the weighted value of each input channel K.

[0153] There is a problem with grouped convolution, that is, each group is independent of each other and there is no feature fusion. The channel rearrangement method realizes cross-group information fusion. The channel rearrangement method allows information fusion between different groups, solving the problem of independence between groups in traditional grouped convolution. This feature fusion enables the model to better learn complex feature representations and improves the model's expressiveness. Channel rearrangement can effectively enhance the model's feature diversity, thereby improving the accuracy of classification or recognition tasks. In lightweight models, fewer parameters and computational complexity may lead to performance degradation, and channel rearrangement helps alleviate this problem.

[0154] No channel rearrangement is performed. Figure 4 As shown in the first figure, the convolution kernels are divided into three groups, and the generated feature maps are also three groups. Each group only interacts with information internally, and there is no information fusion between groups. Channel rearrangement is as follows Figure 4 As shown in the second and third figures, the first portion of each group is collected as the next group; the second portion of each group is collected as the next group.

[0155] Residual connection is used to add input features directly to output features after a series of operations to alleviate gradient vanishing and enhance information flow. Its mathematical expression is:

[0156] Output=F(x)+x

[0157] Among them, F(x) is the feature map obtained by grouped convolution, channel rearrangement and point-by-point convolution operations, and x is the input feature map.

[0158] In this embodiment, during the detection of underground drainage pipes, challenges such as complex background textures, uneven lighting, and noise interference are faced, which makes defect identification difficult. Traditional convolution operations can usually only focus on local areas and lack a comprehensive grasp of overall information. To address these problems, especially for tiny cracks, the attention mechanism can improve feature extraction capabilities. By adding a hybrid attention mechanism within and at the end of the base model and improving the sampling layer of the neural network, the model is able to strengthen important feature information while suppressing irrelevant or minor information. This approach not only helps the model better understand contextual relationships, but also improves the detection accuracy of drainage pipe defects.

[0159] The LSKA (Local Semantic Knowledge Attention) attention mechanism captures extensive contextual information of the image by utilizing large and separable convolution kernels and spatial dilated convolutions, generates an attention map, and weights the original features through this attention map, thereby enhancing the network's attention to important features and improving the performance of the model. LSKA decomposes the two-dimensional convolution kernel of the deep convolution layer into cascaded horizontal and vertical one-dimensional convolution kernels. Compared with the standard LKA design, the proposed decomposition enables the deep convolution layer with large convolution kernels to be used directly in the attention module without the need for additional blocks. In the YOLOv8 model, LSKA can enable the model to better capture important information in the image by applying the attention mechanism to the extracted feature map. This helps improve the model's detection ability for small targets, overlapping targets, or targets in complex backgrounds. LSKA can better utilize contextual information by considering the semantic relationship between local features. This is very important for target detection tasks because the appearance and position of the target are often affected by the surrounding environment. By enhancing feature representation and utilizing contextual information, LSKA can effectively improve the detection accuracy of the YOLOv8 model in different scenarios and reduce missed detections and false detections.

[0160] The LSKA model first extracts local features from the input image. This process is usually achieved by initializing the convolutional layers (conv0h and conv0v), which are responsible for extracting information in the horizontal and vertical directions of the feature map, respectively. The generated feature map contains information from different regions in the image and lays the foundation for the subsequent attention map generation. After obtaining the preliminary attention map, LSKA further extracts features using spatial dilated convolutions with different dilation rates. These convolutional layers can cover a larger receptive field without increasing the computational cost, thereby capturing a wider range of contextual information. By operating in the horizontal and vertical directions respectively, the model can process image features more carefully and enhance the understanding of spatial relationships in the image. Next, LSKA models the semantic relationships of local features by calculating the similarity between features. This process is usually implemented through the self-attention mechanism, which enables the model to pay attention to other features related to the current feature. Based on these semantic relationships, LSKA calculates the attention weight of each local feature, which reflects the importance of each feature in the current context and helps the model focus on more relevant local information. Finally, LSKA applies the calculated attention weights to the local features, weighting and fusing them to generate more semantically informative feature representations. These weighted features will be used in subsequent target detection tasks to improve the performance and accuracy of the model when processing images. Figure 5As shown in Figure 2, the head structure of YOLOv8 is directly responsible for generating the final detection results. By introducing the LSKA mechanism in the head, important features can be selectively enhanced in the initial feature fusion stage, thereby improving the subsequent detection accuracy.

[0161] In this embodiment, loading the pre-trained weights of the YOLOv8 model refers to obtaining the parameter values ​​saved by the YOLOv8 model that has been trained on large-scale data. These weights contain the common features and patterns learned by the model from a large amount of data. Using this existing knowledge, it can be used as initial values ​​in new specific tasks (such as underground drainage pipe defect detection) to speed up the training of new models and improve performance. For example: It is like standing on the shoulders of giants, directly using the weight information of the previously trained YOLOv8 model in image recognition, instead of training a new model from scratch.

[0162] The beneficial effects of the above technologies include: loading the pre-trained weights of the YOLOv8 model, utilizing the existing training results, and speeding up the training of the new model. Replacing the feature extraction network with ShuffleNetV2 can reduce the amount of computation and the number of parameters of the model and improve the running efficiency of the model. Introducing the LSKA attention mechanism in the head enhances the model's focus on key features and improves the accuracy of detection. Replacing the loss function with the DIoU loss function optimizes the model's training process, making the model converge faster and perform better. Ensuring that the input and output channels of the basic unit block and the downsampling unit are equal ensures the consistency and stability of the model structure. These improvements make the pre-trained model more efficient, accurate, and stable, providing a more powerful model foundation for underground drainage pipe defect detection.

[0163] Embodiment 9:

[0164] On the basis of Example 8, based on the underground drainage pipe detection method of improving YOLOv8, the feature extraction network in the YOLOv8 model is replaced with ShuffleNetV2, including:

[0165] Integrate ShuffleNetV2 into the YOLOv8 framework; replace the C2f module in the YOLOv8 backbone network with the basic module of ShuffleNetV2.

[0166] The beneficial effects of the above technologies include: integrating ShuffleNetV2 into the YOLOv8 framework, combining the advantages of different models and improving the performance of the model. Replacing the C2f module in the YOLOv8 backbone network with the basic module of ShuffleNetV2 reduces the complexity and computational complexity of the model. It helps to improve the running speed and efficiency of the model, making it more suitable for real-time detection scenarios. It can reduce resource consumption while ensuring a certain detection accuracy. This module replacement method optimizes the model structure and provides a more efficient and accurate model solution for underground drainage pipe detection.

[0167] Embodiment 10:

[0168] On the basis of Example 8, based on the underground drainage pipe detection method of improved YOLOv8, the formula of DIoU loss function is:

[0169]

[0170]

[0171] Where IoU is the intersection-over-union ratio of the predicted box and the true box, Area of ​​Intersection is the area of ​​the intersection between the predicted box and the true box, Area of ​​Union is the area of ​​the union between the predicted box and the true box, DIOU is the output value of the DIoU loss function, d is the Euclidean distance between the center point of the predicted box and the center point of the true box, and c is the diagonal length of the minimum circumscribed box between the predicted box and the true box.

[0172] In this embodiment, the IoU (Intersection over Union) loss or CIoU (Complete Intersection over Union) loss used in the original YOLOv8 may be very sensitive to small changes in the bounding box, especially in the case of small targets or target overlap. You can consider using a more robust positioning loss function, such as the DIoU (Distance-IoU) loss function, which performs better when dealing with target overlap and bounding box regression. DIoU pays special attention to the distance of the center point, thereby improving the positioning accuracy. DIoU further introduces the distance between the center point of the predicted box and the real box on the basis of GIoU. By incorporating the center point distance into the loss calculation, it allows the model to focus not only on the overlapping area, but also on the center position of the box, so that the model can better optimize the position of the bounding box and usually converge faster during training, especially when there is a lot of target overlap.

[0173] In this embodiment, the minimum bounding box of the prediction box and the real box is the smallest rectangular box that can completely contain the prediction box and the real box. The size and position of this bounding box depends on the relative position and size of the prediction box and the real box. For example: For example, the shape and position of the prediction box and the real box are irregular, but there is a rectangle that can just enclose them and has the smallest area. This rectangle is the minimum bounding box.

[0174] The beneficial effects of the above technology are: DIOU loss function introduces the square term of the center point distance This makes it so that when the IoU is the same, the predicted box with a smaller center point distance will obtain a lower loss, thereby converging to the true box faster. DIOU is used as a new loss metric, aiming to significantly improve the training effect of bounding box regression, while accelerating the convergence process of the model and improving the accuracy of regression. Unlike traditional methods, DIOU not only focuses on the degree of overlap between bounding boxes, but also considers the distance between their center points, which makes the similarity evaluation more comprehensive. This feature enables DIOU to perform well when dealing with both overlapping and non-overlapping bounding boxes, helping the model to accurately learn the location of the bounding box. Therefore, in computer vision tasks, DIOU can effectively replace the intersection over union ratio, improve the evaluation effect of performance indicators, and ensure the excellent ability of the model in positioning tasks. This leads to faster convergence speed and better regression accuracy, which improves the accuracy and efficiency of defect detection of underground drainage pipes.

[0175] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A method for detecting underground drainage pipes based on improved YOLOv8, characterized in that: include: S1: capturing an underground drainage pipe image, and preprocessing the underground drainage pipe image to obtain a preprocessed underground drainage pipe image; S2: An underground drainage pipe defect detection model was built based on the YOLOv8 convolutional neural network that integrates ShuffleNetV2 and LSKA attention mechanism and adopts DIoU loss function; S3: Input the preprocessed underground drainage pipe image into the underground drainage pipe defect detection model to obtain the underground drainage pipe defect image.

2. The underground drainage pipe detection method based on improved YOLOv8 according to claim 1 is characterized in that: S1: used to capture the underground drainage pipe image and pre-process the underground drainage pipe image to obtain the pre-processed underground drainage pipe image, including: Use CCTV camera to capture the underground drainage pipeline to be tested to obtain the image of the underground drainage pipeline; The underground drainage pipe image is preprocessed to obtain a preprocessed underground drainage pipe image.

3. The underground drainage pipe detection method based on improved YOLOv8 according to claim 2 is characterized in that: Preprocessing the underground drainage pipe image to obtain the preprocessed underground drainage pipe image includes: Identify the pipeline outline in the underground drainage pipeline image, divide the underground drainage pipeline image into regions based on the pipeline outline, and obtain a pipeline pure image and a background image of the underground drainage pipeline image; Graying the background image of the underground drainage pipe image to obtain a graying background image, and performing contrast compression on the graying background image until the pixel values ​​of all pixels in the graying background image are within a preset gray value, thereby obtaining a preprocessed background image; The pixel enhancement is performed on the pure image of the underground drainage pipeline to obtain the preprocessed underground drainage pipeline image.

4. The underground drainage pipe detection method based on improved YOLOv8 according to claim 3 is characterized in that: Perform pixel enhancement on the pure image of the underground drainage pipeline to obtain a preprocessed underground drainage pipeline image, including: Get the pixel stretch range step table; Based on each pixel stretching range in the stretching range ladder table, multiple contrast stretchings are performed on the pipeline pure image of the underground drainage pipeline image to obtain a pipeline image with strong contrast under each pixel stretching range; Grayscale processing is performed on the high-contrast pipeline image under each pixel stretching range to obtain the grayscale pipeline image under each pixel stretching range, and the occurrence frequency of each grayscale value in the grayscale pipeline image under each pixel stretching range is counted; Determine the cumulative distribution probability of each gray value in the gray-scale pipeline image under each pixel stretching range based on the occurrence frequency of all gray values ​​in the gray-scale pipeline image under each pixel stretching range; Based on the cumulative distribution probability of each gray value in the grayscale pipeline image under each pixel stretching range and the maximum grayscale value of the grayscale pipeline image under each pixel stretching range, the grayscale pipeline image under each pixel stretching range is uniformly stretched to obtain a grayscale balanced pipeline image under each pixel stretching range; Based on the grayscale balanced pipeline image under all pixel stretching ranges, the preprocessed underground drainage pipeline image is obtained.

5. The underground drainage pipe detection method based on improved YOLOv8 according to claim 4 is characterized in that: Based on the cumulative distribution probability of each gray value in the grayscale pipeline image under each pixel stretching range and the maximum grayscale value of the grayscale pipeline image under each pixel stretching range, the grayscale pipeline image under each pixel stretching range is uniformly stretched to obtain a grayscale balanced pipeline image under each pixel stretching range, including: The product of the difference between the maximum grayscale value of the grayscale pipeline image under each pixel stretching range and 1 and the cumulative distribution probability of each grayscale value in the grayscale pipeline image under the corresponding pixel stretching range is regarded as the new grayscale value of each grayscale value in the grayscale balanced pipeline image under the corresponding pixel stretching range; Based on the new grayscale values ​​in the grayscale balanced pipeline image under each pixel stretching range of all grayscale values, the grayscale balanced pipeline image under each pixel stretching range is obtained.

6. The underground drainage pipe detection method based on improved YOLOv8 according to claim 4 is characterized in that: Based on the grayscale balanced pipeline image under all pixel stretching ranges, the preprocessed underground drainage pipeline image is obtained, including: Calculate the image display effect evaluation value of the grayscale equalization pipeline image under each pixel stretch range: Where, AM IQ is the image display effect evaluation value of the grayscale equalization pipeline image under the currently calculated pixel stretching range, I max is the maximum grayscale value of the grayscale equalization pipeline image under the currently calculated pixel stretching range, n is the total number of pixels of the grayscale equalization pipeline image under the currently calculated pixel stretching range, I iorg is the gray value of the i-th pixel in the pure image of the underground drainage pipeline, I iproc is the gray value of the i-th pixel in the grayscale equalization pipeline image under the currently calculated pixel stretching range, m is the total number of image display attributes, μ jproc is the attribute mean of the jth graphical attribute of the pure image of the underground drainage pipeline image, μ jproc is the attribute mean of the jth graphic attribute of the grayscale equalization pipeline image under the currently calculated pixel stretching range; The grayscale balanced pipeline image corresponding to the maximum image display effect evaluation value in the grayscale balanced pipeline image under all pixel stretching ranges is regarded as the preprocessed underground drainage pipeline image.

7. The underground drainage pipe detection method based on improved YOLOv8 according to claim 1 is characterized in that: S2: Based on the YOLOv8 convolutional neural network that integrates ShuffleNetV2 and LSKA attention mechanism and adopts DIoU loss function, an underground drainage pipe defect detection model is built, including: The underground drainage pipe images are captured and preprocessed using CCTV cameras to obtain a data set; Preprocess the images in the data set and establish corresponding true labels to obtain the preprocessed data set, and divide the preprocessed data set into a training set, a test set, and a validation set; The YOLOv8 convolutional neural network that integrates ShuffleNetV2 and LSKA attention mechanism and adopts DIoU loss function is selected as the pre-training model; Input the training set into the pre-training model for training to obtain a trained detection model; The trained detection model is used to perform defect detection on the test set and the validation set, and the recognition accuracy of the trained detection model is optimized through the algorithm until the underground drainage pipe defect detection model is obtained.

8. The underground drainage pipe detection method based on improved YOLOv8 according to claim 7 is characterized in that: The YOLOv8 convolutional neural network that integrates ShuffleNetV2 and LSKA attention mechanisms and uses the DIoU loss function is selected as the pre-training model, including: Load the pre-trained weights of the YOLOv8 model, replace the feature extraction network in the YOLOv8 model with ShuffleNetV2, introduce the LSKA attention mechanism in the head of the YOLOv8 model, and replace the loss function of the YOLOv8 model with the DIoU loss function to obtain the pre-trained model; Among them, the input channels of the basic unit blocks and downsampling units in the pre-trained model are equal and the corresponding output channels are equal.

9. The underground drainage pipe detection method based on improved YOLOv8 according to claim 8, characterized in that: Replace the feature extraction network in the YOLOv8 model with ShuffleNetV2, including: Integrate ShuffleNetV2 into the YOLOv8 framework; replace the C2f module in the YOLOv8 backbone network with the basic module of ShuffleNetV2.

10. The underground drainage pipe detection method based on improved YOLOv8 according to claim 8, characterized in that: The formula of DIoU loss function is: Where IoU is the intersection-over-union ratio of the predicted box and the true box, Area of ​​Intersection is the area of ​​the intersection between the predicted box and the true box, Area of ​​Union is the area of ​​the union between the predicted box and the true box, DIOU is the output value of the DIoU loss function, d is the Euclidean distance between the center point of the predicted box and the center point of the true box, and c is the diagonal length of the minimum circumscribed box between the predicted box and the true box.

Citation Information

Patent Citations

  • Steel surface defect detection method based on improved YOLOv5s

    CN115829991A

  • Aluminum material surface defect detection method for enhancing multi-scale feature extraction and target detection

    CN118799268A

  • Drainage pipeline defect detection method based on improved YOLOv8s

    CN119169378A

  • Method for segmentation of underground drainage pipeline defects based on full convolutional neural network

    US20210319265A1

  • Systems, Methods and Apparatuses for Detecting Defects in Underground Infrastructure Systems

    US20220207693A1