Oil pumping unit fault diagnosis method, system and equipment based on indicator diagram and medium
Through the improved ResNet 50 model and Redy Block module, the function diagram features are automatically extracted, which solves the problem of time-consuming and low accuracy of pumping engine fault diagnosis in the prior art, and achieves efficient and accurate identification of pumping engine faults.
Patent Information
- Application Number
- CN202510415960.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-03
- Publication Date
- 2025-07-04
AI Technical Summary
The existing technology relies on manual experience in the diagnosis of pump faults, which is time-consuming and has low accuracy. Machine learning methods require manual feature engineering, and the pre-trained model generalization ability is poor, making it difficult to quickly and accurately identify pump faults.
The image classification model ResNet 50 in deep learning is adopted. Through the fusion of inverse bottleneck structure and cross-scale features, combined with the Redy Block module, the power diagram features are automatically extracted, and the oil pump fault diagnosis model RedyNet is built to realize automatic feature extraction and high-accuracy diagnosis.
It significantly improves the accuracy and efficiency of oil pump fault diagnosis, reduces the calculation complexity, has good adaptability and scalability, and is adapted to fault diagnosis under complex working conditions.
Smart Images

Figure CN120259775A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of pumping unit fault diagnosis, and particularly relates to a pumping unit fault diagnosis method, system, device and medium based on a dynamometer card, which solves the problem of quickly determining the fault type when common faults occur in the pumping unit in oil production equipment. Background Technique
[0002] The pumping unit is an important mechanical equipment for oil extraction. It works in the underground environment for a long time and is easily affected by impurities such as sand, stone, wax, water and gas when pumping underground liquid, and is prone to failure.
[0003] In the early stage, the fault diagnosis of the pumping unit relied on the feeling of the technician's palm to analyze the state of the equipment. The technician contacted the polished rod of the pumping unit by hand and moved up and down with the polished rod to judge the type of equipment fault based on experience. With the increase of the modern oil well depth, this method has been eliminated. With the gradual deepening of the understanding of the pumping unit and the upgrading of oil production equipment, technicians collect data such as the load and displacement of the suspension point of the pumping unit through a dynamometer, draw a dynamometer card, and diagnose the pumping unit according to the characteristics of the shape of the dynamometer card. This method also relies on the professional knowledge and work experience of technicians and is very time-consuming.
[0004] The expert system has also been applied to the fault diagnosis of the pumping unit. The expert system consists of parts such as a user interface, a knowledge base, an inference engine and a database. By storing expert knowledge in the knowledge base and using the inference engine to simulate the thinking of experts, problems can be solved. The use of the expert system reduces the possibility of human error and provides the accuracy rate of fault diagnosis. However, it cannot make full use of the knowledge in the dynamometer card, has poor generalization ability, and weak recognition ability for unknown faults.
[0005] With the rapid development of artificial intelligence, methods such as machine learning and neural networks are applied to the fault diagnosis of pumping units. The dynamometer card reflects the variation of the suspension point load of the pumping unit with displacement. This graph is a closed curve, plotted with displacement within one stroke as the abscissa and load as the ordinate. Due to the complex conditions of pumping wells, the shapes of dynamometer cards are diverse, and the graphs contain rich information, including the working conditions of sucker rods and sucker pumps. By measuring the dynamometer card, it is possible to determine whether the equipment is affected by water, sand, and gas. The fault diagnosis of the pumping unit is transformed into a classification problem of dynamometer cards. The support vector machine method in machine learning (J. Liu, J. Feng and X. Gao, "Fault Diagnosis of Rod Pumping Wells Based on Support Vector Machine Optimized by Improved Chicken Swarm Optimization," in IEEE Access, vol. 7, pp. 171598 - 171608, 2019, doi: 10.1109 / ACCESS.2019.2956221.) is used for diagnosis. SVM uses a kernel function to map data into a high-dimensional space to find the optimal hyperplane for classification. For the problem of determining the SVM hyperparameters, the chicken swarm optimization algorithm is used to find the most suitable hyperparameters. Using the methods in machine learning requires high requirements for feature engineering. Before using machine learning methods, manual feature engineering is needed to extract meaningful image features (such as color histograms, edge features, etc.). This method does not have the ability of automatic feature extraction. Taking the support vector machine SVM as an example, the training process of SVM involves a quadratic programming problem, and the computational complexity of this problem is proportional to the square of the number of samples. For large-scale image datasets, the training time is long and the performance of SVM depends to a large extent on the selection of parameters, such as the penalty parameter and the parameters of the kernel function. However, there is no general method to determine the optimal kernel function, and finding the optimal parameter combination usually requires a large number of experiments and tuning, which is very time-consuming.
[0006] Alternatively, an existing pre-trained model can be used. Wu et al. (Wu, Y.; Feng, Z.; Liang, J.; Liu, Q.; Sun, D. Fault Diagnosis Algorithm of Beam Pumping Unit Based on Transfer Learning and DenseNet Model. Appl. Sci. 2022, 12, 11091. https: / / doi.org / 10.3390 / app122111091.) used an existing DenseNet classification model to solve the fault diagnosis task of the beam pumping unit. DenseNet was pre-trained on a large general image dataset such as ImageNet, and the capabilities of the model after training on other datasets were transferred to the dynamogram dataset to complete the fault diagnosis task. However, using existing open-source network models is not outstanding in terms of domain adaptability, and the accuracy cannot meet the requirements of industrial applications. Pre-trained models are usually trained on large general datasets, which are very different from the dynamogram dataset, and the model cannot generalize well to the fault diagnosis task of the beam pumping unit. Summary of the Invention
[0007] To overcome the deficiencies of the above-mentioned prior art, the purpose of the present invention is to provide a fault diagnosis method, system, device and medium for a beam pumping unit based on a dynamogram, which combines the image classification model ResNet 50 in deep learning and redesigns its structure, including reducing the number of downsamplings and modifying the stride in the image preprocessing module, modifying the linear bottleneck structure in the middle of the image classification model ResNet50 into an inverted bottleneck structure, and using a feature fusion method of concatenating the output of the middle network and the output of the deep structure. This not only solves the difficulty of manual feature engineering in machine learning but also makes full use of the multi-scale information of the existing dynamogram images, realizes the accurate diagnosis of the faults of the beam pumping unit, and has the advantages of high efficiency in automatically extracting features, high accuracy in diagnosing the faults of the beam pumping unit, and good adaptability to new tasks.
[0008] To achieve the above purpose, the technical solution adopted by the present invention is as follows:
[0009] A fault diagnosis method for a beam pumping unit based on a dynamogram, comprising the following steps:
[0010] Step 1, use a dynamometer to collect the operation data of the beam pumping unit during oil production. The operation data includes displacement and load. Collect data at a fixed time interval. The collected data is all the data in one stroke. Record all the data and export it as an excel file;
[0011] Step 2: Read the content in the excel file exported in Step 1, perform preliminary data cleaning and screening, and draw a dynamometer card at intervals of one stroke to obtain the original dynamometer card dataset;
[0012] Step 3: Augment the original dynamometer card dataset obtained in Step 2 using rotation, flipping, and mixcut methods to form a new dynamometer card dataset;
[0013] Step 4: Label and divide the new dynamometer card dataset obtained in Step 3 to get the dynamometer card training set, dynamometer card validation set, and dynamometer card test set;
[0014] Step 5: Build the pumping unit fault diagnosis model RedyNet;
[0015] Step 6: Use the dynamometer card training set divided in Step 4 to train the pumping unit fault diagnosis model RedyNet built in Step 5, and evaluate it on the dynamometer card validation set divided in Step 4 to obtain the optimal model for the pumping unit fault diagnosis task under multiple different hyperparameter schemes;
[0016] Step 7: Use the optimal model for the pumping unit fault diagnosis task obtained in Step 6 to evaluate the dynamometer card test set divided in Step 4 to obtain the evaluation indicators and results.
[0017] The specific method of Step 2 is as follows:
[0018] Step 2.1: Read the excel file exported in Step 1 to obtain all the data in the two columns of displacement and load;
[0019] Step 2.2: Clean all the data in the two columns of displacement and load in Step 2.1 to remove outliers and incomplete data;
[0020] Step 2.3: Take every 200 data points as one stroke, obtain the maximum and minimum values of displacement and the maximum and minimum values of load in the stroke, and perform normalization processing on all the data in the stroke:
[0021]
[0022] where x represents displacement and y represents load;
[0023] Step 2.4: Plot the dynamometer card with the data normalized in Step 2.3, using displacement as the abscissa and load as the ordinate.
[0024] The specific method of Step 3 is as follows:
[0025] Step 3.1: Augment the original dynamometer card dataset obtained in Step 2, perform rotation operations on all the images, and obtain the dynamometer card dataset A with the same number;
[0026] Step 3.2: Use the method of horizontal flipping by 180 degrees on the original dynamometer card dataset obtained in Step 2 to obtain the same number of dynamometer card datasets B.
[0027] Step 3.3: Use the mixcut method to augment the original dynamometer card dataset obtained in Step 2 to obtain the same number of dynamometer card datasets C. Combine the dynamometer card dataset C with the original dynamometer card dataset obtained in Step 2, the dynamometer card dataset A obtained in Step 3.1, and the dynamometer card dataset B obtained in Step 3.2 to obtain a new dynamometer card dataset.
[0028] The specific method of Step 4 is as follows:
[0029] Step 4.1: Label the new dynamometer card dataset obtained in Step 3 to obtain different working conditions, including normal working condition, insufficient liquid supply, gas influence, downhole pump hitting, fixed valve leakage, traveling valve leakage, sand production, and piston ejection.
[0030] Step 4.2: Divide the labeled new dynamometer card dataset into a dynamometer card training set, a dynamometer card validation set, and a dynamometer card test set.
[0031] The specific method of Step 5 is as follows:
[0032] Select the image classification model ResNet 50 as the basic classification model for the fault diagnosis task to construct the pumping unit fault diagnosis model RedyNet. The structure of the image classification model ResNet 50 sequentially includes an image preprocessing module, a residual structure in the middle part, and a final classification head.
[0033] Step 5.1: Modify the image preprocessing module of the image classification model ResNet 50. The modified image preprocessing module consists of a depth convolutional layer PRE Conv1, a batch normalization layer BN, a non-linear activation function ReLU, and a max pooling layer MaxPool layer, reducing the number of downsamplings.
[0034] The input of the image preprocessing module is a three-dimensional input feature matrix with a height H of 112, a width W of 112, and a channel number C of 3:
[0035] F1∈R C×H×W
[0036] After the dimensionality increase by the deep convolutional layer PRE Conv1, the number of channels of the input feature matrix F1 becomes 32, and at the same time, the size of the feature map is halved to half of the original. After processing the feature matrix F1 using the batch normalization layer BN, the non-linear activation function ReLU is used to enhance the generalization ability of the model; finally, through the max pooling layer MaxPool layer, the size of the feature map is further reduced to obtain the output feature matrix of the image preprocessing module:
[0037] F2 ∈ R C×H×W
[0038] where: H, W, and C are the height, width, and number of channels of the output feature map;
[0039] Step 5.2, modify the residual structure in the middle part, including modifying the linear bottleneck structure to an inverted bottleneck structure, and then perform a concat operation on the outputs of the shallow network and the deep network in the middle structure to obtain more features;
[0040] The modified network structure in the middle part consists of four Redy Blocks. The first Redy Block is stacked by three inverted bottleneck structures. The second Redy Block, the third Redy Block, and the fourth Redy Block have the same structure, each consisting of three inverted bottleneck structures and one max pooling layer; the inverted bottleneck structure consists of three deep convolutional layers Conv. The size of the convolutional kernel of the first deep convolutional layer Conv1 is 7x7, the stride is set to 2, the padding is set to 3, and the number of channels remains unchanged; the size of the convolutional kernel of the second deep convolutional layer Conv2 is 1x1, which is responsible for changing the number of output channels to 4 times that of the input; the size of the convolutional kernel of the third deep convolutional layer Conv3 is 1x1, which changes the number of output channels to 1 / 4 of the input; the output of the first Redy Block consists of the output of the image preprocessing module and the output of its own last inverted bottleneck structure. The outputs of the second Redy Block, the third Redy Block, and the fourth Redy Block consist of the output of the previous Redy Block and the output of its own last inverted bottleneck structure;
[0041] The output feature matrix F2 of the image after passing through the image preprocessing module will be temporarily saved. The feature matrix after being processed by the first RedyBlock is:
[0042] F3 ∈ R C×H×W
[0043] where the height and width of F2 and F3 are the same. Subsequently, F2 and F3 are concatenated to obtain F4,
[0044] F4 ∈ R 2C×H×W
[0045] Among them, F4 is the output feature matrix of the first Redy Block, the number of channels becomes twice that of the input, and both shallow and deep information are fused on the image information;
[0046] The second Redy Block, the third Redy Block, and the fourth Redy Block all receive the output feature map of the previous Redy Block. Inside the Redy Block, the maximum pooling layer is used to halve the size of the feature map to obtain the output Output1 of the current module, and in another branch, two inverted bottleneck structures are used to perform convolution operations on the feature map to obtain the output Output2. The output Output1 and the output Output2 are subjected to a concat fusion operation to obtain the output of the current Redy Block;
[0047] Step 5.3, modify the convolutional kernel and activation function of the classification head, change the 3x3 convolutional kernel to a 7x7 convolutional kernel, and add a ReLU activation function layer;
[0048] The modified classification head includes a depth convolutional layer Conv2, a batch normalization layer BN2, a non-linear activation function ReLU, a global average pooling layer AVG Pool, and a fully connected layer FC;
[0049] After passing through four consecutive Redy Blocks, the image is further processed by the deep network. The classification head uses the depth convolutional layer Conv2 to perform convolution operations on the output of the fourth Redy Block, and then uses the batch normalization layer BN2 and the non-linear activation function ReLU to perform normalization and non-linear activation on the output of the depth convolutional layer Conv2. Then, the global average pooling layer AVG Pool is used to reduce the dimension of the output feature map of the last Redy Block;
[0050]
[0051] Among them, H is the height of the feature map, W is the width of the feature map, and C is the number of channels;
[0052] After passing through the global average pooling layer AVG Pool, a feature vector z of length 2048 is obtained. This feature vector is input into the fully connected layer FC and transformed into an output of the number of categories K;
[0053] y = Wz + b
[0054] Among them, w is the weight matrix, and b is the bias term; finally, the softmax function is used to calculate the class probabilities:
[0055]
[0056] Among them, y k is the score of category k, and p k is the probability of category k. The output result of the final pumping unit fault diagnosis model RedyNet is the index corresponding to the maximum probability.
[0057] The specific method of step 6 is as follows:
[0058] Step 6.1: Train on the dynamometer card training set divided in step 4 using convolution kernels of different sizes respectively, and compare the performance of the pumping unit fault diagnosis model RedyNet under different convolution kernel sizes on the dynamometer card validation set divided in step 4, and select the convolution kernel size that can obtain the highest accuracy rate.
[0059] Step 6.2: Compare the original residual structure of the image classification model ResNet 50 and the inverse bottleneck structure used to replace the original residual structure of the image classification model ResNet 50; that is, use the dynamometer card training set and dynamometer card validation set divided in step 4 to train and validate the image classification model ResNet 50 based on the original residual structure, and record its diagnostic accuracy rate and computational complexity; replace the original residual structure with the inverse bottleneck structure, and keep the rest of the structure unchanged to obtain the image classification model ResNet 50 based on the inverse bottleneck structure, and use the dynamometer card training set and dynamometer card validation set divided in step 4 to train and validate it, and record the corresponding diagnostic accuracy rate and complexity; it is obtained that the diagnostic accuracy rate of the image classification model ResNet50 based on the original residual structure on the dynamometer card validation set is lower than that of the image classification model ResNet 50 based on the inverse bottleneck structure on the dynamometer card validation set, and the computational complexity of the image classification model ResNet 50 based on the original residual structure on the dynamometer card validation set is higher than that of the image classification model ResNet 50 based on the inverse bottleneck structure on the dynamometer card validation set.
[0060] Step 6.3: Compare not using the concat operation and using the concat operation in the Redy Block module; that is, use the Redy Block module without the concat operation to train and validate the dynamometer card training set and dynamometer card validation set divided in step 4, and record its diagnostic accuracy rate; then, under the same conditions, use the RedyBlock module containing the concat operation to train and validate the dynamometer card training set and dynamometer card validation set divided in step 4, and record its diagnostic accuracy rate; it is obtained that the diagnostic accuracy rate of the Redy Block module without the concat operation on the dynamometer card validation set is lower than that of the Redy Block module containing the concat operation on the dynamometer card validation set; finally, obtain the optimal network structure using the concat operation.
[0061] Step 6.4, after determining the optimal network structure, use the indicator diagram training set and the indicator diagram validation set divided in Step 4 to finally evaluate the pumping unit fault diagnosis model RedyNet, and further optimize some hyperparameters to obtain the optimal model for the pumping unit fault diagnosis task.
[0062] The specific method of Step 7 is as follows:
[0063] Step 7.1, predict the working condition type. Input the indicator diagram to be recognized in the indicator diagram test set divided in Step 4 into the optimal model for the pumping unit fault diagnosis task trained in Step 6. The optimal model for the pumping unit fault diagnosis task outputs an 8-dimensional vector, representing the prediction distribution of the image under different working condition types:
[0064] P = [P0, P1, P2, P3, P4, P5, P6, P7]
[0065] where P i represents the predicted probability that the image belongs to the i-th working condition;
[0066] Step 7.2, working condition category mapping. By finding the index i corresponding to the maximum probability value in P and querying the working condition index table, the final working condition determination result can be obtained;
[0067] Step 7.3, prediction of the indicator diagram test set and accuracy rate statistics. Input all the indicator diagram images in the indicator diagram test set into the optimal model for the pumping unit fault diagnosis task, record the working condition type corresponding to the maximum probability output by each image, and perform statistics on the prediction results of the indicator diagram validation set. The formula used is:
[0068]
[0069] where TP represents the number of samples with a positive prediction result and a positive true label, TN represents the number of samples with a negative prediction result and a negative true label, FP represents the number of samples with a positive prediction result but a negative true label, and FN represents the number of samples with a negative prediction result but a positive true label.
[0070] The present invention also provides a pumping unit fault diagnosis system based on an indicator diagram, including:
[0071] An excel file export module, which is used to collect the operation data of the pumping unit during oil production using an indicator instrument. The operation data includes displacement and load. Data is collected at fixed time intervals, and all the collected data is the data in one stroke. Record all the data and export it as an excel file;
[0072] The original indicator diagram dataset acquisition module is used to read the content in the excel file, perform preliminary data cleaning and screening, and draw indicator diagrams at intervals of one stroke to obtain the original indicator diagram dataset;
[0073] The new indicator diagram dataset formation module is used to expand the original indicator diagram dataset by means of rotation, flipping, and mixcut respectively to form a new indicator diagram dataset;
[0074] The new indicator diagram dataset division module is used to label and divide the new indicator diagram dataset to obtain an indicator diagram training set, an indicator diagram validation set, and an indicator diagram test set;
[0075] The pumping unit fault diagnosis model RedyNet construction module is used to construct the pumping unit fault diagnosis model RedyNet;
[0076] The pumping unit fault diagnosis model RedyNet training module is used to train the pumping unit fault diagnosis model RedyNet with the indicator diagram training set and evaluate it on the indicator diagram validation set to obtain the optimal model for the pumping unit fault diagnosis task under multiple different hyperparameter schemes;
[0077] The pumping unit fault diagnosis model RedyNet evaluation module is used to evaluate the indicator diagram test set with the optimal model for the pumping unit fault diagnosis task to obtain evaluation indicators and results.
[0078] The present invention also provides a pumping unit fault diagnosis device based on an indicator diagram, including:
[0079] A memory: storing a computer program for the above-mentioned pumping unit fault diagnosis method based on an indicator diagram, which is a computer-readable device;
[0080] A processor: used to implement the above-mentioned pumping unit fault diagnosis method based on an indicator diagram when executing the computer program.
[0081] The present invention also provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, it can implement the above-mentioned pumping unit fault diagnosis method based on an indicator diagram.
[0082] Compared with the prior art, the beneficial effects of the present invention are:
[0083] 1. By introducing an inverse bottleneck structure into the pumping unit fault diagnosis model RedyNet and optimizing the feature extraction process in combination with the maximum pooling layer, the present invention effectively reduces the computational complexity and time cost of model training, significantly improves the diagnosis efficiency compared with the traditional support vector machine method, and at the same time maintains high accuracy.
[0084] 2. The present invention designs and constructs the Redy Block module, which flexibly adjusts the network depth through modular stacking, can quickly adapt to different types of oil pump fault diagnosis tasks, has strong scalability and practicality, and provides an efficient solution for fault diagnosis under complex working conditions.
[0085] 3. The present invention uses a fusion method through cross-scale features to concat the output of the shallow network with the output of the deep network, making full use of the multi-scale information of the indicator diagram, enhancing the model's ability to characterize complex working conditions, thereby significantly improving the generalization ability and diagnostic accuracy of unknown fault types.
[0086] In summary, the present invention transforms the fault diagnosis problem into an image classification problem and designs an optimized pumping unit fault diagnosis model RedyNet, introduces an inverse bottleneck structure and cross-scale feature fusion technology, which has the advantages of high diagnostic accuracy, low computational complexity and strong adaptability to new fault types. BRIEF DESCRIPTION OF THE DRAWINGS
[0087] Figure 1 It is the overall flow chart of fault diagnosis of the present invention.
[0088] Figure 2 : is a schematic diagram comparing the reverse bottleneck structure and the linear bottleneck structure of the present invention; wherein, Figure 2 (a) is a linear bottleneck structure, Figure 2 (b) is the reverse bottleneck structure.
[0089] Figure 3 It is a structural diagram of the pumping unit fault diagnosis model RedyNet of the present invention.
[0090] Figure 4 is a typical working condition indicator diagram; among them, Figure 4 (a) shows the indicator diagram under normal working conditions. Figure 4 (b) The corresponding indicator diagram under the condition of insufficient fluid supply, Figure 4 (c) is the indicator diagram under gas-affected working conditions. Figure 4 (d) shows the indicator diagram under the working condition of the down-impact pump. Figure 4 (e) is the indicator diagram under the condition of fixed valve leakage. Figure 4 (f) is the indicator diagram under the condition of the floating valve leakage. Figure 4 (g) is the indicator diagram under sand production conditions. Figure 4 (h) is the indicator diagram under the piston disengagement condition.
[0091] Figure 5 This is a comparison chart of the accuracy of the pumping unit fault diagnosis model RedyNet. DETAILED DESCRIPTION
[0092] The technical solution of the invention will be described in detail below with reference to the accompanying drawings.
[0093] The overall flowchart of the fault diagnosis of the present invention is as Figure 1 shown. A fault diagnosis method for a pumping unit based on a dynamometer card includes the following steps:
[0094] Step 1: Use a dynamometer to collect the operation data of the pumping unit during oil production. The operation data includes displacement and load. Collect data at a fixed time interval. The collected data is all the data in one stroke. Record all the data and export it as an excel file;
[0095] The specific method of Step 1 is as follows:
[0096] Step 1.1: Use a dynamometer to collect the displacement and load data of the pumping unit during operation, and collect data at an interval of five minutes;
[0097] Step 1.2: Collect all the displacement and load data obtained in Step 1.1, and continuously record all the operation data;
[0098] Step 1.3: Export all the operation data recorded in Step 1.2 to an excel file.
[0099] Step 2: Read the content of the excel file exported in Step 1, perform preliminary data cleaning and screening, and draw a dynamometer card at intervals of one stroke to obtain an original dynamometer card dataset;
[0100] The specific method of Step 2 is as follows:
[0101] Step 2.1: Use the third-party library pandas of the python language to read the excel file exported in Step 1 to obtain all the data in the two columns of displacement and load;
[0102] Step 2.2: Clean all the data in the two columns of displacement and load in Step 2.1 to remove outliers and incomplete data;
[0103] Step 2.3: Take every 200 data points as one stroke to obtain the maximum and minimum values of displacement and the maximum and minimum values of load in the stroke, and perform normalization processing on all the data in the stroke:
[0104]
[0105] where x represents displacement and y represents load;
[0106] Step 2.4: Use the third-party library matplotlib to draw a dynamometer card for the data normalized in Step 2.3, with displacement as the abscissa and load as the ordinate, and set the size of the dynamometer card to 112*112.
[0107] Step 3: Augment the original dynamometer card dataset obtained in Step 2 by using rotation, flipping, and mixcut methods respectively to form a new dynamometer card dataset;
[0108] The specific method of Step 3 is as follows:
[0109] Step 3.1: Augment the original dynamometer card dataset obtained in Step 2. Rotate all images 45 degrees to the right to obtain a dynamometer card dataset A with the same number of images;
[0110] Step 3.2: Use the method of horizontal flipping by 180 degrees for the original dynamometer card dataset obtained in Step 2 to obtain a dynamometer card dataset B with the same number of images;
[0111] Step 3.3: Augment the original dynamometer card dataset obtained in Step 2 by using the mixcut method to obtain a dynamometer card dataset C with the same number of images. Merge the dynamometer card dataset C with the original dynamometer card dataset obtained in Step 2, the dynamometer card dataset A obtained in Step 3.1, and the dynamometer card dataset B obtained in Step 3.2 to obtain a new dynamometer card dataset.
[0112] Step 4: Label and divide the new dynamometer card dataset obtained in Step 3 to obtain a dynamometer card training set, a dynamometer card validation set, and a dynamometer card test set;
[0113] The specific method of Step 4 is as follows:
[0114] Step 4.1: Label the new dynamometer card dataset obtained in Step 3 to obtain 8 different working condition types, including normal working condition, insufficient liquid supply, gas influence, downhole pump hitting, fixed valve leakage, traveling valve leakage, sand production, and piston ejection; the labeling for each working condition is as follows:
[0115]
[0116] Step 4.2: Divide the labeled new dynamometer card dataset into a dynamometer card training set, a dynamometer card validation set, and a dynamometer card test set according to the ratio of 7:2:1.
[0117] Step 5: As Figure 3 shown, construct a pumping unit fault diagnosis model RedyNet;
[0118] The specific method of Step 5 is as follows:
[0119] Select the image classification model ResNet 50 as the basic classification model for the fault diagnosis task to construct the pumping unit fault diagnosis model RedyNet of the present invention; the structure of the image classification model ResNet 50 sequentially includes an image preprocessing module, a residual structure in the middle part, and a final classification head.
[0120] Step 5.1: Modify the image preprocessing module of the image classification model ResNet 50 to conform to the characteristics and size of the indicator diagram. The modified image preprocessing module consists of a depth convolution layer PRE Conv1, a batch normalization layer BN, a non-linear activation function ReLU, and a max pooling layer MaxPool. The stride of the max pooling layer MaxPool is set to 2 to reduce the number of downsamplings and thus retain more detailed information of the feature map.
[0121] The input of the image preprocessing module is a three-dimensional input feature matrix with a height H of 112, a width W of 112, and a channel number C of 3:
[0122] F1∈R C×H×W
[0123] After the dimensionality increase by the depth convolution layer PRE Conv1, the channel number of the input feature matrix F1 becomes 32, and at the same time, the size of the feature map is halved to become half of the original. After processing the feature matrix F1 using the batch normalization layer BN, the non-linear activation function ReLU is used to enhance the generalization ability of the model; finally, after passing through the max pooling layer MaxPool, the size of the feature map is halved to obtain the output feature matrix of the image preprocessing module:
[0124] F2∈R C×H×W
[0125] where: H, W, and C are the height, width, and channel number of the output feature map;
[0126] Step 5.2: Modify the residual structure in the middle part, including modifying the linear bottleneck structure (as shown in Figure 2 (a)) to an inverted bottleneck structure (as shown in Figure 2 (b)), and then performing a concat operation on the outputs of the shallow network and the deep network in the middle structure to obtain more features.
[0127] The modified network structure in the middle part consists of four Redy Blocks, and the number of Blocks can be adjusted to adapt to different dataset types or fault diagnosis tasks.
[0128] The first Redy Block is stacked by three inverted bottleneck structures. The second, third, and fourth Redy Blocks have the same structure, each consisting of three inverted bottleneck structures and a max pooling layer. The inverted bottleneck structure is composed of three depthwise convolutional layers Conv. The first depthwise convolutional layer Conv1 has a kernel size of 7x7, a stride of 2, a padding of 3, and the number of channels remains unchanged. The second depthwise convolutional layer Conv2 has a kernel size of 1x1 and is responsible for changing the number of output channels to 4 times that of the input. The third depthwise convolutional layer Conv3 has a kernel size of 1x1 and changes the number of output channels to 1 / 4 of the input. The output of the first Redy Block consists of the output of the image preprocessing module and the output of its last inverted bottleneck structure. The outputs of the second, third, and fourth Redy Blocks consist of the output of the previous Redy Block and the output of its last inverted bottleneck structure.
[0129] The output feature matrix F2 of the image after passing through the image preprocessing module will be temporarily saved. The feature matrix after being processed by the first RedyBlock is:
[0130] F3 ∈ R C×H×W
[0131] Among them, the height and width of F2 and F3 are the same, providing a basis for the concat operation. Subsequently, F2 and F3 are subjected to the concat operation to obtain F4.
[0132] F4 ∈ R 2C×H×W
[0133] Among them, F4 is the output feature matrix of the first Redy Block, the number of channels becomes twice that of the input, and the image information integrates both shallow and deep information.
[0134] The second, third, and fourth Redy Blocks all receive the output feature map of the previous RedyBlock. Inside the Redy Block, the max pooling layer is used to halve the size of the feature map to obtain the output Output1 of the current module. And in another branch, two inverted bottleneck structures are used to perform convolutional operations on the feature map to obtain the output Output2. The output Output1 and the output Output2 are subjected to the concat fusion operation to obtain the output of the current Redy Block.
[0135] Step 5.3, modify the convolutional kernel and activation function of the classification head, change the 3x3 convolutional kernel to a 7x7 convolutional kernel, and add a ReLU activation function layer.
[0136] The modified classification head part includes a depth convolution layer Conv2, a batch normalization layer BN2, a non-linear activation function ReLU, a global average pooling layer AVG Pool, and a fully connected layer FC.
[0137] After four consecutive Redy Blocks, the image is further processed by a deep network. The classification head uses the depth convolution layer Conv2 to perform a convolution operation on the output of the fourth Redy Block, and then uses the batch normalization layer BN2 and the non-linear activation function ReLU to normalize and non-linearly activate the output of the depth convolution layer Conv2. Then, the global average pooling layer AVG Pool is used to reduce the dimension of the output feature map of the last Redy Block;
[0138]
[0139] Where H is the height of the feature map, W is the width of the feature map, and C is the number of channels.
[0140] After passing through the global average pooling layer AVG Pool, a feature vector z of length 2048 is obtained. This feature vector is input into the fully connected layer FC and transformed into an output of the number of categories K;
[0141] y = Wz + b
[0142] Where w is the weight matrix and b is the bias term; finally, the normalized exponential function softmax is used to calculate the category probability:
[0143]
[0144] Where y k is the score of category k, and p k is the probability of category k. The final output of the pumping unit fault diagnosis model RedyNet is the index corresponding to the maximum probability.
[0145] Step 6: Use the dynamometer card training set divided in Step 4 to train the pumping unit fault diagnosis model RedyNet constructed in Step 5, and evaluate it on the dynamometer card validation set divided in Step 4 to obtain the optimal model for the pumping unit fault diagnosis task under multiple different hyperparameter schemes.
[0146] The specific method of the said Step 6 is:
[0147] Step 6.1, train on the indicator diagram training set divided in Step 4 using convolution kernels of different sizes respectively, and compare the performance of the pumping unit fault diagnosis model RedyNet with convolution kernel sizes of 3x3, 5x5, 7x7, 9x9, and 11x11 on the indicator diagram validation set divided in Step 4. Select the convolution kernel size of 7x7 that can obtain the highest accuracy. This size achieves the best balance between feature extraction ability and computational cost. The training parameters are set as follows: the number of iterations is 300 Epochs, the initial learning rate is 0.001 (cosine annealing scheduling), the optimizer is SGD, the momentum is set to 0.9, the weight decay is set to 1e-4, the batch size is 64, and the loss function is the cross-entropy loss function;
[0148] Step 6.2, compare the original residual structure of the image classification model ResNet 50 and the original residual structure of the image classification model ResNet 50 replaced by the inverted bottleneck structure; that is, use the indicator diagram training set and indicator diagram validation set divided in Step 4 to train and validate the image classification model ResNet 50 based on the original residual structure, and record its diagnostic accuracy rate and computational complexity; replace the original residual structure with the inverted bottleneck structure, and keep the rest of the structure unchanged to obtain the image classification model ResNet 50 based on the inverted bottleneck structure. Use the indicator diagram training set and indicator diagram validation set divided in Step 4 to train and validate it, and record the corresponding diagnostic accuracy rate and complexity; it is obtained that the diagnostic accuracy rate of the image classification model ResNet50 based on the original residual structure on the indicator diagram validation set is lower than that of the image classification model ResNet 50 based on the inverted bottleneck structure on the indicator diagram validation set, and the computational complexity of the image classification model ResNet 50 based on the original residual structure on the indicator diagram validation set is higher than that of the image classification model ResNet 50 based on the inverted bottleneck structure on the indicator diagram validation set; finally, select the image classification model ResNet 50 based on the inverted bottleneck structure;
[0149] Step 6.3: Compare the use of the concat operation and the non - use of the concat operation in the Redy Block module. That is, use the Redy Block module without the concat operation to train and validate the indicator diagram training set and the indicator diagram validation set divided in Step 4, and record its diagnostic accuracy rate. Then, under the same conditions, use the Redy Block module with the concat operation to train and validate the indicator diagram training set and the indicator diagram validation set divided in Step 4, and record its diagnostic accuracy rate. It is obtained that the diagnostic accuracy rate of the Redy Block module without the concat operation on the indicator diagram validation set is lower than that of the Redy Block module with the concat operation on the indicator diagram validation set. Finally, the optimal network structure with the concat operation is obtained. The use of the concat operation improves the feature expression ability of the network.
[0150] Step 6.4: After determining the optimal network structure, use the indicator diagram training set and the indicator diagram validation set divided in Step 3 to finally evaluate the pumping unit fault diagnosis model RedyNet, and further optimize some hyperparameters to obtain the optimal model for the pumping unit fault diagnosis task. The number of training rounds is 300. The learning rate warm - up strategy is adopted. The learning rate is gradually increased in the first 50 Epochs and dynamically adjusted in combination with cosine annealing. Mixed - precision training is used to accelerate the model convergence.
[0151] Step 7: Use the optimal model for the pumping unit fault diagnosis task obtained in Step 6 to evaluate the indicator diagram test set divided in Step 4, and obtain the evaluation indicators and results.
[0152] The specific method of Step 7 is as follows:
[0153] Step 7.1: Predict the working condition type. Input the indicator diagram to be recognized in the indicator diagram test set divided in Step 4 into the optimal model for the pumping unit fault diagnosis task trained in Step 6. The optimal model for the pumping unit fault diagnosis task outputs an 8 - dimensional vector, representing the prediction distribution of the image under 8 different working condition types:
[0154] P = [P0, P1, P2, P3, P4, P5, P6, P7]
[0155] where P i represents the predicted probability that the image belongs to the i - th working condition;
[0156] Step 7.2: Working condition category mapping. By finding the index i corresponding to the maximum probability value in P and querying the working condition index table, the final working condition determination result can be obtained. The working condition index table is as follows:
[0157] Index (i) Operating condition type 0 Normal operating condition 1 Insufficient liquid supply 2 Gas influence 3 Lower hitting the pump 4 Fixed valve leakage 5 Traveling valve leakage 6 Sand production 7 Piston disengagement
[0158] If the index position corresponding to the maximum value is 0, the working condition type is determined to be normal; if the index position is 1, the working condition type is determined to be insufficient fluid supply; and so on. Figure 4 As shown, 8 typical working condition indicator diagrams for the pumping unit fault diagnosis of the present invention are shown. Among them, Figure 4 (a) shows the indicator diagram under normal working conditions. Figure 4 (b) The corresponding indicator diagram under the condition of insufficient fluid supply, Figure 4 (c) is the indicator diagram under gas-affected working conditions. Figure 4 (d) shows the indicator diagram under the working condition of the down-impact pump. Figure 4 (e) is the indicator diagram under the condition of fixed valve leakage. Figure 4 (f) is the indicator diagram under the condition of the floating valve leakage. Figure 4 (g) is the indicator diagram under sand production conditions. Figure 4 (h) is the indicator diagram under the piston disengagement condition.
[0159] Step 7.3, prediction and accuracy statistics of the dynamometer test set, input all the dynamometer images in the dynamometer test set into the optimal model of the pumping unit fault diagnosis task, record the working condition type corresponding to the maximum probability output of each image, and perform statistics on the prediction results of the dynamometer verification set, using the formula:
[0160]
[0161] Among them, TP represents the number of samples whose predicted results are positive and whose true labels are also positive, TN represents the number of samples whose predicted results are negative and whose true labels are also negative, FP represents the number of samples whose predicted results are positive but whose true labels are negative, and FN represents the number of samples whose predicted results are negative but whose true labels are positive. The accuracy of the optimal model RedyNet for the pumping unit fault diagnosis task in step 6 on the dynamometer test set is as follows: Figure 5 As shown in the figure, it can be concluded that the accuracy of the pumping unit fault diagnosis model RedyNet of the present invention reaches 98.8%, which is 6.1% and 7.6% higher than the image classification model ResNet50 (92.7%) and the image classification model DenseNet121 (91.2%), respectively, indicating that it has significant advantages in the classification of indicator diagrams.
[0162] Experimental analysis
[0163] Simulation conditions
[0164] In order to verify the effectiveness of the pumping unit fault diagnosis method based on the dynamometer diagram proposed in this invention, the following simulation experiment environment was built:
[0165] The hardware environment includes a central processing unit Intel i5-12400, a graphics processing unit NVIDIA Tesla P40, 24GB of video memory, 32GB of memory, and a 1TB solid-state drive as the storage device.
[0166] The software environment includes the operating system Ubuntu 20.04LTS, the deep learning framework PyTorch 1.12.1, the integrated development environment PyCharm2023.2, and the programming language Python3.12.
[0167] Simulation content
[0168] The simulation experiment specifically includes the following steps:
[0169] 1. Data preparation and preprocessing: Collect the operation data of the pumping unit, generate an excel file containing displacement and load, draw a dynamometer card, and obtain the original dynamometer card dataset; perform data augmentation through rotation, horizontal flipping, and mixcut methods to form a new dynamometer card dataset; label the new dynamometer card dataset, divide it into 8 working condition types, and divide it into a dynamometer card training set, a dynamometer card validation set, and a dynamometer card test set.
[0170] 2. Construction of the pumping unit fault diagnosis model RedyNet: Based on the improvement of the image classification model ResNet50, specifically including reducing the downsampling times of the image preprocessing module, replacing the residual structure in the middle part with 4 Redy Block modules, changing the convolution kernel of the classification head module to 7x7 and adding a ReLU activation function.
[0171] 3. Training the pumping unit fault diagnosis model RedyNet: Set the training parameters: the number of iterations is 300 epochs, the initial learning rate is 0.001, use cosine annealing scheduling, the optimizer is SGD, the momentum is 0.9, the weight decay is 1e-4, the batch size is 64, and the loss function is the cross-entropy loss function; adopt the learning rate warm-up strategy and use mixed-precision training to accelerate convergence; evaluate the performance on the validation set and save the model parameters with the highest accuracy; train the image classification model ResNet50 and the image classification model DenseNet121 with the same training parameters to ensure a fair comparison.
[0172] 4. Testing: Use the dynamometer card test set to perform inference on the trained pumping unit fault diagnosis model RedyNet, the image classification model ResNet50, and the image classification model DenseNet121, output the predicted probability of the fault type of each image, and record the working condition category corresponding to the maximum probability.
[0173] Simulation results
[0174] The performance of the pumping unit fault diagnosis model RedyNet, the image classification model ResNet50, and the image classification model DenseNet121 in the pumping unit fault diagnosis task was evaluated through a dynamometer card test set, and the accuracy rate was used as the evaluation index. The results are as Figure 5 shown.
[0175] The accuracy rate of the pumping unit fault diagnosis model RedyNet of the present invention reaches 98.8%, which is 6.1% and 7.6% higher than that of the image classification model ResNet50 (92.7%) and the image classification model DenseNet121 (91.2%) respectively, indicating that it has significant advantages in dynamometer card classification.
[0176] The key points and protected points of the present invention are:
[0177] 1. Innovative design of inverse bottleneck structure and cross-scale feature fusion: The present invention introduces an inverse bottleneck structure in the deep learning image classification model ResNet 50 to replace the traditional linear bottleneck structure, and realizes cross-scale fusion of shallow and deep features through the concat operation. This is the core innovation to solve the problems of insufficient feature extraction ability and poor generalization ability in the prior art.
[0178] 2. The pumping unit fault diagnosis model RedyNet optimized for the characteristics of dynamometer cards: By reducing the downsampling times of the image preprocessing module, adjusting the stride, and optimizing the classification head structure, the model is more suitable for the image characteristics of dynamometer cards.
[0179] 3. Modular design of the Redy Block module: The modular design of the Redy Block module proposed by the present invention realizes flexible adjustment of network depth through stacking inverse bottleneck structures and max pooling layers to adapt to different fault diagnosis tasks.
[0180] The application prospect of the present invention:
[0181] The pumping unit of oil extraction equipment operates in a harsh environment for a long time. The present invention can diagnose the types of equipment faults in time, reduce the positioning time, optimize the maintenance plan through accurate fault positioning, avoid premature or late maintenance, and reduce the operation cost. Timely fault diagnosis can effectively prevent safety accidents caused by equipment faults, thereby protecting the safety of workers, reducing the accident rate, and ensuring the safety of the production environment.
[0182] The present invention also provides a pumping unit fault diagnosis system based on dynamometer cards, including:
[0183] An Excel file export module, which is used to implement the operation data collection of the pumping unit during oil production using a dynamometer in step 1. The operation data includes displacement and load. Data is collected at fixed time intervals, and the collected data is all the data in one stroke. All the data is recorded and exported as an Excel file;
[0184] An original dynamogram data set acquisition module, which is used to implement reading the content of the Excel file exported in step 1 in step 2, performing preliminary data cleaning and screening, and plotting dynamograms at intervals of one stroke to obtain an original dynamogram data set;
[0185] A new dynamogram data set formation module, which is used to implement expanding the original dynamogram data set obtained in step 2 using means such as rotation, flipping, and mixcut in step 3 to form a new dynamogram data set;
[0186] A new dynamogram data set division module, which is used to implement annotating and dividing the new dynamogram data set obtained in step 3 in step 4 to obtain a dynamogram training set, a dynamogram validation set, and a dynamogram test set;
[0187] A pumping unit fault diagnosis model RedyNet construction module, which is used to implement constructing the pumping unit fault diagnosis model RedyNet in step 5;
[0188] A pumping unit fault diagnosis model RedyNet training module, which is used to implement training the pumping unit fault diagnosis model RedyNet constructed in step 5 using the dynamogram training set divided in step 4 in step 6, and evaluating on the dynamogram validation set divided in step 4 to obtain the optimal model for the pumping unit fault diagnosis task under multiple different hyperparameter schemes;
[0189] A pumping unit fault diagnosis model RedyNet evaluation module, which is used to implement evaluating the dynamogram test set divided in step 4 using the optimal model for the pumping unit fault diagnosis task obtained in step 6 to obtain evaluation indicators and results.
[0190] The present invention also provides a pumping unit fault diagnosis device based on dynamograms, including:
[0191] A memory: storing a computer program for the above-mentioned pumping unit fault diagnosis method based on dynamograms, which is a computer-readable device;
[0192] A processor: used to implement the above-mentioned pumping unit fault diagnosis method based on dynamograms when executing the computer program.
[0193] The present invention also provides a computer-readable storage medium storing a computer program, which can implement the described pumping unit fault diagnosis method based on the dynamometer card when executed by a processor.
Claims
1. A fault diagnosis method for a pumping unit based on a dynamometer card, characterized in that The following steps are involved: Step 1: Use a dynamometer to collect the operating data of the pumping unit during oil production. The operating data includes displacement and load. The data is collected at fixed time intervals. The collected data is all the data in one stroke. All the data is recorded and exported as an Excel file. Step 2, read the content in the Excel file exported in step 1, perform preliminary data cleaning and screening, draw a dynamometer diagram according to one stroke interval, and obtain the original dynamometer diagram data set; Step 3, the original dynamometer data set obtained in step 2 is expanded by means of rotation, flipping, and mixcut to form a new dynamometer data set; Step 4, annotating and dividing the new dynamometer data set obtained in step 3 to obtain a dynamometer training set, a dynamometer verification set, and a dynamometer test set; Step 5, construct the pumping unit fault diagnosis model RedyNet; Step 6, using the dynamometer diagram training set divided in step 4 to train the pumping unit fault diagnosis model RedyNet constructed in step 5, and evaluating it on the dynamometer diagram verification set divided in step 4 to obtain the optimal model for the pumping unit fault diagnosis task under multiple groups of different hyperparameter schemes; Step 7, using the optimal model for the pumping unit fault diagnosis task obtained in step 6, evaluate the dynamometer test set divided in step 4 to obtain evaluation indicators and results.
2. The fault diagnosis method of a pumping unit based on an indicator diagram according to claim 1, wherein The specific method of step 2 is: Step 2.1, read the Excel file exported in step 1 and obtain all the data in the displacement and load columns; Step 2.2, clean all the data in the displacement and load columns of step 2.1 to remove outliers and incomplete data; Step 2.3, every 200 data points is a stroke, get the maximum and minimum displacement, the maximum and minimum load in the stroke, and normalize all the data in the stroke: Where x represents displacement and y represents load; Step 2.4, draw an indicator diagram using the normalized data from step 2.3, with displacement as the horizontal axis and load as the vertical axis.
3. The method for diagnosing faults of a pumping unit based on an indicator diagram according to claim 1, characterized in that, The specific method of step 3 is: Step 3.1, expanding the original dynamometer data set obtained in step 2, rotating all images, and obtaining the same number of dynamometer data sets A; Step 3.2, horizontally flip the original dynamometer data set obtained in step 2 by 180 degrees to obtain a dynamometer data set B of the same number; Step 3.3, use the mixcut method to expand the original dynamometer data set obtained in step 2 to obtain the same number of dynamometer data sets C, and merge the dynamometer data set C with the original dynamometer data set obtained in step 2, the dynamometer data set A obtained in step 3.1, and the dynamometer data set B obtained in step 3.2 to obtain a new dynamometer data set.
4. A fault diagnosis method for a pumping unit based on an indicator diagram according to claim 1, characterized in that, The specific method of step 4 is: Step 4.1, annotating the new dynamometer data set obtained in step 3 to obtain different operating condition types, including normal operating condition, insufficient liquid supply, gas influence, pump impact, fixed valve leakage, floating valve leakage, sand production and piston disengagement; Step 4.2: Divide the new labeled indicator diagram dataset into an indicator diagram training set, an indicator diagram validation set, and an indicator diagram test set.
5. A fault diagnosis method for a pumping unit based on an indicator diagram according to claim 1, characterized in that, The specific method of Step 5 is as follows: Select the image classification model ResNet 50 as the basic classification model for the fault diagnosis task to construct the pumping unit fault diagnosis model RedyNet. The structure of the image classification model ResNet 50 sequentially includes an image preprocessing module, a residual structure in the middle part, and a final classification head. Step 5.1: Modify the image preprocessing module of the image classification model ResNet 50. The modified image preprocessing module consists of a depth convolution layer PRE Conv1, a batch normalization layer BN, a non-linear activation function ReLU, and a max pooling layer MaxPool layer, reducing the number of downsamplings. The input of the image preprocessing module is a three-dimensional input feature matrix with a height H of 112, a width W of 112, and a channel number C of 3. F1 belongs to R C×H×W After the dimensionality increase by the depth convolution layer PRE Conv1, the channel number of the input feature matrix F1 becomes 32, and at the same time, the feature map size is halved to half of the original. After processing the feature matrix F1 using the batch normalization layer BN, the non-linear activation function ReLU is used to enhance the generalization ability of the model. Finally, after passing through the max pooling layer MaxPool layer, the feature map size is further reduced to obtain the output feature matrix of the image preprocessing module. F2 ∈ R C×H×W Where: H, W, and C are the height, width, and channel number of the output feature map. Step 5.2: Modify the residual structure in the middle part, including modifying the linear bottleneck structure to an inverted bottleneck structure, and then performing a concat operation on the output of the shallow network and the output of the deep network in the middle structure to obtain more features. The modified network structure in the middle part consists of four Redy Blocks. The first Redy Block is stacked by three inverted bottleneck structures. The second Redy Block, the third Redy Block, and the fourth Redy Block have the same structure, each consisting of three inverted bottleneck structures and a max pooling layer. The inverted bottleneck structure consists of three depth convolution layers Conv. The convolution kernel size of the first depth convolution layer Conv1 is 7x7, the stride is set to 2, the padding is set to 3, and the channel number remains unchanged. The convolution kernel size of the second depth convolution layer Conv2 is 1x1, responsible for changing the output channel number to 4 times the input. The convolution kernel size of the third depth convolution layer Conv3 is 1x1, changing the output channel number to 1 / 4 of the input. The output of the first Redy Block consists of the output of the image preprocessing module and the output of its last inverted bottleneck structure. The output of the second Redy Block, the third Redy Block, and the fourth Redy Block consists of the output of the previous Redy Block and the output of its last inverted bottleneck structure. The output feature matrix F2 after the image passes through the image preprocessing module will be temporarily saved. The feature matrix after being processed by the first RedyBlock is as follows: F3 belongs to R C×H×W Among them, the height and width of F2 and F3 are the same. Subsequently, F2 and F3 are concatenated to obtain F4. F4 ∈ R 2C×H×W Among them, F4 is the output feature matrix of the first Redy Block, the number of channels becomes twice that of the input, and the image information fuses both shallow and deep information. The second Redy Block, the third Redy Block, and the fourth Redy Block all receive the output feature map of the previous Redy Block. Inside the Redy Block, the maximum pooling layer is used to halve the size of the feature map to obtain the output Output1 of the current module. And in another branch, two inverted bottleneck structures are used to perform convolution operations on the feature map to obtain the output Output2. The output Output1 and the output Output2 are concatenated and fused to obtain the output of the current Redy Block. Step 5.3: Modify the convolution kernel and activation function of the classification head, change the 3x3 convolution kernel to a 7x7 convolution kernel, and add a ReLU activation function layer. The modified classification head includes a depth convolution layer Conv2, a batch normalization layer BN2, a non-linear activation function ReLU, a global average pooling layer AVG Pool, and a fully connected layer FC. After passing through four consecutive Redy Blocks, the image is further processed by the deep network. The classification head uses the depth convolution layer Conv2 to perform convolution operations on the output of the fourth Redy Block, and then uses the batch normalization layer BN2 and the non-linear activation function ReLU to normalize and non-linearly activate the output of the depth convolution layer Conv2. Then, the global average pooling layer AVGPool is used to reduce the dimension of the output feature map of the last Redy Block. Among them, H is the height of the feature map, W is the width of the feature map, and C is the number of channels. After passing through the global average pooling layer AVG Pool, a feature vector z with a length of 2048 is obtained. This feature vector is input into the fully connected layer FC and transformed into an output of the number of categories K. y = Wz + b Among them, w is the weight matrix, and b is the bias term. Finally, the softmax function is used to calculate the class probabilities. where y k is the score of class k, and p k is the probability of class k. The output result of the final pumping unit fault diagnosis model RedyNet is the index corresponding to the maximum probability.
6. The fault diagnosis method for a pumping unit based on an indicator diagram according to claim 1, characterized in that, The specific method of step 6 is as follows: Step 6.1: Use convolution kernels of different sizes to train on the indicator diagram training set divided in step 4, and compare the performance of the pumping unit fault diagnosis model RedyNet under different convolution kernel sizes on the indicator diagram validation set divided in step 4, and select the convolution kernel size that can obtain the highest accuracy. Step 6.2: Compare the original residual structure of the image classification model ResNet 50 with the inverse bottleneck structure replacing the original residual structure of the image classification model ResNet 50. That is, use the indicator diagram training set and the indicator diagram validation set divided in Step 4 to train and validate the image classification model ResNet 50 based on the original residual structure, and record its diagnostic accuracy rate and computational complexity. Replace the original residual structure with the inverse bottleneck structure, keeping the other structures unchanged, to obtain the image classification model ResNet 50 based on the inverse bottleneck structure. Use the indicator diagram training set and the indicator diagram validation set divided in Step 4 to train and validate it, and record the corresponding diagnostic accuracy rate and complexity. It is obtained that the diagnostic accuracy rate of the image classification model ResNet 50 based on the original residual structure on the indicator diagram validation set is lower than that of the image classification model ResNet 50 based on the inverse bottleneck structure on the indicator diagram validation set, and the computational complexity of the image classification model ResNet 50 based on the original residual structure on the indicator diagram validation set is higher than that of the image classification model ResNet 50 based on the inverse bottleneck structure on the indicator diagram validation set. Finally, select the image classification model ResNet 50 based on the inverse bottleneck structure; Step 6.3: Compare not using the concat operation and using the concat operation in the Redy Block module. That is, use the Redy Block module without the concat operation to train and validate the indicator diagram training set and the indicator diagram validation set divided in Step 4, and record its diagnostic accuracy rate; Then, under the same conditions, use the Redy Block module with the concat operation to train and validate the indicator diagram training set and the indicator diagram validation set divided in Step 4, and record its diagnostic accuracy rate. It is obtained that the diagnostic accuracy rate of the Redy Block module without the concat operation on the indicator diagram validation set is lower than that of the Redy Block module with the concat operation on the indicator diagram validation set. Finally, obtain the optimal network structure using the concat operation; Step 6.4: After determining the optimal network structure, use the indicator diagram training set and the indicator diagram validation set divided in Step 4 to conduct a final evaluation of the pumping unit fault diagnosis model RedyNet, and further optimize some hyperparameters to obtain the optimal model for the pumping unit fault diagnosis task.
7. A fault diagnosis method for a pumping unit based on an indicator diagram according to claim 1, characterized in that The specific method of Step 7 is as follows: Step 7.1: Predict the working condition type. Input the indicator diagram to be recognized in the indicator diagram test set divided in Step 4 into the optimal model for the pumping unit fault diagnosis task trained in Step 6. The optimal model for the pumping unit fault diagnosis task outputs an 8-dimensional vector, representing the prediction distribution of the image under different working condition types: P = [P0, P1, P2, P3, P4, P5, P6, P7] where P i represents the predicted probability that the image belongs to the i-th working condition; Step 7.2: Working condition category mapping. By finding the index i corresponding to the maximum probability value in P and querying the working condition index table, the final working condition determination result can be obtained; Step 7.3, Prediction and Accuracy Statistics of the Dynamometer Card Test Set: Input all the dynamometer card images in the dynamometer card test set into the optimal model for the pumping unit fault diagnosis task, record the working condition type corresponding to the maximum probability output for each image, and perform statistics on the prediction results of the dynamometer card validation set. The formula used is: Among them, TP represents the number of samples with a positive prediction result and a positive true label, TN represents the number of samples with a negative prediction result and a negative true label, FP represents the number of samples with a positive prediction result but a negative true label, and FN represents the number of samples with a negative prediction result but a positive true label.
8. A dynamometer card-based pumping unit fault diagnosis system based on the method according to any one of claims 1 to 7, characterized in that Including: An excel file export module, which is used to collect the operation data of the pumping unit during oil production using a dynamometer. The operation data includes displacement and load. Data is collected at fixed time intervals, and the collected data is all the data in one stroke. All the data is recorded and exported as an excel file; An original dynamometer card dataset acquisition module, which is used to read the content in the excel file, perform preliminary data cleaning and screening, and draw dynamometer cards at intervals of one stroke to obtain the original dynamometer card dataset; A new dynamometer card dataset formation module, which is used to expand the original dynamometer card dataset by means of rotation, flipping, and mixcut respectively to form a new dynamometer card dataset; A new dynamometer card dataset division module, which is used to label and divide the new dynamometer card dataset to obtain a dynamometer card training set, a dynamometer card validation set, and a dynamometer card test set; A pumping unit fault diagnosis model RedyNet construction module, which is used to construct the pumping unit fault diagnosis model RedyNet; A pumping unit fault diagnosis model RedyNet training module, which is used to train the pumping unit fault diagnosis model RedyNet using the dynamometer card training set and evaluate it on the dynamometer card validation set to obtain the optimal model for the pumping unit fault diagnosis task under multiple different hyperparameter schemes; A pumping unit fault diagnosis model RedyNet evaluation module, which is used to evaluate the dynamometer card test set using the optimal model for the pumping unit fault diagnosis task to obtain evaluation indicators and results.
9. An oil pumping unit fault diagnosis device based on a dynamometer card, characterized in that Including: A memory: storing a computer program of a dynamometer card-based pumping unit fault diagnosis method according to any one of claims 1-7, which is a computer-readable device; A processor: used to implement a dynamometer card-based pumping unit fault diagnosis method according to any one of claims 1-7 when executing the computer program.
10. A computer-readable storage medium, characterized in that, A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it can implement a dynamometer card-based pumping unit fault diagnosis method according to any one of claims 1-7.