Pipeline defect detection method and device based on YOLOv11

By introducing an attention mechanism and improving the detection head on the YOLOv11 model, combined with data augmentation and multi-loss optimization, the accuracy and adaptability issues of pipeline defect identification in existing technologies are solved, and efficient and accurate detection of complex boundary defects is achieved.

CN121837875APending Publication Date: 2026-04-10TSINGHUA UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-18
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing technologies have shortcomings in image feature extraction and defect recognition. They are difficult to accurately identify pipeline images with blurred defect boundaries and irregular shapes, and are prone to missed or false detections. Furthermore, the generalization ability and robustness of the models are insufficient.

Method used

Based on the YOLOv11 model, a pre-defined attention mechanism and an improved detection head are introduced to construct an initial pipeline defect detection model. The model is then trained using a constructed pipeline defect sample library. Through multi-branch parallel feature extraction and fusion processing, multi-scale information is adaptively integrated. Combined with data augmentation and multi-loss joint optimization strategies, the model's adaptability and detection accuracy are improved.

Benefits of technology

It significantly improves the precision of the defect mask, enhances the model's ability to accurately segment complex boundary defects, improves detection efficiency and accuracy, and enhances the model's environmental adaptability and robustness under different lighting conditions, dirt occlusion, and complex scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121837875A_ABST
    Figure CN121837875A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image data processing, in particular to a pipeline defect detection method and device based on YOLOv11, and the method comprises the steps: adding a preset attention mechanism and a preset detection head on the basis of a preset YOLOv11 first-stage model, so as to construct a loss function for detecting pipeline defects, constructing an initial pipeline defect detection model according to the loss function; and training the initial pipeline defect detection model by using a pipeline defect sample library constructed by the marked pipeline defect image data to construct a final pipeline defect detection model, and inputting the image data of the to-be-detected pipeline to the final pipeline defect detection model to output a pipeline defect detection result. Therefore, the problem that the reliability of a detection result and the adaptability of a model are reduced due to the fact that a pipeline image with a fuzzy defect boundary and an irregular shape is difficult to accurately recognize and the phenomenon of missing detection or false detection is easy to occur due to the defects of related technologies in the aspects of image feature extraction and defect recognition is solved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of image data processing, in particular to a pipeline defect detection method and device based on YOLOv11. BACKGROUND

[0002] In related technologies, computer vision technology, especially deep learning and image processing algorithms, can be used to automatically, intelligently and in real time identify and analyze defects of underground drainage pipelines. The introduction of computer vision enables the detection of underground drainage pipeline defects to gradually develop in the direction of automation and high precision. By integrating image processing, pattern recognition and deep learning technologies, computer vision algorithms can automatically extract defect features from images, locate and identify multiple types of defects such as cracks, leaks, scaling and misalignment in real time, and significantly improve the efficiency and accuracy of detection.

[0003] However, due to the deficiencies in image feature extraction and defect recognition in related technologies, it is difficult to accurately identify drainage pipeline images with fuzzy defect boundaries and irregular shapes. In addition, due to the limited coverage of the sample library and uneven data distribution, the generalization ability and robustness of the model are still lacking, and it is difficult to adapt to the detection needs of different pipeline structures, shooting angles and lighting conditions, which needs to be solved. SUMMARY

[0004] The present application provides a pipeline defect detection method and device based on YOLOv11 to solve the problem that in related technologies, due to the deficiencies in image feature extraction and defect recognition, it is difficult to accurately identify pipeline images with fuzzy defect boundaries and irregular shapes, and it is prone to miss detection or false detection, thereby reducing the reliability of the detection result and the adaptability of the model.

[0005] The first aspect of the present application provides a pipeline defect detection method based on YOLOv11, comprising the following steps: obtaining image data of a drainage pipeline, labeling pipeline defects in the image data, determining defect information, and obtaining labeled pipeline defect image data, and using the labeled pipeline defect image data to construct a pipeline defect sample library; based on a preset YOLOv11 one-stage model, a preset attention mechanism and a preset detection head are added to construct a loss function for detecting pipeline defects, and an initial pipeline defect detection model is constructed according to the loss function; the sample library is used to train the initial pipeline defect detection model to construct a final pipeline defect detection model, and the image data of the pipeline to be detected is input into the final pipeline defect detection model to output the pipeline defect detection result.

[0006] Through the technical means, the embodiment of the present application can introduce the preset attention mechanism and the improved detection head on the basis of the preset YOLOv11 one-stage model, construct an initial pipeline defect detection model, and train the constructed pipeline defect sample library to obtain a final pipeline defect detection model. The final pipeline defect detection model can be processed through multi-branch parallel feature extraction and fusion, and can adaptively integrate multi-scale information without the need for artificial design of a complex multi-scale structure, thereby effectively improving the adaptability of the model. Meanwhile, the final pipeline defect detection model can better capture instance-level detail features and significantly improve the fineness of the defect mask, thereby meeting the accurate segmentation requirement of complex boundary defects.

[0007] Optionally, in an embodiment of the present application, the image data of the drainage pipeline is acquired, and pipeline defects in the image data are labeled to determine defect information to obtain labeled pipeline defect image data, which comprises: collecting pipeline defect feature images under different climates and environmental conditions to generate an initial image data set of the drainage pipeline; extracting at least one static image satisfying a preset representative condition in the initial image data set to generate the image data based on the at least one static image; performing instance segmentation labeling on each image in the image data, marking the position of the defect information and depicting the contour of the defect information to obtain the labeled pipeline defect image data.

[0008] Through the technical means, the embodiment of the present application can collect pipeline defect feature images under different climates and environmental conditions, and then perform instance segmentation labeling on the images, which can enrich the diversity and representativeness of the sample library, enable the model to learn defect feature distribution under various complex backgrounds and illumination conditions, thereby improving the generalization ability and environmental adaptability of the model, and provide high-quality data support for subsequent intelligent detection of pipeline defects.

[0009] Optionally, in an embodiment of the present application, the pipeline defect sample library is constructed by using the labeled pipeline defect image data, which comprises: performing data enhancement processing on the labeled pipeline defect image data to obtain image data satisfying a preset processing condition; and constructing the pipeline defect sample library by using the image data.

[0010] Through the technical means, the embodiment of the present application can perform data enhancement processing on the labeled pipeline defect image data, which can expand the training sample size, enhance the adaptability of the model to complex environments such as different illuminations, angles, dirt occlusions and noise interference, and improve the robustness and stability of the model to diversified defect features, thereby effectively preventing model overfitting and improving the accuracy and generalization performance of pipeline defect detection.

[0011] Optionally, in one embodiment of the present invention, before adding the preset attention mechanism and the preset detection head, the method further includes: determining a selective convolution kernel attention mechanism, generating the preset attention mechanism based on the selective convolution kernel attention mechanism, and obtaining the preset detection head from the dynamic detection head.

[0012] Through the above technical means, the embodiments of the present invention can construct a pipeline defect detection model by introducing a selective convolution kernel attention mechanism and a dynamic detection head. During the feature extraction process, the weight allocation of convolution kernels of different scales can be adaptively adjusted to enhance the model's comprehensive expression ability of local details and global semantics. At the same time, the dynamic detection head can dynamically adjust the detection parameters according to the spatial and semantic differences of the input features, thereby improving the model's feature discrimination ability and detection accuracy for multiple types of defects, and achieving high-precision and robust detection of pipeline defects in complex scenarios.

