Oil and gas pipeline defect detection system based on lightweight cascading visual network

By constructing a lightweight cascaded vision network for oil and gas pipeline defect detection, the problems of insufficient real-time processing capability and image degradation in existing technologies have been solved. This enables accurate detection of defects with extreme scale variations in a closed darkroom environment, improving detection recall and accuracy.

CN123135809APending Publication Date: 2026-11-20CHONGQING UNIVERSITY OF SCIENCE AND TECHNOLOGY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611303459.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-26
Publication Date
2026-11-20

AI Technical Summary

Technical Problem

Existing oil and gas pipeline defect detection technologies lack real-time processing capabilities on low-power edge devices, making it unable to cope with image degradation caused by non-uniform motion and unstructured lighting, as well as heterogeneous defects with extreme scale changes.

Method used

A defect detection system for oil and gas pipelines based on a lightweight cascaded vision network is constructed. The system adopts a three-level cascaded vision system consisting of image restoration preprocessing, lightweight backbone feature extraction, and multi-scale detection and segmentation output. Combined with six-degree-of-freedom motion decoupling, spatial variation deblurring, polarization illumination restoration, and a multi-scale detection head, it achieves real-time autonomous defect detection at the end side.

Benefits of technology

Real-time and accurate defect detection was achieved in a closed, darkroom environment without external power supply and communication, improving detection recall and accuracy, reducing power consumption, and solving the compatibility problem of defects with extreme scale changes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123135809A_ABST
    Figure CN123135809A_ABST
Patent Text Reader

Abstract

The application provides a kind of oil and gas pipeline defect detection system based on lightweight cascade visual network, it is related to defect detection field, including device ontology (10), drive module (20), battery module (30), light source module (40), visual sensor module (50), edge computing module (60) and storage module (70);Device ontology (10) is the physical bearing platform of entire detection system, its inside is equipped with sealed cabin;Drive module (20), battery module (30), light source module (40), visual sensor module (50), edge computing module (60) and storage module (70) are all set on device ontology (10).The system can be in the closed darkroom environment without external power supply and communication, complete end side real-time autonomous defect detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of defect detection technology, and specifically to an oil and gas pipeline defect detection system based on a lightweight cascaded vision network. Background Technology

[0002] Long-distance oil and gas pipelines are vital arteries for energy transportation. Due to their long-term operation in harsh environments, the inner walls of these pipelines are highly susceptible to serious defects such as sulfur buildup, corrosion perforation, and media leakage. Currently, internal inspection of long-distance oil and gas pipelines mainly relies on large magnetic flux leakage or ultrasonic pigs. These devices are bulky, expensive, and have stringent environmental requirements. In recent years, offline internal inspection devices driven by the existing gas pressure difference within the pipeline have gradually become a research hotspot. However, in the face of an absolutely sealed, dark chamber environment, how to achieve autonomous and accurate inspection of pipe wall defects using lightweight visual sensors without continuous external power supply and communication remains a pressing problem in pipeline operation and maintenance.

[0003] Currently, visual inspection methods applied to confined spaces or industrial pipelines typically employ the traditional "blind recording-export-offline analysis" model. This involves installing a large-capacity storage device inside the equipment to record high-definition video throughout the process. After the equipment exits the pipeline, a large backend server replays and screens the footage. At the visual recognition algorithm level, standard deep learning object detection networks (such as standard YOLO or Mask R-CNN) are usually directly applied. These networks extract features through massive convolutional layers and output the recognition results in a fixed detection head.

[0004] However, the above methods have the following problems when applied to offline inspection of gas-driven oil and gas pipelines: 1. The contradiction between the limited computing power of edge devices and the computational overhead of models: The inspection equipment inside the pipeline must rely on its own high-energy battery for power, and can only be equipped with low-power edge computing modules (such as NVIDIA Jetson); the existing standard deep learning large model has a large number of parameters, and cannot achieve the real-time processing frame rate on low-power motherboards, resulting in serious frame loss and missed detection when the device slides rapidly with the gas. 2. Severe image degradation caused by non-uniform motion and unstructured lighting: The inspection device is driven by gas pressure difference, and its operating speed is extremely unstable due to gas pressure fluctuations; in the absolutely dark chamber of the pipeline, instantaneous acceleration and deceleration will cause severe image motion blur. At the same time, direct reflection of sulfur deposits or water stains from a single light source can easily cause local overexposure; traditional pure vision models lack dynamic recovery mechanisms and cannot cope with this dynamic degradation process, resulting in serious distortion of input features. Third, heterogeneous defects with extreme scale variations are difficult to be compatible with a single network: the morphology of defects inside pipelines varies greatly: sulfur deposits usually manifest as large-area, irregular protrusions, while perforations and tiny leaks are extremely small targets; existing single-target detection networks are difficult to simultaneously take into account defects with extreme scale variations, and are prone to the phenomenon of "catching the big and ignoring the small", making it impossible to complete the high-precision classification and location of multiple types of heterogeneous defects in a single detection. Summary of the Invention

[0005] To address the problems existing in the prior art, the present invention aims to provide an oil and gas pipeline defect detection system based on a lightweight cascaded vision network. This system is designed for offline detection scenarios of long-distance oil and gas pipelines driven by gas pressure difference. It constructs a three-level cascaded vision system consisting of "image restoration preprocessing - ultra-lightweight backbone feature extraction - multi-scale detection and segmentation output", thereby enabling real-time autonomous defect detection at the end side in a closed darkroom environment without external power supply and communication.

[0006] The objective of this invention is achieved through the following technical solution: A defect detection system for oil and gas pipelines based on a lightweight cascaded vision network includes a device body, a drive module, a battery module, a light source module, a vision sensor module, an edge computing module, and a storage module. The device body serves as the physical platform for the entire detection system. Its external structure is adapted to the inner diameter of long-distance oil and gas pipelines, and a sealed chamber is located inside the device body. The drive module, battery module, light source module, vision sensor module, edge computing module, and storage module are all located on the device body. The drive module is installed on the outside of the device body or at both ends. The battery module is fixed inside the sealed chamber of the device body and is electrically connected to the light source module, vision sensor module, edge computing module, and storage module. The light source module is deployed at the detection end of the device body. The vision sensor module is deployed at the detection end of the device body and is arranged adjacent to the light source module. The vision sensor module is communicatively connected to the edge computing module and storage module. The edge computing module is encapsulated inside the sealed chamber of the device body. The storage module is installed inside the sealed chamber of the device body and interacts with the vision sensor module and edge computing module for data exchange.

[0007] Based on further optimization of the above scheme, the edge computing module includes a preprocessing layer, a feature extraction layer, and a detection output layer. The preprocessing layer receives the original images of adjacent frames output by the visual sensor module. ,in, H Image axis height, W Circumferential width, C The number of channels is given by the nominal radius of the pipe. R Camera focal length f Inter-frame time interval △t As input, the process sequentially performs six-degree-of-freedom motion decoupling, spatial transformation deblurring, and polarization illumination restoration, outputting a restored illumination image. ; The feature extraction layer is based on a lightweight defect detection backbone network. It receives the restored illumination image and extracts multi-level robust feature maps through initial feature extraction, temporal polarity pruning, dual-dimensional perceptual routing, multi-branch heterogeneous feature extraction, and sparse-heavy parameterization fusion. The detection output layer takes multi-level robust feature maps as input, and after topological alignment and fusion with cylinders, it simultaneously completes large-area sulfur deposition segmentation, shallow feature orientation enhancement of sulfur deposition coverage area, small target feature enhancement, multi-scale detection head synchronous inference and joint loss calculation, cross-level result integration and redundancy filtering, and finally outputs structured defect classification, localization and segmentation results.

[0008] Based on further optimization of the above scheme, the six-degree-of-freedom motion decoupling in the preprocessing layer specifically involves: firstly, decoupling the motion of the six degrees of freedom... I t-1 and I t ORB feature point extraction and matching are performed to obtain a set of effective matching key points. S After removing mismatched points, the pixel displacement vector field is obtained. D(x,y) ; Then, the RANSAC algorithm is used to fit the fundamental matrix F, combined with the camera calibration intrinsic parameter matrix. K cam Obtain the essential matrix E and the essential matrix E Decomposition yields the rotation matrix R B Translation direction with scale t B Combined with the nominal radius of the pipeline R With camera focal length f Provided cylindrical geometric dimensions constraints, recover the rigid body transformation matrix with absolute dimensions. , R B Represents rotation matrix, t B Represents the translation vector; decomposes the device into six degrees of freedom instantaneous motion parameters, including translation components. v z , v x , v y With rotational components , , ; The final global equivalent axial velocity is obtained as follows: ; In the formula: D z (x,y) Represents the axial component of the displacement at key points. This represents the initial depth map output by the lightweight depth prediction head.

