Image recognition method and device of focusing pipe network system

By performing grayscale histogram analysis, image segmentation and Gaussian filtering on pipeline images, combined with the recognition ability of convolutional neural network models, the problem of difficulty in capturing subtle defect features in the prior art is solved, and more efficient and accurate pipeline defect recognition is achieved.

CN120014369APending Publication Date: 2025-05-16POWERCHINA HUADONG ENG CORP LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202510466161.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-15
Publication Date
2025-05-16

AI Technical Summary

Technical Problem

The prior art is difficult to effectively capture subtle defect characteristics under complex backgrounds in pipeline detection, and cannot adapt to different lighting conditions, noise levels and changes in pipeline materials, resulting in unstable detection results and high false alarm rates and missed alarm rates.

Method used

By acquiring the pipeline image, drawing a grayscale histogram, determining the frequency distribution of grayscale values, and performing image segmentation, multiple segmented sub-images are obtained, and each sub-image is subjected to Gaussian filtering to enhance image quality. Then, the enhanced image is recognized using the pre-constructed convolutional neural network model and the defect type prediction results are output.

Benefits of technology

It improves the effect of feature extraction and the accuracy of image recognition, can more accurately reflect the actual characteristics of the image, enhances image quality, reduces false alarm rates and missed alarm rates, and improves the stability and adaptability of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120014369A_ABST
    Figure CN120014369A_ABST
Patent Text Reader

Abstract

The invention provides an image recognition method and device for a focused pipe network system, and relates to the technical field of image recognition, the segmentation standard of an image is determined by analyzing a frequency peak value in a gray histogram of a pipeline image, a corresponding segmentation mode can be determined according to different image contents, and the segmentation efficiency is improved. The actual features of the image are reflected more accurately, and the segmentation precision and adaptability are improved. According to the method, image enhancement processing is carried out on each segmented sub-image after segmentation, the image quality is enhanced, and optimization is carried out especially for the characteristics of different areas, so that a pipeline image recognition model can carry out image recognition on a clearer and more focused image, and the feature extraction effect is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image recognition, and in particular to an image recognition method and device for a focused pipe network system. Background Art

[0002] In pipeline inspection, accurate identification of defects inside the pipeline (such as corrosion, cracks, deformation, etc.) is crucial to ensure the safe operation of the pipeline. Traditional methods usually rely on manual inspection or use simple image processing techniques such as threshold segmentation or edge detection, which are difficult to effectively capture subtle defect features under complex backgrounds. Existing technologies cannot adapt to different lighting conditions, noise levels, and changes in pipeline materials, resulting in unstable detection results and high false alarm and missed alarm rates. Summary of the invention

[0003] In view of this, an object of the present invention is to provide an image recognition method and device focusing on a pipe network system, which can improve the effect of feature extraction and improve the accuracy of image defect recognition.

[0004] In a first aspect, an embodiment of the present invention provides an image recognition method focusing on a pipe network system, wherein the method comprises: acquiring a pipe image of a preset pipe and drawing a grayscale histogram of the pipe image; determining the grayscale value frequency distribution of the pipe image based on the grayscale value frequency distribution; performing image segmentation on the pipe image according to the grayscale value frequency distribution to obtain a plurality of segmented sub-images of the pipe image; performing Gaussian filtering on each segmented sub-image of the pipe image to obtain an enhanced image corresponding to each segmented sub-image; using a pre-constructed pipe image recognition model to recognize the enhanced image of the pipe image, and outputting a defect type prediction result of the pipe image; and determining the pipe defect of the pipe image based on the defect type prediction result.

[0005] In combination with the first aspect, an embodiment of the present invention provides a first implementation of the first aspect, wherein the step of performing image segmentation on the pipeline image according to the gray value frequency distribution to obtain multiple segmented sub-images of the pipeline image includes: determining, according to the gray value frequency distribution, an image segmentation threshold of the pipeline image in the grayscale interval corresponding to the gray value frequency distribution; and dividing the pipeline image into regions based on the image segmentation threshold to form multiple segmented sub-images of the pipeline image.

[0006] In combination with the first aspect, an embodiment of the present invention provides a second implementation of the first aspect, wherein the step of dividing the pipeline image into regions based on the image segmentation threshold includes: performing image segmentation on the pipeline image according to the image segmentation threshold based on a preset maximum inter-class variance method to obtain multiple segmented regions of the pipeline image.

[0007] In combination with the first aspect, an embodiment of the present invention provides a third implementation of the first aspect, wherein the step of performing Gaussian filtering on each segmented sub-image of the pipeline image to obtain an enhanced image corresponding to each segmented sub-image includes: taking the center position of the segmented sub-image as the coordinate origin, sampling the segmented sub-image, and determining the position coordinates of a preset Gaussian filter in each segmented area of ​​the pipeline image; determining a weight value of the segmented sub-image of the current segmented area based on the position coordinates, and calculating a Gaussian filter matrix corresponding to the pipeline image; and performing a convolution operation on each segmented sub-image using the Gaussian filter matrix to obtain an enhanced image corresponding to each segmented sub-image.