[0013] Optionally, in one embodiment of the present invention, training the initial pipeline defect detection model using the sample library to construct a final pipeline defect detection model includes: determining the training objective and evaluation index; determining the training loss curve based on the objective and the evaluation index according to a preset multi-loss joint optimization strategy; and training the initial pipeline defect detection model using the sample library according to a preset training round until the loss curve meets a preset descent condition to obtain the final pipeline defect detection model.

[0014] Through the above technical means, the embodiments of the present invention can determine the loss curve during the training process according to the preset multi-loss joint optimization strategy, and achieve simultaneous improvement of detection accuracy and segmentation accuracy by using the weighted joint optimization of multiple loss functions. By dynamically adjusting the weight ratio of each loss function, the contribution of different detection tasks can be balanced during the training process, improving the feature extraction capability and stability of the model in complex backgrounds, ensuring that the loss curve decreases smoothly and eventually converges, thereby obtaining the pipeline defect detection model with optimal performance.

[0015] A second aspect of the present invention provides a pipeline defect detection device based on YOLOv11, comprising: an acquisition module, configured to acquire image data of a drainage pipeline, and annotate pipeline defects in the image data to determine defect information, thereby obtaining annotated pipeline defect image data, and constructing a pipeline defect sample library using the annotated pipeline defect image data; a construction module, configured to add a preset attention mechanism and a preset detection head to a preset YOLOv11 one-stage model to construct a loss function for detecting pipeline defects, and construct an initial pipeline defect detection model based on the loss function; and a detection module, configured to train the initial pipeline defect detection model using the sample library to construct a final pipeline defect detection model, and input the image data of the pipeline to be detected into the final pipeline defect detection model to output pipeline defect detection results.

[0016] Through the above technical means, the embodiments of the present invention can, on the basis of a preset YOLOv11 one-stage model, introduce a preset attention mechanism and an improved detection head to construct an initial pipeline defect detection model, and use the constructed pipeline defect sample library for training to obtain the final pipeline defect detection model. It can adaptively integrate multi-scale information through multi-branch parallel feature extraction and fusion processing, without the need to manually design complex multi-scale structures, thereby effectively improving the adaptability of the model; at the same time, it can better capture instance-level detailed features, significantly improve the precision of the defect mask, and meet the requirements for accurate segmentation of complex boundary defects.

[0017] Optionally, in one embodiment of the present invention, the acquisition module includes: a collection unit, used to collect pipeline defect features under different climate and environmental conditions to generate an initial image dataset of the drainage pipeline; an extraction unit, used to extract at least one static image from the initial image dataset that meets preset representative conditions to generate the image data based on the at least one static image; and a labeling unit, used to perform instance segmentation labeling on each image in the image data, marking the location of the defect information and depicting the outline of the defect information to obtain the labeled pipeline defect image data.

[0018] Through the above technical means, the embodiments of the present invention can collect pipeline defect feature images under different climate and environmental conditions, and then perform instance segmentation and annotation on the images. This can enrich the diversity and representativeness of the sample library, enabling the model to learn the distribution of defect features under various complex backgrounds and lighting conditions, thereby improving the model's generalization ability and environmental adaptability, and providing high-quality data support for subsequent intelligent pipeline defect detection.

[0019] Optionally, in one embodiment of the present invention, the acquisition module includes: a processing unit, configured to perform data augmentation processing on the labeled pipeline defect image data to obtain image data that meets preset processing conditions; and a construction unit, configured to construct the pipeline defect sample library using the image data.

[0020] Through the above technical means, the embodiments of the present invention can expand the training sample size by performing data augmentation processing on the labeled pipeline defect image data, enhance the model's adaptability to complex environments such as different lighting, angles, dirt occlusion and noise interference, improve the robustness and stability of the model to diverse defect features, thereby effectively preventing model overfitting and improving the accuracy and generalization performance of pipeline defect detection.

[0021] Optionally, in one embodiment of the present invention, it further includes: a first determining module, configured to determine a selective convolution kernel attention mechanism and generate the preset attention mechanism based on the selective convolution kernel attention mechanism; and a second determining module, configured to obtain the preset detection head from the dynamic detection head.

[0022] Through the above technical means, the embodiments of the present invention can construct a pipeline defect detection model by introducing a selective convolution kernel attention mechanism and a dynamic detection head. During the feature extraction process, the weight allocation of convolution kernels of different scales can be adaptively adjusted to enhance the model's comprehensive expression ability of local details and global semantics. At the same time, the dynamic detection head can dynamically adjust the detection parameters according to the spatial and semantic differences of the input features, thereby improving the model's feature discrimination ability and detection accuracy for multiple types of defects, and achieving high-precision and robust detection of pipeline defects in complex scenarios.

[0023] Optionally, in one embodiment of the present invention, the detection module includes: a first determining unit, configured to determine the training objective and evaluation index; a second determining unit, configured to determine the training loss curve based on the objective and the evaluation index and according to a preset multi-loss joint optimization strategy; and a training unit, configured to train the initial pipeline defect detection model using the sample library according to a preset training round until the loss curve meets a preset descent condition, thereby obtaining the final pipeline defect detection model.

[0024] Through the above technical means, the embodiments of the present invention can determine the loss curve during the training process according to the preset multi-loss joint optimization strategy, and achieve simultaneous improvement of detection accuracy and segmentation accuracy by using the weighted joint optimization of multiple loss functions. By dynamically adjusting the weight ratio of each loss function, the contribution of different detection tasks can be balanced during the training process, improving the feature extraction capability and stability of the model in complex backgrounds, ensuring that the loss curve decreases smoothly and eventually converges, thereby obtaining the pipeline defect detection model with optimal performance.

[0025] A third aspect of the present invention provides an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the pipeline defect detection method based on YOLOv11 as described in the above embodiments.

[0026] A fourth aspect of the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described YOLOv11-based pipeline defect detection method.

[0027] A fifth aspect of the present invention provides a computer program product, including a computer program that, when executed, is used to implement the above-described YOLOv11-based pipeline defect detection method.

[0028] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description

[0029] The above and / or additional aspects and advantages of the present invention will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein: Figure 1 A flowchart illustrating a pipeline defect detection method based on YOLOv11 according to an embodiment of the present invention; Figure 2 This is a schematic diagram of an image set using a tool for frame extraction according to an embodiment of the present invention; Figure 3 This is a comparative diagram of data annotation tools according to an embodiment of the present invention; Figure 4 This is a schematic diagram illustrating an example of interface material detachment marking according to an embodiment of the present invention; Figure 5 This is a schematic diagram illustrating an example of corrosion defect labeling according to an embodiment of the present invention; Figure 6 This is a schematic diagram illustrating the principle of a pipeline defect detection method based on YOLOv11 according to an embodiment of the present invention. Figure 7 This is a schematic diagram illustrating the principle of a normalized confusion matrix according to an embodiment of the present invention; Figure 8 This is a schematic diagram of four types of loss curves for the training set in one embodiment of the present invention. Figure 9 This is a schematic diagram of four types of loss curves for the validation set according to an embodiment of the present invention; Figure 10This is a schematic diagram of the mAP (mean Average Precision) and PR (Precision-Recall) curves before model improvement in one embodiment of the present invention. Figure 11 This is a schematic diagram of the improved mAP and PR curves of a model according to an embodiment of the present invention; Figure 12 This is a schematic diagram of the F1 score curve before model improvement in one embodiment of the present invention; Figure 13 This is a schematic diagram of the improved F1 score curve of a model according to an embodiment of the present invention; Figure 14 This is a schematic diagram comparing algorithm models according to an embodiment of the present invention; Figure 15 This is a block diagram of a pipeline defect detection device based on YOLOv11 according to an embodiment of the present invention; Figure 16 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention.