[0009] Based on further optimization of the above scheme, the spatial variation deblurring in the preprocessing layer specifically includes: First, a lightweight depth prediction head is constructed based on the geometric prior of the pipe cylinder, taking the current frame image as input and outputting an initial depth map. D init0 (x,y) The loss function incorporates geometric constraints to ensure that the depth distribution conforms to the cylindrical topology. ; ; In the formula: Loss pixel This represents the pixel-level depth regression loss function. Represents pixels ( i,j Depth label at ) Indicates the geometric constraint weights; D 0 (x,y) This represents the theoretical depth distribution of the wall of an ideal cylindrical tube. , Indicates the nominal eccentricity of the device. ; Output corrected pixel-by-pixel depth map This represents the physical distance from the pipe wall position corresponding to each pixel to the camera; Then, by combining motion parameters and depth maps, a pixel-by-pixel varying total blur kernel is generated, which includes a translation blur kernel, a rotation blur kernel, and a scale blur kernel. Translation blur kernel: Based on the pinhole imaging model, pixel-level motion displacement is inversely proportional to depth; calculate the pixel-by-pixel axial motion step size. ; Translation fuzzy kernel K trans (x,y) It is a straight, uniform core along the axial direction, with a length of... L trans (x,y) ; Rotating blur kernel: generated by roll angular velocity: ; Rotational fuzzy kernel K rot (x,y) The uniform core of the circular arc trajectory has a rotation arc length of... L rot (x,y) ; The scale fuzzy kernel is caused by radial jump. Assume the local coordinates of the fuzzy kernel are ( u,v Then its radial coordinates If the current pixel is not the center point of the image, its distance to the center point of the image. , ( cx,cy () represents the coordinates of the image center, then the scale blur kernel K scale (u,v) for: ; In the formula: Indicates the radial width with fuzzy scale. This indicates the sensor exposure time for a single frame image; If the current pixel is the center point of the image, then the scale blur kernel... for: ; The translation, rotation, and scaling blur kernels are convolved and combined to obtain the pixel-by-pixel total blur kernel: ; In the formula: Represents a two-dimensional convolution operation; Finally, the image is divided into overlapping patches of 16×16 or 32×32 pixels, and within each patch, a blur kernel is applied corresponding to the center pixel of that patch. As a locally spatially invariant kernel, Wiener deconvolution is performed in the frequency domain: ; In the formula: Fou() , Fou -1 () They represent the two-dimensional fast Fourier transform and inverse Fourier transform, respectively. express Fou() The conjugate of complex numbers, Indicates the signal-to-noise ratio penalty coefficient; The deconvolution results of each patch are windowed and then weighted and stitched together to eliminate block artifacts, resulting in a preliminary clear image of the entire image. ; Finally, a preliminary clear image is obtained after deblurring. .

[0010] Based on further optimization of the above scheme, the polarization restoration in the preprocessing layer specifically involves: First, using images acquired in three polarization directions by rotating a polarizer in front of the lens, the extreme brightness values ​​of each pixel are statistically analyzed. I max (x,y) , I min (x,y) To obtain the pixel polarization degree: ; And based on the two-color reflection model I = I s + I d , I s For specular reflection component, I d For the diffuse reflection component, the specular reflection component and the diffuse reflection component are approximately separated based on the degree of polarization: ; Then, brightness compression is performed to suppress overexposure of metallic reflections: ; In the formula: Indicates the mirror suppression coefficient; Subsequently, by combining contrast-limited adaptive histogram equalization with dark channel priors, sulfur deposition texture and dark defect details are enhanced: First to I d (x,y)Perform CLAHE processing with an 8×8 mesh size and a truncation threshold. T clip =0.02, resulting in a contrast-enhanced image. Then, residual light haze is removed using the dark channel prior, and the dark channel map is calculated: ; In the formula: Indicated by x A local window centered on the user; Take dark channel image The top 0.1% of pixels in mid-brightness, and the diffuse image after CLAHE enhancement. In the mean value of these pixels, the average value is taken as the global atmospheric light value. A air ; Through global atmospheric light value A air With transmittance ts(x) Reverse engineering to restore the real texture: ; ; In the formula: ts 0 indicates the lower limit of transmittance. Indicates the depth retention factor; Finally, the restored lighting image was obtained. .

[0011] Based on further optimization of the above scheme, the initial feature extraction in the feature extraction layer specifically involves: using an initial convolutional layer for initial feature extraction. The initial convolutional layer is a single 3×3 convolutional layer with a stride of 2 and padding of 1, and the number of output channels is... C 0=32, followed by a batch normalization layer (1 layer) to output features. ; The restored illumination image is input into the initial convolutional layer to obtain the initial feature tensor. .

[0012] Based on further optimization of the above scheme, the temporal polarity pruning in the feature extraction layer is specifically as follows: First, receive C 1. Feature map, and calculate the mean spatial feature of the c-th channel of the current frame: ; The single-channel polarity activation density of the current frame is obtained by using the mean of spatial features: ; Introducing temporal memory weights and fusing the polarity memory of the previous frame helps suppress single-frame noise fluctuations. ; In the formula: Indicates the time-series update weights. This represents the polarity memory vector of the previous frame; Update the polarity memory vector: ; Then, based on the global background proportion estimate B t Dynamically adjust the baseline threshold: ; In the formula: Indicates the baseline pruning threshold. This represents the statistical average percentage of the proportion of pipeline background. Indicates the threshold adaptive coefficient; Introducing a hysteresis mechanism to generate a pruning mask: ; In the formula: Indicates the width of the hysteresis interval; Multiply the mask by the initial features channel by channel to obtain the sparsed backbone feature map: ; During the training phase, the mask activation frequency of each channel on the entire training set is statistically analyzed using an exponential moving average. ,right The channels undergo permanent structural pruning and are removed from the network topology; during the inference phase, for the remaining channels, As a frame-by-frame modulation feature for soft channel attention weights, it no longer changes the network topology; channels that are permanently pruned do not participate in computation during the inference phase. The final output includes a fixed set of channel indices and frame-by-frame attention weights after pruning. M t With sparsified feature map .

[0013] Based on further optimization of the above scheme, the two-dimensional perceptual routing in the feature extraction layer is specifically as follows: First, perform average pooling along the circumferential direction to extract the axial spatial continuity features and generate the axial weight matrix: ; In the formula: Indicates the axial 1D convolution kernel parameters; Then, perform average pooling along the axial direction to extract the circumferential closed-loop continuity features and generate the circumferential weight matrix: ; In the formula: Represents the parameters of the circumferential 1D convolution kernel; Bidirectional feature enhancement is achieved by multiplying the weights of the two orthogonal directions element-wise using a broadcast mechanism. ; In the formula: This indicates element-wise multiplication.

[0014] Based on further optimization of the above scheme, the multi-branch heterogeneous feature extraction in the feature extraction layer specifically involves: It includes four levels of feature extraction layers. Each feature extraction layer contains a channel adjustment convolutional block and a spatial downsampling convolutional block in sequence: the channel adjustment convolutional block is a single 1×1 convolutional layer with a stride of 1 and padding of 0, followed by a BN layer for cross-channel information fusion; the spatial downsampling convolutional block is a single 3×3 convolutional layer with a stride of 2 and padding of 1, followed by a BN layer to simultaneously halve the feature map size and double the number of channels; several RepBlocks are stacked after the downsampling convolutional blocks; The first-level feature extraction layer has a downsampling factor of 4x, 32 input channels, 2 RepBlock stacks, and 64 output channels, outputting features. ; The second-level feature extraction layer has a downsampling factor of 8x, 64 input channels, 3 RepBlock stacks, and 128 output channels, outputting features. ; The third-level feature extraction layer has a downsampling factor of 16x, 128 input channels, 3 RepBlock stacks, and 256 output channels, outputting features. ; The fourth-level feature extraction layer has a downsampling factor of 32x, 256 input channels, 2 RepBlock stacks, and 512 output channels, producing output features. ; Downsampling is achieved through 3×3 convolutions with a stride of 2, simultaneously halving the feature map size and doubling the number of channels; each feature extraction layer's RepBlock employs a multi-branch structure in training mode to ensure the model's feature representation capability; the output of the initial convolutional layer... C 1 and the output of all feature extraction layers C 2~ C These five elements together form the input basis for the subsequent detection output layer.

[0015] Based on further optimization of the above scheme, the sparse-reparameterized fusion in the feature extraction layer is specifically as follows: First, for each convolutional branch, perform an equivalent fusion of the convolutional kernel and the BN layer: ; In the formula: This represents the kernel weights of the k-th branch and the c-th output channel. This represents the moving average of the BN layer and the c-th channel after the k-th branch. This represents the sliding variance of the BN layer and the c-th channel after the k-th branch. This represents the scaling factor for the c-th channel of the BN layer. represents the offset factor of the c-th channel in the BN layer; k corresponds to the 3×3 convolution branch and the 1×1 convolution branch; Then, based on the fixed set of channel indices after training, the input / output channels that have been permanently pruned are removed to obtain the pruned branch weights. With bias ; Next, the parameters of the pruned 3×3 convolution, the zero-padding 1×1 convolution, and the pruned unit direct connection branch are summed to obtain the final deployment weights and biases: ; In the formula: Pad() Indicates zero-filling operation; This represents the equivalent identity matrix convolution kernel after clipping; Finally, the fused single-path parameters are directly used on the edge hardware to calculate and output multi-level feature maps: ; In the formula: l Corresponding to the four-level feature extraction layer, each RepBlock of each level independently performs reparameterized fusion, outputting C2 to C5 in sequence.

[0016] Based on further optimization of the above scheme, the cylindrical topology alignment and fusion in the detection output layer specifically involves: First, deep feature C5 is selected as the starting point of the pyramid, and the number of channels is adjusted through a 1×1 convolution to obtain the top-level feature: ; Then, circumferential boundary filling is performed on the deep feature map to simulate the continuity of a closed cylinder: ; In the formula: w pad Indicates the fill width; Next, the padded deep features are bilinearly upsampled by a factor of 2 and then added element-wise to the corresponding shallow features that have undergone 1×1 convolution dimensionality reduction: ; Finally, the filled edge regions are cropped, and then a 3×3 convolution is applied to smooth out the upsampling aliasing, resulting in the final multi-scale fused feature map: ; In the formula: Crop()This indicates a spatial dimension clipping operation. F 3 indicates shallow high-resolution features. F 4 indicates the fusion feature of the intermediate level. F 5 represents deep, strong semantic features; The final output is an aligned multi-scale fused feature map. F 3 ,F 4 ,F 5}.

[0017] Based on further optimization of the above scheme, the large-area sulfur deposition segmentation in the detection output layer specifically refers to: In deep strong semantic features F 5. A lightweight instance segmentation header is added, which includes two branches: a classification branch and a mask branch. Classification branch: Outputs the confidence level of the sulfur deposition region category; Masking Branch: Output Junction Binary Partition Mask ; The segmentation loss uses Dice loss to optimize mask overlap. ; In the formula: M pred Indicates the prediction mask. M gt This indicates that the actual mask was manually labeled. Final output sulfur segmentation mask M sulfur Large-area sulfur deposition detection frame and classification results.

[0018] Based on further optimization of the above scheme, the targeted enhancement of shallow features in the sulfur deposition coverage area in the detection output layer specifically involves: firstly, bilinearly upsampling the sulfur deposition mask to the shallow feature layer. F At a resolution of 3, a mask of the same scale is obtained. ; Further regional weighting of shallow features enhances the amplitude of features in sulfur-covered areas, thus amplifying weak internal defect signals. ; In the formula: Indicates the enhancement coefficient of the sulfur deposition region; The final output shows the enhanced shallow features of the sulfur deposition region. F 3,weighted .

[0019] Based on further optimization of the above scheme, the enhancement of small target features in the detection output layer specifically involves: First, considering the approximately uniform axial motion characteristics of fixed defects within the pipeline as they slide along with the device, a uniform motion (CV) Kalman filter is used to analyze each defect trajectory. Ti Perform state estimation and prediction, and output the predicted location region of the current frame. R CV-i Compared with historical average confidence level p CV-i ; Then, the features within the prediction region are subjected to a second weighted enhancement: ; In the formula: Indicates the timing enhancement coefficient; The final output is an enhanced shallow feature map of small targets. F 3,enhanced .

[0020] A uniform velocity (CV) Kalman filter is used to estimate and predict the state of each defect trajectory, and the predicted location region of the current frame is output. R CV-i Compared with historical average confidence level p CV-i Specifically: Each trajectory T i For each independent Kalman filter, the state vector describes the position and velocity of the defect in the image plane: , ( x k ,y k ) indicates the first k The center pixel coordinates of the defective target in the frame. v x,k 、v y,k This indicates the pixel movement speed of the defect in the image; When a tiny target that cannot be matched with any existing trajectory is detected, initialize a new trajectory: And initialize the covariance matrix: ; Then, Kalman filtering prediction is performed: the posterior state of the previous frame is input. Posterior covariance ; State prediction: ; Covariance prediction: ; in, FZ The state transition matrix represents the state evolution relationship of uniform motion between frames: ; Qfc This represents the process noise covariance, describing the model uncertainty caused by pressure fluctuations and speed jitter in the device. ; In the formula: q fc Indicates the intensity of process noise; Before updating the filter, it is necessary to match all the small target detection results in the current frame with the predicted positions of existing trajectories to establish a one-to-one correspondence: first, calculate the intersection-union ratio (IOU) between each detection box and each predicted position of the trajectory; then, use the Hungarian algorithm to perform global optimal matching, setting an IOU threshold or a distance threshold, and those that match are considered to be the same defect trajectory; for detection results that do not match, initialize them as new trajectories; if no detected trajectory is matched for 3 consecutive frames, it is determined that the defect has slipped out of the field of view and the trajectory is deleted. Then, Kalman filtering is performed to update the input prior state. Prior covariance Current frame measurement value ; Calculate the measurement residuals: ; Calculate the residual covariance: ; Calculate the Kalman gain: ; Estimated update status: ; Update the covariance matrix: ; Where HC represents the measurement matrix: , representing the measurement noise covariance: ; Finally, predict the location Centered on, from the prior covariance Extract the first 2 rows and 2 columns to obtain the position covariance submatrix. This allows us to obtain the predicted location region of the current frame. R CV-i : ; The historical average confidence score is fused using exponential moving average (EMA) fusion. p CV-i : ; In the formula: This represents the target category confidence score output by the detection head in the k-th frame, corresponding to the trajectory. Indicates the smoothing coefficient; Cold start strategy: In the first frame or the first few frames before the trajectory is established, temporal feature enhancement is not performed, and the system directly uses... F 3,weightedAs input to the small target detection branch; after the detection branch outputs the initial detection result and completes trajectory initialization, feature enhancement guided by Kalman prediction region is enabled from the next frame; for the newly initialized trajectory, only the predicted location region is used in the first 3 frames after its establishment without applying confidence weighting, and then weighting is applied according to the formula after the EMA confidence stabilizes.

[0021] Based on further optimization of the above scheme, the multi-scale detection head synchronous inference and joint loss calculation in the detection output layer are specifically as follows: Parallel inference of three scale detection heads: small target detection branch, medium target detection branch, and large area defect detection branch. Small object detection branch: Input F 3, enhanced Output the bounding box parameters for three types of small targets: ordinary perforations, leak points, and perforations covered by sulfur deposits. t small With category confidence p small : ; In the formula: These represent the weights of the shallow regression and classification convolution kernels, respectively. These represent shallow regression and classification bias, respectively. Medium-sized object detection branch: Input F 4. Output the bounding box parameters of medium-scale defects. t mid With category confidence p mid : ; In the formula: These represent the weights of the mid-level regression and classification convolution kernels, respectively. These represent mid-level regression and classification bias, respectively. Large-area defect detection branch: Input F 5. Output the bounding box parameters for large-area defects such as sulfur deposition. t large With category confidence p large : ; In the formula: These represent the weights of the large-area defect regression and classification convolution kernels, respectively. These represent large-area defect regression and classification bias, respectively. Then, the classification focus loss and GIoU regression loss are fused together to simultaneously optimize the three scales: ; In the formula: These represent the weight coefficients of the corresponding loss function; This represents the true classification label and regression coordinates for the corresponding level; Representing the focus loss function: ; In the formula: nc represents the total number of defect categories. Indicates the focus parameter, Indicates the category balance weight; Indicates the GIoU regression loss: ; In the formula: Indicates the predicted bounding box. This represents the actual bounding box. This represents the area of ​​the smallest closed rectangular region that simultaneously contains both the predicted bounding box and the ground truth bounding box. Loss seg Indicates the segmentation mask loss for sulfur deposition instances: ; The final output includes a set of candidate detection boxes at three scales, class confidence, and a sulfur segmentation mask.

[0022] Based on further optimization of the above scheme, the cross-level result integration and redundancy filtering in the detection output layer are specifically as follows: First, all candidate boxes and confidence scores output at the small, medium, and large area scales are aggregated into a unified global candidate set by category: Regression parameters for each scale t j First, the bounding boxes are converted to true bounding boxes in pixel coordinates using the anchor box decoding formula. Then, they are grouped according to defect categories, and the boxes of the same category at the three scales are merged to obtain a global candidate box set divided by category. With the corresponding confidence set c is the defect category index, and nx is the total number of candidate boxes for that category; Sort the candidate set of the current category from highest to lowest confidence to obtain the sorted box sequence. ,satisfy Initialize the result set: Let the final retained set be... ; When the candidate set is not empty, perform iterative filtering: a) Select the box with the highest confidence. With corresponding confidence level Add to the final hold set b. For all remaining boxes in the candidate set If i ≥ 2, calculate the result with each other. intersection ratio c. Preset intersection-union ratio threshold IoU th Remove all intersections with a ratio greater than 1. IoU th d) The candidate boxes are selected, and the remaining boxes form a new candidate set; d) The new candidate set is re-sorted by confidence and enters the next iteration. After processing all categories, the retained results for each category are merged to obtain the global final detection set: ; For the sulfur deposition category, each candidate detection box corresponds to an instance segmentation mask, and the sulfur deposition segmentation mask is output synchronously. M sulfur The final output set of sulfur deposition segmentation masks corresponds one-to-one with the sulfur deposition detection frames.