[0008] In combination with the first aspect, an embodiment of the present invention provides a fourth implementation of the first aspect, wherein the step of calculating the Gaussian filter matrix corresponding to the pipeline image includes: arranging the weight values ​​of the segmented sub-images according to the positions of the segmented areas of the pipeline image to obtain an initial Gaussian filter matrix; normalizing the initial Gaussian filter matrix to generate a Gaussian filter matrix corresponding to the pipeline image.

[0009] In combination with the first aspect, an embodiment of the present invention provides a fifth implementation of the first aspect, wherein the pipeline image recognition model is constructed based on a preset convolutional neural network; the step of using the pre-constructed pipeline image recognition model to recognize the enhanced image of the pipeline image, and outputting the defect type prediction result of the pipeline image includes: performing convolution calculation on the enhanced image through the convolutional neural network of the pipeline image recognition model, and outputting the target features of the enhanced image; mapping the target features using the fully connected layer of the convolutional neural network, and determining the probability distribution of the defect type indicated by the target features; and determining the defect type prediction result of the pipeline image based on the defect type probability distribution.

[0010] In combination with the first aspect, an embodiment of the present invention provides a sixth implementation of the first aspect, wherein the method further includes: training a preset convolutional neural network using a preset training sample set to construct an objective function corresponding to the convolutional neural network; the training sample set includes pipeline image samples of multiple defect types; and constructing a pipeline image recognition model based on the trained objective function.

[0011] In combination with the first aspect, an embodiment of the present invention provides a seventh implementation method of the first aspect, wherein the method for constructing the objective function includes: obtaining the prediction probability corresponding to each sample in the training sample set; based on the prediction probability, calculating the cross entropy loss corresponding to each defect type, and constructing an initial objective function; optimizing the weight parameters in the initial objective function to minimize the initial objective function, and determining the final objective function.

[0012] In combination with the first aspect, an embodiment of the present invention provides an eighth implementation of the first aspect, wherein the step of constructing the initial objective function includes: calculating the average loss corresponding to the cross entropy loss corresponding to each defect type; introducing a regularization term to the average loss, and constructing the initial objective function corresponding to the training sample set.

[0013] In a second aspect, an embodiment of the present invention provides an image recognition device focusing on a pipe network system, wherein the device includes: a data acquisition module, used to acquire a pipe image of a preset pipe and draw a grayscale histogram of the pipe image; a calculation module, used to determine the grayscale value frequency distribution of the pipe image based on the grayscale histogram; an execution module, used to perform image segmentation on the pipe image according to the grayscale value frequency distribution to obtain a plurality of segmented sub-images of the pipe image; a data processing module, used to perform Gaussian filtering on each segmented sub-image of the pipe image to obtain an enhanced image corresponding to each segmented sub-image; a recognition module, used to recognize the enhanced image of the pipe image using a pre-built pipe image recognition model, and output a defect type prediction result of the pipe image; and an output module, used to determine the pipe defect of the pipe image based on the defect type prediction result.

[0014] The embodiments of the present invention bring the following beneficial effects: The embodiments of the present invention provide an image recognition method and device for a focused pipe network system, which determines the segmentation standard by analyzing the frequency peak in the grayscale histogram, and can determine the corresponding segmentation method according to different image contents, which can more accurately reflect the actual characteristics of the image and improve the accuracy and adaptability of the segmentation. After segmentation, each sub-image is subjected to targeted enhancement processing, which not only enhances the image quality, but also optimizes the characteristics of different regions, ensuring that image recognition can be performed on clearer and more focused images, thereby improving the effect of feature extraction.

[0015] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention are realized and obtained by the structures particularly pointed out in the description, claims and drawings.

[0016] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0018] Figure 1 A flow chart of an image recognition method for a focused pipe network system provided by an embodiment of the present invention; Figure 2 Grayscale histograms corresponding to pipelines with different defect types provided in an embodiment of the present invention; Figure 3 A flowchart of another image recognition method for a focused pipe network system provided by an embodiment of the present invention; Figure 4 A schematic diagram of the structure of an image recognition device for a focusing pipe network system provided by an embodiment of the present invention; Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0019] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution of the present invention will be clearly and completely described in combination with the embodiments below. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0020] The embodiments of the present invention provide an image recognition method and device focusing on a pipe network system, which can effectively capture subtle defect features under a complex background and identify pipe defects more accurately.

[0021] Among them, the defects of drainage pipes include functional defects and structural defects. After classifying images of different types of defects, if there are enough samples of rupture images, for example, 1,000 images are prepared, a histogram is drawn for these rupture images, and mathematical and statistical analysis is performed. It is found that the frequency peaks of 900 rupture images are between 20 and 25 Hz; similarly, the frequency peak of leakage is between 60 and 75 Hz. The frequency peaks of the two defects are obviously different and easy to distinguish. Correspondingly, the embodiment of the present invention draws a grayscale histogram for the pipeline image, clarifies the frequency peak interval of the defect, and then performs image segmentation to determine the defect location in the pipeline image, and extracts and identifies local features for the defect location to determine the probability of the defect type of the preset pipeline indicated by the pipeline image.