[0030] Figure label: 10- Pipeline defect detection device based on YOLOv11; 100- Acquisition module, 200- Construction module, 300- Detection module; 1601- Memory, 1602- Processor, 1603- Communication interface. Detailed Implementation

[0031] Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain the present invention, and should not be construed as limiting the present invention.

[0032] The following description, with reference to the accompanying drawings, illustrates a pipeline defect detection method and apparatus based on YOLOv11 according to embodiments of the present invention. To address the technical problems mentioned in the background section, such as the inadequacy of related technologies in image feature extraction and defect recognition, which makes it difficult to accurately identify pipeline images with blurred defect boundaries and irregular shapes, leading to missed or false detections and reducing the reliability of detection results and the adaptability of the model, this invention provides a pipeline defect detection method based on YOLOv11. In this method, based on a pre-set YOLOv11 one-stage model, a pre-set attention mechanism and an improved detection head are introduced to construct an initial pipeline defect detection model. This model is then trained using a constructed pipeline defect sample library to obtain the final pipeline defect detection model. Through multi-branch parallel feature extraction and fusion processing, it adaptively integrates multi-scale information without the need for manually designing complex multi-scale structures, thereby effectively improving the model's adaptability. Simultaneously, it can better capture instance-level detailed features, significantly improving the precision of the defect mask and meeting the requirements for accurate segmentation of complex boundary defects. Furthermore, it can enhance the detection capability for small-scale defects, greatly improving the detection efficiency and accuracy of pipeline inspection, reducing engineering inspection costs, and significantly enhancing the model's environmental adaptability and detection robustness under different lighting conditions, dirt occlusion, and complex scenarios. This solves the problem that the shortcomings of related technologies in image feature extraction and defect recognition make it difficult to accurately identify pipeline images with blurred defect boundaries and irregular shapes, which easily leads to missed or false detections, thereby reducing the reliability of detection results and the adaptability of the model.

[0033] Specifically, Figure 1 This is a schematic flowchart of a pipeline defect detection method based on YOLOv11 provided in an embodiment of the present invention.

[0034] like Figure 1 As shown, the pipeline defect detection method based on YOLOv11 includes the following steps: In step S101, image data of the drainage pipe is acquired, and pipe defects in the image data are annotated to determine defect information, so as to obtain annotated pipe defect image data, and a pipe defect sample library is constructed using the annotated pipe defect image data.

[0035] It can be noted that the acquisition methods may include, but are not limited to, using a pipe crawling robot to move along the inside of the pipe and taking pictures of the inner wall of the pipe with a high-definition industrial camera or webcam. In addition, the image data should cover different positions, angles and lighting conditions of the pipe to meet the needs of subsequent inspection.

[0036] The annotation can be done manually or semi-automatically. Defect information can include, but is not limited to, cracks, leaks, scale, misalignments, etc. Each defect can be annotated in the image with a bounding box or polygonal area and assigned a corresponding category label.

[0037] The acquisition method, annotation method, and defect information can all be set by those skilled in the art according to the actual situation, and no specific restrictions are imposed here.

[0038] Optionally, in one embodiment of the present invention, acquiring image data of a drainage pipe and annotating pipe defects in the image data to determine defect information to obtain annotated pipe defect image data includes: collecting pipe defect features under different climate and environmental conditions to generate an initial image dataset of the drainage pipe; extracting at least one static image from the initial image dataset that meets preset representative conditions to generate image data based on at least one static image; and performing instance segmentation and annotation on each image in the image data to mark the location of defect information and depict the outline of defect information to obtain annotated pipe defect image data.

[0039] The preset representative conditions can cover common sewer defect types, including but not limited to cracks, leaks, scale, misalignment, etc., and can represent images of different lighting conditions, degree of dirt obstruction and other complex environmental factors inside the pipe, so as to ensure that the detection model trained subsequently has strong generalization ability and robustness.

[0040] As one possible implementation method, embodiments of the present invention can employ a CCTV (Closed-Circuit Television) pipeline robot to collect video image data inside the pipeline. This device can move stably inside a closed pipeline and capture high-definition video, ensuring that the acquired images can clearly present defect details (such as crack width, corrosion area, and joint detachment range).

[0041] To ensure the comprehensiveness and representativeness of the sample library, the data collection phase of this invention can meet the following four criteria: (1) Sample category coverage: The embodiments of the present invention should focus on the types of pipeline defects that frequently occur in engineering practice, and cover at least the 16 types of defects defined by national standards, including but not limited to structural defects: misalignment, leakage, deformation, corrosion, foreign object penetration, rupture, branch pipe concealed connection, disconnection, interface material detachment, undulation; functional defects: tree roots, obstacles, scale, residual wall and dam roots, scum, sediment.

[0042] (2) Image quality: In the embodiments of the present invention, the pipeline defect image should be clearly distinguishable, the RGB channels should be complete, the resolution should be not less than 640×640, and the basic parameters of conventional CCTV pipeline robot camera equipment should be matched.

[0043] (3) Pipe type coverage: The embodiments of the present invention should cover common pipe types (such as concrete pipes, plastic pipes, cast iron pipes), materials and different pipe diameter specifications in my country.

[0044] (4) Diverse data sources: In this embodiment of the invention, pipeline images from different regions and seasons should be selected, with priority given to cities with distinct seasons as sampling locations, in order to cover the differences in defect characteristics caused by climate differences (such as cracks caused by frost heave in the north and corrosion caused by humid environments in the south).

[0045] Furthermore, the embodiments of the present invention describe instance segmentation annotation, which may include the following steps: (1) Video data frame extraction and sample selection: like Figure 2 As shown, in this embodiment of the invention, FFmpeg (Fast Forward Moving Picture Experts Group, multimedia processing software) software can be used to perform frame extraction processing on the original video collected by the CCTV robot, with the specific parameter set to "1 frame per second" to extract static image frames from the continuous video images.

[0046] Furthermore, embodiments of the present invention can screen samples that meet representativeness criteria: Specifically, embodiments of the present invention can perform a combination of manual and algorithmic filtering on the image set obtained by frame extraction, removing the following types of images: 1) Duplicate images: Images whose content highly overlaps in adjacent frames (e.g., similarity ≥ 90%); 2) Blurry image: An image in which the defect outline cannot be identified due to equipment vibration or insufficient lighting; 3) Defect-free image: A blank image that does not contain any pipe defects; 4) Severely interfered images: Images with incomplete defect information due to water accumulation or scum obscuring the pipe.

[0047] (2) Sample instance segmentation and annotation: like Figure 3 As shown, instance segmentation annotation can be pixel-level annotation of each defect instance in the image. Each instance can have an independent mask, which not only annotates the defect location but also accurately depicts its shape. Instance segmentation annotation tools can include, but are not limited to, LabelImg, LabelMe, Roboflow, etc.