[0023] The following are the technical effects of the present invention: This invention addresses the contradiction between "limited edge computing power and model computational overhead" by employing temporal polarity pruning, sparse-reparameterized fusion, and a multi-level lightweight backbone network structure design. This significantly reduces the number of parameters and computational load (permanent structure pruning can eliminate less than 5% of low-frequency channels, and reparameterization merges three branches into a single path, reducing the multiply-accumulate operation load during inference by 40% to 60%), enabling real-time inference on the edge (single-frame inference latency is controlled within 15 to 30 ms, fundamentally eliminating frame drops and missed detections in fast gas gliding scenarios), and significantly reducing power consumption (single-path convolutional computation reduces the number of on-chip memory accesses and intermediate feature map caching requirements, and the overall power consumption of the edge module can be controlled within 10W, adapting to the long-term offline operation requirements of devices with built-in high-energy batteries). Meanwhile, addressing the issue of image degradation caused by non-uniform motion and unstructured illumination, this approach employs six-degree-of-freedom motion decoupling, spatial variation deblurring, and polarization illumination restoration. This effectively suppresses motion blur (based on Wiener deconvolution with absolute scale motion estimation and pixel-wise adaptive blur kernels, improving peak signal-to-noise ratio and structural similarity of motion-blurred images caused by non-uniform gliding), simultaneously recovers overexposure and dark details (polarization dual-component separation compresses the brightness of overexposed areas of specular reflection, while CLAHE and dark channel priors enhance the contrast of dark defect areas, thus resolving the contradiction of "brightening equals overexposure" in traditional single histogram equalization), and improves the fidelity of input features (the restored image provides high-fidelity, low-noise input for subsequent feature extraction networks, eliminating feature distortion caused by image degradation at its source, and improving defect detection recall by 15%–25% under adverse imaging conditions). The introduction of cylindrical geometry priors allows depth estimation, motion scale restoration, and blur kernel modeling to utilize pipe-specific topological constraints, resulting in higher accuracy and lower computational overhead in pipe scenarios.Furthermore, addressing the issue of incompatibility between heterogeneous defects at extreme scales, this paper employs cylindrical topology alignment and fusion, large-area sulfur deposition instance segmentation, shallow feature orientation enhancement in sulfur deposition-covered areas, temporal feature enhancement for small targets, and simultaneous inference and joint loss optimization for three-scale detection heads. This achieves simultaneous detection of defects at extreme scales (branch-parallel inference enables full coverage from a few pixels to the entire image scale, completely resolving the "missing small" problem), ensuring the detection of hidden defects beneath sulfur deposition (increasing the shallow feature orientation enhancement guided by the sulfur deposition mask amplifies the feature amplitude of the sulfur deposition-covered area, thus amplifying weak defect signals such as perforations and corrosion hidden by the sulfur deposition layer), effectively improving the detection of micro-defects. The temporal stability of small targets (feature enhancement guided by Kalman filter prediction region utilizes the prior of the near uniform motion of defects as they slide with the device, and weights the current frame features after fusing the confidence EMA of historical multiple frames, thereby improving the consistency of continuous frame detection of small targets and reducing the false detection rate of a single frame), the detection integrity of circumferential continuous defects (circumferential loop boundary filling eliminates feature breaks at the circumferential joints of the pipe, so that continuous defects around the pipe wall will not be incorrectly segmented into two segments) and the detection accuracy (segmentation mask provides accurate sulfur deposit region boundaries for feature enhancement, and detection box provides category semantics for mask instance differentiation, the two work together to improve the overall detection accuracy).