[0022] For ease of understanding, an image recognition method for a focusing pipe network system provided by an embodiment of the present invention is first described. Figure 1 A flowchart of an image recognition method for a focusing pipe network system provided by an embodiment of the present invention is shown. Figure 1 , the method comprises the following steps: Step S102, obtaining a pipeline image of a preset pipeline, drawing a grayscale histogram of the pipeline image, and determining a grayscale value frequency distribution of the pipeline image.

[0023] In order to identify pipeline defects, the embodiment of the present invention performs data image segmentation on the pipeline image of a preset pipeline, and the pipeline image recognition model recognizes each segmented image area to determine the pipeline defects.

[0024] Traditional image segmentation methods may perform image segmentation based on general features such as color, texture, and edges, and perform poorly in complex or changing backgrounds. For example, there may be multiple materials, uneven lighting, and surface reflections inside a pipe, making it difficult for these methods to distinguish between real defects and normal structures. Different types of defects have unique visual features, and traditional methods are usually unable to capture these subtle differences well, making it impossible to effectively distinguish different types of defects, limiting classification capabilities and reducing diagnostic accuracy.

[0025] The possible defect types of the preset pipeline include cracks, corrosion, deformation, etc. The embodiment of the present invention draws a grayscale histogram for the pipeline image and determines the defect position corresponding to the pipeline image based on the grayscale value frequency distribution of the grayscale histogram. Then, the pipeline image is segmented based on the defect position to achieve more targeted segmentation. Afterwards, the pipeline defects of the segmented pipeline image are identified using the pipeline image recognition model, which can more accurately identify the defect type of the pipeline.

[0026] In specific implementation, the pipeline image can be collected by an industrial camera or other imaging device. The original pipeline image is colored relative to the ambient light. Drawing the grayscale histogram of the pipeline image to determine the grayscale value frequency distribution helps to understand the number of pixels with different brightness levels in the image. Different defects will show obvious frequency peaks in a specific grayscale interval. The frequency peak is the peak point that appears in the grayscale histogram, indicating that there are more pixels in this grayscale value range. Different types of defects usually cause the grayscale values ​​of certain areas in the image to be concentrated in one or more specific ranges, thus forming obvious frequency peaks on the grayscale histogram. Reference Figure 2 The grayscale histograms corresponding to different defect types of pipelines are shown. Figure 2, the x-axis of the histogram represents the grayscale level (from 0 to 255), and the y-axis represents the number of occurrences or frequency of each grayscale level. By observing the generated histogram, the quality and contrast of the image can be evaluated to apply the corresponding method or threshold technology to segment the pipeline image. According to the drawn grayscale histogram, the defect type corresponding to the pipeline image can also be preliminarily determined, such as functional defects and structural defects.

[0027] in, Figure 2 The grayscale histogram shown reflects the grayscale value frequency distribution of the pipeline image in different grayscale intervals, which can clearly identify the interval where the grayscale value frequency peak of the pipeline image is located to determine the defect location in the pipeline image. Usually, the grayscale value frequency peak corresponds to the background or normal area in the image. A normal pipeline wall may show a higher grayscale value frequency, while a defective area may show different grayscale characteristics. Defects such as corrosion and cracks may cause the local grayscale value to decrease, forming a darker area. Sediments, foreign matter, etc. may cause the local grayscale value to increase, forming a brighter area.

[0028] In summary, the embodiment of the present invention plots a grayscale histogram to understand the distribution of different grayscale values ​​in an image. For a pipeline image with defects to be identified, the grayscale histogram of the focus frequency peak interval can highlight areas in the image where defects may exist. These areas usually show abnormal grayscale value distribution, such as being too bright or too dark, or having particularly concentrated grayscale values. By analyzing these peak intervals, the location of the defect can be preliminarily determined, and guidance can be provided for subsequent processing.

[0029] Step S104, performing image segmentation on the pipeline image according to the gray value frequency distribution to obtain a plurality of segmented sub-images of the pipeline image.

[0030] The gray value frequency distribution in the gray histogram of the pipeline image can focus on the defect location of the pipeline image and effectively capture the subtle defect features under complex backgrounds. Furthermore, in order to more accurately determine the defect location, the image segmentation technology can be used to divide the image into normal areas and defect areas to obtain multiple segmented sub-images. Image segmentation based on the defect location can only process the area of ​​interest, reducing the demand for computing resources. Focusing on the defect area can reduce background interference and make subsequent analysis more accurate. Moreover, it can better highlight the defect features, facilitate further processing, and improve targeting and efficiency. Step S106, performing Gaussian filtering on each segmented sub-image of the pipeline image to obtain an enhanced image corresponding to each segmented sub-image.