[0048] As a concrete example, such as Figure 4 , Figure 5As shown, this embodiment of the invention can use Roboflow for core annotation operations. Annotators open the filtered image through the Roboflow platform and manually draw the contour along the defect edge using a "point-to-line" method to form a closed polygon. Each annotated defect contour is assigned a corresponding category label (such as "crack," "corrosion," or "misalignment"). Multiple defects existing in the same image (including multiple bodies of the same category and defects of different categories) are annotated independently to avoid label confusion (e.g., "scum" and "deposition" in the same image need to be annotated with their contours and categories separately). After annotation, a dataset containing "image file + txt annotation file" is exported. The txt file records information such as defect category and contour coordinates (pixel level). An example of annotating interface material detachment is shown below. Figure 4 As shown, an example of a "corrosion" defect labeling. Figure 5 As shown.

[0049] The embodiments of the present invention can use the Roboflow tool to perform instance segmentation and annotation on each image, which can not only mark the location of defects, but also accurately depict the outline of defects, thereby improving the model's ability to recognize defect morphology.

[0050] Optionally, in one embodiment of the present invention, constructing a pipeline defect sample library using labeled pipeline defect image data includes: performing data augmentation processing on the labeled pipeline defect image data to obtain image data that meets preset processing conditions; and constructing a pipeline defect sample library using the image data.

[0051] Among them, the image data that meets the preset processing conditions can be a brightness-enhanced image to improve the visibility of pipeline defect areas in low-light environments; it can also be a contrast-enhanced image to strengthen the grayscale difference between the defect and the background; it can also include images that have undergone color balancing, noise reduction, or sharpening to improve the quality and stability of the input data, thereby providing clearer input information for subsequent feature extraction and defect identification.

[0052] Specifically, considering the characteristics of pipeline defects, this embodiment of the invention can employ two enhancement methods: brightness adjustment and contrast adjustment, instead of rotation or flipping. This is mainly because pipeline defects have fixed directional characteristics (e.g., sediment and scum are usually located at the bottom of the pipeline, while interface material detachment is usually located at the top). Rotation / flipping would cause the model to learn incorrect defect distribution patterns (e.g., "flipping" bottom scum to the top), leading to prediction bias. Brightness and contrast adjustment can simulate actual lighting changes during inspection (e.g., insufficient light in certain areas inside the pipeline, differences in equipment exposure), improving the model's adaptability to complex lighting environments.

[0053] In embodiments of the present invention, the brightness adjustment range can be [-10%, 10%], and the contrast adjustment range can be [-10%, 10%].

[0054] Given the complex lighting conditions inside pipelines, the ±10% adjustment range in this embodiment can cover most actual lighting differences without excessively distorting defect features. An excessively large adjustment range (such as exceeding ±20%) may cause the defect outline to become blurred (e.g., the crack disappears due to low brightness), affecting the model's learning accuracy. Small adjustments can take into account the defect features of different types of pipelines (such as the gray background of concrete pipes and the black background of cast iron pipes), avoiding image distortion after enhancement.

[0055] As one possible implementation method, embodiments of the present invention can use the built-in data augmentation function of the Roboflow platform to randomly adjust the brightness and contrast of the training set images (the adjustment range of each image is randomly generated within a set range), thereby expanding the number of samples and ultimately forming an instance segmentation sample library with a scale of over 10,748 images, covering 16 types of defects and with a balanced category distribution.

[0056] In step S102, a preset attention mechanism and a preset detection head are added to the preset YOLOv11 one-stage model to construct a loss function for detecting pipeline defects, and an initial pipeline defect detection model is constructed based on the loss function.

[0057] The pre-defined YOLOv11 one-stage model can be an end-to-end object detection method, directly predicting object categories and bounding boxes on feature maps without the need for candidate region generation. YOLOv11, designed for pipeline detection, achieves near real-time inference (frames per second ≥ 15fps) through a lightweight backbone network and single-stage design, adapting to the resource limitations of embedded devices. Its native instance segmentation capability directly outputs pixel-level results through built-in mask branches, accurately depicting defect contours such as crack paths. Multi-scale processing, combined with an FPN+PAN structure and dynamic anchor mechanism, effectively covers defect detection from micro-cracks (<2mm) to large-scale fractures (>50cm).

[0058] It can be explained that the preset attention mechanism can be channel attention, spatial attention, or SK (Selective Kernel) attention, etc., which can be used to enhance the model's feature response to key defect regions. The preset detection head can adopt the standard YOLO detection head or the Dynamic Head, which enhances the ability to identify defects of different sizes and irregular shapes through multi-scale feature fusion and variable convolution, thereby improving the model's detection accuracy and robustness in complex pipeline environments. The preset attention mechanism and preset detection head can further enhance the feature response to key regions and improve the detection accuracy and robustness in complex environments.

[0059] The preset attention mechanism and preset detection head can be set by those skilled in the art according to the actual situation, and no specific restrictions are imposed here.

[0060] Optionally, in one embodiment of the present invention, before adding the preset attention mechanism and the preset detection head, the method further includes: determining a selective convolution kernel attention mechanism, generating a preset attention mechanism based on the selective convolution kernel attention mechanism, and obtaining the preset detection head from the dynamic detection head.

[0061] The SK attention mechanism takes into account multi-scale features. Due to the existence of convolutional branches with different receptive fields, SK attention can simultaneously capture small-scale details, such as minor defects like cracks, and large-scale background information, such as large areas of damage. In the forward inference stage, for different input images or feature maps, the SK attention mechanism can "prefer" the fusion output of one or more branches according to actual needs, improving the model's adaptability. By processing multiple branches in parallel and then fusing them, the network can adaptively integrate information at multiple scales without the need for manually designing complex multi-scale structures.

[0062] In practical engineering, pipeline imaging can be affected by factors such as lighting, angle, and ambient humidity, leading to unstable image quality. The multi-branch feature representations learned during the training phase by the SK attention mechanism help to cope with these variations, making the model more robust to changes in input. Furthermore, as a pluggable module, SK attention can be relatively easily integrated with existing pipeline defect detection frameworks without requiring large-scale modifications to the overall network structure.

[0063] For pipeline defect detection, an application scenario with diverse types, sizes, and background interference, the SK attention mechanism can improve the accuracy of identification while reducing the rate of missed and false detections.

[0064] As a concrete example, the core idea of ​​the SK attention mechanism can be summarized in the following four key steps: (1) Multi-scale feature extraction: In its convolutional layer design, the SK mechanism constructs multiple parallel convolutional branches simultaneously, each using convolutional kernels of different sizes (e.g., 3×3, 5×5, 7×7) to extract features at different scales. Assume the input feature map is , No. The output of each branch is: , in, Represents the output feature map of the m-th branch 、 This represents the convolution operation in the m-th branch (using the m-th convolution kernel size). 、 Indicates the number of branches.

[0065] It can be explained that the convolution kernels of different branches have different receptive field sizes, which can capture information at different scales simultaneously.

[0066] (2) Feature fusion and channel feature aggregation: In this embodiment of the invention, the feature maps of the multiple branches described above can be added element by element and fused into a single feature map: , Then, embodiments of the present invention can process the fused feature map. Perform global average pooling to obtain channel-level statistics: , Where, vector Global information representing the features of each channel can be used as input for the next step of generating attention weights; Represents the vector after global average pooling. () indicates a global average pooling operation.

