A PE pipe defect detection method based on image recognition

By generating a dense optical flow field and decomposing it into rigid translation vectors and non-rigid deformation vectors, the problem of false detection caused by dynamic water stains and oil contamination on the surface of PE pipes is solved, and accurate detection of defects in PE pipes is achieved.

CN122492590APending Publication Date: 2026-07-31GUIZHOU WUSU TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GUIZHOU WUSU TECHNOLOGY CO LTD
Filing Date
2026-04-29
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

Existing morphological filtering or convolutional neural network methods based on single-frame images cannot effectively distinguish between dynamic water stains and oil stains on the surface of PE pipes and real defects, leading to false detections.

Method used

A deformable convolutional network is used to generate a dense optical flow field, which is decomposed into rigid translation vectors and non-rigid deformation vectors. Pixel-level motion compensation alignment is performed using rigid translation vectors, and inter-frame difference residual images are calculated. Spatial suppression weight matrix is ​​generated using the magnitude of non-rigid deformation vectors, and suppressed residual images are generated by multiplying them element by element. Finally, the defect location and category are output through a defect detection head.

Benefits of technology

It effectively separates the static defect features and dynamic optical deformation of the PE pipe surface, removes the pixel response of non-rigid deformation areas caused by water stains and oil stains, eliminates false detections caused by dynamic reflection interference, and improves the accuracy of defect detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122492590A_ABST
    Figure CN122492590A_ABST
Patent Text Reader

Abstract

This invention relates to the field of image recognition technology, specifically to a method for detecting defects in PE pipes based on image recognition. The method acquires a sequence of three consecutive surface images of the pipe during uniform motion, and uses a deformable convolutional network to calculate the dense optical flow field between adjacent frames. The dense optical flow field is decomposed into a rigid translation vector representing the overall motion of the pipe and a non-rigid deformation vector representing local pixel abrupt changes. The rigid translation vector is used to perform pixel-level motion compensation alignment on adjacent frames, and an inter-frame difference residual image is calculated. The magnitude of the non-rigid deformation vector is converted into a spatial suppression weight matrix. The spatial suppression weight matrix is ​​multiplied element-wise with the inter-frame difference residual image to generate a suppressed residual image, which is then input into a defect detection head to output the defect location and category. This scheme separates static defect features from the dynamic optical deformation of attached materials at the physical motion level, and removes the non-rigid deformation pixel response caused by water stains and oil contamination.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image recognition technology, and more specifically to a method for detecting defects in PE pipes based on image recognition. Background Technology

[0002] Currently, when inspecting the appearance of polyethylene pipes on the production line, a line scan camera is typically used to acquire images of the pipe surface under a fixed light source. Due to the limitations of the production environment, water stains or oil stains often adhere to the pipe surface. Existing conventional recognition schemes usually employ morphological filtering to process single-frame images, or directly use ordinary convolutional neural networks to extract features and classify single-frame visible light images. The aforementioned morphological filtering method attempts to remove the interfering textures of water stains and oil stains by setting structuring elements of fixed size and shape and performing erosion and dilation operations on the bright or dark areas in the image. The scheme that directly uses ordinary convolutional neural networks trains the network weights with a large number of positive and negative samples containing water stains and oil stains, relying on the network to learn the static spatial texture distribution within a single-frame image to distinguish between defective areas and interference areas.

[0003] During the actual operation of the conveyor belt in a production line, water stains and oil contaminants on the pipe surface are not static. Under illumination, the liquid surface undergoes continuous dynamic refraction and deformation flickering, causing the water stains and oil contaminants to exhibit randomly changing optical features in images at adjacent moments. Existing techniques based on single-frame image morphological filtering or ordinary convolutional neural networks only utilize static spatial texture features, failing to capture and distinguish this time-varying dynamic optical deformation from the pipe's actual physical defects. When the pixel fluctuation features generated by the dynamic deformation of water stains and oil contaminants overlap with the static texture features of real defects, existing technologies cannot separate the two, leading to the misidentification of the dynamic flickering of water stains and oil contaminants as pipe defects. Summary of the Invention

[0004] The purpose of this invention is to provide a PE pipe defect detection method based on image recognition, which can effectively solve the problems mentioned in the background art.

[0005] To achieve the above objectives, the technical solution adopted by the present invention is as follows: A defect detection method for PE pipe based on image recognition includes: acquiring a sequence of three consecutive surface images of the PE pipe as it moves at a constant speed on a conveyor belt; A deformable convolutional network is used to extract features and calculate offsets for adjacent frames in the three consecutive frames of surface images to generate a dense optical flow field between adjacent frames. The dense optical flow field is decomposed into a rigid translation vector characterizing the overall motion of the pipe and a non-rigid deformation vector characterizing local pixel abrupt changes. The rigid translation vector is used to perform pixel-level motion compensation alignment on the adjacent frame images, and the aligned inter-frame difference residual image is calculated. The magnitude of the non-rigid deformation vector is converted into a spatial suppression weight matrix through a preset mapping function; The spatial suppression weight matrix is ​​multiplied element-wise with the inter-frame difference residual image to generate a suppression residual image; The suppressed residual image is input into a pre-built defect detection head, which outputs the location and type of PE pipe defects.

[0006] Preferably, the step of using a deformable convolutional network to extract features and calculate offsets for adjacent frames in the three consecutive frames of surface images to generate a dense optical flow field between adjacent frames includes: inputting the previous frame and the next frame in the adjacent frames into the first feature extraction branch and the second feature extraction branch of the deformable convolutional network to generate a first feature map and a second feature map, respectively. The first feature map and the second feature map are concatenated and input into a cascaded deformable convolutional layer. The deformable convolutional layer generates horizontal and vertical offsets based on the pixel differences between the first and second feature maps. The horizontal offset and the vertical offset are combined to form the dense optical flow field.

[0007] Preferably, the step of decomposing the dense optical flow field into a rigid translation vector characterizing the overall motion of the pipe and a non-rigid deformation vector characterizing local pixel abrupt changes includes: dividing the dense optical flow field into regional blocks and calculating the mean and variance of the optical flow vectors of all pixels in each regional block; Regions with variance less than a preset consistency threshold are marked as rigid regions, and the mean optical flow vector within the rigid region is used as the rigid translation vector. Regions with variance greater than or equal to the preset consistency threshold are marked as non-rigid regions, and the optical flow vectors of each pixel within the non-rigid region are extracted as the non-rigid deformation vectors.

[0008] Preferably, the step of using the rigid translation vector to perform pixel-level motion compensation alignment on the adjacent frame images and calculating the aligned inter-frame difference residual image includes: using the previous frame image in the adjacent frame images as a reference, using a bicubic interpolation algorithm, and based on the rigid translation vector, performing reverse mapping on the coordinates of each pixel point in the next frame image in the adjacent frame images to generate the aligned next frame image. Calculate the absolute value of the pixel grayscale difference between the previous frame image and the aligned next frame image at the same coordinate position, and use the matrix composed of the absolute values ​​of the pixel grayscale difference as the inter-frame difference residual image.