[0031] For the segmented pipeline image, the embodiment of the present invention also performs image enhancement processing, which can further increase the contrast between the defect and the surrounding environment, so that the defect features are more obvious. Moreover, it helps to define the boundary more accurately, so as to better identify the pipeline defect.

[0032] Step S108, using the pre-built pipeline image recognition model to recognize the enhanced image of the pipeline image, and outputting the defect type prediction result of the pipeline image. Step S110, determining the pipeline defect of the pipeline image based on the defect type prediction result.

[0033] In a specific implementation, a pipeline image recognition model can be used to extract feature vectors from each segmented sub-image of the pipeline image. In one embodiment, a high-dimensional representation can be obtained by a convolutional neural network or other feature extractor. Further, the category to which each region belongs is determined based on the extracted features, and then the classification results are optimized and sorted to determine the defect type prediction result corresponding to the pipeline image. The prediction result can be determined by the category label.

[0034] In summary, the image recognition method focused on the pipe network system provided by the embodiment of the present invention determines the segmentation standard by analyzing the frequency peak in the grayscale histogram, can determine the corresponding segmentation method according to different image contents, and focus on the defective area of ​​the pipe network image, which can more accurately reflect the actual characteristics of the image and improve the accuracy and adaptability of the segmentation. After segmentation, each sub-image is subjected to targeted enhancement processing, which not only enhances the image quality, but also optimizes the characteristics of different areas, ensuring that image recognition can be performed on clearer and more focused images, thereby improving the effect of feature extraction.

[0035] Further, based on the above embodiment, the embodiment of the present invention provides another image recognition method focusing on the pipe network system. Figure 3 A flowchart of another image recognition method for a focusing pipe network system provided by an embodiment of the present invention is shown. Figure 3 , the method comprises the following steps: Step S202, obtaining a pipeline image of a preset pipeline, drawing a grayscale histogram of the pipeline image, and determining a grayscale value frequency distribution of the pipeline image.

[0036] Step S204: determining an image segmentation threshold of the pipeline image in a grayscale interval corresponding to the grayscale frequency distribution according to the grayscale frequency distribution. Step S206: based on the image segmentation threshold, the pipeline image is divided into regions to form a plurality of segmented sub-images of the pipeline image.

[0037] In combination with the above embodiments, the embodiments of the present invention select a suitable image segmentation threshold based on the gray value frequency distribution corresponding to the pipeline image, thereby performing image segmentation. In specific implementation, the corresponding image segmentation method can be selected according to the needs. In one embodiment, Otsu's method can be used to automatically select a threshold based on the gray value frequency distribution, effectively dividing the image into foreground and background, and obtaining multiple segmented sub-images of the pipeline image. Among them, it is assumed that the gray histogram of the image presents an obvious bimodal distribution, that is, there are two significant frequency peaks. The image can be divided into foreground and background by using the bimodal method based on the lowest point between the two peaks as the threshold.

[0038] Step S208, performing Gaussian filtering on each segmented sub-image of the pipeline image to obtain an enhanced image corresponding to each segmented sub-image.

[0039] Gaussian filtering is performed on the segmented sub-images of the pipeline image to reduce noise in the image and smooth the image. The pixels and their neighborhoods are weighted averaged based on the Gaussian distribution function, so that the new value of each pixel is the weighted sum of the values ​​of its surrounding pixels, which helps to retain edge information while reducing the impact of noise.

[0040] Specifically, the steps include: 1) Taking the center position of the segmented sub-image as the coordinate origin, sampling the segmented sub-image, and determining the position coordinates of the preset Gaussian filter in each segmented area of ​​the pipeline image.

[0041] First, a two-dimensional coordinate system is constructed, and sampling is performed with the center position of the segmented sub-image of the pipeline image as the origin of the coordinates. The coordinates of each position of the Gaussian kernel are as follows:

[0042] 2) Determine the weight value of the segmented sub-image of the current segmented area based on the position coordinates, and calculate the Gaussian filter matrix corresponding to the pipeline image.

[0043] Specifically, the weight values ​​of the segmented sub-images are arranged according to the segmented region positions of the pipeline image to obtain an initial Gaussian filter matrix; the initial Gaussian filter matrix is ​​normalized to generate a Gaussian filter matrix corresponding to the pipeline image.

[0044] In the specific implementation, a two-dimensional Gaussian distribution matrix is ​​constructed as the convolution kernel. The size and standard deviation of the kernel determine the filtering effect. In image processing, when using a Gaussian filter for convolution operation, the radius σ of the filter plays a decisive role, affecting several key aspects of the filtering effect: 1. Smoothness: A larger σ value will cause the filter to cover a larger area, making the smoothing effect of the image more obvious. This means that the noise in the image will be removed more effectively, but at the same time, the details of the image may also be lost. Edge preservation: A smaller σ value will cause the filter to mainly affect a small area in the image, so that while smoothing the image, the edges and details of the image can be better preserved. This is very important for applications that need to retain image details (such as edge detection). In one embodiment, the radius of the filter is set to σ=1.5, indicating that the filter will cover a relatively small area, so that while smoothing the image, the details and edges of the image are better preserved. Substitute the coordinates (x, y) of the Gaussian filter into the following formula, and arrange each calculated value obtained in the corresponding position to determine the initial Gaussian filter matrix.