[0024] This invention employs a three-tiered "restoration-extraction-detection" architecture, treating image restoration as a pre-processed independent module to address image degradation at its source, rather than relying on the robustness of the detection network itself. Through the full-link penetration of cylindrical geometric priors, from depth estimation, motion scale recovery, fuzzy kernel modeling to circumferential loop filling, specific topological constraints of the pipeline permeate the entire preprocessing and feature fusion process, improving scene adaptability. A decoupled training-inference design ensures expressive power through multi-branch RepBlock and polarity pruning in the training state, while reparameterized single-path in the inference state, combined with soft attention, achieves extremely low latency, balancing accuracy and efficiency. Cross-level feature enhancement guided by junction masking utilizes deep segmentation results to inversely enhance shallow features, realizing cross-scale information flow from "large-area segmentation to small target enhancement." The fusion of Kalman temporal priors and spatial feature enhancement introduces motion prediction from the target tracking domain into the feature enhancement stage before detection, leveraging the uniform motion prior of the gliding device to improve the stability of small target detection. Attached Figure Description

[0025] Figure 1 This is a schematic diagram of the defect detection system in an embodiment of the present invention.

[0026] Figure 2 This is a flowchart of the edge computing module in an embodiment of the present invention.

[0027] Among them, 10 is the device body; 20 is the drive module; 30 is the battery module; 40 is the light source module; 50 is the vision sensor module; 60 is the edge computing module; and 70 is the storage module. Detailed Implementation

[0028] The technical solutions in the embodiments of the present invention will be clearly and completely described below. In the following description, specific details such as specific system structures and technologies are presented for illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present invention.

[0029] Example 1: A defect detection system for oil and gas pipelines based on lightweight cascaded vision networks, referring to... Figure 1 As shown, it includes a device body 10, a drive module 20, a battery module 30, a light source module 40, a vision sensor module 50, an edge computing module 60, and a storage module 70. The device body 10 serves as the physical platform for the entire detection system. Its external structure is adapted to the inner diameter of the long-distance oil and gas pipeline. The device body 10 contains a sealed chamber (for physical isolation and protection of internal electronic components from harsh environments such as sulfur deposits, water stains, and gases within the pipeline). The drive module 20, battery module 30, light source module 40, vision sensor module 50, edge computing module 60, and storage module 70 are all mounted on the device body 10. The drive module 20 is installed on the outside of the device body 10 or at both ends (for physical contact with the inner wall of the pipeline; the drive module 20 utilizes the existing gas pressure difference within the pipeline as its sole power source, enabling passive drive and gliding propulsion of the device body 10 within the sealed pipeline). The battery module 30 is fixed within the sealed chamber of the device body 10 and is connected to the light source module 40, vision sensor module 50, edge computing module 60, and storage module 70. Zero electrical connection (providing all necessary power for offline detection without continuous external power supply); Light source module 40 is deployed at the detection end of device body 10 (preferably a constant power LED light source, with a linear polarizer installed at the light outlet for providing polarized static illumination to the forward or circumferential pipe wall in a completely dark environment); Visual sensor module 50 is deployed at the detection end of device body 10 and arranged adjacent to light source module 40 (Visual sensor module 50 uses a lightweight high-definition camera, with an electrically rotatable linear polarizer installed in front of the lens, capable of quickly switching to three polarization directions of 0°, 45°, and 90° within a single frame exposure cycle, simultaneously acquiring three polarized images in conjunction with the polarized light source); Visual sensor module 50 is communicatively connected to edge computing module 60 and storage module 70 (real-time output of video stream and image frame data); Edge computing module 60 is encapsulated in a sealed chamber of device body 10 (e.g., NVIDIA). The storage module 70 is installed in the sealed chamber of the device body 10 and interacts with the vision sensor module 50 and the edge computing module 60 respectively. The storage module 70 is used to record and save high-definition video data throughout the process, and at the same time, it synchronously stores the defect coordinates, classification labels and processed feature images generated by the edge computing module 60 in the pipe, so that after the detection device leaves the pipe, it can be exported to the back-end server for offline analysis and review through the physical interface.