[0009] Preferably, the step of converting the magnitude of the non-rigid deformation vector into a spatial suppression weight matrix through a preset mapping function includes: calculating the sum of squares of the horizontal and vertical components corresponding to each pixel in the non-rigid deformation vector, and taking the square root of the sum of squares to obtain the non-rigid deformation magnitude of each pixel. The non-rigid deformation modulus value of each pixel is input into the Gaussian decay mapping function, which uses the non-rigid deformation modulus value as the independent variable and the weight coefficient in the range of zero to one as the dependent variable. The spatial suppression weight matrix is ​​generated by arranging the weight coefficients corresponding to all pixels according to their pixel coordinates.

[0010] Preferably, the step of multiplying the spatial suppression weight matrix element-wise with the inter-frame difference residual image to generate a suppressed residual image, and inputting the suppressed residual image into a pre-constructed defect detection head to output the location and category of the PE pipe defect includes: multiplying the pixel value at each coordinate position in the inter-frame difference residual image with the weight coefficient at the same coordinate position in the spatial suppression weight matrix, and using the product as the pixel value at the corresponding coordinate position in the suppressed residual image; The defect detection head sequentially comprises three convolutional layers and one global average pooling layer. The three convolutional layers extract dimensionality reduction features from the suppressed residual image. The global average pooling layer transforms the dimensionality reduction features into a classification feature vector. The classification feature vector is then passed through a fully connected layer to output the location and the category.

[0011] Preferably, the cascaded deformable convolutional layer comprises three deformable convolutional sub-layers connected in sequence. The first deformable convolutional sub-layer has a kernel size of 3×3 and an expansion rate of 1. The second deformable convolutional sub-layer has a kernel size of 3×3 and an expansion rate of 2. The third deformable convolutional sub-layer has a kernel size of 3×3 and an expansion rate of 4. Both the first feature extraction branch and the second feature extraction branch contain two cascaded ordinary convolutional layers, each of which is followed by a batch normalization layer and an activation function layer. The output of the cascaded deformable convolutional layer is connected to an optical flow smoothing layer, which uses a guided filter to perform edge-preserving filtering on the horizontal and vertical offsets.

[0012] Preferably, after marking the region blocks with variance greater than or equal to the preset consistency threshold as non-rigid regions, the method further includes: performing morphological closing operations on all marked non-rigid regions to fill the voids inside the non-rigid regions, and removing non-rigid regions with an area smaller than the preset area threshold. The non-rigid region boundary after morphological closing operation and area culling is shrunk inward by three pixels to generate a shrunk non-rigid region mask. When extracting the optical flow vector of each pixel within the non-rigid region as the non-rigid deformation vector, only the optical flow vector of the pixels falling inside the shrunken non-rigid region mask is extracted.

[0013] Preferably, before using the bicubic interpolation algorithm to reverse map the coordinates of each pixel in the next frame of the adjacent frame image according to the rigid translation vector, the method further includes: obtaining the real-time running speed of the conveyor belt and converting the real-time running speed into the physical displacement amount within the time interval between the acquisition of two adjacent frame images. By combining the physical displacement with the outer diameter parameter of the PE pipe, the theoretical horizontal pixel displacement value between two adjacent frames of images is calculated. The theoretical horizontal pixel displacement value is weighted and fused with the horizontal component in the rigid translation vector, and the fused horizontal component is used as the actual horizontal mapping offset. When performing the reverse mapping, the horizontal component in the rigid translation vector is replaced by the actual horizontal mapping offset.

[0014] Preferably, the Gaussian decay mapping function includes a dynamically adjusted standard deviation parameter, and the process of determining the standard deviation parameter includes: extracting the local gray-level variance of the region corresponding to the non-rigid deformation vector in the previous frame image; Calculate the ratio between the local grayscale variance and the preset baseline variance, and use the ratio as the scaling factor for the standard deviation parameter; When the ratio is greater than 1, the standard deviation parameter is increased to reduce the decay rate of the weighting coefficient; when the ratio is less than 1, the standard deviation parameter is decreased to increase the decay rate of the weighting coefficient. The adjusted standard deviation parameter is substituted into the Gaussian decay mapping function formula containing the scaling factor to calculate the weight coefficient.

[0015] Compared with the prior art, the beneficial effects of the present invention are as follows: 1. This scheme acquires a sequence of three consecutive surface images and uses a deformable convolutional network to generate a dense optical flow field. The optical flow field is decomposed into a rigid translation vector representing the overall motion of the pipe and a non-rigid deformation vector representing local pixel abrupt changes. The rigid translation vector is used to perform pixel-level motion compensation alignment on adjacent frames, and inter-frame difference residual images are calculated. Simultaneously, the magnitude of the non-rigid deformation vector is converted into a spatial suppression weight matrix. By multiplying the weight matrix element-wise with the residual image, the static defect features that move synchronously with the pipe and the random dynamic optical deformation of surface attachments are separated at the physical motion level. This removes the pixel response of non-rigid deformation regions caused by water stains and oil under light sources, retains true defect pixels that conform to rigid motion laws, and eliminates false detections caused by dynamic reflection interference.

[0016] 2. By employing cascaded deformable convolutional sub-layers with different dilation rates and combining them with guided filters for optical flow smoothing in the optical flow field calculation, the horizontal and vertical offsets under multi-scale receptive fields were obtained, and the edge abrupt changes of the optical flow field were smoothed. By performing morphological closing operations and inward shrinking processing on the marked non-rigid regions to generate masks, noise regions were eliminated, and aliasing interference from pixels at the boundaries of non-rigid regions was avoided during extraction. The theoretical horizontal pixel displacement value was calculated by obtaining the real-time running speed of the conveyor belt and then weighted and fused with the rigid translation vector, correcting the horizontal offset benchmark in the pixel-level motion compensation reverse mapping process. By introducing a Gaussian decay mapping function based on dynamically adjusting the standard deviation parameter according to the local gray-level variance, the decay rate of the weight coefficients was adjusted according to the degree of gray-level change in non-rigid regions, so that the spatial suppression distribution of the weight matrix matched the intensity of local texture fluctuations in the image. Attached Figure Description

[0017] Figure 1 This is the main flowchart of the polyethylene pipe defect detection method based on image recognition of the present invention; Figure 2 This is a flowchart of the dense optical flow field generation process of the present invention; Figure 3 This is a flowchart of the optical flow field decomposition and non-rigid region processing of the present invention. Figure 4 This is a flowchart of the motion compensation and residual calculation process of the present invention; Figure 5 This is a flowchart of the spatial suppression weight matrix generation process of the present invention; Figure 6 This is a flowchart of the defect detection head processing of the present invention. Detailed Implementation