[0067] (3) Dynamic attention weight generation: In an embodiment of the present invention, a lightweight fully connected network, specifically two fully connected layers, is used for vector... Processing: First layer (dimensionality reduction): Reduce channel dimensions to decrease computational load.

[0068] Second layer (upgraded dimension): Restore the channel dimension to the number of branches. Similarly, the attention weights for each branch are obtained. After normalization using the Softmax function, the attention weights are obtained: , in, Indicates the first The weight of each branch; This indicates a fully connected layer.

[0069] (4) Adaptive feature fusion: Finally, embodiments of the present invention can utilize dynamic attention weights. For each branch feature map Weighted fusion is performed to obtain the final output feature map. Weighted fusion is performed to obtain the final output feature map.

[0070] , Understandably, the output feature map at this time Each channel in the system incorporates dynamic receptive field information that is best suited to the current input feature scale.

[0071] Furthermore, embodiments of the present invention may employ a Dynamic Head to improve the accuracy of defect segmentation and positioning.

[0072] Dynamic Head is a relatively innovative detection head design in object detection in recent years. Compared with traditional detection heads, such as Mask R-CNN head, YOLACT head (You Only Look At Coefficients Head), and SOLO head (Segmenting Objects by Locations Head), it has stronger instance awareness. The dynamic convolutional kernel can adjust the convolution parameters according to the specific features of each object, and adaptively adjust to adapt to the shape, scale and complexity of different objects. It is especially suitable for handling irregular or shape-variable objects and can perform more accurate instance segmentation.

[0073] Dynamic Heads reduce a large number of redundant parameters in the detection head and dynamically adjust the calculation process. This not only improves the detection accuracy of complex targets but also enhances the efficiency of real-time detection, making it particularly suitable for applications requiring rapid response, such as intelligent detection of defects in drainage pipes. Furthermore, Dynamic Heads have strong generalization capabilities, dynamically generating convolution kernel parameters to avoid overfitting and better generalize to different scenarios. Therefore, the design features and advantages of Dynamic Heads make them ideal for intelligent detection tasks of drainage pipe defects, especially for detection scenarios with complex shapes and high real-time requirements.

[0074] Furthermore, the operation of Dynamic Head mainly includes the following three key steps: (1) Extraction of instance features: For each instance (target) to be detected in the image, embodiments of the present invention can first utilize a shared feature extractor to extract uniform image features. Then, the network extracts the instance-specific feature vector from the shared feature map based on the location of the target instance (e.g., through a detection box or center point). This represents the unique information of that instance.

[0075] (2) Dynamic convolution kernel generation: In this embodiment of the invention, the instance feature vector obtained above can be input into a lightweight kernel generation module, which outputs a set of convolution kernel parameters: , in, These are convolution kernel parameters customized for the current instance; each instance has a different feature vector, so the convolution kernel parameters obtained for each instance are also completely different, reflecting the instance-aware characteristics of Dynamic Head.

[0076] (3) Dynamic prediction of instance masks: Finally, embodiments of the present invention can dynamically generate convolution kernels. Acting on the original shared feature map Above, we obtain the mask prediction for the instance: , It can be noted that the convolution operation here uses the dynamic convolution kernel generated in the previous step, so it is an instance-specific convolution operation. The predicted mask has higher instance specificity and clearer boundary information.

[0077] Furthermore, in response to the challenges of varying defect scales in drainage pipelines, requiring precise boundary segmentation and rapid detection, this invention introduces a Dynamic Head mechanism, which can significantly improve the precision of defect masks, detection speed, and generalization ability for diverse defects such as micro-cracks, thereby optimizing the overall system performance.

[0078] In actual implementation, embodiments of the present invention can introduce GWD Loss (Generalized Wasserstein Distance Loss) to improve localization and segmentation stability.

[0079] Specifically, GWD Loss is a novel bounding box regression loss function primarily used to address the bounding box regression problem in object detection. Unlike traditional bounding box losses such as IoU loss (Intersection over Union Loss) and GIoU loss (Generalized Intersection over Union Loss), its core idea is to treat the predicted and ground truth bounding boxes in object detection as two-dimensional Gaussian distributions. By calculating the Wasserstein distance between the two Gaussian distributions, the positional and scale differences between the predicted and ground truth boxes are quantified, thereby effectively improving the accuracy and stability of object localization.

[0080] The calculation process for GWD Loss can be as follows: (1) Gaussian representation of the bounding box: In GWD Loss, a bounding box is modeled as a two-dimensional Gaussian distribution. Specifically, for a rectangular bounding box, typically represented as: the center point position (x, y), the width and height (x, y), this rectangular bounding box is represented as a two-dimensional Gaussian distribution 𝒩(x, Σ), specifically defined as follows: mean (center position) Covariance matrix (bounding box size): , It can be noted that, in the embodiments of the present invention, width and height are used as the standard deviation of the distribution, taking into account the combined features of position and size information.

[0081] (2) Calculation of Gausswasserstein distance: Two Gaussian distributions (Prediction box) and The second-order Wassstein distance of the (real bounding box) can be expressed as: , in, The square of the Gauss-Wasserstein distance; It can reflect the distance difference between the center points of the predicted box and the ground truth box; tr(•) can reflect the scale difference between the predicted box and the ground truth box, and use the covariance matrix to reflect the differences in size and direction.

[0082] (2) Definition of GWD Loss: In actual training, for ease of optimization, the Wasserstein distance described above can be appropriately simplified in this embodiment of the invention. The commonly used form of the simplified GWD Loss can be expressed as: , The addition of a logarithmic function in this embodiment of the invention can ensure a smoother loss value, thereby stabilizing the optimization process.

[0083] In response to the characteristics of drainage pipe defects, such as varying scales, fine edges, and irregular shapes, this invention can accurately measure target differences using the Wasserstein distance of the Gaussian distribution GWD Loss. This can effectively improve the detection accuracy of minute defects and the ability to locate complex boundaries, thereby ensuring the stability of the training process.

[0084] As a concrete example, such as Figure 6 As shown, embodiments of the present invention can add an attention mechanism, improve the Dynamic Head detection head, and implement GWD Loss on the basis of the YOLOv11 one-stage model to construct a pipeline defect detection model, which may include: (1) Input stage: In an embodiment of the present invention, the input to the model can be a 640x640x3 image, i.e., an RGB image with a size of 640x640.

[0085] (2) Backbone network: In an embodiment of the invention, the input image is first processed through nine convolutional layers, including five CBS (Convolution + Batch Normalization + Sigmoid Linear Unit) layers and four C3K2 layers. Each CBS layer consists of one Conv (convolutional layer), one BN (Batch Normalization) layer, and a SiLU activation function. Each C3K2 layer contains two convolutional layers (cv1 and cv2) and multiple C3K layers (if C3K = FALSE, it is replaced with Bottleneck, which is the same as C2F). After each convolutional layer, a downsampling operation (with a stride of up to 2) is performed to gradually reduce the spatial size while preserving important image features. SPPF (Spatial Pyramid Pooling - Fast) and C2PSA (Point-wise Spatial Attention) further enhance feature extraction, and the output feature maps can be used for fusion and further feature extraction in the neck network.

