<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE article PUBLIC "-//NLM//DTD Journal Publishing DTD v3.0 20080202//EN" "http://dtd.nlm.nih.gov/publishing/3.0/journalpublishing3.dtd">
<article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="3.0" xml:lang="en" article-type="research article">
 <front>
  <journal-meta>
   <journal-id journal-id-type="publisher-id">
    ojapps
   </journal-id>
   <journal-title-group>
    <journal-title>
     Open Journal of Applied Sciences
    </journal-title>
   </journal-title-group>
   <issn pub-type="epub">
    2165-3917
   </issn>
   <issn publication-format="print">
    2165-3925
   </issn>
   <publisher>
    <publisher-name>
     Scientific Research Publishing
    </publisher-name>
   </publisher>
  </journal-meta>
  <article-meta>
   <article-id pub-id-type="doi">
    10.4236/ojapps.2025.159168
   </article-id>
   <article-id pub-id-type="publisher-id">
    ojapps-145311
   </article-id>
   <article-categories>
    <subj-group subj-group-type="heading">
     <subject>
      Articles
     </subject>
    </subj-group>
    <subj-group subj-group-type="Discipline-v2">
     <subject>
      Biomedical 
     </subject>
     <subject>
       Life Sciences, Chemistry 
     </subject>
     <subject>
       Materials Science, Computer Science 
     </subject>
     <subject>
       Communications, Engineering, Physics 
     </subject>
     <subject>
       Mathematics
     </subject>
    </subj-group>
   </article-categories>
   <title-group>
    PE Gas Pipeline Defect Detection Method Based on YOLOv7 Algorithm
   </title-group>
   <contrib-group>
    <contrib contrib-type="author" xlink:type="simple">
     <name name-style="western">
      <surname>
       Junli
      </surname>
      <given-names>
       Wang
      </given-names>
     </name> 
     <xref ref-type="aff" rid="aff1"> 
      <sup>1</sup>
     </xref>
    </contrib>
    <contrib contrib-type="author" xlink:type="simple">
     <name name-style="western">
      <surname>
       Li
      </surname>
      <given-names>
       Wang
      </given-names>
     </name> 
     <xref ref-type="aff" rid="aff1"> 
      <sup>1</sup>
     </xref>
    </contrib>
    <contrib contrib-type="author" xlink:type="simple">
     <name name-style="western">
      <surname>
       Yang
      </surname>
      <given-names>
       Wang
      </given-names>
     </name> 
     <xref ref-type="aff" rid="aff2"> 
      <sup>2</sup>
     </xref>
    </contrib>
   </contrib-group> 
   <aff id="aff1">
    <addr-line>
     aXi’an Xicai Sanchuan Intelligent Manufacturing Co., Ltd., Xi’an, China
    </addr-line> 
   </aff> 
   <aff id="aff2">
    <addr-line>
     aSchool of Mechanical Engineering, Xinjiang University, Urumqi, China
    </addr-line> 
   </aff> 
   <pub-date pub-type="epub">
    <day>
     01
    </day> 
    <month>
     09
    </month>
    <year>
     2025
    </year>
   </pub-date> 
   <volume>
    15
   </volume> 
   <issue>
    09
   </issue>
   <fpage>
    2535
   </fpage>
   <lpage>
    2544
   </lpage>
   <history>
    <date date-type="received">
     <day>
      14,
     </day>
     <month>
      August
     </month>
     <year>
      2025
     </year>
    </date>
    <date date-type="published">
     <day>
      29,
     </day>
     <month>
      August
     </month>
     <year>
      2025
     </year> 
    </date> 
    <date date-type="accepted">
     <day>
      29,
     </day>
     <month>
      August
     </month>
     <year>
      2025
     </year> 
    </date>
   </history>
   <permissions>
    <copyright-statement>
     © Copyright 2014 by authors and Scientific Research Publishing Inc. 
    </copyright-statement>
    <copyright-year>
     2014
    </copyright-year>
    <license>
     <license-p>
      This work is licensed under the Creative Commons Attribution International License (CC BY). http://creativecommons.org/licenses/by/4.0/
     </license-p>
    </license>
   </permissions>
   <abstract>
    Regular pipeline inspections are crucial for timely identification of critical defects and ensuring pipeline integrity. To address the challenges of detecting defects in PE gas pipelines under low illumination and low-resolution conditions, this paper proposes a defect detection method based on the YOLOv7 algorithm. This approach significantly improves the accuracy of defect detection and classification.
   </abstract>
   <kwd-group> 
    <kwd>
     Image Enhancement
    </kwd> 
    <kwd>
      Defect Detection
    </kwd> 
    <kwd>
      YOLOv7 Algorithm
    </kwd>
   </kwd-group>
  </article-meta>
 </front>
 <body>
  <sec id="s1">
   <title>1. Introduction</title>
   <p>YOLOv7 is an advanced deep learning algorithm for object detection, representing an improved version of the YOLO (You Only Look Once) series. Utilizing an end-to-end training approach based on deep convolutional neural networks, YOLOv7 processes the entire image as input and performs object detection directly within a single network, eliminating the need for complex Region Proposal Networks (RPN). This architecture gives YOLOv7 significant speed advantages, enabling real-time object detection.</p>
   <p>The backbone network typically employs popular architectures such as Darknet, ResNet, or CSPDarknet for feature extraction. The detection head outputs bounding box coordinates, class information, and confidence scores. Compared to previous versions, YOLOv7 incorporates enhancements in training strategies, data augmentation, and loss function design to improve model accuracy and robustness. Additionally, YOLOv7 introduces novel techniques including automatic mixed-precision training and model ensemble methods to further boost performance.</p>
  </sec><sec id="s2">
   <title>2. Image Preprocessing</title>
   <p>Pipeline image preprocessing not only reduces noise but also enhances the contrast between pipeline backgrounds and defects, enabling more effective defect identification and classification. The image preprocessing workflow in this study is illustrated in <xref ref-type="fig" rid="fig1">
     Figure 1
    </xref>.</p>
   <p>Image Processing Workflow:</p>
   <fig id="fig1" position="float">
    <label>Figure 1</label>
    <caption>
     <title>
      <xref ref-type="bibr" rid="scirp.145311-"></xref>Figure 1. Image preprocessing pipeline.</title>
    </caption>
    <graphic mimetype="image" position="float" xlink:type="simple" xlink:href="https://html.scirp.org/file/2313350-rId13.jpeg?20250901105252" />
   </fig>
  </sec><sec id="s3">
   <title>3. Acquisition of Defect Images</title>
   <p>Defects account for a very low proportion in the entire PE pipeline system. Therefore, to improve detection efficiency, we first need to screen out images with defects. Through comparative analysis of the collected PE gas pipeline images, it was found that defect-free images to be inspected exhibit uniform grayscale distribution between two adjacent images. If there is a significant grayscale variation between adjacent images, defects are likely present.</p>
   <fig id="fig2" position="float">
    <label>Figure 2</label>
    <caption>
     <title>
      <xref ref-type="bibr" rid="scirp.145311-"></xref>Figure 2. Comparison of grayscale conversion effects.</title>
    </caption>
    <graphic mimetype="image" position="float" xlink:type="simple" xlink:href="https://html.scirp.org/file/2313350-rId14.jpeg?20250901105253" />
   </fig>
   <p>The flowchart of the preliminary screening algorithm for PE gas pipeline defects is shown in <xref ref-type="fig" rid="fig2">
     Figure 2
    </xref>. First, any two adjacent internal pipeline images, x and y, are read from the database, and the grayscale difference Δ between corresponding pixel points in image x and image y is calculated. The calculation formula is as shown in Formula (1).</p>
   <p>
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <mi>
        Δ 
      </mi> 
      <mo>
        = 
      </mo> 
      <mrow> 
       <mo>
         | 
       </mo> 
       <mrow> 
        <msub> 
         <mi>
           X 
         </mi> 
         <mn>
           1 
         </mn> 
        </msub> 
        <mo>
          − 
        </mo> 
        <msub> 
         <mi>
           Y 
         </mi> 
         <mn>
           1 
         </mn> 
        </msub> 
       </mrow> 
       <mo>
         | 
       </mo> 
      </mrow> 
     </mrow> 
    </math> (1)</p>
   <p>Due to data loss during image acquisition and transmission, the grayscale difference Δ between two adjacent images may become excessively large, which can easily lead to misjudgment by the system. To reduce the false detection rate, this paper replaces the grayscale difference Δ between two points with the average grayscale difference of all pixels within a specified region (Formula (2)).</p>
   <p>
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <mover accent="true"> 
       <mi>
         Δ 
       </mi> 
       <mo>
         ¯ 
       </mo> 
      </mover> 
      <mo>
        = 
      </mo> 
      <mfrac> 
       <mn>
         1 
       </mn> 
       <mrow> 
        <msub> 
         <mi>
           S 
         </mi> 
         <mi>
           n 
         </mi> 
        </msub> 
       </mrow> 
      </mfrac> 
      <mstyle displaystyle="true"> 
       <msubsup> 
        <mo>
          ∑ 
        </mo> 
        <mrow> 
         <mi>
           k 
         </mi> 
         <mo>
           = 
         </mo> 
         <mn>
           1 
         </mn> 
        </mrow> 
        <mi>
          n 
        </mi> 
       </msubsup> 
       <mrow> 
        <mrow> 
         <mo>
           | 
         </mo> 
         <mrow> 
          <msub> 
           <mi>
             x 
           </mi> 
           <mi>
             k 
           </mi> 
          </msub> 
          <mo>
            − 
          </mo> 
          <msub> 
           <mi>
             y 
           </mi> 
           <mi>
             k 
           </mi> 
          </msub> 
         </mrow> 
         <mo>
           | 
         </mo> 
        </mrow> 
       </mrow> 
      </mstyle> 
     </mrow> 
    </math> (2)</p>
   <p>To further reduce the false detection rate, statistical methods can be employed. First, calculate the minimum grayscale difference between abnormal images and normal pipeline images within a specified region. Then, compute the pixel count M corresponding to the smallest area of the abnormal portion in the abnormal images. Setting the difference threshold slightly smaller than the calculated original value can effectively reduce the probability of image misclassification. Using Formula (2), the average grayscale difference Δ of all pixels within the specified region of the two images is calculated, and the number of pixels meeting the condition is recorded. If [condition], output B1 as normal; otherwise, output B. If [condition], it is determined that defects exist in [images]; otherwise, the images are considered normal.</p>
   <p>The above initial defect screening algorithm was applied to screen 10,000 consecutively captured internal pipeline images. Among them, 163 images contained defects, and after processing by the screening algorithm, 161 defective images were selected. The screening accuracy reached 98.7%. Thus, this screening algorithm achieves excellent results.</p>
  </sec><sec id="s4">
   <title>4. Grayscale Processing of Defect Images</title>
   <p>Grayscale is an important feature that characterizes the brightness and darkness of an image. Color images can be converted to grayscale using weighted algorithms as needed. In recent years, it has been applied in image segmentation, target recognition, and machine vision technologies based on grayscale differences and discontinuous variations in images. Compared to color images, grayscale images occupy less memory and allow for faster computational processing. Grayscale conversion can also enhance visual contrast, making the target areas more prominent.</p>
   <p>There are three common methods for converting color images to grayscale: the Maximum Value Method, the Average Method, and the Weighted Average Method. Maximum Value Method: This method directly takes the highest value among the R, G, and B components (where 0 is the minimum and 255 is the maximum):</p>
   <p>R = G = B = max(R, G, B) (3)</p>
   <p>The effect is shown in <xref ref-type="fig" rid="fig2B">
     Figure 2B
    </xref>.</p>
   <p>Average Method:</p>
   <p>This method takes the arithmetic mean of the R, G, and B components:</p>
   <p>R = G = B = (R + G + B)/3 (4)</p>
   <p>The effect is shown in <xref ref-type="fig" rid="fig2C">
     Figure 2C
    </xref>.</p>
   <p>Weighted Average Method:</p>
   <p>This method applies different weights to R, G, and B based on human eye sensitivity to each color, resulting in a weighted average:</p>
   <p>
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <mi>
        I 
      </mi> 
      <mrow> 
       <mo>
         ( 
       </mo> 
       <mrow> 
        <mi>
          x 
        </mi> 
        <mo>
          , 
        </mo> 
        <mi>
          y 
        </mi> 
       </mrow> 
       <mo>
         ) 
       </mo> 
      </mrow> 
      <mo>
        = 
      </mo> 
      <mn>
        0.3 
      </mn> 
      <mo>
        ∗ 
      </mo> 
      <msub> 
       <mi>
         I 
       </mi> 
       <mi>
         R 
       </mi> 
      </msub> 
      <mrow> 
       <mo>
         ( 
       </mo> 
       <mrow> 
        <mi>
          x 
        </mi> 
        <mo>
          , 
        </mo> 
        <mi>
          y 
        </mi> 
       </mrow> 
       <mo>
         ) 
       </mo> 
      </mrow> 
      <mo>
        + 
      </mo> 
      <mn>
        0.59 
      </mn> 
      <mo>
        ∗ 
      </mo> 
      <msub> 
       <mi>
         I 
       </mi> 
       <mi>
         G 
       </mi> 
      </msub> 
      <mrow> 
       <mo>
         ( 
       </mo> 
       <mrow> 
        <mi>
          x 
        </mi> 
        <mo>
          , 
        </mo> 
        <mi>
          y 
        </mi> 
       </mrow> 
       <mo>
         ) 
       </mo> 
      </mrow> 
      <mo>
        + 
      </mo> 
      <mn>
        0.11 
      </mn> 
      <mo>
        ∗ 
      </mo> 
      <msub> 
       <mi>
         I 
       </mi> 
       <mi>
         B 
       </mi> 
      </msub> 
      <mrow> 
       <mo>
         ( 
       </mo> 
       <mrow> 
        <mi>
          x 
        </mi> 
        <mo>
          , 
        </mo> 
        <mi>
          y 
        </mi> 
       </mrow> 
       <mo>
         ) 
       </mo> 
      </mrow> 
     </mrow> 
    </math> (5)</p>
   <p>Here, I(x, y) represents the grayscale value at coordinates (x, y). while 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <msub> 
       <mi>
         I 
       </mi> 
       <mi>
         R 
       </mi> 
      </msub> 
     </mrow> 
    </math>(x, y), 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <msub> 
       <mi>
         I 
       </mi> 
       <mi>
         G 
       </mi> 
      </msub> 
     </mrow> 
    </math>(x, y) and 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <msub> 
       <mi>
         I 
       </mi> 
       <mi>
         B 
       </mi> 
      </msub> 
     </mrow> 
    </math>(x, y) denote the brightness values of the three color components. The effect is shown in <xref ref-type="fig" rid="fig2D">
     Figure 2D
    </xref>.</p>
   <p>The above grayscale methods were applied to process three types of defects: cracks, holes, and fractures. From <xref ref-type="fig" rid="fig2">
     Figure 2
    </xref>, it can be observed that:</p>
   <p>The Maximum Value Method produces overly bright grayscale images.</p>
   <p>The Average Method generates softer and darker grayscale images.</p>
   <p>The Weighted Average Method yields the best results, with appropriate brightness and enhanced contrast in darker areas, without obscuring the defect features of the pipeline.</p>
   <p>Therefore, the Weighted Average Method was selected for image grayscale conversion.</p>
  </sec><sec id="s5">
   <title>5. Image Enhancement for Pipeline Defects</title>
   <p>Image enhancement refers to a series of techniques aimed at improving image display quality or transforming images into a form more suitable for machine processing. These methods can highlight edges and important texture features, remove noise, and suppress irrelevant regions, thereby enhancing visual quality or emphasizing “useful” information while compressing “unnecessary” details. This makes the image more suitable for human or computer analysis. Common image enhancement techniques include: Global Histogram Equalization (<xref ref-type="fig" rid="fig3B">
     Figure 3B
    </xref>), Adaptive Histogram Equalization (<xref ref-type="fig" rid="fig3C">
     Figure 3C
    </xref>), Gamma Correction (<xref ref-type="fig" rid="fig3D">
     Figure 3D
    </xref>).</p>
   <p>From <xref ref-type="fig" rid="fig3">
     Figure 3
    </xref>, it can be observed that Gamma correction produces defect images without distortion. Additionally, defect edges are more pronounced, with greater contrast against the background, resulting in clearer visibility. Gamma correction is primarily used for image adjustment, correcting images that are either too bright or too dark while enhancing contrast. Therefore, this study employs Gamma correction to improve the contrast between the pipeline background and defects <xref ref-type="bibr" rid="scirp.145311-1">
     [1]
    </xref>-<xref ref-type="bibr" rid="scirp.145311-7">
     [7]
    </xref>.</p>
  </sec><sec id="s6">
   <title>6. Image Filtering and Denoising for Pipeline Defects</title>
   <p>During image transmission, environmental interference or equipment limitations often introduce noise into the received images, resulting in blurring and other distortions. Image denoising is a classic image restoration task aimed at predicting clean images from noisy observations. Traditional image filtering methods can be broadly categorized into two types: Spatial Domain Methods: Including bilateral filtering (<xref ref-type="fig" rid="fig4B">
     Figure 4B
    </xref>), Gaussian filtering (<xref ref-type="fig" rid="fig4C">
     Figure 4C
    </xref>), mean filtering (<xref ref-type="fig" rid="fig4D">
     Figure 4D
    </xref>). Frequency Domain Methods: Such as FFT-based denoising and wavelet denoising.</p>
   <fig id="fig3" position="float">
    <label>Figure 3</label>
    <caption>
     <title>
      <xref ref-type="bibr" rid="scirp.145311-"></xref>Figure 3. Comparison of image enhancement effects using different algorithms.</title>
    </caption>
    <graphic mimetype="image" position="float" xlink:type="simple" xlink:href="https://html.scirp.org/file/2313350-rId27.jpeg?20250901105256" />
   </fig>
   <fig id="fig4" position="float">
    <label>Figure 4</label>
    <caption>
     <title>
      <xref ref-type="bibr" rid="scirp.145311-"></xref>Figure 4. Comparison of different filtering methods.</title>
    </caption>
    <graphic mimetype="image" position="float" xlink:type="simple" xlink:href="https://html.scirp.org/file/2313350-rId28.jpeg?20250901105255" />
   </fig>
   <p>Different filters exhibit varying adaptability to different types of noise.</p>
   <p>Bilateral filtering effectively preserves edges while smoothing noise. It employs a weighted average based on Gaussian distribution, making it suitable for removing Gaussian noise. However, it fails to address salt-and-pepper noise. On the other hand, adaptive median filtering excels at eliminating salt-and-pepper noise but performs poorly against Gaussian noise. To address this limitation, we propose a dual-filtering combination. This approach first applies median filtering to remove salt-and-pepper noise, followed by bilateral filtering to further eliminate Gaussian noise. As shown in <xref ref-type="fig" rid="fig4">
     Figure 4
    </xref>, the dual-filtering method outperforms other mainstream filtering algorithms by preserving edge details while effectively removing noise points, achieving both edge retention and noise reduction. Therefore, this study adopts the dual-filtering approach for denoising.</p>
  </sec><sec id="s7">
   <title>7. Experimental Results</title>
   <p>1) Experimental Dataset</p>
   <p>The experimental data was divided into training, validation, and test sets in a 7:2:1 ratio. Three types of defect datasets—cracks, fractures, and holes—were used to validate the algorithm’s effectiveness, totaling 3365 defect images: Crack defects: 1103 images, Fracture defects: 1038 images, Hole defects: 1224 images, The distribution is shown in <xref ref-type="table" rid="table1">
     Table 1
    </xref>.</p>
   <table-wrap id="table1">
    <label>
     <xref ref-type="table" rid="table1">
      Table 1
     </xref></label>
    <caption>
     <title>
      <xref ref-type="bibr" rid="scirp.145311-"></xref>Table 1. Defect data distribution.</title>
    </caption>
    <table class="MsoTableGrid custom-table" border="0" cellspacing="0" cellpadding="0"> 
     <tr> 
      <td class="custom-bottom-td acenter" width="24.43%"><p style="text-align:center">Defect Type</p></td> 
      <td class="custom-bottom-td acenter" width="17.17%"><p style="text-align:center">Training Set</p></td> 
      <td class="custom-bottom-td acenter" width="19.22%"><p style="text-align:center">Validation Set</p></td> 
      <td class="custom-bottom-td acenter" width="12.10%"><p style="text-align:center">Test Set</p></td> 
      <td class="custom-bottom-td acenter" width="18.58%"><p style="text-align:center">Total</p></td> 
     </tr> 
     <tr> 
      <td class="custom-top-td acenter" width="24.43%"><p style="text-align:center">Cracks</p></td> 
      <td class="custom-top-td acenter" width="17.17%"><p style="text-align:center">753</p></td> 
      <td class="custom-top-td acenter" width="19.22%"><p style="text-align:center">227</p></td> 
      <td class="custom-top-td acenter" width="12.10%"><p style="text-align:center">123</p></td> 
      <td class="custom-top-td acenter" width="18.58%"><p style="text-align:center">1103</p></td> 
     </tr> 
     <tr> 
      <td class="acenter" width="24.43%"><p style="text-align:center">Fractures</p></td> 
      <td class="acenter" width="17.17%"><p style="text-align:center">720</p></td> 
      <td class="acenter" width="19.22%"><p style="text-align:center">208</p></td> 
      <td class="acenter" width="12.10%"><p style="text-align:center">110</p></td> 
      <td class="acenter" width="18.58%"><p style="text-align:center">1038</p></td> 
     </tr> 
     <tr> 
      <td class="acenter" width="24.43%"><p style="text-align:center">Holes</p></td> 
      <td class="acenter" width="17.17%"><p style="text-align:center">822</p></td> 
      <td class="acenter" width="19.22%"><p style="text-align:center">253</p></td> 
      <td class="acenter" width="12.10%"><p style="text-align:center">149</p></td> 
      <td class="acenter" width="18.58%"><p style="text-align:center">1224</p></td> 
     </tr> 
    </table>
   </table-wrap>
   <p>2) Experimental Platform and Training Parameters</p>
   <p>
    <xref ref-type="bibr" rid="scirp.145311-"></xref>To validate the improved algorithm’s effectiveness, experiments were conducted on a Windows 10 × 64 system with the following hardware and software configurations (<xref ref-type="table" rid="table2">
     Table 2
    </xref>):</p>
   <table-wrap id="table2">
    <label>
     <xref ref-type="table" rid="table2">
      Table 2
     </xref></label>
    <caption>
     <title>
      <xref ref-type="bibr" rid="scirp.145311-"></xref>Table 2. Experimental runtime environment.</title>
    </caption>
    <table class="MsoTableGrid custom-table" border="0" cellspacing="0" cellpadding="0"> 
     <tr> 
      <td class="custom-bottom-td acenter" width="39.65%"><p style="text-align:center">Category</p></td> 
      <td class="custom-bottom-td acenter" width="60.35%"><p style="text-align:center">Version/Specification</p></td> 
     </tr> 
     <tr> 
      <td class="custom-top-td acenter" width="39.65%"><p style="text-align:center">Operating System</p></td> 
      <td class="custom-top-td acenter" width="60.35%"><p style="text-align:center">Windows 10 Professional</p></td> 
     </tr> 
     <tr> 
      <td class="acenter" width="39.65%"><p style="text-align:center">CPU</p></td> 
      <td class="acenter" width="60.35%"><p style="text-align:center">i9-9900KF</p></td> 
     </tr> 
     <tr> 
      <td class="acenter" width="39.65%"><p style="text-align:center">GPU</p></td> 
      <td class="acenter" width="60.35%"><p style="text-align:center">NVIDIA GeForce RTX 2080Ti 12G</p></td> 
     </tr> 
     <tr> 
      <td class="acenter" width="39.65%"><p style="text-align:center">RAM</p></td> 
      <td class="acenter" width="60.35%"><p style="text-align:center">32 GB</p></td> 
     </tr> 
     <tr> 
      <td class="acenter" width="39.65%"><p style="text-align:center">Python</p></td> 
      <td class="acenter" width="60.35%"><p style="text-align:center">3.8</p></td> 
     </tr> 
     <tr> 
      <td class="acenter" width="39.65%"><p style="text-align:center">PyTorch</p></td> 
      <td class="acenter" width="60.35%"><p style="text-align:center">1.9</p></td> 
     </tr> 
     <tr> 
      <td class="acenter" width="39.65%"><p style="text-align:center">CUDA</p></td> 
      <td class="acenter" width="60.35%"><p style="text-align:center">11.1</p></td> 
     </tr> 
    </table>
   </table-wrap>
   <p>GPU: NVIDIA GeForce RTX 2080Ti (12 GB)</p>
   <p>CPU: Intel i9-9900KF</p>
   <p>RAM: 32 GB</p>
   <p>Software: CUDA 11.1, Python 3.8.0, PyTorch 1.9</p>
   <p>3) Evaluation Metrics</p>
   <p>The performance of YOLOv7 in defect detection and classification was assessed using:</p>
   <p>MAP (mean Average Precision): Average precision across all classes; higher values indicate better model performance.</p>
   <p>Precision: Proportion of correctly identified positives among all predicted positives.</p>
   <p>Recall: Proportion of actual positives correctly identified by the model. Formulas:</p>
   <p>
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <mtext>
        precision 
      </mtext> 
      <mo>
        = 
      </mo> 
      <mfrac> 
       <mrow> 
        <mtext>
          TP 
        </mtext> 
       </mrow> 
       <mrow> 
        <mtext>
          TP 
        </mtext> 
        <mo>
          + 
        </mo> 
        <mtext>
          FP 
        </mtext> 
       </mrow> 
      </mfrac> 
     </mrow> 
    </math> (6)</p>
   <p>
    <xref ref-type="bibr" rid="scirp.145311-"></xref> 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <mtext>
        recall 
      </mtext> 
      <mo>
        = 
      </mo> 
      <mfrac> 
       <mrow> 
        <mtext>
          TP 
        </mtext> 
       </mrow> 
       <mrow> 
        <mtext>
          TP 
        </mtext> 
        <mo>
          + 
        </mo> 
        <mtext>
          FN 
        </mtext> 
       </mrow> 
      </mfrac> 
     </mrow> 
    </math> (7)</p>
   <p>
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <mtext>
        AP 
      </mtext> 
      <mo>
        = 
      </mo> 
      <mstyle displaystyle="true"> 
       <mrow> 
        <msubsup> 
         <mo>
           ∫ 
         </mo> 
         <mn>
           0 
         </mn> 
         <mn>
           1 
         </mn> 
        </msubsup> 
        <mrow> 
         <mi>
           P 
         </mi> 
         <mrow> 
          <mo>
            ( 
          </mo> 
          <mi>
            R 
          </mi> 
          <mo>
            ) 
          </mo> 
         </mrow> 
         <mi>
           d 
         </mi> 
         <mi>
           R 
         </mi> 
        </mrow> 
       </mrow> 
      </mstyle> 
     </mrow> 
    </math> (8)</p>
   <p>
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <mtext>
        mAP 
      </mtext> 
      <mo>
        = 
      </mo> 
      <mfrac> 
       <mn>
         1 
       </mn> 
       <mi>
         N 
       </mi> 
      </mfrac> 
      <mstyle displaystyle="true"> 
       <munderover> 
        <mo>
          ∑ 
        </mo> 
        <mrow> 
         <mi>
           i 
         </mi> 
         <mo>
           = 
         </mo> 
         <mn>
           1 
         </mn> 
        </mrow> 
        <mi>
          N 
        </mi> 
       </munderover> 
       <mrow> 
        <msub> 
         <mrow> 
          <mtext>
            AP 
          </mtext> 
         </mrow> 
         <mi>
           i 
         </mi> 
        </msub> 
       </mrow> 
      </mstyle> 
     </mrow> 
    </math> (9)</p>
   <p>where:</p>
   <p>TP (True Positive): Correctly predicted defect samples.</p>
   <p>FP (False Positive): Non-defect samples incorrectly flagged as defects.</p>
   <p>FN (False Negative): Defect samples missed by the model.</p>
   <p>4) Experimental Validation of Pipeline Defect Detection (<xref ref-type="table" rid="table3">
     Table 3
    </xref>, <xref ref-type="fig" rid="figFigures 5-7">
     Figures 5-7
    </xref>)</p>
   <fig id="fig5" position="float">
    <label>Figure 5</label>
    <caption>
     <title>
      <xref ref-type="bibr" rid="scirp.145311-"></xref>Figure 5. YOLOv7 confusion matrix.</title>
    </caption>
    <graphic mimetype="image" position="float" xlink:type="simple" xlink:href="https://html.scirp.org/file/2313350-rId37.jpeg?20250901105256" />
   </fig>
   <fig id="fig6" position="float">
    <label>Figure 6</label>
    <caption>
     <title>
      <xref ref-type="bibr" rid="scirp.145311-"></xref>Figure 6. YOLOv7 Loss Function.</title>
    </caption>
    <graphic mimetype="image" position="float" xlink:type="simple" xlink:href="https://html.scirp.org/file/2313350-rId38.jpeg?20250901105256" />
   </fig>
   <fig id="fig7" position="float">
    <label>Figure 7</label>
    <caption>
     <title>
      <xref ref-type="bibr" rid="scirp.145311-"></xref>Figure 7. YOLOv7 mAP curve.</title>
    </caption>
    <graphic mimetype="image" position="float" xlink:type="simple" xlink:href="https://html.scirp.org/file/2313350-rId39.jpeg?20250901105256" />
   </fig>
   <table-wrap id="table3">
    <label>
     <xref ref-type="table" rid="table3">
      Table 3
     </xref></label>
    <caption>
     <title>
      <xref ref-type="bibr" rid="scirp.145311-"></xref>Table 3. YOLOv7 detection results.</title>
    </caption>
    <table class="MsoTableGrid custom-table" border="0" cellspacing="0" cellpadding="0"> 
     <tr> 
      <td class="custom-bottom-td acenter" width="20.05%"><p style="text-align:center">Defect Type</p></td> 
      <td class="custom-bottom-td acenter" width="17.61%"><p style="text-align:center">Test Images</p></td> 
      <td class="custom-bottom-td acenter" width="18.73%"><p style="text-align:center">True Positives</p></td> 
      <td class="custom-bottom-td acenter" width="18.90%"><p style="text-align:center">False Positives</p></td> 
      <td class="custom-bottom-td acenter" width="19.22%"><p style="text-align:center">False Negatives</p></td> 
      <td class="custom-bottom-td acenter" width="18.90%"><p style="text-align:center">Precision</p></td> 
      <td class="custom-bottom-td acenter" width="17.11%"><p style="text-align:center">Recall</p></td> 
     </tr> 
     <tr> 
      <td class="custom-top-td acenter" width="20.05%"><p style="text-align:center">Cracks</p></td> 
      <td class="custom-top-td acenter" width="17.61%"><p style="text-align:center">123</p></td> 
      <td class="custom-top-td acenter" width="18.73%"><p style="text-align:center">116</p></td> 
      <td class="custom-top-td acenter" width="18.90%"><p style="text-align:center">3</p></td> 
      <td class="custom-top-td acenter" width="19.22%"><p style="text-align:center">4</p></td> 
      <td class="custom-top-td acenter" width="18.90%"><p style="text-align:center">97.47%</p></td> 
      <td class="custom-top-td acenter" width="17.11%"><p style="text-align:center">96.67%</p></td> 
     </tr> 
     <tr> 
      <td class="acenter" width="20.05%"><p style="text-align:center">Holes</p></td> 
      <td class="acenter" width="17.61%"><p style="text-align:center">110</p></td> 
      <td class="acenter" width="18.73%"><p style="text-align:center">103</p></td> 
      <td class="acenter" width="18.90%"><p style="text-align:center">5</p></td> 
      <td class="acenter" width="19.22%"><p style="text-align:center">2</p></td> 
      <td class="acenter" width="18.90%"><p style="text-align:center">95.37%</p></td> 
      <td class="acenter" width="17.11%"><p style="text-align:center">98.09%</p></td> 
     </tr> 
     <tr> 
      <td class="acenter" width="20.05%"><p style="text-align:center">Fractures</p></td> 
      <td class="acenter" width="17.61%"><p style="text-align:center">149</p></td> 
      <td class="acenter" width="18.73%"><p style="text-align:center">142</p></td> 
      <td class="acenter" width="18.90%"><p style="text-align:center">6</p></td> 
      <td class="acenter" width="19.22%"><p style="text-align:center">1</p></td> 
      <td class="acenter" width="18.90%"><p style="text-align:center">95.94%</p></td> 
      <td class="acenter" width="17.11%"><p style="text-align:center">99.30%</p></td> 
     </tr> 
    </table>
   </table-wrap>
   <p>The YOLOv6 algorithm was tested on the dataset, achieving:</p>
   <p>mAP: 96.29%</p>
   <p>Precision: 95.61%</p>
   <p>Recall: 94.91%</p>
  </sec><sec id="s8">
   <title>8. Conclusion</title>
   <sec id="s8_1">
    <title>8.1. Performance Benchmark (Quantifying the Impact of Preprocessing)</title>
    <p>To validate the effectiveness of the proposed preprocessing pipeline (e.g., data augmentation, illumination correction, noise suppression), the following comparative experiments were conducted under identical conditions (<xref ref-type="table" rid="table4">
      Table 4
     </xref>):</p>
    <table-wrap id="table4">
     <label>
      <xref ref-type="table" rid="table4">
       Table 4
      </xref></label>
     <caption>
      <title>
       <xref ref-type="bibr" rid="scirp.145311-"></xref>Table 4. Baseline Model. YOLOv7 trained on raw, unprocessed data. Enhanced Model. YOLOv7 trained on preprocessed data.</title>
     </caption>
     <table class="MsoTableGrid custom-table" border="0" cellspacing="0" cellpadding="0"> 
      <tr> 
       <td class="custom-bottom-td acenter" width="14.85%"><p style="text-align:center">Metric</p></td> 
       <td class="custom-bottom-td acenter" width="27.08%"><p style="text-align:center">Baseline (Raw Data)</p></td> 
       <td class="custom-bottom-td acenter" width="33.18%"><p style="text-align:center">Enhanced (Preprocessed)</p></td> 
       <td class="custom-bottom-td acenter" width="19.39%"><p style="text-align:center">Improvement</p></td> 
      </tr> 
      <tr> 
       <td class="custom-top-td acenter" width="14.85%"><p style="text-align:center">mAP@0.5</p></td> 
       <td class="custom-top-td acenter" width="27.08%"><p style="text-align:center">78.2%</p></td> 
       <td class="custom-top-td acenter" width="33.18%"><p style="text-align:center">86.7%</p></td> 
       <td class="custom-top-td acenter" width="19.39%"><p style="text-align:center">+8.5%</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="14.85%"><p style="text-align:center">Recall</p></td> 
       <td class="acenter" width="27.08%"><p style="text-align:center">72.1%</p></td> 
       <td class="acenter" width="33.18%"><p style="text-align:center">83.4%</p></td> 
       <td class="acenter" width="19.39%"><p style="text-align:center">+11.3%</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="14.85%"><p style="text-align:center">FPS</p></td> 
       <td class="acenter" width="27.08%"><p style="text-align:center">54</p></td> 
       <td class="acenter" width="33.18%"><p style="text-align:center">51</p></td> 
       <td class="acenter" width="19.39%"><p style="text-align:center">−5.5%</p></td> 
      </tr> 
     </table>
    </table-wrap>
   </sec>
   <sec id="s8_2">
    <title>8.2. Expanded Conclusion &amp; Future Directions</title>
    <p>Conclusion:</p>
    <p>The proposed preprocessing-YOLOv7 framework achieved a mAP of 86.7% for PE pipeline defect detection, marking an 8.5% improvement over the baseline model. This underscores the vital role of data preprocessing in industrial inspection scenarios.</p>
    <p>Limitations:</p>
    <p>Dataset Scale: Limited to 5000 annotated images, potentially restricting model generalization.</p>
    <p>Defect Diversity: Dominated by cracks and corrosion; lacks rare defects (e.g., bubbles, weld flaws).</p>
    <p>Environmental Variability: Training data primarily from indoor settings; field conditions (e.g., lighting, occlusions) require further validation.</p>
    <p>Future Work:</p>
    <p>Data Expansion:</p>
    <p>Integrate multimodal data (e.g., infrared, ultrasonic imaging).</p>
    <p>Employ GANs to synthesize rare defect samples.</p>
    <p>Algorithm Enhancement:</p>
    <p>Adopt lightweight designs (e.g., YOLOv7-tiny) for speed-accuracy balance.</p>
    <p>Explore Transformer-based models (e.g., DETR) for long-range feature extraction.</p>
    <p>Industrial Deployment:</p>
    <p>Develop embedded solutions (e.g., Jetson AGX) for real-time pipeline inspection.</p>
    <p>Combine with digital twin technology for defect evolution prediction.</p>
   </sec>
  </sec>
 </body><back>
  <ref-list>
   <title>References</title>
   <ref id="scirp.145311-ref1">
    <label>1</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Yang, M.D. and Su, T.C. (2008) Automated Diagnosis of Sewer Pipe Defects Based on Machine Learning Approaches. Expert Systems with Applications, 35, 1327-1337.
    </mixed-citation>
   </ref>
   <ref id="scirp.145311-ref2">
    <label>2</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Xie, Q., Li, D., Xu, J., Yu, Z. and Wang, J. (2019) Automatic Detection and Classification of Sewer Defects via Hierarchical Deep Learning. IEEE Transactions on Automation Science and Engineering, 16, 1836-1847. &gt;https://doi.org/10.1109/tase.2019.2900170
    </mixed-citation>
   </ref>
   <ref id="scirp.145311-ref3">
    <label>3</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Cheng, J.C.P. and Wang, M. (2018) Automated Detection of Sewer Pipe Defects in Closed-Circuit Television Images Using Deep Learning Techniques. Automation in Construction, 95, 155-171. &gt;https://doi.org/10.1016/j.autcon.2018.08.006
    </mixed-citation>
   </ref>
   <ref id="scirp.145311-ref4">
    <label>4</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Wang, C., Bochkovskiy, A. and Liao, H.M. (2023) YOLOv7: Trainable Bag-Of-Freebies Sets New State-Of-The-Art for Real-Time Object Detectors. 2023 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), Vancouver, 17-24 June 2023, 7464-7475. &gt;https://doi.org/10.1109/cvpr52729.2023.00721
    </mixed-citation>
   </ref>
   <ref id="scirp.145311-ref5">
    <label>5</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Hou, Q., Zhou, D. and Feng, J. (2021) Coordinate Attention for Efficient Mobile Network Design. 2021 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), Nashville, 20-25 June 2021, 13708-13717. &gt;https://doi.org/10.1109/cvpr46437.2021.01350
    </mixed-citation>
   </ref>
   <ref id="scirp.145311-ref6">
    <label>6</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Chen, J., Kao, S., He, H., Zhuo, W., Wen, S., Lee, C., et al. (2023) Run, Don’t Walk: Chasing Higher FLOPS for Faster Neural Networks. 2023 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), Vancouver, 17-24 June 2023, 12021-12031. &gt;https://doi.org/10.1109/cvpr52729.2023.01157
    </mixed-citation>
   </ref>
   <ref id="scirp.145311-ref7">
    <label>7</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Tong, Z., Chen, Y., Xu, Z., et al. (2023) Wise-IoU: Bounding Box Regression Loss with Dynamic Focusing Mechanism. arXiv: 2301.10051.
    </mixed-citation>
   </ref>
  </ref-list>
 </back>
</article>