[0018] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0019] Please refer to Figure 1 This embodiment provides a PE pipe defect detection method based on image recognition. The PE pipe moves at a constant linear speed along a conveyor on a production line. An image acquisition device acquires surface images of the PE pipe at fixed time intervals, generating a sequence of three consecutive surface images. Adjacent frames in the three consecutive surface image sequences correspond to continuously acquired areas on the PE pipe surface. The acquisition time interval between adjacent frames matches the operating speed of the conveyor, ensuring pixel displacement between adjacent frames corresponds to the overall movement of the PE pipe. The axial direction of the PE pipe is parallel to the movement direction of the conveyor, and the linear array arrangement direction of the image acquisition device is perpendicular to the axial direction of the PE pipe. Each row of pixels acquired corresponds to a cross-section in the circumferential direction of the PE pipe. As the PE pipe moves at a constant speed, the continuously acquired rows of pixels form a planar unfolded image of the PE pipe surface, ensuring that pixel displacement between adjacent frames is only caused by the axial movement of the PE pipe, avoiding circumferential misalignment interference.

[0020] Specifically, a sequence of three consecutive surface images is denoted as... , , ,in The previous frame image in terms of time sequence. This is an intermediate frame image in time sequence. This is the next frame in the time sequence, and the time interval between the acquisition of adjacent frames is... , This is a fixed constant, inversely related to the frame rate of the image acquisition device. Each frame of the surface image is a single-channel grayscale image. The pixel value of each pixel in the image corresponds to the light intensity reflection value at the corresponding position on the PE pipe surface. The coordinates of the pixel are taken with the upper left corner of the image as the origin, the horizontal direction to the right as the positive x-axis, and the vertical direction downward as the positive y-axis. The coordinates of each pixel are: Where x is the horizontal coordinate and y is the vertical coordinate. In processing a sequence of three consecutive surface images, the first step is to process... and The adjacent frame image pairs are then processed. and The adjacent frame image pairs are formed, generating two sets of corresponding processing results. The two sets of processing results are fused and then input into the subsequent modules to reduce the interference of single frames on accidental noise during the processing.

[0021] ; This table provides a unified definition of all basic parameters involved in a three-frame surface image sequence, clarifying the physical meaning and value constraints of each parameter. This ensures the consistency of parameter meanings during subsequent data processing and avoids confusion in dimensions or meanings during coordinate mapping and pixel value calculations.

[0022] Specifically, adjacent frames from a three-frame surface image sequence are input into a pre-constructed deformable convolutional network. The deformable convolutional network processes each pair of adjacent frames to generate a dense optical flow field between each pair. The processing of a single pair of adjacent frames involves extracting features from the preceding and following frames to generate feature maps of corresponding dimensions. Based on the pixel-level feature differences between the two feature maps, the horizontal and vertical offsets corresponding to each pixel are calculated. The horizontal and vertical offsets corresponding to the same pixel are combined to form the optical flow vector for that pixel. The optical flow vectors of all pixels are arranged according to their coordinate positions to generate a dense optical flow field between adjacent frames.

[0023] The dense optical flow field is denoted as W, and its expression is: in, coordinates The horizontal offset of a pixel corresponds to the horizontal component of the optical flow vector. coordinates The vertical offset of a pixel corresponds to the vertical component of the optical flow vector. coordinates The optical flow vector at a given pixel is represented by the dense optical flow field W, which is a two-dimensional vector field with the same size as the input adjacent frame image. Each coordinate position corresponds to a two-dimensional optical flow vector.

[0024] Specifically, the generated dense optical flow field is divided into regions, with the two-dimensional plane corresponding to the entire optical flow field divided into multiple non-overlapping rectangular regions. Each region contains a fixed number of pixels. The optical flow vectors corresponding to all pixels within each region are statistically calculated to obtain the mean and variance of the optical flow vectors within each region. Based on the comparison between the calculated variance and a preset consistency threshold, the regions are divided into rigid and non-rigid regions. Regions with a variance less than the preset consistency threshold are marked as rigid regions, while regions with a variance greater than or equal to the preset consistency threshold are marked as non-rigid regions. The mean of the optical flow vectors within all rigid regions is globally statistically analyzed to generate a rigid translation vector representing the overall movement of the pipe. The optical flow vectors of each pixel within all non-rigid regions are extracted to generate non-rigid deformation vectors representing local pixel abrupt changes.

[0025] For any region R, the set of pixel coordinates contained within it is: The mean of the optical flow vector within this region. With variance The expression is: ; ; in, This represents the total number of pixels contained within region block R. The L2 norm of a two-dimensional vector. It is a two-dimensional mean vector containing the mean of the horizontal component and the mean of the vertical component. denoted as the variance of the optical flow vector within region block R, representing the degree of consistency of the optical flow vectors within the region block.

[0026] The rigid translation vector is denoted as T, where T is a two-dimensional vector containing a horizontal component. With vertical component The value of T is the value corresponding to all rigid regions. The global mean is used to ensure that T can characterize the pixel displacement corresponding to the uniform motion of the PE tube as a whole. The non-rigid deformation vector is denoted as... , coordinates The difference between the optical flow vector and the rigid translation vector corresponding to a pixel represents the degree of deviation between the motion state of that pixel and the overall rigid motion of the PE pipe.

[0027] Specifically, using the previous frame in an adjacent frame as a reference, pixel-level motion compensation alignment is performed on the subsequent frame in the adjacent frame based on a rigid translation vector to generate an aligned subsequent frame. The motion compensation alignment process involves calculating the corresponding mapped coordinates in the subsequent frame to be aligned for each pixel coordinate in the reference image based on the rigid translation vector. An interpolation algorithm is then used to calculate the pixel value at the mapped coordinates, and this calculated pixel value is used as the pixel value at that coordinate in the aligned subsequent frame, thus achieving pixel-level alignment between the subsequent and previous frames. The absolute value of the pixel grayscale difference between the previous and aligned frames at the same coordinate positions is calculated. The two-dimensional matrix composed of the absolute values ​​of the differences at all coordinate positions is the inter-frame difference residual image.

[0028] Inter-frame difference residual image is denoted as Its expression is: ; in, The reference image is the previous frame in the adjacent frame images. This is the next frame image after motion compensation and alignment. For the inter-frame difference residual image in coordinates Pixel value at that location, This is for absolute value operations.

[0029] Specifically, the magnitude of the non-rigid deformation vector corresponding to each pixel is calculated. The magnitude represents the degree of deviation between the optical flow vector and the rigid translation vector at that pixel. The larger the magnitude, the greater the difference between the motion state of that pixel and the rigid motion of the PE pipe as a whole, and the higher the probability of it being a dynamically deformed area such as water stains or oil stains. The non-rigid deformation magnitude corresponding to each pixel is input into a preset mapping function. The output of the mapping function is a weight coefficient in the range of 0 to 1. The larger the magnitude, the smaller the output weight coefficient, and the higher the degree of suppression of the residual response of that pixel. The weight coefficients corresponding to all pixels are arranged according to their coordinate positions to generate a spatial suppression weight matrix with the same size as the input image.