[0045]

[0046] in, are the position coordinates relative to the center point.

[0047] The initial Gaussian filter matrix corresponding to the preset pipeline image is as follows:

[0048] Since filtering an image using a weight matrix with a sum value greater than 1 or less than 1 will cause a deviation in the brightness of the image, the obtained weight matrix is ​​normalized so that the total weight value of the final filtered image channel is 1.

[0049] The sum of the 9 weight values ​​of the weight matrix of the above initial Gaussian filter matrix is ​​equal to 0.4787147. Dividing each value in the weight matrix by the sum, the normalized weight matrix is ​​obtained, that is, the final Gaussian filter matrix, as shown below:

[0050] 3) Use the Gaussian filter matrix to perform convolution operation on each segmented sub-image to obtain the enhanced image corresponding to each segmented sub-image.

[0051] Through the above steps, the segmented sub-image of the pipeline image is Gaussian filtered, the Gaussian kernel is covered on the image, the weighted sum of all pixel values ​​in the covered area is calculated, and the center pixel is replaced with this new value. The image after convolution becomes smoother, the details such as noise are weakened, but the main structural features are retained. In one embodiment, the filter size is set to 3×3 and the filter radius is 1.5.

[0052] Step S210, using a pre-built pipeline image recognition model to recognize the enhanced image of the pipeline image, and outputting a defect type prediction result of the pipeline image.

[0053] In the embodiment of the present invention, the pipeline image recognition model is constructed based on a preset convolutional neural network to perform convolution calculation on the pipeline image and output the target features of the enhanced image. The target features are mapped using the fully connected layer of the convolutional neural network to determine the probability distribution of the defect type indicated by the target feature; based on the probability distribution of the defect type, the defect type prediction result of the pipeline image is determined.

[0054] The preset training sample set can be used to train the preset convolutional neural network, construct the objective function corresponding to the convolutional neural network, and construct the pipeline image recognition model based on the trained objective function. The training sample set includes pipeline image samples of multiple defect types.

[0055] Specifically, the steps to construct the objective function are as follows: 1) Get the predicted probability corresponding to each sample in the training sample set.

[0056] For multi-classification problems, we first output the probability of the classification of images within a pipeline, with the probability of each item between 0 and 1, and perform model prediction probability analysis on images of different internal categories.

[0057] Model prediction probability calculation formula:

[0058] Take the normal image Z01, the leakage image Z02, and the rupture image Z02 as examples. Assume that for a given input image, the logits output by the network are as follows: Z01=2.0; Z02=1.0; Z03=0.5. Convert these logits to probabilities to understand the network's confidence in each category. The Softmax function can be applied: softmax(z)I = ∑jexp(zj)exp(zi).

[0059] For normal images: softmax(z)01 = exp(2.0)+exp(1.0)+exp(0.5)exp(2.0) For leakage: softmax(z)02 =exp(2.0)+exp(1.0)+exp(0.5)exp(1.0) For rupture: softmax(z)03 =exp(2.0)+exp(1.0)+exp(0.5)exp(0.5) By calculation, we can get: exp(2.0)≈7.389; exp(1.0)≈2.718; exp(0.5)≈1.649.

[0060] Therefore, the denominator (the sum of all exponents) is: 7.389 + 2.718 + 1.649 = 11.756.

[0061] Correspondingly, the output probability of Softmax is: softmax(z)01≈11.7567.389≈0.628; softmax(z)02≈11.7562.718≈0.231; softmax(z)03≈11.7561.649≈0.140.

[0062] That is, corresponding to the training sample, the probability that the image is normal is about 62.8%, the probability that it is leaking is about 23.1%, and the probability that it is ruptured is about 14.0%.

[0063] 2) Based on the predicted probability, calculate the cross entropy loss corresponding to each defect type and construct the initial objective function.

[0064] For sample 1, the true label is a normal image, and the model predicts that the probability of a positive image is 0.8. Therefore, the cross entropy loss for sample 1 is: J1(h)=-(1log(0.8)+0log(0.1)+0log(0.1))=-log(0.8) For sample 2, the true label is dog leakage, and the model predicts that the probability of leakage is 0.8. The cross entropy loss for sample 2 is: J2(h)=-(0log(0.1)+1log(0.8)+0log(0.1))=-log(0.8).

[0065] For sample 3, the true label is rupture, and the model predicts that the probability of rupture is 0.7. The cross entropy loss for sample 3 is: J3(h)=-(0log(0.1)+0log(0.2)+1log(0.7))=-log(0.7).