[0086] (3) Backbone network improvement: In this embodiment of the invention, the C2PSA technical solution can be replaced with SK. Convolutional branches with different kernel sizes are applied to the same feature map, and finally, the most suitable branch output is adaptively "selected" through learnable weights, thus taking into account both local details and global contextual information within the same network. Simply put, SK attention is equivalent to preparing multiple parallel "paths" for the same input feature map, each path corresponding to a different convolutional kernel, and the network can dynamically fuse the outputs of these paths according to the characteristics of the input.

[0087] (4) Neck network: After feature extraction from the backbone network, this embodiment of the invention can proceed to the neck network section. In this section, the network fuses features at different scales. The "Concat" operation concatenates feature maps of different scales, while "Upsample" upsamples the feature maps to restore their size to a higher resolution. This part helps to fuse features at different levels, improving the model's ability to detect small objects.

[0088] (5) Detection head: The final part of the network is the detection head. This embodiment of the invention can introduce a Dynamic Head detection head and a GWD loss function. The Dynamic Head can extract instance features to generate a dedicated dynamic convolution kernel, which is then applied to a shared feature map to achieve instance mask prediction, accurately segmenting drainage pipe defects while ensuring detection efficiency. The GWD loss function treats the predicted and ground truth bounding boxes as a two-dimensional Gaussian distribution, quantizing the difference by calculating the Wasserstein distance to improve target localization accuracy and stability. Compared to IoU, GIoU, and other losses, it has more stable convergence, richer gradient information, and more accurate localization of targets with small overlap or large scale differences. It can also effectively reduce errors caused by changes in target size and angle.

[0089] The pipeline defect detection model constructed in this embodiment of the invention can extract features at multiple levels, fuse features at different scales, and optimize the loss function, which can effectively improve the performance of drainage pipeline defect detection.

[0090] In step S103, the initial pipeline defect detection model is trained using a sample library to construct the final pipeline defect detection model. The image data of the pipeline to be detected is then input into the final pipeline defect detection model to output the pipeline defect detection result.

[0091] In this embodiment of the invention, the sample library can be divided into a training set, a test set, and a validation set in an 8:1:1 ratio. The training set (80%) can be used for model parameter learning; the test set (10%) can be used to monitor overfitting / underfitting during the training process; and the validation set (10%) can be used to finally evaluate the generalization ability of the model to ensure that it has practical deployment value.

[0092] Optionally, in one embodiment of the present invention, the initial pipeline defect detection model is trained using a sample library to construct a final pipeline defect detection model, including: determining the training objective and evaluation index; determining the training loss curve based on the objective and evaluation index and according to a preset multi-loss joint optimization strategy; and training the initial pipeline defect detection model using the sample library according to a preset training round until the loss curve meets a preset descent condition to obtain the final pipeline defect detection model.

[0093] The training objectives can include improving the instance segmentation performance of 16 types of defects in drainage pipes, optimizing defect localization accuracy, and contour segmentation accuracy; the evaluation metrics can include mAP association precision and recall.

[0094] The preset training rounds can be 50 or 100.

[0095] The preset descent condition can be that the loss curve continues to decrease and tends to stabilize during model training, or the loss value is less than a certain threshold, or the decrease is less than a set proportion for several consecutive rounds, in which case the loss curve is considered to meet the preset descent condition.

[0096] The training objectives, evaluation indicators, preset training rounds, and preset descent conditions can all be set by those skilled in the art according to the actual situation, and no specific restrictions are imposed here.

[0097] The pre-defined multi-loss joint optimization strategy can adopt a weighted combination of various loss functions, including but not limited to bounding box regression loss, classification loss, segmentation loss, and distribution focus loss. By jointly constraining different task objectives, it can achieve synergistic optimization of feature extraction and detection accuracy.

[0098] As one possible approach, embodiments of the present invention can optimize the pipeline defect detection model, also known as the Sewer-YOLO (Sewer YOLO Detection Model), based on a sample library, throughout the entire process. The effectiveness of the model is then verified using core metrics such as loss curves, confusion matrices, and mAP, ultimately resulting in a trained model with stable performance and satisfactory accuracy. The specific steps are as follows: (1) Model training: Iterative optimization of parameters based on the training set.

[0099] To ensure the model can fully learn the characteristics of pipeline defects and avoid overfitting, the training environment and hyperparameter settings should be clearly defined, as follows: 1) Hardware environment: The processor is an Intel Core i5-13400F CPU (Central Processing Unit), and the graphics card is an NVIDIA GeForce RTX 4090 (accelerated by CUDA (Compute Unified Device Architecture) 12.6), which meets the requirements for parallel computing of large batches of data, and the training time for a single round is controlled within 25 minutes; 2) Software environment: Python 3.10 + PyTorch 2.6.0 deep learning framework, using GPU (Graphics Processing Unit) to accelerate data loading and backpropagation, with the number of data loading threads (workers) set to 8 to avoid IO (Input / Output) bottlenecks; 3) Core hyperparameters: number of training epochs = 50, batch size = 16, input image size (imgsz(Image Size)) = 640×640, initial learning rate = 1e-4, optimizer is AdamW (Adaptive Moment Estimation with Weight Decay).

[0100] (2) Model evaluation index system: To comprehensively and objectively evaluate the detection performance of the Sewer-YOLO model, embodiments of the present invention can construct a multi-dimensional evaluation index system covering classification accuracy, localization accuracy, segmentation accuracy, and overall performance.

[0101] Basic classification metrics may include, but are not limited to, precision, recall, and F1 score. Precision can be calculated using the formula... Recall reflects the proportion of true defects among samples predicted as defects by the model, where TP represents the true positive class and FP represents the false positive class; recall can be expressed by the formula... The calculation measures the model's ability to detect real defects, where FN represents the false negative class; the F1 score, as the harmonic mean of the two, can be calculated using the formula... The calculation comprehensively balances precision and recall to avoid the one-sidedness of evaluating a single indicator.

[0102] like Figure 7 As shown, the confusion matrix can be used to visually display the model's classification results for various defects. The higher the value of the diagonal elements (TP, TN), the stronger the model's classification accuracy for the corresponding category of defects. The off-diagonal elements can reflect the misclassification between categories and can quickly locate the defect types that the model is weak in classifying (such as misaligned or disjointed shapes).

[0103] It can be noted that the precision-recall curve and the F1 score-confidence curve can be used to analyze the performance of the model at different confidence thresholds. The closer the former curve is to the upper right corner and the larger the area under the curve, the stronger the model's overall classification and detection capabilities. The longer the stable segment of the latter curve, the lower the model's sensitivity to the confidence threshold, and the more stable the detection can be without frequent threshold adjustments during actual deployment.

[0104] In an embodiment of the present invention, the core comprehensive index can be mAP@0.5 (the average precision when the IoU threshold is 0.5), and its calculation process can be expressed as follows: First, through the formula Calculate the intersection-union ratio (IU / R) to determine if the predicted bounding box is correct; then sort the prediction results in descending order of confidence level, calculate precision and recall point by point, and plot the PR curve; then obtain the average precision (AP) for each category by the area under the PR curve; finally, use the formula... Calculate mAP, where N is the total number of defect categories; this metric can comprehensively reflect the model's detection accuracy for multiple types of defects and is the core standard for evaluating target detection and instance segmentation models in academia and industry.

[0105] (3) Loss optimization analysis during the training and validation phases: In embodiments of the present invention, during the training phase, the model's feature learning performance and optimization trend can be evaluated by real-time monitoring of four core losses on the training and validation sets: box_loss (Bounding Box Loss), seg_loss (Segmentation Loss), cls_loss (Classification Loss), and dfl_loss (DistributionFocal Loss).