[0030] coordinate The expression for the magnitude of the non-rigid deformation vector is: ; in, coordinates The magnitude of the non-rigid deformation vector. The horizontal component of the rigid translation vector. The vertical component of the rigid translation vector. , These are the horizontal and vertical components of the optical flow vector at that coordinate, respectively.

[0031] The preset Gaussian decay mapping function expression is: ; in, coordinates The weighting coefficient at the location, The standard deviation parameter of the Gaussian decay mapping function, It is a natural exponential function. The value range of is (0,1], when When it is 0, A value of 1 corresponds to no suppression; when When it increases, It exhibits exponential decay, corresponding to an increase in the degree of inhibition.

[0032] Specifically, the spatial suppression weight matrix is ​​multiplied element-wise with the inter-frame difference residual image. That is, the residual pixel value at each corresponding coordinate position is multiplied by the weight coefficient, and the product is used as the pixel value of the suppressed residual image at that coordinate position. During the element-wise multiplication process, for dynamic deformation regions with large non-rigid deformation moduli, the weight coefficient is close to 0, and the corresponding residual pixel value is significantly suppressed. For regions conforming to rigid motion laws, the weight coefficient is close to 1, and the corresponding residual pixel value is completely preserved.

[0033] Suppressing residual image denoted as Its expression is: ; in, This is an element-wise multiplication operation. To suppress residual images in coordinates The pixel value at that location.

[0034] Specifically, the generated suppressed residual image is input into a pre-constructed defect detection head. The defect detection head performs feature extraction and classification regression processing on the suppressed residual image, outputting the location and category of the PE pipe defect. The defect detection head is built based on a convolutional neural network, performing multi-layer convolution operations on the input suppressed residual image to extract the texture and shape features of the defect region. The extracted features are converted into feature vectors, which are then processed through fully connected layers to output the bounding box coordinates and category probability of the defect. The bounding box coordinates correspond to the location of the defect in the PE pipe surface image, and the category corresponding to the maximum category probability is the defect classification.

[0035] In this embodiment, a dense optical flow field is generated based on a deformable convolutional network using the temporal information of three consecutive frames of surface images. The optical flow field is decomposed into a rigid translation vector representing the overall motion of the pipe and a non-rigid deformation vector representing local pixel abrupt changes. Motion compensation alignment of adjacent frames is completed based on the rigid translation vector, and an inter-frame differential residual image is generated. At the same time, a spatial suppression weight matrix is ​​generated based on the non-rigid deformation vector. The residual image is subjected to element-wise suppression processing through the weight matrix. Finally, the location and category of the defect are output through the defect detection head, realizing the separation of static defects and dynamic deformation interference on the PE pipe surface and eliminating the interference of pixel response in the dynamic deformation region on defect detection.

[0036] In an alternative embodiment, refer to Figure 2This is a deformable convolutional network that performs feature extraction and offset calculation on adjacent frames. It includes parallel first and second feature extraction branches, as well as cascaded deformable convolutional layers and optical flow smoothing layers. The deformable convolutional network is trained end-to-end. The training dataset consists of a sequence of simulated motion images of a PE pipe surface, with the true offset of each pixel labeled. The loss function during training is the endpoint error of the optical flow vector, i.e., the mean of the L2 distance between the predicted and actual optical flow vectors. The network's weight parameters are updated using a backpropagation algorithm to minimize the error between the network's output optical flow field and the actual optical flow field.

[0037] Specifically, the preceding frame from adjacent frames is input into the first feature extraction branch, and the following frame from adjacent frames is input into the second feature extraction branch. The first and second feature extraction branches have identical structures but do not share weight parameters. Feature extraction is performed on the input preceding and following frames respectively, generating a first feature map and a second feature map. Both the first and second feature extraction branches contain two cascaded ordinary convolutional layers. The output of each ordinary convolutional layer is connected to a batch normalization layer and an activation function layer. The kernel size of the ordinary convolutional layers is fixed, performing local feature extraction on the input image. The batch normalization layer normalizes the feature map output by the convolutional layers, eliminating the influence of feature distribution offset. The activation function layer performs a non-linear transformation on the normalized feature map, improving the network's feature representation capability. The stride of both cascaded ordinary convolutional layers is 1, and the padding method is the same, ensuring that the output feature map is exactly the same size as the input image, guaranteeing pixel-level alignment for subsequent offset calculations.

[0038] ; This table provides a unified definition of the structure, modules, and operational rules of each layer of deformable convolutional networks, clarifies the input and output dimension constraints of each layer, ensures dimension matching during feature extraction and offset calculation, and avoids operational errors due to mismatched feature map sizes.

[0039] Specifically, the first feature map output from the first feature extraction branch and the second feature map output from the second feature extraction branch are concatenated along the channel dimension to generate a concatenated feature map. This concatenated feature map is then input into a cascaded deformable convolutional layer. The cascaded deformable convolutional layer contains three sequentially connected deformable convolutional sub-layers. The kernel size of each of the three sub-layers is 3×3, with dilation rates of 1, 2, and 4, respectively. These different dilation rates give the three sub-layers different receptive field sizes, enabling them to capture pixel offset features at different scales. The sub-layer with a dilation rate of 1 captures fine-grained local pixel offset features, the sub-layer with a dilation rate of 2 captures medium-scale region offset features, and the sub-layer with a dilation rate of 4 captures large-scale global motion offset features. All three sub-layers use the same padding method to ensure that the size of the feature map output by each sub-layer is exactly the same as the size of the input feature map, avoiding misalignment between offset and pixel coordinates.

[0040] The operational expression for deformable convolutional sublayers is: ; in, To output the feature map in coordinates The feature value at point X is the input feature map. For the convolution kernel at position The weight parameters at that location, The set of sampling points for the convolution kernel. The relative coordinates of the sampling points within the convolution kernel. The learnable offset of the sampling point is generated by convolution operation from the input concatenated feature map. The offset includes horizontal and vertical components, corresponding to the horizontal and vertical offset of the pixel.

[0041] Specifically, cascaded deformable convolutional layers perform layer-by-layer operations on the input stitched feature map, ultimately outputting a feature map with two channels of the same size as the input adjacent frame image. The feature map of the first channel corresponds to the horizontal offset of each pixel. The feature map of the second channel corresponds to the vertical offset of each pixel. In the cascaded deformable convolutional layers, the output of the previous deformable convolutional sublayer serves as the input of the next deformable convolutional sublayer. The multi-scale receptive field enables the network to simultaneously capture the global offset and defects corresponding to the overall movement of the PE pipe, as well as the local offset corresponding to dynamic interference, thus improving the accuracy of offset calculation.