[0066] Among them, the cross entropy loss function of the multi-classification problem can be used. The average loss corresponding to the cross entropy loss corresponding to each defect type is calculated; a regularization term is introduced into the average loss to construct the initial objective function corresponding to the training sample set.

[0067] After calculating the loss for each sample, take the average to get the overall cross entropy loss: J(h)=-1 / 3×(log(0.8)+log(0.8)+log(0.7)) Using mathematical calculations, we can get: J(h)≈-1 / 3×(-0.223+(-0.223)+(-0.357)) J(h)≈1 / 3×(0.223+0.223+0.357)≈1 / 3×0.803J(h)≈1 / 3×0.803 J(h)≈0.268 That is, combined with the above training samples, the cross entropy loss of the model on the given data set is about 0.268. The smaller this value is, the closer the model's prediction is to the true label, and the better the model's performance is.

[0068] The objective function is assumed to be (can be used for multi-classification):

[0069] Where: n is the number of samples; m is the number of categories; y i,c is an indicator variable, which is 1 if sample i belongs to category c, otherwise it is 0; is the model prediction sample i The probability of belonging to class c.

[0070] Regularize the objective function to prevent overfitting.

[0071]

[0072] Where k is a hyperparameter that weighs the contribution of the norm penalty term R(w) relative to the normalized objective function J(h). This parameter reduces the size of the original and objective functions on the training data. It provides some measure of the size of the parameter w when training the algorithm to minimize the normalized objective function J(h).

[0073] Setting the value of the hyperparameter k, for example k=0.01, indicates that you want to give the L2 penalty term a smaller weight in the objective function. Assume that there are only three weights w1, w2, w3 in the network, and their values ​​during training are: w1= 0.50; w2=-1.50; w3= 2.00.

[0074] Then, the L2 regularization term R(w) is calculated as follows: R(w)=0.01×(w12+w22+w32) =0.01×0.52+(-1.5)2+2.02) =0.01×(0.25+2.25+4.00) =0.01×6.50 =0.065 Now, assuming that the error of the objective function J(h) calculated under the current weight is 0.20, then the total objective function after L2 regularization is will be: =J(h)+kR(w)=0.268+0.01×6.50=0.10+0.065=0.165J^(h) =J(h)+kR(w)=0.10+0.01×6.50=0.268+0.065=0.333 3) Optimize the weight parameters in the initial objective function to minimize the initial objective function and determine the final objective function.

[0075] During training, the weights w1,w2,w3 are adjusted to minimize L2 regularization encourages the model to learn smaller weight values ​​by increasing the penalty for weight size, thereby reducing model complexity and reducing the risk of overfitting.

[0076] Step S212: determining the pipeline defect of the pipeline image based on the defect type prediction result.

[0077] In summary, another image recognition method focusing on the pipe network system provided by an embodiment of the present invention performs image segmentation on the grayscale histogram of the pipe image to extract detailed features of the possible defective area of ​​the pipe image. Sampling with the area where the defect may be present as the center can better highlight the features of the area, which is helpful for subsequent feature extraction and recognition. Especially when the defect boundary is blurred or the background interference is large, this method can improve the visibility and clarity of the defect. Since the center of the filter is always located at the defect, the influence of background noise on defect detection can be reduced.

[0078] Combined with the pipeline image recognition model, global feature extraction is performed on the input image to determine whether there are defects. The combination of global feature extraction and local feature extraction can capture important information in the image more comprehensively. Moreover, the present invention can be adjusted according to different defect types and locations of the pipeline, can better cope with various types of defects, has higher flexibility and adaptability, and can improve the overall detection performance.

[0079] Furthermore, based on the above embodiment, the embodiment of the present invention also provides an image recognition device focusing on the pipe network system. Figure 4 FIG. 1 shows a schematic diagram of a structure of an image recognition device for a focusing pipe network system provided by an embodiment of the present invention, referring to FIG. Figure 4 The device includes: a data acquisition module 100, which is used to acquire a pipeline image of a preset pipeline and draw a grayscale histogram of the pipeline image; a calculation module 200, which is used to determine the grayscale value frequency distribution of the pipeline image based on the grayscale value frequency distribution; an execution module 300, which is used to perform image segmentation on the pipeline image according to the grayscale value frequency distribution to obtain multiple segmented sub-images of the pipeline image; a data processing module 400, which is used to perform Gaussian filtering on each segmented sub-image of the pipeline image to obtain an enhanced image corresponding to each segmented sub-image; an identification module 500, which is used to identify the enhanced image of the pipeline image using a pre-constructed pipeline image recognition model and output a defect type prediction result of the pipeline image; and an output module 600, which is used to determine the pipeline defect of the pipeline image based on the defect type prediction result.

[0080] An embodiment of the present invention provides an image recognition device for a focused pipe network system, and its implementation principle and technical effects are the same as those of the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the device embodiment, reference may be made to the corresponding contents in the aforementioned method embodiment.