[0106] like Figure 8 As shown, all four loss curves exhibit a smooth decreasing trend with increasing training epochs: box_loss decreases from the initial 3.0 to below 0.5, verifying the effectiveness of GWD Loss in optimizing bounding box regression through Gaussian Wasserstein distance, and the model's accuracy in locating defect locations continuously improves; seg_loss (segmentation loss) decreases from the initial 5.5 to below 1.0, reflecting the optimization effect of Dynamic Head's "dynamically generated convolutional kernel" on defect contour segmentation, significantly improving pixel-level segmentation accuracy; cls_loss (classification loss) decreases from the initial 5.1 to below 0.5, indicating that the model's ability to distinguish 16 types of defects (especially low-frequency defects such as undulations) is enhanced through class weight optimization; dfl_loss decreases from the initial 3.8 to below 1.0, proving that the SK attention mechanism's "multi-scale feature adaptive selection" can effectively improve the model's prediction accuracy for defect scale distribution.

[0107] like Figure 9 As shown, the loss curve of the validation set is highly consistent with the trend of the training set. Finally, the difference between the losses of the four classes is ≤0.5, which indicates that the model does not have overfitting (the loss of the training set is much lower than that of the validation set) or underfitting (the loss of both classes is high), and has a good foundation for generalization ability.

[0108] (4) Test set metrics and final model selection: In an embodiment of the present invention, the test set (1075 images) is a sample completely independent of the training / validation set, used to simulate real detection scenarios and unbiasedly evaluate the model's generalization ability.

[0109] like Figure 10 As shown, the core metric mAP@0.5 indicates that the original YOLO11 model achieved 87.6% mAP@0.5 on the test set, while the improved Sewer-YOLO model improved to 91.0%, an increase of 3.4 percentage points. Specifically, adding the SK attention mechanism alone increased mAP by 0.9 percentage points (87.6% → 88.5%), and adding DynamicHead alone increased it by 2.2 percentage points (87.6% → 89.8%). Figure 11 As shown, adding GWD Loss further increases the performance by 0.2 percentage points (90.8% → 91.0%), which verifies the synergistic effect of the three optimization parameters.

[0110] like Figure 12 , Figure 13 As shown in the F1-Confidence (F1 Score based on Confidence) curves before and after the improvement, a significant improvement in overall performance can be observed. Before the improvement, the model's peak F1 score was 0.85; after the improvement, the peak F1 score reached 0.89. This change not only reflects the optimization of the model in terms of accuracy and recall, but also indicates that the model's ability to identify different categories has been enhanced. With the improvement in the F1 score, the model can better achieve accurate classification and detection when dealing with various defects or anomalies, reducing false positives and false negatives. The improved model demonstrates stronger robustness and generalization ability when dealing with complex data, especially when handling marginal cases or samples with ambiguous categories.

[0111] (5) Summary of model usefulness and effectiveness: like Figure 14As shown, this embodiment of the invention optimizes the entire process of "training-verification-testing," resulting in a Sewer-YOLO model with three core values: First, high-precision detection, achieving 91.0% mAP@0.5 on the test set, accurately identifying complex defects such as micro-cracks and irregular corrosion, meeting the needs of quantitative maintenance assessment; second, high robustness, with enhanced illumination and multi-scale feature learning, maintaining F1≥0.85 even in low-light, equipment vibration, and background interference scenarios, addressing the pain point of traditional models' environmental sensitivity; and third, high practicality, with a small model size and fast inference (≥15fps on embedded devices), allowing direct deployment on pipeline robots to achieve integrated "on-site detection-real-time feedback-defect annotation," improving manual inspection efficiency and significantly reducing pipeline maintenance costs.

[0112] The pipeline defect detection method based on YOLOv11 proposed in this embodiment of the invention introduces a preset attention mechanism and an improved detection head on the basis of a preset one-stage YOLOv11 model to construct an initial pipeline defect detection model. This initial model is then trained using a constructed pipeline defect sample library to obtain the final pipeline defect detection model. Through multi-branch parallel feature extraction and fusion processing, it adaptively integrates multi-scale information without the need for manually designing complex multi-scale structures, thereby effectively improving the model's adaptability. Simultaneously, it can better capture instance-level detailed features, significantly improving the precision of the defect mask and meeting the requirements for accurate segmentation of complex boundary defects. Furthermore, it can enhance the detection capability for small-scale defects, greatly improving the detection efficiency and accuracy of pipeline inspections, reducing engineering inspection costs, and significantly enhancing the model's environmental adaptability and detection robustness under different lighting conditions, contaminant occlusion, and complex scenarios.

[0113] Next, referring to the accompanying drawings, a pipeline defect detection device based on YOLOv11 proposed according to an embodiment of the present invention is described.

[0114] Figure 15 This is a block diagram of a pipeline defect detection device based on YOLOv11 according to an embodiment of the present invention.

[0115] like Figure 15 As shown, the YOLOv11-based pipeline defect detection device 10 includes: an acquisition module 100, a construction module 200, and a detection module 300.

[0116] The acquisition module 100 is used to acquire image data of drainage pipes, annotate pipe defects in the image data, determine defect information, obtain annotated pipe defect image data, and construct a pipe defect sample library using the annotated pipe defect image data.

[0117] Module 200 is used to add a preset attention mechanism and a preset detection head to the preset YOLOv11 one-stage model in order to construct a loss function for detecting pipeline defects, and to construct an initial pipeline defect detection model based on the loss function.

[0118] The detection module 300 is used to train the initial pipeline defect detection model using a sample library to build the final pipeline defect detection model, and to input the image data of the pipeline to be detected into the final pipeline defect detection model to output the pipeline defect detection result.

[0119] Optionally, in one embodiment of the present invention, the acquisition module 100 includes: a collection unit, an extraction unit, and a labeling unit.

[0120] The acquisition unit is used to collect pipeline defect features under different climate and environmental conditions to generate an initial image dataset of the drainage pipeline.

[0121] An extraction unit is used to extract at least one static image from the initial image dataset that meets preset representative conditions, so as to generate image data based on at least one static image.

[0122] The annotation unit is used to perform instance segmentation annotation on each image in the image data, mark the location of defect information and depict the outline of defect information to obtain annotated pipeline defect image data.

[0123] Optionally, in one embodiment of the present invention, the acquisition module 100 includes a processing unit and a construction unit.

[0124] The processing unit is used to perform data enhancement processing on the labeled pipeline defect image data to obtain image data that meets the preset processing conditions.

[0125] The building unit is used to construct a pipeline defect sample library using image data.

[0126] Optionally, in one embodiment of the present invention, it further includes: a first determining module and a second determining module.

[0127] The first determining module is used to determine the selective convolution kernel attention mechanism and generate a preset attention mechanism based on the selective convolution kernel attention mechanism.

[0128] The second determining module is used to obtain the preset detection head from the dynamic detection head.

[0129] Optionally, in one embodiment of the present invention, the detection module 300 includes: a first determining unit, a second determining unit, and a training unit.

[0130] The first determining unit is used to determine the training objectives and evaluation metrics.

[0131] The second determining unit is used to determine the training loss curve based on the target and evaluation indicators, according to a preset multi-loss joint optimization strategy.