[0042] Specifically, the output of the cascaded deformable convolutional layers is connected to an optical flow smoothing layer. This smoothing layer employs a guided filter to perform edge-preserving filtering on both the horizontal and vertical offsets. The guided filter uses the previous frame of the adjacent input frame as a guide image to smooth the horizontal and vertical offsets. This smooths noise within the optical flow field while preserving edge abrupt changes, preventing the smoothing process from blurring the optical flow abrupt features corresponding to defect areas. The guided filter has a fixed filter window size, matched to the minimum size of the defect on the PE pipe surface, ensuring that the filtering process does not over-smooth the optical flow features in the defect area.

[0043] The output expression of the guided filter is: ; in, This is the filtered output value, corresponding to the smoothed horizontal or vertical offset. The guiding image, i.e., the image preceding the adjacent frame. The filtering window is centered at pixel k. and For filtering window The linear coefficients within the input are obtained by minimizing the squared error between the output value and the input offset.

[0044] Specifically, the horizontal and vertical offsets, after being processed by the optical flow smoothing layer, are combined according to pixel coordinates to generate the final dense optical flow field. After processing two sets of adjacent frame image pairs, two corresponding dense optical flow fields are generated. The average value of the two dense optical flow fields is calculated pixel by pixel to generate a fused dense optical flow field, which is used for subsequent rigid and non-rigid motion decomposition to further reduce noise interference in the optical flow field.

[0045] In this embodiment, a dual-branch feature extraction structure is used to extract features from the previous and next frames of adjacent frames. Cascaded deformable convolutional sub-layers with different dilation rates are used to capture multi-scale pixel offset features, generating horizontal and vertical offsets. The offsets are then smoothed with edge preservation by a guided filter to generate a high-precision dense optical flow field. This improves the optical flow field's ability to capture minute motion differences on the PE tube surface, providing a reliable data foundation for subsequent rigid and non-rigid motion decomposition.

[0046] In another alternative embodiment, refer to Figure 3When decomposing a dense optical flow field into rigid translation vectors and non-rigid deformation vectors, the dense optical flow field is first divided into uniformly distributed blocks with a fixed size. All resulting blocks completely cover the two-dimensional plane of the entire optical flow field, and there is no overlap between adjacent blocks. The size of the blocks matches the minimum size of defects on the PE pipe surface, ensuring that each defect area is covered by at least one block. Simultaneously, the block size is not excessively large to prevent rigid and non-rigid areas from being grouped into the same block, which would cause the variance calculation results to fail to accurately represent the motion consistency within the region.

[0047] Specifically, for each divided region block, the mean and variance of the optical flow vectors of all pixels within that region block are calculated. The variance is calculated based on the sum of squared differences between the L2 norm of the optical flow vector and the L2 norm of the mean vector. The variance value characterizes the consistency of the motion state of all pixels within that region block. A preset consistency threshold is a fixed constant used to distinguish between rigid and non-rigid regions. When the variance of a region block is less than the preset consistency threshold, it indicates that the motion state of all pixels within that region block is highly consistent, conforming to the rigid motion law of the PE tube as a whole, and the region block is marked as a rigid region. When the variance of a region block is greater than or equal to the preset consistency threshold, it indicates that the motion state of pixels within that region varies significantly, with local pixel abrupt changes that are inconsistent with the overall rigid motion of the PE tube, and the region block is marked as a non-rigid region. The value of the preset consistency threshold is determined based on the statistical results of the optical flow field variance under normal PE tube motion conditions, ensuring that the division between rigid and non-rigid regions conforms to the actual motion characteristics of the PE tube.

[0048] ; This table clarifies the region type labeling rules under different variance conditions, as well as the motion characteristics and subsequent processing methods corresponding to different types of regions, ensuring the accurate division of rigid and non-rigid regions and avoiding interference from noise regions in the subsequent processing.

[0049] Specifically, after marking all regions, an initial non-rigid region mask is generated. This initial non-rigid region mask is a binary image, where the pixel value corresponding to a non-rigid region is 1, and the pixel value corresponding to a rigid region is 0. Morphological closing operations are then performed on the initial non-rigid region mask. These operations use a fixed-size structuring element. First, a dilation operation is performed on the mask image, followed by an erosion operation to fill the holes inside the non-rigid regions, connecting adjacent non-rigid regions and preventing the incorrect extraction of rigid region pixels within non-rigid regions. The structuring element for the morphological closing operation is a rectangular structuring element, and its size matches the size of the region block to ensure that small holes within the region block are filled without altering the overall outline of the non-rigid region.

[0050] Specifically, after morphological closing operations are performed, the area of ​​all connected regions in the mask image is statistically analyzed. The total number of pixels contained in each connected region is calculated, and a preset area threshold is set to a fixed constant. Connected regions with an area smaller than the preset area threshold are removed, i.e., their pixel values ​​are set to 0, marking them as rigid regions. This avoids isolated noise points being mistakenly marked as non-rigid regions, reducing noise interference in subsequent processing. The preset area threshold is determined based on the pixel size of the smallest defect on the PE pipe surface, ensuring that isolated regions smaller than the minimum defect size are considered noise and are removed, while real defect regions are not mistakenly removed.

[0051] Specifically, the non-rigid region mask, after morphological closing and area culling, undergoes boundary shrinkage processing. The shrinkage is three pixels wide; that is, the boundary contour of the non-rigid region is shrunk by three pixels along the normal direction of the contour inwards to generate the shrunken non-rigid region mask. This inward shrinkage process removes boundary pixels at the intersection of non-rigid and rigid regions, preventing boundary pixels from simultaneously containing features of both rigid and non-rigid motion, which could lead to feature aliasing during subsequent non-rigid deformation vector extraction, thus improving the purity of the non-rigid deformation vector. During the boundary shrinkage process, if the area of ​​the shrunken region is smaller than a preset area threshold, the entire region is discarded and marked as a rigid region.

[0052] Specifically, when extracting non-rigid deformation vectors, only the optical flow vectors corresponding to pixels falling inside the shrunken non-rigid region mask are extracted. Pixels outside the mask are considered rigid regions and are not included in the extraction of non-rigid deformation vectors. For pixels outside the mask, their corresponding non-rigid deformation modulus is set to 0 by default, with a corresponding weight coefficient of 1, resulting in no suppression effect. During the calculation of rigid translation vectors, only the mean of the optical flow vectors corresponding to the regions marked as rigid regions is used for global statistics, eliminating optical flow vectors corresponding to non-rigid regions. This ensures that the rigid translation vectors can accurately represent the overall rigid motion state of the PE tube and are not affected by local non-rigid deformations. For the two sets of optical flow fields generated from two adjacent frame image pairs, rigid and non-rigid regions are divided respectively, generating two sets of corresponding rigid translation vectors and non-rigid deformation vectors, which are used for subsequent motion compensation and weight matrix generation, ensuring the temporal consistency of the processing.