[0081] Furthermore, the execution module 300 is also used to determine the image segmentation threshold of the pipeline image in the grayscale interval corresponding to the grayscale frequency distribution according to the grayscale frequency distribution; and to divide the pipeline image into regions based on the image segmentation threshold to form multiple segmented sub-images of the pipeline image.

[0082] The execution module 300 is further configured to perform image segmentation on the pipeline image based on a preset maximum inter-class variance method according to an image segmentation threshold, so as to obtain a plurality of segmented regions of the pipeline image.

[0083] The above-mentioned data processing module 400 is also used to take the center position of the segmented sub-image as the coordinate origin, sample the segmented sub-image, determine the position coordinates of the preset Gaussian filter in each segmented area of ​​the pipeline image; determine the weight value of the segmented sub-image of the current segmented area based on the position coordinates, and calculate the Gaussian filter matrix corresponding to the pipeline image; use the Gaussian filter matrix to perform a convolution operation on each segmented sub-image to obtain an enhanced image corresponding to each segmented sub-image.

[0084] The data processing module 400 is further used to arrange the weight values ​​of the segmented sub-images according to the segmented region positions of the pipeline image to obtain an initial Gaussian filter matrix; and normalize the initial Gaussian filter matrix to generate a Gaussian filter matrix corresponding to the pipeline image.

[0085] Among them, the pipeline image recognition model is constructed based on a preset convolutional neural network; the above-mentioned recognition module 500 is also used to perform convolution calculation on the enhanced image through the convolutional neural network of the pipeline image recognition model, and output the target features of the enhanced image; use the fully connected layer of the convolutional neural network to map the target features, and determine the probability distribution of the defect type indicated by the target features; based on the defect type probability distribution, determine the defect type prediction result of the pipeline image.

[0086] The above-mentioned recognition module 500 is also used to train a preset convolutional neural network using a preset training sample set to construct an objective function corresponding to the convolutional neural network; the training sample set includes pipeline image samples of multiple defect types; based on the trained objective function, a pipeline image recognition model is constructed.

[0087] The above-mentioned identification module 500 is also used to obtain the prediction probability corresponding to each sample in the training sample set; based on the prediction probability, the cross entropy loss corresponding to each defect type is calculated to construct an initial objective function; the weight parameters in the initial objective function are optimized to minimize the initial objective function and determine the final objective function.

[0088] The above-mentioned identification module 500 is also used to calculate the average loss corresponding to the cross entropy loss corresponding to each defect type; introduce a regularization term into the average loss to construct an initial objective function corresponding to the training sample set.

[0089] An embodiment of the present invention further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the above Figures 1 to 3 The embodiment of the present invention also provides a computer-readable storage medium having a computer program stored thereon, and the computer program is executed by a processor to perform the above Figures 1 to 3 Any of the steps of the method shown.

[0090] The embodiment of the present invention also provides a schematic diagram of the structure of an electronic device, such as Figure 5 FIG. 5 is a schematic diagram of the structure of the electronic device, wherein the electronic device includes a processor 51 and a memory 50, the memory 50 stores computer executable instructions that can be executed by the processor 51, and the processor 51 executes the computer executable instructions to implement the above Figures 1 to 3 Any of the methods shown.

[0091] exist Figure 5In the illustrated embodiment, the electronic device further includes a bus 52 and a communication interface 53, wherein the processor 51, the communication interface 53 and the memory 50 are connected via the bus 52. The memory 50 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 53 (which may be wired or wireless), and the Internet, a wide area network, a local area network, a metropolitan area network, etc. may be used. The bus 52 may be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus, etc. It may also be an AMBA (Advanced Microcontroller Bus Architecture) bus, where AMBA defines three types of buses, including an APB (Advanced Peripheral Bus) bus, an AHB (Advanced High-performance Bus) bus, and an AXI (Advanced Xtensible Interface) bus. The bus 52 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0092] The processor 51 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 51. The above processor 51 can be a general processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to execute, or the hardware and software modules in the decoding processor are combined and executed. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor 51 reads the information in the memory and combines its hardware to complete the above Figures 1 to 3 Any of the methods shown.

[0093] A computer program product of an image recognition method and device for a focused pipe network system provided in an embodiment of the present invention includes a computer-readable storage medium storing a program code, and the instructions included in the program code can be used to execute the method described in the previous method embodiment. The specific implementation can refer to the method embodiment, which will not be repeated here. A person skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the system described above can refer to the corresponding process in the above method embodiment, which will not be repeated here. For those skilled in the art, the specific meaning of the above terms in the present invention can be understood in specific circumstances. If the function is implemented in the form of a software function unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk and other media that can store program code. In the description of the present invention, it should be noted that the terms "first", "second" and "third" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance.