[0030] Example 2: As another preferred embodiment of the technical solution of the present invention, based on the solution of Embodiment 1 above, The edge computing module includes a preprocessing layer, a feature extraction layer, and a detection output layer. The preprocessing layer receives the original images of adjacent frames output by the visual sensor module. ,in, H Image axis height, W Circumferential width, CThe number of channels is given by the nominal radius of the pipe. R Camera focal length f Inter-frame time interval △t As input, the process sequentially performs six-degree-of-freedom motion decoupling, spatial transformation deblurring, and polarization illumination restoration, outputting a restored illumination image. ; The specific steps for decoupling six-degree-of-freedom motion are: first, to... I t-1 and I t ORB feature point extraction and matching are performed to obtain a set of effective matching key points. S After removing mismatched points, the pixel displacement vector field is obtained. D(x,y) The specific steps are as follows: using pixels p Centered on the 16 neighboring pixels of a circle with a radius of 3, take the 16 neighboring pixels. p i , i =1,2,…,16; If there exist 9 consecutive pixels that satisfy: all grayscale values ​​are greater than 1,2,…,16; I(p) + th gray ( th gray The grayscale difference threshold is typically 20, or both are less than 20. I(p) - th gray Then determine p Candidate corner points; After filtering, non-maximum suppression (NMS) is used to remove adjacent overlapping corner points, retaining the points with the strongest local corner responses; Then, using the feature point as the center, calculate the image moments within a circular neighborhood of radius r (typically 15 pixels), and determine the principal direction of the feature point through the centroid: Zeroth moment and first moment: ; Neighboring gray centroid: ; The main direction of the feature point (and) x (Axis angle) ; A 256-bit binary descriptor is generated for each feature point, and rotation invariance is achieved through rotation in the main direction: within the neighborhood of the feature point, 256 pairs of random sampling points are pre-defined. a i , b i ), and based on the main direction of the feature points Rotate all sampling points The angle is used to obtain the rotated sampling coordinates; the gray values ​​of each pair of sampling points are compared to generate a binary descriptor. ; Generate a 256-bit descriptor vector: ; right I t-1 Each feature point in I t Find the point with the smallest Hamming distance as a candidate matching pair, complete the initial matching of feature points in two frames, and calculate the nearest neighbor distance of the feature points. d min1 Distance to the next nearest neighbor d min2 ,when hour( T ratio This represents the matching threshold, typically 0.75, and retains matching pairs (removing easily confused fuzzy matches). homogeneous pixel coordinates of matching point pairs x a =[ x 1 ,y 1 ,1 ] T (Previous frame) x b =[ x 2 ,y 2 ,1 ] T (Later frame), satisfies the epipolar constraint: Where F represents a 3×3 fundamental matrix with a rank of 2; The final effective interior point set S is obtained through RANSAC iteration. The specific process is as follows: 8 pairs of points are randomly selected from the coarsely matched points, and the initial fundamental matrix F is calculated using the 8-point method; and the Sampson distance is calculated for all matched points. ,like ( Th d If the distance threshold is 1 to 3 pixels, then the point is an interior point. Count the total number of interior points in the current model. Repeat the iteration nx times (usually 1000 times), retain the basis matrix with the most interior points, and re-optimize the basis matrix with all interior points to output the final interior point matching set S. For each pair of matching points in the set of valid interior points S Calculate the pixel displacement components at that point: ; ; If a dense displacement field is required, bilinear interpolation can be performed on the sparse matching points to obtain a pixel-level displacement vector field D(x,y) for the entire image.

[0031] Then, the RANSAC algorithm is used to fit the fundamental matrix F, combined with the camera calibration intrinsic parameter matrix. Kcam Obtain the essential matrix E and the essential matrix E Decomposition yields the rotation matrix R B Translation direction with scale t B Combined with the nominal radius of the pipeline R With camera focal length f Provided cylindrical geometric dimensions constraints, recover the rigid body transformation matrix with absolute dimensions. (This matrix fully describes the six degrees of freedom relative motion of the device from time t-1 to time t.) R B Represents rotation matrix, t B Represents the translation vector; decomposes the device into six degrees of freedom instantaneous motion parameters, including translation components. v z (Axial velocity) v x (Horizontal radial velocity) v y (Vertical radial velocity) and rotational component (angular velocity of rotation about the axis) (Pitch angular velocity about the horizontal radial axis) (Yaw rate about the vertical radial axis); the specific steps are as follows: First, based on the camera calibration intrinsic parameter matrix K cam (including focal length) f Main point ( c x ,c y Transforming the fundamental matrix into the essential matrix. ; Then, singular value decomposition is performed on the essential matrix E to obtain four candidate combinations. For each group of candidate triangulated matching points, check whether the 3D point is simultaneously in front of the camera in two frames (depth is positive), and select the unique correct rotation matrix according to the Cheirality criterion. R B With unit translation vector (at this time (This only indicates the direction of translation and does not have a measurement scale). Then, the absolute scale is recovered using the cylindrical geometric prior provided by the nominal radius R of the pipe: for each pair of matching points in S, the three-dimensional points are obtained by unit translation triangulation. Since the feature point of the pipe wall is located on a cylindrical surface of radius R, it satisfies... ,in sLet be the scaling factor to be determined; for all interior points, robustly estimate the scaling factor: ; Median estimation is used to suppress interference from defects such as sulfur buildup and corrosion pits that deviate from the cylindrical surface; if the nominal eccentricity of the device... d If 0 is known, then replace the radial distance with ; Finally, we obtain the translation vector with absolute scale. Assembled into SE(3) rigid body transformation matrix: ; This matrix fully describes the six-degree-of-freedom relative motion of the device from time t-1 to time t.

[0032] The final global equivalent axial velocity is obtained as follows: ; In the formula: D z (x,y) Represents the axial component of the displacement at key points. This represents the initial depth map output by the lightweight depth prediction head (this depth prediction head is executed before the six-degree-of-freedom motion decoupling, and outputs the initial depth map for motion estimation; the subsequent spatial change deblurring step then performs geometric constraint correction on it).

[0033] The specific steps for deblurring spatial changes are: First, a lightweight depth prediction head is constructed based on the geometric prior of the pipe cylinder, taking the current frame image as input and outputting an initial depth map. D init0 (x,y) The loss function incorporates geometric constraints to ensure that the depth distribution conforms to the cylindrical topology. ; ; In the formula: Loss pixel This represents the pixel-level depth regression loss function. Represents pixels ( i,j The depth label at the location (obtained from synthetic data rendered by the pipeline 3D simulation environment during the training phase; this loss term is not used during the inference phase, and the depth prediction head directly outputs the initial depth map using forward inference). This represents the geometric constraint weight (typically 0.4). D 0 (x,y) This represents the theoretical depth distribution of the wall of an ideal cylindrical tube. , Indicates the nominal eccentricity of the device. ; Output corrected pixel-by-pixel depth map This represents the physical distance from the pipe wall position corresponding to each pixel to the camera; Then, by combining motion parameters and depth maps, a pixel-by-pixel varying total blur kernel is generated, which includes a translation blur kernel, a rotation blur kernel, and a scale blur kernel. Translation blur kernel: Based on the pinhole imaging model, pixel-level motion displacement is inversely proportional to depth; calculate the pixel-by-pixel axial motion step size. ; Translation fuzzy kernel K trans (x,y) It is a straight, uniform core along the axial direction, with a length of... L trans (x,y) ; Rotating blur kernel: generated by roll angular velocity: ; Rotational fuzzy kernel K rot (x,y) The uniform core of the circular arc trajectory has a rotation arc length of... L rot (x,y) ; The scale fuzzy kernel is caused by radial jump. Assume the local coordinates of the fuzzy kernel are ( u,v Then its radial coordinates If the current pixel is not the center point of the image, its distance to the center point of the image. , ( cx,cy () represents the coordinates of the image center, then the scale blur kernel K scale (u,v) for: ; In the formula: Indicates the radial width with fuzzy scale. This indicates the sensor exposure time for a single frame image; If the current pixel is the center point of the image (i.e., r0=0), then the scale blur kernel... for: ; The translation, rotation, and scaling blur kernels are convolved and combined to obtain the pixel-by-pixel total blur kernel: ; In the formula: Represents a two-dimensional convolution operation; Finally, the image is divided into overlapping patches of 16×16 (or 32×32) pixels, and within each patch, a blur kernel is applied to the pixel corresponding to the center of the patch. As a locally spatially invariant kernel, Wiener deconvolution is performed in the frequency domain: ; In the formula: Fou() , Fou -1 () They represent the two-dimensional fast Fourier transform and inverse Fourier transform, respectively. express Fou() The conjugate of complex numbers, This represents the signal-to-noise ratio penalty coefficient (typically 10). -4 ); The deconvolution results of each image patch are then weighted and stitched together after being windowed (e.g., using a Hann window) to eliminate block artifacts and obtain a preliminary clear image of the entire image. ; Finally, a preliminary clear image is obtained after deblurring. .

[0034] The specific steps for restoring polarized light illumination are as follows: First, images were acquired using a rotating polarizer in front of the lens at three polarization directions (0°, 45°, 90°), and the extreme brightness values ​​of each pixel were statistically analyzed. I max (x,y) , I min (x,y) To obtain the pixel polarization degree (the polarization degree of metallic mirror reflection is high, generally greater than 0.6; the polarization degree of junctional diffuse reflection is low, generally less than 0.3): ; And based on the two-color reflection model I = I s + I d , I s For specular reflection component, I d For the diffuse reflection component, the specular reflection component and the diffuse reflection component are approximately separated based on the degree of polarization: ; Then, brightness compression is performed to suppress overexposure of metallic reflections: ; In the formula: This represents the mirror suppression coefficient (typically 0.6). Subsequently, by combining Limit Contrast Adaptive Histogram Equalization (CLAHE) with dark channel priors, sulfur deposition textures and dark defect details are enhanced: First to I d(x,y) Perform CLAHE processing with an 8×8 mesh size and a truncation threshold. T clip =0.02, resulting in a contrast-enhanced image. Then, residual light haze is removed using the dark channel prior, and the dark channel map is calculated: ; In the formula: Indicated by x A local window centered on the object (typically 15×15); Take dark channel image The top 0.1% of pixels in mid-brightness, and the diffuse image after CLAHE enhancement. In the mean (or maximum) pixel value of these pixels, the global atmospheric light value is taken. A air ; Through global atmospheric light value A air With transmittance ts(x) Reverse engineering to restore the real texture: ; ; In the formula: ts 0 indicates the lower limit of transmittance (to prevent overflow from division by zero, it is generally 0.1). This represents the depth retention factor (typically 0.95). Finally, the restored lighting image was obtained. .

[0035] The feature extraction layer is based on a lightweight defect detection backbone network. It receives the restored illumination image and extracts multi-level robust feature maps through initial feature extraction, temporal polarity pruning, dual-dimensional perceptual routing, multi-branch heterogeneous feature extraction, and sparse-heavy parameterization fusion. The initial feature extraction is as follows: an initial convolutional layer is used for initial feature extraction. The initial convolutional layer is a single 3×3 convolutional layer with a stride of 2 and padding of 1, and the number of output channels is... C 0=32, followed by a batch normalization (BN) layer (to complete the initial mapping from the RGB image to the high-dimensional feature space, simultaneously achieving 2x downsampling, and outputting the first layer of basic features of the backbone network), output features ; The restored illumination image is input into the initial convolutional layer to obtain the initial feature tensor. .

[0036] Temporal polarity pruning specifically includes: First, receive C1. Feature map, and calculate the mean spatial feature of the c-th channel of the current frame: ; The single-channel polarity activation density of the current frame is obtained by using the spatial feature mean (only positive activations above the mean are retained, characterizing the channel's response strength to defects): ; Introducing temporal memory weights and fusing the polarity memory of the previous frame helps suppress single-frame noise fluctuations. ; In the formula: This indicates the time-series update weight (typically 0.7). This represents the polarity memory vector of the previous frame (the initial memory vector is the mean channel polarity density of all normal tube wall samples, obtained statistically from the training set). Update the polarity memory vector: ; Then, based on the global background proportion estimate B t (Obtained from feature mean statistics) Dynamically adjust the baseline threshold: ; In the formula: This represents the baseline pruning threshold (initially set to the 30th percentile of polarity density sorting). This represents the statistical average percentage of the pipeline background (typically 0.85). This represents the threshold adaptive coefficient (typically 0.3). Introducing a hysteresis mechanism to generate a pruned mask (to avoid frequent channel switching jitter): ; In the formula: This indicates the width of the hysteresis interval (typically 10% of the baseline threshold). Multiply the mask by the initial features channel by channel to obtain the sparsed backbone feature map: ; During the training phase, the mask activation frequency of each channel on the entire training set is statistically analyzed using an exponential moving average. ,right The channels undergo permanent structural pruning and are removed from the network topology; during the inference phase, for the remaining channels, As a frame-by-frame modulation feature for soft channel attention weights (with values ​​relaxed to continuous values ​​in [0,1]), it no longer changes the network topology; channels that are permanently pruned do not participate in the calculation during the inference phase; The final output includes a fixed set of channel indices and frame-by-frame attention weights after pruning. Mt With sparsified feature map .

[0037] The two-dimensional perceptual routing is specifically as follows: First, perform average pooling along the circumferential direction (i.e., the width dimension) to extract the axial spatial continuity features and generate the axial weight matrix: ; In the formula: Indicates the axial 1D convolution kernel parameters; Then, perform average pooling along the axial direction (height dimension) to extract the circumferential closed-loop continuity features and generate the circumferential weight matrix: ; In the formula: Represents the parameters of the circumferential 1D convolution kernel; Bidirectional feature enhancement is achieved by multiplying the weights of the two orthogonal directions element-wise using a broadcast mechanism. ; In the formula: This indicates element-wise multiplication (under broadcast mechanism). W qA Copy along the width dimension W qB After copying along the height dimension and F prune Element-by-element multiplication).

[0038] Multi-branch heterogeneous feature extraction specifically involves: The system comprises four feature extraction layers. Each layer consists of a channel adjustment convolutional block and a spatial downsampling convolutional block. The channel adjustment convolutional block is a single 1×1 convolutional layer with a stride of 1 and padding of 0, followed by a BN layer for cross-channel information fusion. The spatial downsampling convolutional block is a single 3×3 convolutional layer with a stride of 2 and padding of 1, followed by a BN layer to simultaneously halve the feature map size and double the number of channels. After the downsampling convolutional blocks, several RepBlocks are stacked (each RepBlock adopts a three-branch structure in the training state: the main branch is a 3×3 convolution + BN, the side branch is a 1×1 convolution + BN, and the residual branch is an identity mapping; the outputs of the three branches are added element-wise and then activated by ReLU). The first-level feature extraction layer has a downsampling factor of 4x, 32 input channels, 2 RepBlock stacks, and 64 output channels, outputting features. ; The second-level feature extraction layer has a downsampling factor of 8x, 64 input channels, 3 RepBlock stacks, and 128 output channels, outputting features. ; The third-level feature extraction layer has a downsampling factor of 16x, 128 input channels, 3 RepBlock stacks, and 256 output channels, outputting features. ; The fourth-level feature extraction layer has a downsampling factor of 32x, 256 input channels, 2 RepBlock stacks, and 512 output channels, producing output features. ; Downsampling is achieved through 3×3 convolutions with a stride of 2, simultaneously halving the feature map size and doubling the number of channels; each feature extraction layer's RepBlock employs a multi-branch structure in training mode to ensure the model's feature representation capability; the output of the initial convolutional layer... C 1 and the output of all feature extraction layers C 2~ C These five elements together form the input basis for the subsequent detection output layer.

[0039] The sparse-reparameterized fusion is specifically as follows: First, for each convolutional branch, perform an equivalent fusion of the convolutional kernel and the BN layer: ; In the formula: This represents the convolutional kernel weights of the k-th branch and the c-th output channel (obtained through gradient descent optimization during training). This represents the moving average of the BN layer after the k-th branch and the c-th channel (updated cumulatively during training using the moving average). This represents the sliding variance of the BN layer and the c-th channel after the k-th branch (accumulated during synchronous sliding during training). This represents the scaling factor for the c-th channel of the BN layer (obtained through gradient descent optimization during training). represents the offset factor of the c-th channel in the BN layer (obtained through gradient descent optimization during training); k corresponds to the 3×3 convolutional branch and the 1×1 convolutional branch; Then, based on the fixed set of channel indices after training, the input / output channels that have been permanently pruned are removed to obtain the pruned branch weights. With bias ; Next, the parameters of the pruned 3×3 convolution, the zero-padding 1×1 convolution, and the pruned unit direct connection branch are summed to obtain the final deployment weights and biases: ; In the formula: Pad() This indicates a zero-padding operation (that is, padding the 1×1 convolution kernel with zeros around its perimeter to expand it to a 3×3 size, ensuring that it has the same dimensions as the 3×3 convolution kernel and can be added element by element). This represents the equivalent unit array convolution kernel after pruning (its shape is consistent with the pruned 3×3 convolution, each output channel corresponds only to the input channel with the same index, the weight at the center of the kernel is 1, and the weights at the other positions are 0; since RepBlock is stacked after channel adjustment and spatial downsampling, its number of input and output channels is equal and its spatial size remains unchanged, so the identity mapping branch exists). Finally, the fused single-path parameters are directly used on the edge hardware to calculate and output multi-level feature maps: ; In the formula: l Corresponding to the four-level feature extraction layer, each RepBlock of each level independently performs reparameterized fusion, outputting C2 to C5 in sequence.

[0040] The detection output layer takes multi-level robust feature maps as input, and after topological alignment and fusion with cylinders, it simultaneously completes large-area sulfur deposition segmentation, shallow feature orientation enhancement of sulfur deposition coverage area, small target feature enhancement, multi-scale detection head synchronous inference and joint loss calculation, cross-level result integration and redundancy filtering, and finally outputs structured defect classification, localization and segmentation results. The specific process of cylinder topology alignment and blending is as follows: First, deep feature C5 is selected as the starting point of the pyramid, and the number of channels is adjusted through a 1×1 convolution to obtain the top-level feature: ; Then, loop boundary padding is performed on the circumferential (width dimension) of the deep feature map to simulate the continuity of a closed cylinder: ; In the formula: w pad This indicates the padding width (typically 1 / 10 of the feature map width). Next, the padded deep features are bilinearly upsampled by a factor of 2 and then added element-wise to the corresponding shallow features that have undergone 1×1 convolution dimensionality reduction: ; Finally, the filled edge regions are cropped, and then a 3×3 convolution is applied to smooth out the upsampling aliasing, resulting in the final multi-scale fused feature map: ; In the formula: Crop() This indicates a spatial dimension clipping operation. F 3 indicates shallow high-resolution features (adapted to small targets). F 4 indicates the fusion feature of the intermediate level (connecting shallow, small targets with deep, large-area defects). F 5 indicates deep, strong semantic features (suitable for large-area defects); The final output is an aligned multi-scale fused feature map.F 3 ,F 4 ,F 5}.

[0041] Large-area sulfur deposition segmentation specifically refers to: In deep strong semantic features F 5. A lightweight instance segmentation header is added, which includes two branches: a classification branch and a mask branch. Classification branch: Outputs the confidence level of the sulfur deposition region category; Masking Branch: Output Junction Binary Partition Mask ; The segmentation loss uses Dice loss to optimize mask overlap. ; In the formula: M pred Indicates the prediction mask. M gt This indicates that the actual mask was manually labeled. Final output sulfur segmentation mask M sulfur Large-area sulfur deposition detection frame and classification results.

[0042] The specific method for targeted enhancement of shallow features in sulfur-covered areas is as follows: first, the sulfur-covered mask is bilinearly upsampled to shallow features. F At a resolution of 3, a mask of the same scale is obtained. ; Further regional weighting of shallow features enhances the amplitude of features in sulfur-covered areas, thus amplifying weak internal defect signals. ; In the formula: This represents the sulfur deposition enhancement factor (typically 0.7). The final output shows the enhanced shallow features of the sulfur deposition region. F 3,weighted .

[0043] The specific methods for enhancing the features of small targets are: First, considering the approximately uniform axial motion characteristics of fixed defects within the pipeline as they slide along with the device, a uniform motion (CV) Kalman filter is used to analyze each defect trajectory. T i Perform state estimation and prediction, and output the predicted location region of the current frame. R CV-i Compared with historical average confidence level p CV-i Specifically: Each trajectory T iFor each independent Kalman filter, the state vector describes the position and velocity of the defect in the image plane: , ( x k ,y k ) indicates the first k The center pixel coordinates of the defective target in the frame. v x,k 、v y,k This indicates the pixel movement speed of the defect in the image; When a tiny target that cannot be matched with any existing trajectory is detected, initialize a new trajectory: And initialize the covariance matrix: ; Then, Kalman filtering prediction is performed: the posterior state of the previous frame is input. Posterior covariance ; State prediction: ; Covariance prediction: ; in, FZ The state transition matrix represents the state evolution relationship of uniform motion between frames: ; Qfc This represents the process noise covariance, describing the model uncertainty caused by pressure fluctuations and speed jitter in the device. ; In the formula: q fc Indicates process noise intensity (typically 0.5 per pixel). 2 / frame 4 )); Before updating the filter, it is necessary to match all the small target detection results in the current frame with the predicted positions of existing trajectories to establish a one-to-one correspondence: first, calculate the intersection-union ratio (IOU) between each detection box and each trajectory prediction position; then, use the Hungarian algorithm for global optimal matching, setting an IOU threshold (such as 0.3) or a distance threshold. Successful matches are considered as the same defect trajectory; for unmatched detection results, initialize them as new trajectories; if no detected trajectory is matched for 3 consecutive frames, it is determined that the defect has slipped out of the field of view and the trajectory is deleted. Then, Kalman filtering is performed to update the input prior state. Prior covariance Current frame measurement value ; Calculate the measurement residual (i.e., the deviation between the predicted position and the actual detection position): ; Calculate the residual covariance: ; Calculate the Kalman gain: ; Estimated update status: ; Update the covariance matrix: ; Where HC represents the measurement matrix: , representing the measurement noise covariance: ; Finally, predict the location Centered on, from the prior covariance Extract the first 2 rows and 2 columns to obtain the position covariance submatrix. This allows us to obtain the predicted location region of the current frame. R CV-i : ; The historical average confidence score is fused using exponential moving average (EMA) fusion. p CV-i : ; In the formula: This represents the target category confidence score output by the detection head in the k-th frame, corresponding to the trajectory. This represents the smoothing coefficient (usually 0.3). Cold start strategy: In the first frame or the first few frames before the trajectory is established, temporal feature enhancement is not performed, and the system directly uses... F 3,weighted As input to the small target detection branch; after the detection branch outputs the initial detection result and completes trajectory initialization, Kalman prediction region-guided feature enhancement is enabled from the next frame; for the newly initialized trajectory, only the predicted location region is used in the first 3 frames after its establishment without applying confidence weighting (i.e., p CV-i (Use a fixed initial value of 0.5) and wait for the EMA confidence level to stabilize before weighting according to the formula.

[0044] Then, the features within the prediction region are subjected to a second weighted enhancement: ; In the formula: This represents the timing enhancement factor (typically 0.6). The final output is an enhanced shallow feature map of small targets. F 3,enhanced .

[0045] The multi-scale detection head synchronous inference and joint loss calculation are specifically as follows: Parallel inference of three scale detection heads: small target detection branch, medium target detection branch, and large area defect detection branch. Small object detection branch: Input F 3, enhanced Output the bounding box parameters for three types of small targets: ordinary perforations, leak points, and perforations covered by sulfur deposits. t small With category confidence p small : ; In the formula: These represent the weights of the shallow regression and classification convolution kernels, respectively. These represent shallow regression and classification bias, respectively. Medium-sized object detection branch: Input F 4. Output the bounding box parameters for medium-scale defects (including pipe wall flaking corrosion, weld abnormalities, medium-area sulfur residue, etc.). t mid With category confidence p mid : ; In the formula: These represent the weights of the mid-level regression and classification convolution kernels, respectively. These represent mid-level regression and classification bias, respectively. Large-area defect detection branch: Input F 5. Output the bounding box parameters for large-area defects such as sulfur deposition. t large With category confidence p large : ; In the formula: These represent the weights of the large-area defect regression and classification convolution kernels, respectively. These represent large-area defect regression and classification bias, respectively. Then, the classification focus loss and GIoU regression loss are fused together to simultaneously optimize the three scales: ; In the formula: These represent the weight coefficients of the corresponding loss function (generally) ); This represents the true classification label and regression coordinates for the corresponding level; Representing the focus loss function: ; In the formula: nc represents the total number of defect categories. This indicates the focusing parameter (usually 2). This indicates the category balance weights (0.75 for foreground class and 0.25 for background class). Indicates the GIoU regression loss: ; In the formula: Indicates the predicted bounding box. This represents the actual bounding box. This represents the area of ​​the smallest closed rectangular region that simultaneously contains both the predicted bounding box and the ground truth bounding box. Loss seg Indicates the segmentation mask loss for sulfur deposition instances: ; The final output includes a set of candidate detection boxes at three scales, class confidence, and a sulfur segmentation mask.

[0046] Cross-level result integration and redundancy filtering specifically refer to: First, all candidate boxes and confidence scores output at the small, medium, and large area scales are aggregated into a unified global candidate set by category: Regression parameters for each scale t j First, the bounding boxes are converted to true bounding boxes in pixel coordinates using the anchor box decoding formula. Then, they are grouped according to defect categories, and the boxes of the same category at the three scales are merged to obtain a global candidate box set divided by category. With the corresponding confidence set c is the defect category index, and nx is the total number of candidate boxes for that category; Sort the candidate set of the current category from highest to lowest confidence to obtain the sorted box sequence. ,satisfy Initialize the result set: Let the final retained set be... ; When the candidate set is not empty, perform iterative filtering: a) Select the box with the highest confidence. With corresponding confidence level Add to the final hold set b. For all remaining boxes in the candidate set If i ≥ 2, calculate the result with each other. intersection ratio c. Preset intersection-union ratio threshold IoU th (Usually 0.45), remove all crossover ratios greater than 0.45. IoU thd) The candidate boxes are selected, and the remaining boxes form a new candidate set; d) The new candidate set is re-sorted by confidence and enters the next iteration. After processing all categories, the retained results for each category are merged to obtain the global final detection set: ; For the sulfur deposition category, each candidate detection box corresponds to an instance segmentation mask, and the sulfur deposition segmentation mask is output synchronously. M sulfur The final output set of sulfur deposition segmentation masks corresponds one-to-one with the sulfur deposition detection frames.