[0053] In this embodiment, the initial marking of rigid and non-rigid regions is completed through region block division and variance statistics. The internal holes of non-rigid regions are filled by morphological closing operations. Small noise regions are eliminated by area statistics. A pure non-rigid region mask is generated by boundary shrinkage processing. Only the optical flow vectors of the pixels inside the mask are extracted as non-rigid deformation vectors. At the same time, rigid translation vectors are calculated based on the pure rigid regions, which improves the decomposition accuracy of rigid translation vectors and non-rigid deformation vectors and avoids the impact of boundary aliasing and noise interference on subsequent processing.

[0054] In yet another alternative embodiment, reference is made to... Figures 4 to 6 When performing pixel-level motion compensation alignment of adjacent frames based on rigid translation vectors, the previous frame in the adjacent frame is used as a reference. A bicubic interpolation algorithm is employed to reverse-map the coordinates of each pixel in the subsequent frame in the adjacent frame according to the rigid translation vector, generating the aligned frame. This reverse mapping method ensures that each pixel in the reference image can find its corresponding mapped coordinates in the image to be aligned, avoiding pixel holes that occur during forward mapping and improving the integrity of the aligned image.

[0055] Specifically, the reverse mapping process involves, for any pixel coordinate in the reference image... The original coordinates of this coordinate in the next frame image to be aligned are calculated based on the rigid translation vector. ,in , , The horizontal component of the rigid translation vector. This is the vertical component of the rigid translation vector. Due to the original coordinates... The coordinates may be non-integer, making it impossible to directly read the corresponding pixel value from the next frame. Therefore, a bicubic interpolation algorithm is used to calculate the pixel value at these non-integer coordinates, and the calculated pixel value is used to align the next frame image with these coordinates. The bicubic interpolation algorithm calculates the pixel value at the non-integer coordinate by weighting the pixel values ​​of the 16 neighboring integer coordinate pixels around the target coordinate. Compared with the linear interpolation algorithm, the bicubic interpolation algorithm can preserve the edge details of the image, avoid image blurring caused by the interpolation process, and improve the accuracy of motion compensation alignment.

[0056] The kernel function expression for bicubic interpolation is: ; Where s is the distance between the interpolation point and the sampling point. It is a fixed constant, with a value of -0.5. These are the weighting coefficients for the corresponding distances. (Non-integer coordinates) The interpolated pixel value at a given coordinate is obtained by weighting and summing the pixel values ​​of integer coordinate pixels within a 4×4 range around that coordinate with the weight coefficients calculated by the corresponding kernel function.

[0057] Specifically, after the reverse mapping and interpolation of the next frame image, an aligned next frame image with the exact same size as the reference image is generated. The absolute value of the pixel grayscale difference between the reference image and the aligned next frame image at the same coordinate positions is calculated. The two-dimensional matrix composed of the absolute values ​​of the differences at all coordinate positions is the inter-frame difference residual image. In the inter-frame difference residual image, the higher the pixel value at a position, the greater the pixel change between adjacent frames, and the higher the probability of defects or dynamic interference. The lower the pixel value at a position, the smaller the pixel change between adjacent frames, and the higher the probability of it being a normal surface area of ​​the PE pipe. For the actual defect area on the surface of the PE pipe, the defect and the PE pipe have a fixed relative position and move synchronously with the PE pipe. After motion compensation and alignment, the coordinates of the defect area in adjacent frame images are completely aligned, and the pixel value in the corresponding inter-frame difference residual image is close to 0. For dynamic deformation areas such as water stains and oil stains, the pixel movement inside them does not conform to the rigid motion law. After motion compensation and alignment, the pixels in adjacent frame images cannot be completely aligned, and the pixel value in the corresponding inter-frame difference residual image is higher.

[0058] Specifically, before performing the reverse mapping, the real-time operating speed of the transmission device is first obtained. This real-time operating speed is then converted into the physical displacement of the PE tube within the time interval between two adjacent image acquisition frames. Combining the outer diameter parameter of the PE tube with the physical resolution of the image acquisition device, the theoretical horizontal pixel displacement value between two adjacent image frames is calculated. The calculated theoretical horizontal pixel displacement value is then weighted and fused with the horizontal component of the rigid translation vector. The fused horizontal component is used as the actual horizontal mapping offset. During the reverse mapping, this actual horizontal mapping offset replaces the horizontal component of the rigid translation vector to perform the reverse mapping of the horizontal coordinates of the next image frame. Since the movement direction of the PE tube is parallel to the horizontal direction of the image, the overall movement of the PE tube only produces horizontal pixel displacement. Vertical pixel displacement is only caused by installation errors or vibration. Therefore, only the horizontal component is weighted and fused for correction, while the vertical component retains the original value of the rigid translation vector.

[0059] The expression for the theoretical horizontal pixel displacement value is: ; in, Here, v represents the theoretical horizontal pixel displacement value, and v represents the real-time operating speed of the transmission device. The time interval between the acquisition of adjacent frames. The physical resolution of the image acquisition device represents the number of pixels per unit physical length, D is the outer diameter parameter of the PE pipe, and π is the constant pi.

[0060] The expression for the actual horizontal mapping offset after weighted fusion is: ; in, This is the actual horizontal mapping offset. These are the weighting coefficients, with values ​​ranging from (0,1). The original horizontal component of the rigid translation vector. This represents the theoretical horizontal pixel displacement value.

[0061] The weighting coefficient α can be adjusted according to the proportion of the rigid region. When the proportion of the rigid region is higher, the value of α is larger, indicating that the reliability of the rigid translation vector calculated based on the optical flow field is higher. When the proportion of the rigid region is lower, the value of α is smaller, indicating that the reliability of the rigid translation vector calculated based on the optical flow field is lower. It is necessary to rely more on the theoretical horizontal pixel displacement value calculated based on the operating speed of the transmission device for correction to ensure the accuracy of motion compensation alignment.

[0062] Specifically, when converting the magnitude of the non-rigid deformation vector into a spatial suppression weight matrix, the magnitude of the non-rigid deformation vector corresponding to each pixel is first calculated. The non-rigid deformation vector is the difference between the optical flow vector and the rigid translation vector of that pixel, and its magnitude is the L2 norm of the difference vector. The non-rigid deformation magnitude of each pixel is then input into a Gaussian attenuation mapping function to generate corresponding weight coefficients. The standard deviation parameter of the Gaussian attenuation mapping function is a dynamically adjusted parameter, and its value is adjusted according to the local gray-level variance of the region corresponding to the non-rigid deformation vector in the previous frame of the adjacent frame.