[0132] The training unit is used to train the initial pipeline defect detection model using a sample library according to a preset training round until the loss curve meets the preset descent condition, thus obtaining the final pipeline defect detection model.

[0133] It should be noted that the foregoing explanation of the embodiment of the pipeline defect detection method based on YOLOv11 also applies to the pipeline defect detection device 10 based on YOLOv11 in this embodiment, and will not be repeated here.

[0134] The pipeline defect detection device based on YOLOv11 proposed in this embodiment of the invention introduces a preset attention mechanism and an improved detection head on the basis of a preset YOLOv11 one-stage model to construct an initial pipeline defect detection model. This initial model is then trained using a constructed pipeline defect sample library to obtain the final pipeline defect detection model. Through multi-branch parallel feature extraction and fusion processing, it adaptively integrates multi-scale information without the need for manually designing complex multi-scale structures, thereby effectively improving the model's adaptability. Simultaneously, it can better capture instance-level detailed features, significantly improving the precision of the defect mask and meeting the requirements for accurate segmentation of complex boundary defects. Furthermore, it can enhance the detection capability for small-scale defects, greatly improving the detection efficiency and accuracy of pipeline inspections, reducing engineering inspection costs, and significantly enhancing the model's environmental adaptability and detection robustness under different lighting conditions, contaminant occlusion, and complex scenarios.

[0135] Figure 16 This is a schematic diagram of an electronic device provided in an embodiment of the present invention. The electronic device may include: The memory 1601, the processor 1602, and the computer program stored on the memory 1601 and executable on the processor 1602.

[0136] When the processor 1602 executes the program, it implements the pipeline defect detection method based on YOLOv11 provided in the above embodiments.

[0137] Furthermore, electronic devices also include: Communication interface 1603 is used for communication between memory 1601 and processor 1602.

[0138] The memory 1601 is used to store computer programs that can run on the processor 1602.

[0139] The memory 1601 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.

[0140] If the memory 1601, processor 1602, and communication interface 1603 are implemented independently, then the communication interface 1603, memory 1601, and processor 1602 can be interconnected via a bus to complete communication between them. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be divided into address buses, data buses, control buses, etc. For ease of representation, Figure 16 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0141] Optionally, in a specific implementation, if the memory 1601, processor 1602, and communication interface 1603 are integrated on a single chip, then the memory 1601, processor 1602, and communication interface 1603 can communicate with each other through an internal interface.

[0142] The processor 1602 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention.

[0143] This embodiment also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described pipeline defect detection method based on YOLOv11.

[0144] This invention also provides a computer program product, including a computer program that can run computer instructions. When these computer instructions are executed by a processor, they implement the YOLOv11-based pipeline defect detection method provided in this invention.

[0145] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.

[0146] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this invention, "N" means at least two, such as two, three, etc., unless otherwise explicitly specified.

[0147] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or N executable instructions for implementing custom logic functions or processes, and the scope of preferred embodiments of the invention includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as will be understood by those skilled in the art to which embodiments of the invention pertain.

[0148] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Alternatively, the computer-readable medium may be paper or other suitable media on which the program can be printed, since the program can be obtained electronically by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.

[0149] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, the N steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. If implemented in hardware, as in another embodiment, it can be implemented using any one or more of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0150] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.

[0151] Furthermore, the functional units in the various embodiments of the present invention can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.

[0152] The storage medium mentioned above can be a read-only memory, a disk, or an optical disk, etc. Although embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present invention.

Claims

1. A pipeline defect detection method based on YOLOv11, characterized in that, Includes the following steps: Image data of drainage pipes is acquired, and pipe defects in the image data are annotated to determine defect information, so as to obtain annotated pipe defect image data, and a pipe defect sample library is constructed using the annotated pipe defect image data. Based on the preset YOLOv11 one-stage model, a preset attention mechanism and a preset detection head are added to construct a loss function for detecting pipeline defects, and an initial pipeline defect detection model is constructed based on the loss function. The initial pipeline defect detection model is trained using the sample library to construct a final pipeline defect detection model. Image data of the pipeline to be detected is then input into the final pipeline defect detection model to output pipeline defect detection results.

2. The method according to claim 1, characterized in that, The process of acquiring image data of the drainage pipe and annotating pipe defects in the image data to determine defect information, in order to obtain annotated pipe defect image data, includes: Collect pipeline defect features under different climate and environmental conditions to generate an initial image dataset of the drainage pipeline; Extract at least one static image from the initial image dataset that meets the preset representative conditions, and generate the image data based on the at least one static image; Each image in the image data is segmented and labeled to mark the location of the defect information and depict the outline of the defect information, so as to obtain the labeled pipeline defect image data.

3. The method according to claim 1, characterized in that, The construction of a pipeline defect sample library using the labeled pipeline defect image data includes: The labeled pipeline defect image data is subjected to data augmentation processing to obtain image data that meets the preset processing conditions; The pipeline defect sample library is constructed using the image data.

4. The method according to claim 1, characterized in that, Before incorporating the preset attention mechanism and the preset detection head, the following is also included: Determine the selective convolution kernel attention mechanism, and generate the preset attention mechanism based on the selective convolution kernel attention mechanism; The preset detection head is obtained from the dynamic detection head.

5. The method according to claim 1, characterized in that, The step of training the initial pipeline defect detection model using the sample library to construct the final pipeline defect detection model includes: Define the training objectives and evaluation metrics; Based on the objective and the evaluation metric, the training loss curve is determined according to a preset multi-loss joint optimization strategy; The initial pipeline defect detection model is trained using the sample library according to the preset training rounds until the loss curve meets the preset descent condition, thus obtaining the final pipeline defect detection model.

6. A pipeline defect detection device based on YOLOv11, characterized in that, include: The acquisition module is used to acquire image data of drainage pipes, and to annotate the pipe defects in the image data to determine the defect information, so as to obtain annotated pipe defect image data, and to construct a pipe defect sample library using the annotated pipe defect image data. The construction module is used to add a preset attention mechanism and a preset detection head to the preset YOLOv11 one-stage model to construct a loss function for detecting pipeline defects, and to construct an initial pipeline defect detection model based on the loss function. The detection module is used to train the initial pipeline defect detection model using the sample library to construct the final pipeline defect detection model, and to input the image data of the pipeline to be detected into the final pipeline defect detection model to output the pipeline defect detection result.

7. The apparatus according to claim 6, characterized in that, The acquisition module includes: The acquisition unit is used to acquire pipeline defect features under different climate and environmental conditions to generate an initial image dataset of the drainage pipeline. An extraction unit is used to extract at least one static image from the initial image dataset that meets a preset representative condition, so as to generate the image data based on the at least one static image; The annotation unit is used to perform instance segmentation annotation on each image in the image data, mark the location of the defect information and depict the outline of the defect information to obtain the annotated pipeline defect image data.

8. An electronic device, characterized in that, include: The memory, the processor, and the computer program stored in the memory and executable on the processor, the processor executing the program to implement the YOLOv11-based pipeline defect detection method as described in any one of claims 1-5.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, The program is executed by the processor to implement the YOLOv11-based pipeline defect detection method as described in any one of claims 1-5.

10. A computer program product, comprising a computer program, characterized in that, The computer program is executed to implement the YOLOv11-based pipeline defect detection method as described in any one of claims 1-5.