A contour-based method for segmenting defects in hydraulic structures
Through a two-stage instance segmentation method based on contours, combined with the contour deformation network of instance center features and differentiated modules, the problem of large number of instances and occlusion in defect detection of hydraulic buildings is solved, the accuracy and real-time performance of detection are improved, and the implementation Efficient evaluation of defects in hydraulic structures.
Patent Information
- Application Number
- CN202410529026.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-29
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2044-04-29
AI Technical Summary
Traditional hydraulic building defect detection methods rely on manual survey, which is time-consuming, laborious and error-prone. The pixel-based instance segmentation method consumes a lot of computing resources. The single-stage instance segmentation method based on contours has low accuracy and the number of instances in the hydraulic building scene Multiple,instances block each other, making it difficult to achieve efficient,accurate defect detection.
A two-stage contour-based instance segmentation method is adopted. By constructing a contour initialization network based on instance center features and a contour deformation network based on the differentiation module, DLA-34 is used to extract features, predict the segmentation initial contour, and use global deformation and position encoding to The Deep Snake module performs contour deformation to improve segmentation accuracy and speed.
It improves the accuracy and real-time performance of defect instance segmentation of hydraulic structures, reduces the consumption of computing resources, enhances the position awareness of the model, and enables online evaluation and intelligent decision-making of defects in hydraulic structures.
Smart Images