[0063] ; This table displays the weighting coefficients of the Gaussian decay mapping function output under different non-rigid deformation moduli and standard deviation parameters. It clarifies the influence of the standard deviation parameter on the decay rate of the weighting coefficients, providing data reference for the dynamic adjustment of the standard deviation parameter. When the standard deviation parameter increases, the decay rate of the weighting coefficients decreases, resulting in higher output weighting coefficients and lower suppression for the same modulus. Conversely, when the standard deviation parameter decreases, the decay rate of the weighting coefficients increases, resulting in lower output weighting coefficients and higher suppression for the same modulus.

[0064] Specifically, the process of determining the standard deviation parameter is as follows: for any pixel within a non-rigid region, extract a local image region within a preset window size surrounding that pixel, calculate the pixel grayscale variance within that local image region, and denot it as... The preset window size is a fixed value, matching the size of the region block, ensuring that the local grayscale variance accurately represents the degree of texture fluctuation around the pixel. The preset baseline variance is a fixed constant, denoted as . The preset baseline variance is determined based on the statistical results of the grayscale variance of a normally flat surface of the PE pipe. Local grayscale variance is then calculated. variance relative to preset benchmark The ratio between them, this ratio is used as a scaling factor for the standard deviation parameter, denoted as k, i.e. When the scaling factor k is greater than 1, it indicates that the grayscale texture of the local area fluctuates greatly, corresponding to a region with complex texture on the PE pipe surface. It is necessary to increase the standard deviation parameter and reduce the decay rate of the weighting coefficient to avoid normal texture areas being falsely suppressed. When the scaling factor k is less than 1, it indicates that the grayscale texture of the local area fluctuates little, corresponding to a region with a smooth PE pipe surface. It is necessary to decrease the standard deviation parameter and increase the decay rate of the weighting coefficient to improve the ability to suppress dynamically deformed regions.

[0065] The expression for the dynamically adjusted standard deviation parameter is: ; in, The standard deviation parameter is dynamically adjusted. Here, k is the initial baseline value for the standard deviation parameter, and k is the scaling factor. For local grayscale variance, This is the preset baseline variance.

[0066] Specifically, the dynamically adjusted standard deviation parameter is substituted into the Gaussian decay mapping function to calculate the weight coefficient corresponding to each pixel. All the weight coefficients corresponding to all pixels are arranged according to their coordinate positions to generate a spatial suppression weight matrix. The dynamically adjusted standard deviation parameter ensures that the suppression distribution of the spatial suppression weight matrix matches the intensity of local texture fluctuations in the image. In areas with complex textures, the suppression intensity is reduced to avoid false suppression of normal textures, while in areas with smooth textures, the suppression intensity is increased to enhance the suppression effect against dynamic deformation interference. For pixels in rigid regions, their corresponding weight coefficient is set to 1 by default, with no suppression effect, ensuring that the residual response of the normal surface area of ​​the PE pipe is not suppressed.

[0067] Specifically, the pixel value at each coordinate position in the inter-frame difference residual image is multiplied element-wise with the weight coefficient at the same coordinate position in the spatial suppression weight matrix. The product is used as the pixel value at the corresponding coordinate position in the suppressed residual image. During the element-wise multiplication process, in dynamic deformation regions with large non-rigid deformation moduli, the weight coefficient is close to 0, and the corresponding residual pixel value is significantly suppressed, eliminating the pixel response of dynamic deformation regions such as water stains and oil stains. In real defect regions that conform to rigid motion laws, the non-rigid deformation moduli are close to 0, and the weight coefficient is close to 1, and the corresponding residual pixel value is completely preserved, ensuring that defect features are not suppressed. For two sets of adjacent frame images, the two sets of inter-frame difference residual images generated are multiplied element-wise with the spatial suppression weight matrix to generate two sets of suppressed residual images. The pixel-wise mean of the two sets of suppressed residual images is calculated to generate a fused suppressed residual image, which is input into the defect detection head to further reduce the interference of random noise.

[0068] Specifically, the defect detection head consists of three convolutional layers, one global average pooling layer, and a fully connected layer. The three convolutional layers are connected sequentially, with each layer having a fixed kernel size and a stride of 2. They perform layer-by-layer dimensionality reduction and feature extraction on the input suppressed residual image, transforming the high-resolution residual image into a low-dimensional depth feature map. The output of each convolutional layer is connected to a batch normalization layer and an activation function layer. The batch normalization layer eliminates the influence of feature distribution offset, while the activation function layer performs non-linear transformations to enhance feature representation. The number of channels in the three convolutional layers increases sequentially, ensuring that shallow convolutions extract low-level features such as edges and textures, while deeper convolutions extract semantic features of defects. The global average pooling layer performs global average pooling on the depth feature map output from the last convolutional layer, transforming the feature map of each channel into a feature value, generating a one-dimensional classification feature vector. Global average pooling reduces the dimensionality of the feature vector, avoiding overfitting, while preserving global feature information. The fully connected layer performs a linear transformation on the classification feature vector, outputting the bounding box coordinates and class probability of the defect. The bounding box coordinates correspond to the defect's location on the PE pipe surface image, including the coordinates of the top-left corner, width, and height. The class probability corresponds to different categories of PE pipe defects, including common surface defect types such as scratches, dents, bubbles, and cracks. The category corresponding to the maximum class probability is the defect's identified category. The defect detection head is trained using suppressed residual images labeled with defect locations and categories. The loss function during training is a weighted sum of classification cross-entropy loss and smoothing L1 loss from bounding box regression. The network's weight parameters are updated through backpropagation to minimize the error between the network's output defect location and category and the labeled information.

[0069] In this embodiment, a bicubic interpolation algorithm is used for reverse mapping to achieve pixel-level motion compensation alignment. The theoretical horizontal pixel displacement value is calculated in conjunction with the real-time operating speed of the transmission device, and the horizontal component of the rigid translation vector is weighted and fused to improve the accuracy of motion compensation alignment. A Gaussian decay mapping function based on local gray-level variance dynamically adjusts the standard deviation parameter to generate a spatial suppression weight matrix that matches the local texture features of the image, thereby improving the suppression accuracy of dynamic deformation regions and the ability to preserve defect regions. A defect detection head containing three convolutional layers, a global average pooling layer, and a fully connected layer is used to extract features and classify and regress the suppressed residual image, accurately outputting the location and category of PE pipe defects, and completing the detection of PE pipe surface defects.

Claims

1. A method for detecting defects in PE pipes based on image recognition, characterized in that, include: Acquire a sequence of three consecutive surface images of a PE pipe moving at a constant speed on a conveyor belt. A deformable convolutional network is used to extract features and calculate offsets for adjacent frames in the three consecutive frames of surface images to generate a dense optical flow field between adjacent frames. The dense optical flow field is decomposed into a rigid translation vector characterizing the overall motion of the pipe and a non-rigid deformation vector characterizing local pixel abrupt changes. The rigid translation vector is used to perform pixel-level motion compensation alignment on the adjacent frame images, and the aligned inter-frame difference residual image is calculated. The magnitude of the non-rigid deformation vector is converted into a spatial suppression weight matrix through a preset mapping function; The spatial suppression weight matrix is ​​multiplied element-wise with the inter-frame difference residual image to generate a suppression residual image; The suppressed residual image is input into a pre-built defect detection head, which outputs the location and type of PE pipe defects.