Claims

1. A defect detection system for oil and gas pipelines based on a lightweight cascaded vision network, characterized in that: It includes the device body, drive module, battery module, light source module, vision sensor module, edge computing module, and storage module; The device body serves as the physical platform for the entire detection system, and it contains a sealed chamber. The drive module, battery module, light source module, vision sensor module, edge computing module, and storage module are all mounted on the device body. The drive module is installed externally or at either end of the device body. The battery module is fixed within the sealed chamber of the device body and is electrically connected to the light source module, vision sensor module, edge computing module, and storage module. The light source module is deployed at the detection end of the device body. The vision sensor module is deployed at the detection end of the device body and is arranged adjacent to the light source module. The vision sensor module communicates with the edge computing module and storage module. The edge computing module is encapsulated within the sealed chamber of the device body. The storage module is installed within the sealed chamber of the device body and interacts with the vision sensor module and edge computing module for data exchange.

2. The oil and gas pipeline defect detection system based on a lightweight cascaded vision network according to claim 1, characterized in that: The edge computing module includes a preprocessing layer, a feature extraction layer, and a detection output layer. The preprocessing layer receives adjacent frame raw images output by the visual sensor module. ,in, H Image axis height, W Circumferential width, C The number of channels is given by the nominal radius of the pipe. R Camera focal length f Inter-frame time interval △t As input, the process sequentially performs six-degree-of-freedom motion decoupling, spatial transformation deblurring, and polarization illumination restoration, outputting a restored illumination image. ; The feature extraction layer is based on a lightweight defect detection backbone network. It receives the restored illumination image and extracts multi-level robust feature maps through initial feature extraction, temporal polarity pruning, dual-dimensional perceptual routing, multi-branch heterogeneous feature extraction, and sparse-heavy parameterization fusion. The detection output layer takes multi-level robust feature maps as input, and after topological alignment and fusion with cylinders, it simultaneously completes large-area sulfur deposition segmentation, shallow feature orientation enhancement of sulfur deposition coverage area, small target feature enhancement, multi-scale detection head synchronous inference and joint loss calculation, cross-level result integration and redundancy filtering, and finally outputs structured defect classification, localization and segmentation results.