Figure CN118379495B
Abstract
Description
Technical Field
[0001] The invention belongs to the field of water conservancy and hydropower, and in particular relates to a contour-based hydraulic structure defect instance segmentation method. Background Art
[0002] Hydraulic structures (such as reservoirs, sluice gates, etc.) are an indispensable and important part of water conservancy project construction. The stability and safety of these structures are of great significance to ensure the rational use of water resources and the safety of people's lives and property. However, due to the complexity of water conservancy project construction, the long-term use of structures and environmental factors, hydraulic structures are prone to various defects and damages, such as cracks, seepage, deformation, dislocation, dissolution, etc.
[0003] Traditional defect detection methods mainly rely on manual surveys and field measurements, which are time-consuming, labor-intensive and prone to errors. At the same time, if defects and damage are not repaired in time, it will have a significant impact on the stability and safety of the building. Therefore, it is of practical application value to develop and utilize technologies such as computer vision and artificial intelligence to realize instance segmentation detection of hydraulic structure defects.
[0004] In recent years, with the rapid development of deep learning, image segmentation technology has been continuously optimized and updated, and the results achieved are significantly better than traditional methods, with greatly improved accuracy and efficiency. However, the pixel-based instance segmentation method requires a lot of calculations and consumes too many resources; while the single-stage instance segmentation method based on contours has low accuracy. At the same time, in the process of instance segmentation, there are challenges such as a large number of instances and mutual occlusion between instances in the hydraulic structure scene. Therefore, it is necessary to further improve the model performance while ensuring the stability of the model performance. Solve the above problems, improve the speed of contour segmentation, optimize the details of instance edge segmentation, improve the real-time and accuracy of hydraulic structure defect judgment, and assist in online evaluation and intelligent decision-making of hydraulic structure defects. Summary of the invention
[0005] Purpose of the invention: In view of the fact that traditional defect detection methods mainly rely on manual investigation and field measurement, which is time-consuming, labor-intensive and prone to errors, and the pixel-based instance segmentation method consumes a lot of computational resources, a contour-based two-stage instance segmentation method for hydraulic structure defects is proposed to perform instance segmentation on images of hydraulic structures.
[0006] Technical solution: To achieve the above purpose, the present invention provides a contour-based hydraulic structure defect instance segmentation method, comprising the following steps:
[0007] S1: Preprocess the data set to obtain a hydraulic structure defect image data set, and divide the data set into a training data set and a test data set;
[0008] S2: Construct a contour initialization network based on instance center features, use DLA-34 to extract features, and generate the initial contour of the dataset defect through the prediction branch network;
[0009] S3: Build a contour deformation network based on the differentiation module. The contour deformation network consists of a global deformation module and two position encoding Deep Snake modules. The model is trained using the training dataset based on S2.
[0010] S4: Input the test data set into the trained contour deformation network in step S3, and obtain the instance segmented image through three contour deformations;
[0011] S5: Continue to take photos of the hydraulic structure, execute step S4, obtain defect segmentation results at different times, compare the segmentation results, and determine the defect evolution trend.
[0012] Furthermore, the specific steps of step S1 are:
[0013] S11: Select five different hydraulic structure defect images of seepage, precipitation, dislocation, crack and dissolution, and hydraulic structure defect images at different times during the day and night;
[0014] S12: Clean, enhance and annotate the defect images of hydraulic structures;
[0015] S13: Split the cleaned, enhanced and annotated data into training and testing data sets with a ratio of 7:3;
[0016] Furthermore, the specific steps of step S2 are:
[0017] S21: Construct a contour initialization network based on instance center features, where the backbone network is DLA-34, and the prediction branch networks are instance center branch, center point offset branch, N-gon regression branch, and relative distance branch. The instance center branch is used to classify instances and detect instance centers; the center point offset branch is used to predict the discretization error caused by input downsampling; the N-gon regression branch is used to predict the distance between the instance center and the contour point; the relative distance network predicts the relative distance of instances in the image to determine the occlusion relationship between instances;
[0018] S22: Use the backbone network DLA-34 to extract features from the image and obtain a feature map;
[0019] S23: The obtained feature maps are input into four branch output layers in parallel to obtain the instance category and instance center position, offset error, relative distance between the instance center and the contour point, and relative distance between the instance in the image respectively;
[0020] S24: The initialization contour result is obtained by combining the instance center, offset, category, and relative distance.
[0021] Furthermore, when the N-gon regression branch is trained in step S21, the N intersection points of the N rays emitted from the instance center and the instance contour are selected as the contour vertex rays to be regressed, with the positive direction of the Y axis as the starting ray, and are selected at equal angles, with an angle size of 360 / N. In order to make the initial contour wrap the instance as much as possible, the intersection point farthest from the instance center is selected as the initial contour point; in the N-gon regression branch, the network is designed to simultaneously predict the offset of the contour point relative to the instance center in the X-axis and Y-axis directions, thereby increasing the degree of freedom of contour point prediction; the N-gon regression branch structure consists of a 3×3 convolution and a 1×1×2N convolution. After downsampling the feature map, the number of channels is changed to output a two-dimensional image of 2N channels to represent the offset of the N contour points of each instance relative to the instance center in the X-axis and Y-axis directions; for the instance whose instance center is at the position (x′, y′), the network outputs a floating-point number of (i1, j1, i2, j2, ..., i N , j N ), the coordinates of the nth initial contour point are (x′+i n , y′+j n );By connecting N points, we can obtain the initial outline of the N-sided polygon;_
[0022] The training loss of the relative distance branch in step S21 is:
[0023] L distance =smoothl1(distance,distance GT )
[0024] Where distance represents the instance distance value of the relative distance branch regression, distance GT Relative distance values of the annotations representing the instances; relative distances are used as reference annotations in training. The relative distance branch is trained on the entire image, so an object with the center of the instance at (x′, y′) will have a distance D(x′, y′), where D is a two-dimensional relative distance map. To train this branch, the same strategy as the polygon regression branch is used, and only the values associated with the object will affect the loss.
[0025] Furthermore, in step S21, the instance center position of the instance center branch is obtained by solving the centroid of the instance plane, and an elliptical Gaussian kernel function is used to generate a heat map. The expression of the elliptical Gaussian kernel function is:
[0026]
[0027] The upper left corner and lower right corner of the feasible detection box are restricted to be centered on the upper left corner and lower right corner of the real detection box, with a horizontal semi-axis length of a and a vertical semi-axis length of b, and . Where (x, y) is the coordinate after downsampling. is the coordinate of the target center point after downsampling, σ a =a / 3,σ b =b / 3.
[0028] Furthermore, the specific steps of step S3 are:
[0029] S31: Build a contour deformation network based on differentiation module, which consists of a global deformation module, two position-encoded Deep Snake modules, which will be used to perform different stages of contour deformation, and integrate position encoding and keypoint-first nearest neighbor matching algorithms;
[0030] S32: inputting the initial contour into the global deformation module to obtain the first contour deformation result;
[0031] S33: Input the first contour deformation result, the feature map output by the feature extraction network DLA-34, and the X, Y coordinate channels into the position-encoded Deep Snake module, perform the second position-encoded contour deformation, and obtain the second contour deformation result;
[0032] S34: The second contour deformation result, the feature map output by the feature extraction network DLA-34, and the X, Y coordinate channels are input into the Deep Snake module of position encoding, and the third contour deformation is performed using the key point priority nearest neighbor matching algorithm to obtain the final contour deformation result.
[0033] Furthermore, in step S32, the global deformation module first directly fuses the center point feature and all the features of the contour points to be regressed, and then predicts the initial contour deformation displacement based on the fused features, that is, the features of the N initial contour points and the center point are connected into a vector with a length of (N+1)×C, where C is the number of channels of the vertex feature; then the vector is input into the MLP module (the number of channels of the hidden layer and the output layer are both N×2) to obtain the offset of the contour point (a vector with a length of N×2, recorded as The initial contour point coordinates are superimposed with the offset to obtain the deformed contour, which is recorded as the global contour and is recorded as
[0034] Furthermore, in step S33, the position-encoded Deep Snake module adds X and Y coordinate channels based on the feature map output by the feature extraction network DLA-34, which respectively represent the normalized X-axis coordinate and Y-axis coordinate of the specific position. If the X and Y coordinate channels do not learn any information, then the position-encoded Deep Snake module is equivalent to the original Deep Snake module; and if the X and Y coordinate channels learn certain position information, then the Deep Snake module has certain translation dependence and can more accurately predict the contour deformation offset.
[0035] Furthermore, in step S34, the nearest neighbor matching algorithm with key point priority selects and annotates the reference contour points through the Douglas-Peucker algorithm to determine the contour key points and use them to train the model; key point priority matching is performed at the key points, and the nearest neighbor matching mechanism is selected otherwise.
[0036] Furthermore, the specific steps of step S5 are:
[0037] S51: Determine the key defect monitoring areas of hydraulic structures. Based on the expected speed of defect evolution and monitoring needs, take photos of ordinary parts every 3 days in the non-flood season, take photos of key parts once a day in the non-flood season, take photos of ordinary parts once a day in the flood season, and take photos of key parts twice a day in the flood season; each photo should be taken in the same time period to ensure consistency of lighting conditions, for example, take photos at 9 am and 5 pm each time.
[0038] S52: Use a camera to take photos of the pre-determined monitoring area, ensuring that the photos can identify small defects; keep the camera position and angle consistent, and mark and archive the photos taken by date for easy tracking and retrieval;
[0039] S53: Execute step S4 for each photo taken to segment the defect instances; record the result of each segmentation and compare it with the photos taken during the same period of the previous year; after each photo is taken, compare and analyze the new segmentation result with the previous 30 results, and the comparison formula is:
[0040]
[0041] Among them, Y2 is the segmentation result of this defect instance, and Y1 is the segmentation result of the previous defect instance. The intersection over union (IoU) ratio is calculated for the two segmentation results. The smaller the ratio, the greater the change. At the same time, a defect change trend graph is drawn to analyze the evolution speed and expansion trend of the defect.
[0042] S54: Based on continuous monitoring data, evaluate the evolution trend of defects and determine whether there are signs of accelerated deterioration. If defects are found to have significantly expanded or new defects appear, the maintenance team should be notified immediately for further on-site inspection.
[0043] The present invention is essentially an instance segmentation method for hydraulic structure defects. It adopts a contour-based two-stage instance segmentation network to effectively solve the problems of a large number of hydraulic structure instances and mutual occlusion between instances. The instance center is predicted by a contour initialization method based on instance center features, and the distance from the contour point to the contour is simultaneously regressed according to the features of all instance center points, and the instance relative distance is output to determine the mutual occlusion relationship of the overlapping contours of hydraulic structures. Then, for the error propagation and contour false matching in contour deformation, a contour deformation method based on a differentiation module is proposed, which can effectively improve the accuracy of contour instance segmentation and realize instance segmentation of hydraulic structure defects.
[0044] Beneficial effects: Compared with the prior art, the present invention has the following advantages:
[0045] 1. The present invention uses a contour initialization method based on instance center features, which can effectively improve the instance segmentation accuracy. At the same time, it regresses the distance from the contour point to the contour according to the features of all instance center points, improves the upper limit of the initial contour representation, and speeds up the contour generation speed.
[0046] 2. The present invention uses a contour deformation method based on a differentiation module, and directly outputs contour point displacement from the initial contour point features, thereby avoiding the propagation problem of the initial error of contour deformation in subsequent deformation due to insufficient global information aggregation capability, improving the detailed information of the image, and realizing online evaluation and intelligent decision-making of hydraulic structure defects.
[0047] 3. The present invention adopts an iterative optimization approach and adds explicit location information to the input feature map, thereby enhancing the location perception capability of the model and improving accuracy and model performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 It is a flow chart of the segmentation of hydraulic structure defect instances based on contours of the present invention;
[0049] Figure 2 This is a network structure diagram of the contour initialization method based on the instance center feature of the present invention;
[0050] Figure 3 A diagram of a contour deformation method based on a differentiation module of the present invention;
[0051] Figure 4 This is a schematic diagram of the network structure of the global deformation module of the present invention;
[0052] Figure 5 Schematic diagram of the steps of the Douglas-Peucker algorithm of the present invention;
[0053] Figure 6 It is a schematic diagram of the key point contour matching mechanism of the present invention;
[0054] Figure 7 Schematic diagram of the nearest neighbor matching mechanism of the present invention. DETAILED DESCRIPTION
[0055] The present invention is further explained below in conjunction with the accompanying drawings and specific embodiments. It should be understood that these embodiments are only used to illustrate the present invention and are not used to limit the scope of the present invention. After reading the present invention, various equivalent forms of modifications to the present invention by those skilled in the art all fall within the scope defined by the claims attached to this application.
[0056] The present invention provides a method for segmenting hydraulic structure defect instances based on contours. Figure 1 As shown, it includes the following steps:
[0057] S1: Preprocess the data set to obtain a hydraulic structure defect image data set, and divide the data set into a training data set and a test data set;
[0058] S2: Construct a contour initialization network based on instance center features, use DLA-34 to extract features, and generate the initial contour of the dataset defect through the prediction branch network;
[0059] S3: Build a contour deformation network based on the differentiation module. The contour deformation network consists of a global deformation module and two position encoding Deep Snake modules. The model is trained using the training dataset based on S2.
[0060] S4: Input the test data set into the trained contour deformation network in step S3, and obtain the instance segmented image through three contour deformations;
[0061] S5: Continue to take photos of the hydraulic structure, execute step S4, obtain defect segmentation results at different times, compare the segmentation results, and determine the defect evolution trend.
[0062] The specific steps of step S1 in this example are:
[0063] S11: Select five different hydraulic structure defect images of seepage, precipitation, dislocation, crack and dissolution, and hydraulic structure defect images at different times during the day and night;
[0064] S12: Clean, enhance and annotate the defect images of hydraulic structures;
[0065] S13: Split the cleaned, enhanced and annotated data into training and test sets with a ratio of 7:3;
[0066] Reference Figure 2 , the specific steps of step S2 in this example are:
[0067] S21: Construct a contour initialization network based on instance center features, where the backbone network is DLA-34, and the prediction branch networks are instance center branch, center point offset branch, N-gon regression branch, and relative distance branch. The instance center branch is used to classify instances and detect instance centers; the center point offset branch is used to predict the discretization error caused by input downsampling; the N-gon regression branch is used to predict the distance between the instance center and the contour point; the relative distance network predicts the relative distance of instances in the image to determine the occlusion relationship between instances;
[0068] S22: Use the backbone network DLA-34 to extract features from the image and obtain a feature map;
[0069] S23: The obtained feature maps are input into four branch output layers in parallel to obtain the instance category and instance center position, offset error, relative distance between the instance center and the contour point, and relative distance between the instance in the image respectively;
[0070] S24: The initialization contour result is obtained by combining the instance center, offset, category, and relative distance.
[0071] When training the N-gon regression branch in step S21 of this example, N intersection points of N rays emitted from the instance center and the instance contour are selected as the contour vertex rays to be regressed, and the positive direction of the Y axis is used as the starting ray, and the equiangular angles are selected, and the angle size is 360 / N. In order to make the initial contour wrap the instance as much as possible, the intersection point farthest from the instance center is selected as the initial contour point; in the N-gon regression branch, the network is designed to simultaneously predict the offset of the contour point relative to the instance center in the X-axis and Y-axis directions, thereby increasing the freedom of contour point prediction; the N-gon regression branch structure consists of a 3×3 convolution and a 1×1×2N convolution. After downsampling the feature map, the number of channels is changed to output a two-dimensional image of 2N channels to represent the offset of the N contour points of each instance relative to the instance center in the X-axis and Y-axis directions; for the instance whose instance center is at (x′, y′), the network outputs a floating-point number of (i1, j1, i2, j2, ..., i N , j N ), the coordinates of the nth initial contour point are (x′+i n , y′+j n ); By connecting N points, the initial outline of the N-gon is obtained;
[0072] The training loss of the relative distance branch in step S21 is:
[0073] L distance =smoothl 1 (distance, distance GT )
[0074] Where distance represents the instance distance value of the relative distance branch regression, distance GT Relative distance values of the annotations representing the instances; relative distances are used as reference annotations in training. The relative distance branch is trained on the entire image, so an object with the center of the instance at (x′, y′) will have a distance D(x′, y′), where D is a two-dimensional relative distance map. To train this branch, the same strategy as the polygon regression branch is used, and only the values associated with the object will affect the loss.
[0075] In step S21 of this example, the instance center position of the instance center branch is obtained by solving the centroid of the instance plane, and an elliptical Gaussian kernel function is used to generate a heat map. The expression of the elliptical Gaussian kernel function is:
[0076]
[0077] The upper left corner and lower right corner of the feasible detection box are restricted to be centered on the upper left corner and lower right corner of the real detection box, with a horizontal semi-axis length of a and a vertical semi-axis length of b, and . Where (x, y) is the coordinate after downsampling. is the coordinate of the target center point after downsampling, σ a =a / 3,σ b =b / 3.
[0078] Reference Figure 3 The specific steps of step S3 in this example are:
[0079] S31: Build a contour deformation network based on differentiation module, which consists of a global deformation module, two position-encoded Deep Snake modules, which will be used to perform different stages of contour deformation, and integrate position encoding and keypoint-first nearest neighbor matching algorithms;
[0080] S32: inputting the initial contour into the global deformation module to obtain the first contour deformation result;
[0081] S33: Input the first contour deformation result, the feature map output by the feature extraction network DLA-34, and the X, Y coordinate channels into the position-encoded Deep Snake module, perform the second position-encoded contour deformation, and obtain the second contour deformation result;
[0082] S34: The second contour deformation result, the feature map output by the feature extraction network DLA-34, and the X, Y coordinate channels are input into the Deep Snake module of position encoding, and the third contour deformation is performed using the key point priority nearest neighbor matching algorithm to obtain the final contour deformation result.
[0083] Reference Figure 4 In step S32 of this example, the global deformation module first directly fuses the center point feature and all the features of the contour points to be regressed, and then predicts the initial contour deformation displacement based on the fused features, that is, the features of the N initial contour points and the center point are connected into a vector with a length of (N+1)×C, where C is the number of channels of the vertex feature; then the vector is input into the MLP module (the number of channels of the hidden layer and the output layer are both N×2) to obtain the offset of the contour point (a vector with a length of N×2, recorded as The initial contour point coordinates are superimposed with the offset to obtain the deformed contour, which is recorded as the global contour and is recorded as
[0084] In step S33 of this example, the position-encoded Deep Snake module adds X and Y coordinate channels based on the feature map output by the feature extraction network DLA-34, which respectively represent the normalized X-axis coordinate and Y-axis coordinate of the specific position. If the X and Y coordinate channels do not learn any information, then the position-encoded Deep Snake module is equivalent to the original Deep Snake module; and if the X and Y coordinate channels learn certain position information, then the Deep Snake module has a certain translation dependency and can more accurately predict the contour deformation offset.
[0085] Reference Figure 4 , Figure 5 , Figure 6 , Figure 7 In step S34, the nearest neighbor matching algorithm with key point priority selects and annotates the reference contour points through the Douglas-Peucker algorithm to determine the contour key points and use them for training the model; key point priority matching is performed at the key points, and the nearest neighbor matching mechanism is selected in addition; the Douglas-Peucker algorithm connects the first and last endpoints A and B of the curve, traverses the remaining points on the curve, and solves the distance between all endpoints and the straight line AB; selects the point M farthest from the straight line, and records the point distance from the point to the straight line AB as d max . max Distance from threshold ε d Compare, if the maximum distance value is less than the threshold (d max <ε d ), then discard all the middle points on the curve, and the straight line AB is the simplified result; if the maximum distance value is greater than the threshold (d max ≥ε d), retain point M, then the curve is divided into two parts AM and BM for recursive processing; repeat the above steps for each segment of the self-line, recursively, until all segments meet the threshold condition (d max <ε d ); Finally, the four points A, M, N, and B are the key points of the original broken line AB.
[0086] For each dimensioned datum contour keypoint Traverse all input contour points Find the point with the closest Euclidean distance, recorded as The search process formula is as follows:
[0087]
[0088] Reference Figure 6 , the light grey dots are the vertices of the contour to be regressed, the dark grey dots are the interpolated reference contour points, the black dots are the key points of the reference contour, and the arrows indicate that the key points are matched first. The regression target is set as
[0089] The smooth l1 distance is used to calculate the loss when training this part of the contour points, where n key Indicates the number of key points:
[0090]
[0091] The chamfer distance loss function used can be simplified as the average shortest distance from the contour point to be predicted to the interpolation reference contour point. Without considering the priority matching of key points, the formula is as follows:
[0092]
[0093] At this time, the matching mechanism between contours is transformed into the matching of the contour points to be predicted and the nearest neighbor interpolation reference contour points. This matching method is used for the contour points to be regressed other than those matched with the key points. Figure 7 As shown, the vertex numbered 3 is a contour point that has been matched according to the key point priority matching mechanism and does not participate in the matching.
[0094] For each input contour point to be matched Traverse all interpolation reference contour points to find the point with the closest Euclidean distance to the input contour point and record it as The search process is expressed as:
[0095]
[0096] Take the nearest interpolated reference contour point as the output contour point Matching points, use smooth l1 distance to calculate contour loss:
[0097]
[0098] After key point priority matching and nearest neighbor matching, all contour points to be regressed have their own regression targets. The loss at this time includes two parts: 1) the benchmark contour key point pulls the nearest predicted contour point to the location of the key point; 2) the remaining predicted contour points move toward the nearest neighbor interpolated benchmark contour point. This loss function is the nearest neighbor loss function with key point priority, which is recorded as:
[0099] L(pred,gt)=L keypoint (pred,gt)+L left (pred,gt)
[0100] The specific steps of step S5 in this example are:
[0101] S51: Determine the key defect monitoring areas of hydraulic structures. Based on the expected speed of defect evolution and monitoring needs, take photos of ordinary parts every 3 days in the non-flood season, take photos of key parts once a day in the non-flood season, take photos of ordinary parts once a day in the flood season, and take photos of key parts twice a day in the flood season; each photo should be taken in the same time period to ensure consistency of lighting conditions, for example, take photos at 9 am and 5 pm each time.
[0102] S52: Use a high-resolution camera to take photos of the pre-determined monitoring area to ensure that the photos can identify small defects; keep the camera position and angle consistent, and mark and archive the photos taken by date for easy tracking and retrieval;
[0103] S53: Execute step S4 for each photo taken to segment the defect instances; record the result of each segmentation and compare it with the photos taken during the same period of the previous year; after each photo is taken, compare and analyze the new segmentation result with the previous 30 results, and the comparison formula is:
[0104]
[0105] Among them, Y2 is the segmentation result of this defect instance, and Y1 is the segmentation result of the previous defect instance. The intersection over union (IoU) ratio is calculated for the two segmentation results. The smaller the ratio, the greater the change. At the same time, a defect change trend graph is drawn to analyze the evolution speed and expansion trend of the defect.
[0106] S54: Based on continuous monitoring data, evaluate the evolution trend of defects and determine whether there are signs of accelerated deterioration. If defects are found to have significantly expanded or new defects have appeared, conduct further on-site inspections.
[0107] According to the above examples, the traditional defect detection method mainly relies on manual investigation and field measurement, and the pixel-based instance segmentation method consumes large computational resources, and the single-stage instance segmentation method based on contour has low precision. The present invention uses a two-stage instance segmentation method based on contour to perform instance segmentation on images of hydraulic structure defects. The present invention predicts the instance center through a contour initialization method based on instance center features, regresses the distance from the contour point to the contour based on the features of all instance center points, and outputs the instance relative distance to determine the mutual occlusion relationship of the overlapping contours of hydraulic structures. Then, in view of the error propagation and contour false matching in contour deformation, a contour deformation method based on a differentiation module is proposed, which can effectively improve the accuracy of contour instance segmentation and realize instance segmentation of hydraulic structure defects. Solve the above problems, improve the speed of contour segmentation, optimize the details of instance edge segmentation, improve the real-time and accuracy of hydraulic structure defect judgment, and assist in online evaluation and intelligent decision-making of hydraulic structure defects.
Claims
1. A contour-based method for segmenting defect instances of hydraulic structures, characterized in that: The steps include: S1: Preprocess the data set to obtain a hydraulic structure defect image data set, and divide the data set into a training data set and a test data set; S2: Construct a contour initialization network based on instance center features, use DLA-34 to extract features, and generate the initial contour of the dataset defect through the prediction branch network; The specific steps of step S2 are: S21: Build a contour initialization network based on instance center features, where the backbone network is DLA-34, and the prediction branch networks are instance center branch, center point offset branch, N-gon regression branch, and relative distance branch. S22: Use the backbone network DLA-34 to extract features from the image and obtain a feature map; S23: The obtained feature maps are input into four branch output layers in parallel to obtain the instance category and instance center position, offset error, relative distance between the instance center and the contour point, and relative distance between the instance in the image respectively; S24: Obtain the initialization contour result by combining instance center, offset, category, and relative distance; S3: Build a contour deformation network based on the differentiation module. The contour deformation network consists of a global deformation module and two position encoding Deep Snake modules. The model is trained using the training dataset based on S2. The specific steps of step S3 are: S31: Build a contour deformation network based on differentiation module, which consists of a global deformation module, two position-encoded Deep Snake modules, which will be used to perform different stages of contour deformation, and integrate position encoding and keypoint-first nearest neighbor matching algorithms; S32: inputting the initial contour into the global deformation module to obtain the first contour deformation result; S33: Input the first contour deformation result, the feature map output by the feature extraction network DLA-34, and the X, Y coordinate channels into the position-encoded Deep Snake module, perform the second position-encoded contour deformation, and obtain the second contour deformation result; S34: The second contour deformation result, the feature map output by the feature extraction network DLA-34, and the X, Y coordinate channels are input into the Deep Snake module of the position encoding, and the third contour deformation is performed by using the nearest neighbor matching algorithm with key point priority to obtain the final contour deformation result; S4: Input the test data set into the trained contour deformation network in step S3, and obtain the instance segmented image through three contour deformations; S5: Continue to take photos of the hydraulic structure, execute step S4, obtain defect segmentation results at different times, compare the segmentation results, and determine the defect evolution trend.
2. The method for segmenting hydraulic structure defect instances based on contour according to claim 1, characterized in that: The specific steps of step S1 are: S11: Selecting defect images of different hydraulic structures and defect images of hydraulic structures at different times during the day and at night; S12: Clean, enhance and annotate the defect images of hydraulic structures; S13: The cleaned, enhanced and labeled data are divided into training data set and test data set with a ratio of 7:
3.
3. The method for segmenting hydraulic structure defect instances based on contour according to claim 1, characterized in that: When the N-gon regression branch is trained in step S21, the N intersection points of the N rays emitted from the instance center and the instance contour are selected as the contour vertex rays to be regressed, with the positive direction of the Y axis as the starting ray, and the equiangles are selected, and the angle size is 360 / N; in the N-gon regression branch, the network is designed to simultaneously predict the offset of the contour point relative to the instance center in the X-axis and Y-axis directions; the N-gon regression branch structure consists of a 3×3 convolution and a 1×1×2N convolution, and the number of channels is changed after downsampling the feature map to output a 2N-channel two-dimensional image to represent the offset of the N contour points of each instance relative to the instance center in the X-axis and Y-axis directions; for the instance center at For an instance of position, the network outputs a floating point number of , the coordinates of the nth initial contour point are ; By connecting N points, the initial outline of the N-gon is obtained; The training loss of the relative distance branch in step S21 is: in represents the instance distance value of relative distance branch regression, Relative distance value of the annotation representing the instance; During training, the relative distance is used as the benchmark annotation to train the relative distance branch, and the same strategy as the N-gon regression branch is adopted; The relative distance branch is trained on the entire image, so the instance center is The object will have a distance , where D is a two-dimensional relative distance map.
4. The method for segmenting hydraulic structure defect instances based on contour according to claim 3, characterized in that: In step S21, the instance center position of the instance center branch is obtained by solving the centroid of the instance plane, and an elliptical Gaussian kernel function is used to generate a heat map. The expression of the elliptical Gaussian kernel function is: The upper left corner and lower right corner of the feasible detection box are restricted to be centered on the upper left corner and lower right corner of the real detection box, with a horizontal semi-axis length of a and a vertical semi-axis length of b, and The ellipse of is the coordinate after downsampling, is the coordinate of the target center point after downsampling, , .
5. The method for segmenting hydraulic structure defect instances based on contour according to claim 1, characterized in that: In step S32, the global deformation module first directly fuses the center point features and all the contour point features to be regressed, and then predicts the initial contour deformation displacement based on the fused features, that is, The features of the initial contour points and the center point are connected into a A vector of is the number of channels of the vertex feature; then the vector is input into the MLP module to obtain the offset of the contour point; the length is The vector of ; The initial contour point coordinates are superimposed with the offset to obtain the deformed contour, which is recorded as the global contour and recorded as .
6. The method for segmenting hydraulic structure defect instances based on contour according to claim 1, characterized in that: In step S33, the position-encoded Deep Snake module adds X and Y coordinate channels based on the feature map output by the feature extraction network DLA-34, which respectively represent the normalized X-axis coordinate and Y-axis coordinate of the specific position; if the X and Y coordinate channels have not learned any information, then the position-encoded Deep Snake module is equivalent to the original Deep Snake module; and if the X and Y coordinate channels have learned certain position information, then the Deep Snake module has a certain translation dependence and can more accurately predict the contour deformation offset.
7. The method for segmenting hydraulic structure defect instances based on contour according to claim 1, characterized in that: In step S34, the nearest neighbor matching algorithm with key point priority selects and annotates the reference contour points through the Douglas-Peucker algorithm to determine the contour key points and use them to train the model; key point priority matching is performed at the key points, and the nearest neighbor matching mechanism is selected otherwise.
8. The method for segmenting hydraulic structure defect instances based on contour according to claim 1, characterized in that: The specific steps of step S5 are: S51: Determine the key monitoring areas of defects in hydraulic structures. According to the expected speed of defect evolution and monitoring needs, take photos of ordinary parts every three days in the non-flood season, take photos of key parts once a day in the non-flood season, take photos of ordinary parts once a day in the flood season, and take photos of key parts twice a day in the flood season; ensure the consistency of lighting conditions for each shooting; S52: Use a camera to take photos of the pre-determined monitoring area, ensuring that the photos can identify small defects; keep the camera position and angle consistent, and mark and archive the photos taken by date for easy tracking and retrieval; S53: Execute step S4 for each photo taken to segment the defect instances; record the result of each segmentation and compare it with the photos taken during the same period of the previous year; after each photo is taken, compare and analyze the new segmentation result with the previous 30 results, and the comparison formula is: in is the defect instance segmentation result. is the segmentation result of the previous defect instance. The intersection over union (IoU) ratio is calculated for the two segmentation results. The smaller the ratio, the greater the change. At the same time, a defect change trend graph is drawn to analyze the evolution speed and expansion trend of the defect. S54: Based on continuous monitoring data, evaluate the evolution trend of defects and determine whether there are signs of accelerated deterioration. If defects are found to have significantly expanded or new defects have appeared, conduct further on-site inspections.