2. The method for detecting defects in PE pipes based on image recognition according to claim 1, characterized in that, The step of using a deformable convolutional network to extract features and calculate offsets for adjacent frames in the three consecutive frames of surface images to generate a dense optical flow field between adjacent frames includes: inputting the previous and next frames in the adjacent frames into the first and second feature extraction branches of the deformable convolutional network to generate a first feature map and a second feature map, respectively. The first feature map and the second feature map are concatenated and input into a cascaded deformable convolutional layer. The deformable convolutional layer generates horizontal and vertical offsets based on the pixel differences between the first and second feature maps. The horizontal offset and the vertical offset are combined to form the dense optical flow field.

3. The method for detecting defects in PE pipes based on image recognition according to claim 2, characterized in that, The step of decomposing the dense optical flow field into a rigid translation vector characterizing the overall motion of the pipe and a non-rigid deformation vector characterizing local pixel abrupt changes includes: dividing the dense optical flow field into regional blocks and calculating the mean and variance of the optical flow vectors of all pixels in each regional block. Regions with variance less than a preset consistency threshold are marked as rigid regions, and the mean optical flow vector within the rigid region is used as the rigid translation vector. Regions with variance greater than or equal to the preset consistency threshold are marked as non-rigid regions, and the optical flow vectors of each pixel within the non-rigid region are extracted as the non-rigid deformation vectors.

4. The PE pipe defect detection method based on image recognition according to claim 3, characterized in that, The step of using the rigid translation vector to perform pixel-level motion compensation alignment on the adjacent frame images and calculating the aligned inter-frame difference residual image includes: using the previous frame image in the adjacent frame images as a reference, using a bicubic interpolation algorithm, and based on the rigid translation vector, performing reverse mapping on the coordinates of each pixel point in the next frame image in the adjacent frame images to generate the aligned next frame image. Calculate the absolute value of the pixel grayscale difference between the previous frame image and the aligned next frame image at the same coordinate position, and use the matrix composed of the absolute values ​​of the pixel grayscale difference as the inter-frame difference residual image.

5. The method for detecting defects in PE pipes based on image recognition according to claim 4, characterized in that, The step of converting the magnitude of the non-rigid deformation vector into a spatial suppression weight matrix through a preset mapping function includes: calculating the sum of squares of the horizontal and vertical components corresponding to each pixel in the non-rigid deformation vector, and taking the square root of the sum of squares to obtain the non-rigid deformation magnitude of each pixel. The non-rigid deformation modulus value of each pixel is input into the Gaussian decay mapping function, which uses the non-rigid deformation modulus value as the independent variable and the weight coefficient in the range of zero to one as the dependent variable. The spatial suppression weight matrix is ​​generated by arranging the weight coefficients corresponding to all pixels according to their pixel coordinates.

6. The method for detecting defects in PE pipes based on image recognition according to claim 5, characterized in that, The step of multiplying the spatial suppression weight matrix element-wise with the inter-frame difference residual image to generate a suppression residual image, and inputting the suppression residual image into a pre-constructed defect detection head to output the location and category of the PE pipe defect includes: multiplying the pixel value at each coordinate position in the inter-frame difference residual image with the weight coefficient at the same coordinate position in the spatial suppression weight matrix, and using the product as the pixel value at the corresponding coordinate position in the suppression residual image; The defect detection head sequentially comprises three convolutional layers and one global average pooling layer. The three convolutional layers extract dimensionality reduction features from the suppressed residual image. The global average pooling layer transforms the dimensionality reduction features into a classification feature vector. The classification feature vector is then passed through a fully connected layer to output the location and the category.

7. The method for detecting defects in PE pipes based on image recognition according to claim 6, characterized in that, The cascaded deformable convolutional layer comprises three sequentially connected deformable convolutional sub-layers. The first deformable convolutional sub-layer has a kernel size of 3×3 and an expansion rate of 1. The second deformable convolutional sub-layer has a kernel size of 3×3 and an expansion rate of 2. The third deformable convolutional sub-layer has a kernel size of 3×3 and an expansion rate of 4. Both the first feature extraction branch and the second feature extraction branch contain two cascaded ordinary convolutional layers, each of which is followed by a batch normalization layer and an activation function layer. The output of the cascaded deformable convolutional layer is connected to an optical flow smoothing layer, which uses a guided filter to perform edge-preserving filtering on the horizontal and vertical offsets.

8. The method for detecting defects in PE pipes based on image recognition according to claim 7, characterized in that, After marking the region blocks with variance greater than or equal to the preset consistency threshold as non-rigid regions, the method further includes: performing morphological closing operations on all marked non-rigid regions to fill the voids inside the non-rigid regions, and removing non-rigid regions with an area smaller than the preset area threshold. The non-rigid region boundary after morphological closing operation and area culling is shrunk inward by three pixels to generate a shrunk non-rigid region mask. When extracting the optical flow vector of each pixel within the non-rigid region as the non-rigid deformation vector, only the optical flow vector of the pixels falling inside the shrunken non-rigid region mask is extracted.

9. The method for detecting defects in PE pipes based on image recognition according to claim 8, characterized in that, Before using the bicubic interpolation algorithm to reverse map the coordinates of each pixel in the next frame of the adjacent frame image according to the rigid translation vector, the method further includes: obtaining the real-time running speed of the conveyor belt and converting the real-time running speed into the physical displacement amount within the time interval between the acquisition of two adjacent frames of images. By combining the physical displacement with the outer diameter parameter of the PE pipe, the theoretical horizontal pixel displacement value between two adjacent frames of images is calculated. The theoretical horizontal pixel displacement value is weighted and fused with the horizontal component in the rigid translation vector, and the fused horizontal component is used as the actual horizontal mapping offset. When performing the reverse mapping, the horizontal component in the rigid translation vector is replaced by the actual horizontal mapping offset.

10. The method for detecting defects in PE pipes based on image recognition according to claim 9, characterized in that, The Gaussian decay mapping function includes a dynamically adjusted standard deviation parameter. The process of determining the standard deviation parameter includes: extracting the local gray-level variance of the region corresponding to the non-rigid deformation vector in the previous frame image. Calculate the ratio between the local grayscale variance and the preset baseline variance, and use the ratio as the scaling factor for the standard deviation parameter; When the ratio is greater than 1, the standard deviation parameter is increased; when the ratio is less than 1, the standard deviation parameter is decreased. The adjusted standard deviation parameter is substituted into the Gaussian decay mapping function formula containing the scaling factor to calculate the weight coefficient.