3. The oil and gas pipeline defect detection system based on a lightweight cascaded vision network according to claim 1 or 2, characterized in that: In the preprocessing layer, the six-degree-of-freedom motion decoupling specifically involves: first, decoupling the motion of the six degrees of freedom... I t-1 and I t ORB feature point extraction and matching are performed to obtain a set of effective matching key points. S After removing mismatched points, the pixel displacement vector field is obtained. D(x,y) ; Then, the RANSAC algorithm is used to fit the fundamental matrix F, combined with the camera calibration intrinsic parameter matrix. K cam Obtain the essential matrix E and the essential matrix E Decomposition yields the rotation matrix R B Translation direction with scale t B Combined with the nominal radius of the pipeline R With camera focal length f Provided cylindrical geometric dimensions constraints, recover the rigid body transformation matrix with absolute dimensions. , R B Represents rotation matrix, t B Represents the translation vector; Decompose the device into six degrees of freedom instantaneous motion parameters: including translational components. v z , v x , v y With rotational components , , ; The final global equivalent axial velocity is obtained as follows: ; In the formula: D z (x,y) Represents the axial component of the displacement at key points. This represents the initial depth map output by the lightweight depth prediction head.

4. A defect detection system for oil and gas pipelines based on a lightweight cascaded vision network according to claim 2 or 3, characterized in that: In the preprocessing layer, spatial variation deblurring specifically involves: First, a lightweight depth prediction head is constructed based on the geometric prior of the pipe cylinder, taking the current frame image as input and outputting an initial depth map. D init0 (x,y) The loss function incorporates geometric constraints to ensure that the depth distribution conforms to the cylindrical topology. ; ; In the formula: Loss pixel This represents the pixel-level depth regression loss function. Represents pixels ( i,j Depth label at ) Indicates the geometric constraint weights; D 0 (x,y) This represents the theoretical depth distribution of the wall of an ideal cylindrical tube. , Indicates the nominal eccentricity of the device. ; Output corrected pixel-by-pixel depth map This represents the physical distance from the pipe wall position corresponding to each pixel to the camera; Then, by combining motion parameters and depth maps, a pixel-by-pixel varying total blur kernel is generated, which includes a translation blur kernel, a rotation blur kernel, and a scale blur kernel. Translation blur kernel: Based on the pinhole imaging model, pixel-level motion displacement is inversely proportional to depth; calculate the pixel-by-pixel axial motion step size. ; Translation fuzzy kernel K trans (x,y) It is a straight, uniform core along the axial direction, with a length of... L trans (x,y) ; Rotating blur kernel: generated by roll angular velocity: ; Rotational fuzzy kernel K rot (x,y) The uniform core of the circular arc trajectory has a rotation arc length of... L rot (x,y) ; The scale fuzzy kernel is caused by radial jump. Assume the local coordinates of the fuzzy kernel are ( u,v Then its radial coordinates If the current pixel is not the center point of the image, its distance to the center point of the image. , ( cx,cy () represents the coordinates of the image center, then the scale blur kernel K scale (u,v) for: ; In the formula: Indicates the radial width with fuzzy scale. This indicates the sensor exposure time for a single frame image; If the current pixel is the center point of the image, then the scale blur kernel... for: ; The translation, rotation, and scaling blur kernels are convolved and combined to obtain the pixel-by-pixel total blur kernel: ; In the formula: Represents a two-dimensional convolution operation; Finally, the image is divided into overlapping patches of 16×16 or 32×32 pixels, and within each patch, a blur kernel is applied corresponding to the center pixel of that patch. As a locally spatially invariant kernel, Wiener deconvolution is performed in the frequency domain: ; In the formula: Fou() , Fou -1 () They represent the two-dimensional fast Fourier transform and inverse Fourier transform, respectively. express Fou() The conjugate of complex numbers, Indicates the signal-to-noise ratio penalty coefficient; The deconvolution results of each patch are windowed and then weighted and stitched together to eliminate block artifacts, resulting in a preliminary clear image of the entire image. ; Finally, a preliminary clear image is obtained after deblurring. .

5. The oil and gas pipeline defect detection system based on a lightweight cascaded vision network according to claim 4, characterized in that: The polarization restoration in the preprocessing layer specifically involves: First, using images acquired in three polarization directions by rotating a polarizer in front of the lens, the extreme brightness values ​​of each pixel are statistically analyzed. I max (x,y) , I min (x,y) To obtain the pixel polarization degree: ; And based on the two-color reflection model I = I s + I d , I s For specular reflection component, I d For the diffuse reflection component, the specular reflection component and the diffuse reflection component are approximately separated based on the degree of polarization: ; Then, brightness compression is performed to suppress overexposure of metallic reflections: ; In the formula: Indicates the mirror suppression coefficient; Subsequently, by combining contrast-limited adaptive histogram equalization with dark channel priors, sulfur deposition texture and dark defect details are enhanced: First to I d (x,y) Perform CLAHE processing with an 8×8 mesh size and a truncation threshold. T clip =0.02, resulting in a contrast-enhanced image. Then, residual light haze is removed using the dark channel prior, and the dark channel map is calculated: ; In the formula: Indicated by x A local window centered on the user; Take dark channel image The top 0.1% of pixels in mid-brightness, and the diffuse image after CLAHE enhancement. In the mean value of these pixels, the average value is taken as the global atmospheric light value. A air ; Through global atmospheric light value A air With transmittance ts(x) Reverse engineering to restore the real texture: ; ; In the formula: ts 0 indicates the lower limit of transmittance. Indicates the depth retention factor; Finally, the restored lighting image was obtained. .

6. The oil and gas pipeline defect detection system based on a lightweight cascaded vision network according to claim 5, characterized in that: In the feature extraction layer, the initial feature extraction specifically involves: using an initial convolutional layer for initial feature extraction. The initial convolutional layer is a single 3×3 convolutional layer with a stride of 2 and padding of 1, and the number of output channels is... C 0=32, followed by a batch normalization layer (1 layer) to output features. ; The restored illumination image is input into the initial convolutional layer to obtain the initial feature tensor. .

7. The oil and gas pipeline defect detection system based on a lightweight cascaded vision network according to claim 6, characterized in that: In the feature extraction layer, temporal polarity pruning specifically involves: First, receive C 1. Feature map, and calculate the mean spatial feature of the c-th channel of the current frame: ; The single-channel polarity activation density of the current frame is obtained by using the mean of spatial features: ; Introducing temporal memory weights and fusing the polarity memory of the previous frame helps suppress single-frame noise fluctuations. ; In the formula: Indicates the time-series update weights. This represents the polarity memory vector of the previous frame; Update the polarity memory vector: ; Then, based on the global background proportion estimate B t Dynamically adjust the baseline threshold: ; In the formula: Indicates the baseline pruning threshold. This represents the statistical average percentage of the proportion of pipeline background. Indicates the threshold adaptive coefficient; Introducing a hysteresis mechanism to generate a pruning mask: ; In the formula: Indicates the width of the hysteresis interval; Multiply the mask by the initial features channel by channel to obtain the sparsed backbone feature map: ; During the training phase, the mask activation frequency of each channel on the entire training set is statistically analyzed using an exponential moving average. ,right The channels undergo permanent structural pruning and are removed from the network topology; during the inference phase, for the remaining channels, As a frame-by-frame modulation feature for soft channel attention weights, it no longer changes the network topology; channels that are permanently pruned do not participate in computation during the inference phase. The final output includes a fixed set of channel indices and frame-by-frame attention weights after pruning. M t With sparsified feature map .

8. The oil and gas pipeline defect detection system based on a lightweight cascaded vision network according to claim 7, characterized in that: In the feature extraction layer, the two-dimensional perceptual routing specifically refers to: First, perform average pooling along the circumferential direction to extract the axial spatial continuity features and generate the axial weight matrix: ; In the formula: Indicates the axial 1D convolution kernel parameters; Then, perform average pooling along the axial direction to extract the circumferential closed-loop continuity features and generate the circumferential weight matrix: ; In the formula: Represents the parameters of the circumferential 1D convolution kernel; Bidirectional feature enhancement is achieved by multiplying the weights of the two orthogonal directions element-wise using a broadcast mechanism. ; In the formula: This indicates element-wise multiplication.

9. The oil and gas pipeline defect detection system based on a lightweight cascaded vision network according to claim 8, characterized in that: In the feature extraction layer, the multi-branch heterogeneous feature extraction specifically involves: It includes four levels of feature extraction layers. Each feature extraction layer contains a channel adjustment convolutional block and a spatial downsampling convolutional block in sequence: the channel adjustment convolutional block is a single 1×1 convolutional layer with a stride of 1 and padding of 0, followed by a BN layer for cross-channel information fusion; the spatial downsampling convolutional block is a single 3×3 convolutional layer with a stride of 2 and padding of 1, followed by a BN layer to simultaneously halve the feature map size and double the number of channels; several RepBlocks are stacked after the downsampling convolutional blocks; The first-level feature extraction layer has a downsampling factor of 4x, 32 input channels, 2 RepBlock stacks, and 64 output channels, outputting features. ; The second-level feature extraction layer has a downsampling factor of 8x, 64 input channels, 3 RepBlock stacks, and 128 output channels, outputting features. ; The third-level feature extraction layer has a downsampling factor of 16x, 128 input channels, 3 RepBlock stacks, and 256 output channels, outputting features. ; The fourth-level feature extraction layer has a downsampling factor of 32x, 256 input channels, 2 RepBlock stacks, and 512 output channels, producing output features. ; Downsampling is achieved through 3×3 convolutions with a stride of 2, simultaneously halving the feature map size and doubling the number of channels; each feature extraction layer's RepBlock employs a multi-branch structure in training mode to ensure the model's feature representation capability; the output of the initial convolutional layer... C 1 and the output of all feature extraction layers C 2~ C These five elements together form the input basis for the subsequent detection output layer.

10. The oil and gas pipeline defect detection system based on a lightweight cascaded vision network according to claim 9, characterized in that: In the feature extraction layer, the sparse-re-parameterized fusion specifically involves: First, for each convolutional branch, perform an equivalent fusion of the convolutional kernel and the BN layer: ; In the formula: This represents the kernel weights of the k-th branch and the c-th output channel. This represents the moving average of the BN layer and the c-th channel after the k-th branch. This represents the sliding variance of the BN layer and the c-th channel after the k-th branch. This represents the scaling factor for the c-th channel of the BN layer. represents the offset factor of the c-th channel in the BN layer; k corresponds to the 3×3 convolution branch and the 1×1 convolution branch; Then, based on the fixed set of channel indices after training, the input / output channels that have been permanently pruned are removed to obtain the pruned branch weights. With bias ; Next, the parameters of the pruned 3×3 convolution, the zero-padding 1×1 convolution, and the pruned unit direct connection branch are summed to obtain the final deployment weights and biases: ; In the formula: Pad() Indicates zero-filling operation; This represents the equivalent identity matrix convolution kernel after clipping; Finally, the fused single-path parameters are directly used on the edge hardware to calculate and output multi-level feature maps: ; In the formula: l Corresponding to the four-level feature extraction layer, each RepBlock of each level independently performs reparameterized fusion, outputting C2 to C5 in sequence.