[0094] Finally, it should be noted that the above embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above embodiments, those skilled in the art should understand that any person skilled in the art can still modify the technical solutions recorded in the above embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. An image recognition method focusing on a pipe network system, characterized in that: The method comprises: Acquire a pipeline image of a preset pipeline, draw a grayscale histogram of the pipeline image, and determine a grayscale value frequency distribution of the pipeline image; Performing image segmentation on the pipeline image according to the gray value frequency distribution to obtain a plurality of segmented sub-images of the pipeline image; Performing Gaussian filtering on each of the segmented sub-images of the pipeline image to obtain an enhanced image corresponding to each of the segmented sub-images; Using a pre-built pipeline image recognition model to recognize the enhanced image of the pipeline image, and output a defect type prediction result of the pipeline image; The pipeline defect of the pipeline image is determined based on the defect type prediction result.

2. The method according to claim 1, characterized in that The step of performing image segmentation on the pipeline image according to the gray value frequency distribution to obtain a plurality of segmented sub-images of the pipeline image comprises: According to the gray value frequency distribution, determine an image segmentation threshold of the pipeline image in a gray interval corresponding to the gray value frequency distribution; Based on the image segmentation threshold, the pipeline image is divided into regions to form a plurality of segmented sub-images of the pipeline image.

3. The method according to claim 2, characterized in that The step of dividing the pipeline image into regions based on the image segmentation threshold comprises: The pipeline image is segmented based on the preset maximum inter-class variance method according to the image segmentation threshold to obtain a plurality of segmented regions of the pipeline image.

4. The method according to claim 1, characterized in that The step of performing Gaussian filtering on each of the segmented sub-images of the pipeline image to obtain an enhanced image corresponding to each of the segmented sub-images comprises: Taking the center position of the segmented sub-image as the coordinate origin, sampling the segmented sub-image, and determining the position coordinates of a preset Gaussian filter in each segmented area of ​​the pipeline image; Determine the weight value of the segmented sub-image of the current segmented area based on the position coordinates, and calculate the Gaussian filter matrix corresponding to the pipeline image; The Gaussian filter matrix is ​​used to perform a convolution operation on each of the segmented sub-images to obtain an enhanced image corresponding to each of the segmented sub-images.

5. The method according to claim 4, characterized in that The step of calculating the Gaussian filter matrix corresponding to the pipeline image comprises: Arranging the weight values ​​of the segmented sub-images according to the segmented region positions of the pipeline image to obtain an initial Gaussian filter matrix; The initial Gaussian filter matrix is ​​normalized to generate a Gaussian filter matrix corresponding to the pipeline image.

6. The method according to claim 1, characterized in that The pipeline image recognition model is constructed based on a preset convolutional neural network; the steps of using the pre-constructed pipeline image recognition model to recognize the enhanced image of the pipeline image and outputting the defect type prediction result of the pipeline image include: Performing convolution calculation on the enhanced image through the convolutional neural network of the pipeline image recognition model, and outputting target features of the enhanced image; Mapping the target feature using the fully connected layer of the convolutional neural network to determine the probability distribution of the defect type indicated by the target feature; Based on the defect type probability distribution, a defect type prediction result of the pipeline image is determined.

7. The method according to claim 6, characterized in that The method further comprises: Using a preset training sample set to train a preset convolutional neural network, and constructing an objective function corresponding to the convolutional neural network; the training sample set includes pipeline image samples of multiple defect types; Based on the trained objective function, a pipeline image recognition model is constructed.

8. The method according to claim 7, characterized in that The method for constructing the objective function comprises: Obtain the prediction probability corresponding to each sample in the training sample set; Based on the predicted probability, the cross entropy loss corresponding to each defect type is calculated to construct an initial objective function; The weight parameters in the initial objective function are optimized to minimize the initial objective function and determine the final objective function.

9. The method according to claim 8, characterized in that The steps to construct the initial objective function include: Calculate the average loss corresponding to the cross entropy loss for each defect type; A regularization term is introduced into the average loss to construct an initial objective function corresponding to the training sample set.

10. An image recognition device focusing on a pipe network system, characterized in that: The device comprises: A data acquisition module, used to acquire a pipeline image of a preset pipeline and draw a grayscale histogram of the pipeline image; A calculation module, used for determining the gray value frequency distribution of the pipeline image based on the gray histogram; An execution module, configured to perform image segmentation on the pipeline image according to the gray value frequency distribution to obtain a plurality of segmented sub-images of the pipeline image; A data processing module, used for performing Gaussian filtering on each of the segmented sub-images of the pipeline image to obtain an enhanced image corresponding to each of the segmented sub-images; A recognition module, used to recognize the enhanced image of the pipeline image using a pre-built pipeline image recognition model, and output a defect type prediction result of the pipeline image; An output module is used to determine the pipeline defect of the pipeline image based on the defect type prediction result.

Citation Information

Patent Citations

  • Image recognition method and device, electronic equipment and storage medium

    CN114913463A

  • Numerical control machining surface defect positioning method and device

    CN116309510A

  • Board card defect identification method and system

    CN116309562A

  • On-satellite space target component center positioning and angle measuring method based on area detection

    CN116740332A

  • Pipeline defect detection and evaluation method and device based on deep learning

    CN117036255A