Measurement of Gas-Oil Two-Phase Flow Patterns by Using CNN Algorithm Based on Dual ECT Sensors with Venturi Tube

In modern society, the oil industry has become the foundation of the world economy, and how to efficiently extract oil is a pressing problem. Among them, the accurate measurement of oil-gas two-phase parameters is one of the bottlenecks in oil extraction technology. It is found that through the experiment the flow patterns of the oil-gas two-phase flow will change after passing through the venturi tube with the same flow rates. Under the different oil-gas flow rate, the change will be diverse. Being motivated by the above experiments, we use the dual ECT sensors to collect the capacitance values before and after the venturi tube, respectively. Additionally, we use the linear projection algorithm (LBP) algorithm to reconstruct the image of flow patterns. This paper discusses the relationship between the change of flow patterns and the flow rates. Furthermore, a convolutional neural network (CNN) algorithm is proposed to predict the oil flow rate, gas flow rate, and GVF (gas void fraction, especially referring to sectional gas fraction) of the two-phase flow. We use ElasticNet regression as the loss function to effectively avoid possible overfitting problems. In actual experiments, we compare the Typical-ECT-imaging-based-GVF algorithm and SVM (Support Vector Machine) algorithm with CNN algorithm based on three different ECT datasets. Three different sets of ECT data are used to predict the gas flow rate, oil flow rate, and GVF, and they are respectively using the venturi front-based ECT data only, while using the venturi behind-based ECT data and using both these data.


Introduction
Multiphase flow measurement technology is important in the exploitation of petroleum, the accurate measurement of gas and oil flow rate in the oil-gas two phase flow has been the current research issue. In the traditional flow measurement, multiple mixtures that were obtained in oil wells need to be separated in the well for single-phase measurements [1]. This method improves the accuracy of single-phase measurement, but separating multiphase flow is too complicated [2], the equipment is expensive, and the efficiency is low. Therefore, it is necessary to find an accurate and efficient online measuring technology for multiphase flow [3].
Concerning the flow measurement of two-phase flow, there are many technologies that have been used. Mohmmed et al. and Abbagoni and Yeung introduced high-speed cameras (with transparent tube segments) to take high-speed shooting records for convection type [4,5], while Dong et al. used ultrasonic Doppler sensors to estimate the total surface speed of the oil-water two phase flow [6]. P. Aarabi JeshvaghanI et al. proposed and implemented a flow rate measurement method that was machines, genetic algorithms, etc. Marashdeh et al. used the feed-forward neural network and analogue Hopfield network technology for nonlinear image reconstruction of electrical capacitance tomography [32,33]. Wang H.X and Zhang L.F used the capacitance value that was measured by a single ECT as the input of the support vector machine (SVM) algorithm to perform GVF (gas void fraction, especially referring to sectional gas fraction) prediction with an average relative error of 10% [34].
In this paper, we propose the convolutional neural network (CNN) algorithm to realize the non-linear mapping of the flow rates and flow patterns in oil-gas two-phase flow. Two ECT sensors were used to collect the data under different flow rates. One is located in front of the venturi tube and the other is located in the end of the venturi tube. The LBP algorithm was used to image these different flow patterns. By using the information from the flow pattern diagram, the CNN algorithm is used to predict the oil flow rate, gas flow rate, and GVF. The flow pattern before venturi tube, the flow pattern after venturi tube, and the flow pattern merged before and after venturi tube are predicted, respectively. This paper improves the accuracy of measuring the flow rates of the oil-gas two-phase flow while using the typical ECT measurement technology combined with the machine learning algorithm.

The Sensor
Electrical capacitance tomography consists of three main components: sensors, the system of data acquisition, and the system of computer imaging. The system of data acquisition applies voltage to each electrode plate of the sensor, and then obtains the capacitance value between any two plates by demodulating the voltage value between the excitation plate and the ground plate; the collected capacitance value is input into the computer imaging. The system performs normalization processing, and the computer uses the normalized capacitance value and image reconstruction algorithms to reconstruct the distribution of the internal medium of the measured fluid.
The commonly used ECT sensor consists of eight plates. For a sensor consisting of M electrode plates, the number of independent capacitors is M(M − 1)/2 when only one electrode is energized and all the other electrodes remain at zero potential [35].
The boundary condition for ECT is that the potential distribution of the excitation electrode is φ = V and the potential distribution of the fixed electrode is φ = 0. The relationship between the capacitance and dielectric constant distribution is as follows: Q is the charge, η(x, y) is the distribution of dielectric constant, µ(x, y) is the distribution of potential in the sensing region, and σ is the unit charge on electrode surface.

Image Reconstruction
ECT image reconstruction is an inverse problem, which is based on capacitance measurements between electrode pairs to confirm the electrical constants distribution in a pipeline. There is a nonlinear relationship between the measured capacitance value and the dielectric constant, which can be simplified as [36]: λ is the normalized value of the capacitance vector, S is the normalized sensitive field matrix, and g is the distribution matrix inside the medium (normalized dielectric constant). For the ECT system, the normalization formula for λ is as follows [36]: λ min is the capacitance measurement vector when the pipe is full of gas and λ max is the capacitance measurement vector when the pipe is full of oil. For a two-dimensional field, the sensitive field matrix S can be solved by the following formula [36]: S m,n (q) is the sensitivity of the electrode to the qth cell of m − n, → E m (q) is the distribution of electric field intensity under the condition of applying voltage excitation V m to electrode m, and other electrodes are under grounding conditions. → E n is the same and τ is the area of the grid q. In imaging, it is often necessary to normalize the sensitive matrix, as follows: After obtaining the sensitive matrix S, the formula for calculating the medium distribution matrix can be obtained: In most cases, the sensitive matrix S is irreversible, so S −1 does not exist. Therefore, the linear projection algorithm (LBP) is often used for image reconstruction. The algorithm uses the transposed matrix S T of the sensitive field matrix S instead of the inverse matrix S −1 of the sensitive field matrix to calculate the medium distribution matrix g [37], which is: It can be obtained by normalization:ĝ u is the unit vector. The algorithm has simple principle, fast imaging speed, and wide application range. In this paper, the LBP algorithm is used to obtain the flow patterns of oil-gas two-phase flow, before and after the venturi tube. The flow patterns are obtained by inputting 28 sets of capacitance values.

The Real GVF Calculation Formula
The calculation formula of real GVF β is shown in Equation (9).

of 18
In Equation (9), Q g represents gas volume flow, Q represents the total volume flow, and Q l represents liquid volume flow, which herein represents the oil volume flow rate. Q g and Q l are obtained through experimental measurements.

Typical-ECT-Imaging-Based-GVF Algorithm
We set the threshold to process the flow pattern diagram according to the pixel value of the reconstructed flow pattern diagram. The threshold is set to 0.65, setting the pixel above the threshold (i.e., oil) as 1, and the pixel below the threshold (i.e., air) as 0, the ratio of the number of pixels of air to the total number of pixels is the gas void fraction (GVF, especially referring to sectional gas fraction) in the current state. According to the pixel value of the flow pattern diagram, the calculation formula of gas void fraction (GVF) is shown in Equation (10).
M is the total number of pixels in the section, f j is the gray value of the j th pixel, A j is the area of the j th pixel, and A is the total area of the pipeline section.

SVM (Support Vector Machine) Algorithm
This paper uses the regression model of support vector machine, while using the Function (11): Subsequently, it can derive the Equation (12): f (y) =< ω, φ(y) > +b. (12) x is an independent variable, y is a dependent variable, ω is a weight vector, b is an offset, and φ(x) : R d → H is a nonlinear function that maps the data set S to a high-dimensional linear eigenspace and seeks optimality in the eigenvector. For the regression function, the optimization goals and constraints of the SVM are Equations (13) and (14), respectively. The ε insensitive loss function is used for a given training data set. The corresponding support vector machine is the so-called ε-Support Vector Machine [38].
K is the penalty coefficient, the larger value indicates the higher requirement for error, by introducing Lagrangian function, the optimization problem of Equations (13) and (14) is transformed into dual problem, which is obtained by solving the dual problem (the solution of Equation (11) [38]: The Gaussian core is used in this paper [38]: a j is the vector difference of the Lagrangian multiplier, b is the constant term, which is the offset constant, and the ρ parameter is the kernel width. It can be seen from Equations (11)-(16) that the promotion ability of SVM can be controlled by controlling K, ε, and ρ.
In this paper, the independent variable x is the flow pattern that is obtained by the LBP algorithm, and the dependent variable y is the oil flow rate, gas flow rate, and GVF corresponding to the flow patterns. Finally, the optimal regression function between the image high-dimensional data and the feature vectors is obtained [38].

Convolutional Neural Network (CNN)
The image reconstruction algorithm can obtain the flow patterns under different working conditions. In this paper, the CNN algorithm is used to solve the nonlinear mapping of oil-gas two-phase flow parameters (GVF and flow rates) to the change of flow patterns. The input of the CNN model is the flow patterns before and after the venturi tube, and the output is the oil flow rate, gas flow rate, and GVF under the corresponding state of the flow patterns. The traditional regression algorithm cannot solve the relationship between high-dimensional data (streaming image pixels) and low-dimensional data (GVF and flow rates). In the CNN algorithm, increasing the nonlinear activation response can decouple more nonlinear characteristics, thus the training speed of the network can be improved [39]. In this paper, the Inception V3 model of the CNN algorithm is used to solve the nonlinear mapping of oil-gas two-phase flow parameters (GVF and flow rates) and the changes of flow patterns before and after the venturi tube. Figure 1 shows the model structure diagram [39]. (16) j a is the vector difference of the Lagrangian multiplier, b is the constant term, which is the offset constant, and the  parameter is the kernel width. It can be seen from Equations (11)- (16) that the promotion ability of SVM can be controlled by controlling K ,  , and  .
In this paper, the independent variable x is the flow pattern that is obtained by the LBP algorithm, and the dependent variable y is the oil flow rate, gas flow rate, and GVF corresponding to the flow patterns. Finally, the optimal regression function between the image high-dimensional data and the feature vectors is obtained [38].

Convolutional Neural Network (CNN)
The image reconstruction algorithm can obtain the flow patterns under different working conditions. In this paper, the CNN algorithm is used to solve the nonlinear mapping of oil-gas twophase flow parameters (GVF and flow rates) to the change of flow patterns. The input of the CNN model is the flow patterns before and after the venturi tube, and the output is the oil flow rate, gas flow rate, and GVF under the corresponding state of the flow patterns. The traditional regression algorithm cannot solve the relationship between high-dimensional data (streaming image pixels) and low-dimensional data (GVF and flow rates). In the CNN algorithm, increasing the nonlinear activation response can decouple more nonlinear characteristics, thus the training speed of the network can be improved [39]. In this paper, the Inception V3 model of the CNN algorithm is used to solve the nonlinear mapping of oil-gas two-phase flow parameters (GVF and flow rates) and the changes of flow patterns before and after the venturi tube. Figure 1 shows the model structure diagram [39]. As an extremely deep CNN model, Inception V3 has a very sophisticated design and construction. The structure and branches of the entire network are very complicated. The convolutional network is gradually reduced in size from input to output, and the number of output channels is gradually increased. The spatial information is transformed into high order abstract information by simplifying the spatial structure. Factorization into small convolutions is very effective, it can reduce the amount of parameters, reduce over-fitting, and enhance the nonlinear expression of the network [39]. It is very suitable for solving the high-dimensional and nonlinear relationship between the flow patterns and the GVF. In this paper, the input layer of the neural As an extremely deep CNN model, Inception V3 has a very sophisticated design and construction. The structure and branches of the entire network are very complicated. The convolutional network is gradually reduced in size from input to output, and the number of output channels is gradually increased. The spatial information is transformed into high order abstract information by simplifying the spatial structure. Factorization into small convolutions is very effective, it can reduce the amount of parameters, reduce over-fitting, and enhance the nonlinear expression of the network [39]. It is very suitable for solving the high-dimensional and nonlinear relationship between the flow patterns and the GVF. In this paper, the input layer of the neural network is flow patterns that were obtained by image reconstruction, and the output layer has two neurons for outputting the predicted values of gas and oil flow rates.
When compared to the fully connected neural network, the CNN algorithm implements local connectivity, weight sharing, and down-sampling. For the input image, this algorithm can achieve Sensors 2020, 20, 1200 7 of 18 better learning effects by retaining important parameters as much as possible and removing a large number of unimportant parameters [39].
The forward propagation algorithm in neural networks can be expressed as [39]: k h m is the result of the m th neuron in the h th neural network, k n h−1 is the result of the n th neuron in the (h − 1) th neural network, and w mn h is the h th neuron of the (h − 1) th layer to the h th layer. q m h is the deviation of the m th neuron in the h th layer neural network. The Relu activation function that is used in this paper is expressed, as follows [39]: The loss function of the network uses ElasticNet regression, which is a mixture of Ridge and Lasso regression techniques. In the case of highly correlated variables, the group effect is generated. The number of selected variables is not limited and it can withstand double contraction. When compared to the least squares regression, ElasticNet regression effectively avoids possible over-fitting problems. The input of the network in this paper is an image, which belongs to high-dimensional data. ElasticNet regression has obvious effects in the case of multi-collinearity between high-dimensional and data-set variables. Its objective function is shown in Equation (18) [39]: e is the error between the true and predicted value, h ω (x (i) ) is the predicted oil flow rate and gas flow rate, y (i) is the true oil flow rate and gas flow rate, n is the number of data sets, and λ 1 and λ 2 are regularization parameters. ω is a vector containing weights and deviations between individual neurons [39].
By using the back propagation of the CNN to update the weights, the training model uses the Inception V3 network in the CNN. In this paper, the ECT data is first measured by a large number of experiments, and the acquired ECT data re imaged by a linear projection algorithm to obtain the flow patterns. Under different working conditions, the flow patterns before and after the venturi tube are input the CNN model to predict the oil flow rate, gas flow rate, and GVF.
For the CNN algorithm, the real-time parameters of the algorithm are frames per second (FPS), and the complexity parameters of the algorithm are params and floating-point operations per second (FLOPS) of the model. Algorithm real-time FPS that is based on Nvidia 1080Ti graphics card (NVIDIA, Santa Clara, CA, USA) measured FPS is 130.2, its params is 27.16 (M), and FLOPS is 5.75 (G).

Experiment
The experiment was completed on a semi-industrial multiphase flow experimental measuring platform. The overall experimental equipment is shown below. Oil is stored in a separator, being separated according to the principle of gravity and a gas phase compressor produces the gas. Natural gas and oil flow through single-phase pipelines, the mixture of oil and gas can pass through the test pipe. The test pipe is eight meters long, and the ECT sensor and venturi tube are on the test pipe. The maximum pressure of the device is 2 MPa. The detailed dimensional layout of the venturi tube and ECT sensor is given below. The length of the venturi tube is 1200 mm, the length of the inner diameter is 50 mm, the length of the outer diameter is 60 mm, the length of the throat tube is 130 mm, and the opening Angle is 18 • . The ECT sensor has an internal structure of eight electrodes, and the insulation Sensors 2020, 20, 1200 8 of 18 wall of ECT sensor is 5 mm thick. Its length is 60 mm. The length of the internal diameter is 50 mm. The length of the external diameter is 86 mm and the internal electrode size is 192 mm × 90 mm. Figure 2 shows the schematic diagram of the experimental equipment used to perform this experiment. In this experiment, there are two ECT sensors that are located on upstream and downstream of the venturi tube. There are 8 electrodes inside each ECT sensor. The acquisition frequency of ECT system is 100 frames/s, and the excitation signal frequency of ECT is 100 kHz. The SNR (signal to noise ratio) of the hardware system is about 62 dB. tube is 130 mm, and the opening Angle is 18°. The ECT sensor has an internal structure of eight electrodes, and the insulation wall of ECT sensor is 5 mm thick. Its length is 60 mm. The length of the internal diameter is 50 mm. The length of the external diameter is 86 mm and the internal electrode size is 192 mm × 90 mm.  Figure 2 shows the schematic diagram of the experimental equipment used to perform this experiment. In this experiment, there are two ECT sensors that are located on upstream and downstream of the venturi tube. There are 8 electrodes inside each ECT sensor. The acquisition frequency of ECT system is 100 frames/s, and the excitation signal frequency of ECT is 100 kHz. The SNR (signal to noise ratio) of the hardware system is about 62 dB.
The experimental material is No.15 industrial white oil, having a relative dielectric constant of 2.2, the density is 880 kg/m 3 , and the viscosity is 8.8 mPa s (33 °C), white oil contains high levels of cycloparaffin (MOSH) and 25% Alkyl substituted aromatic hydrocarbons (MOAH). The gas is natural gas, which is consistent with the oilfield site environment. The working pressure is 0.6 MPa. The experimental temperature is 33 °C while using the temperature transmitter.
In this experiment, we collected a large amount of experimental data to train the model. Through the semi-industrial multiphase flow experimental measurement platform, the data collected time under each working condition is 10 min, and the collected data are the capacitance value of ECT sensor. The LBP image reconstruction algorithm is used to convert the capacitance into flow pattern for model training. The train set was collected under 52 working conditions. There were 8000 training samples in each working condition, and the total number of training samples was 416,000. The test set was also collected under the same 52 working conditions. There were 2000 test samples in each working condition, and the total number of test samples was 104,000. Table 1 shows the specific oil flow rate, gas flow rate, and GVF of the 52 working conditions in the experiment.  The experimental material is No.15 industrial white oil, having a relative dielectric constant of 2.2, the density is 880 kg/m 3 , and the viscosity is 8.8 mPa s (33 • C), white oil contains high levels of cycloparaffin (MOSH) and 25% Alkyl substituted aromatic hydrocarbons (MOAH). The gas is natural gas, which is consistent with the oilfield site environment. The working pressure is 0.6 MPa. The experimental temperature is 33 • C while using the temperature transmitter.
In this experiment, we collected a large amount of experimental data to train the model. Through the semi-industrial multiphase flow experimental measurement platform, the data collected time under each working condition is 10 min, and the collected data are the capacitance value of ECT sensor. The LBP image reconstruction algorithm is used to convert the capacitance into flow pattern for model training. The train set was collected under 52 working conditions. There were 8000 training samples in each working condition, and the total number of training samples was 416,000. The test set was also collected under the same 52 working conditions. There were 2000 test samples in each working condition, and the total number of test samples was 104,000. Table 1 shows the specific oil flow rate, gas flow rate, and GVF of the 52 working conditions in the experiment.  Table 1 shows the oil flow rate and gas flow rate distribution of 52 working conditions. In the actual experiment, when collecting experimental data, the oil flow rate and gas flow rate of each working condition are not a fixed value. It will randomly fluctuate by 15% above or below the set working condition. Accordingly, the data of the training set and the test set are not same, which Sensors 2020, 20, 1200 9 of 18 effectively verifies the generality of the trained model. The flow pattern diagram that is shown in Figure 3 is the representative of the flow pattern diagram under some typical working conditions. Figure 3 shows the flow patterns change before and after the venturi tube. The values of GVF in the experiment are evenly distributed between 0.25 and 0.95 in order to ensure the full coverage of GVF. The data collection began once the single flow rate was stable, and the oil and gas mixing was completed.  Table 1 shows the oil flow rate and gas flow rate distribution of 52 working conditions. In the actual experiment, when collecting experimental data, the oil flow rate and gas flow rate of each working condition are not a fixed value. It will randomly fluctuate by 15% above or below the set working condition. Accordingly, the data of the training set and the test set are not same, which effectively verifies the generality of the trained model. The flow pattern diagram that is shown in Figure 3 is the representative of the flow pattern diagram under some typical working conditions. Figure 3 shows the flow patterns change before and after the venturi tube. The values of GVF in the experiment are evenly distributed between 0.25 and 0.95 in order to ensure the full coverage of GVF. The data collection began once the single flow rate was stable, and the oil and gas mixing was completed.

Flow Data Analysis
In this experiment, the two-phase flow flows through the venturi tube, ECT data before and after the venturi tube are collected. The LBP algorithm is used to image the flow distributions. The ECT images vary a lot due to the noise in measurement data. The average ECT images were averaged by 100 pieces of ECT data, and the flow patterns tend to be stable and they are convenient for analysis. The following is the flow patterns before and after the venturi tube under typical working conditions. Figure 3 shows the flow patterns before and after the venturi tube under typical working conditions. Figure 3 shows the flow pattern under typical working conditions. It can be seen from the Figure 3 that, under, different oil and gas flow rate, the flow pattern in front of the venturi tube changes little, but after the oil-gas two-phase flow passes through the venturi tube, the flow pattern changes greatly. When the gas flow rate is small, the flow pattern is stratified flow. With the increase of gas flow rate, the flow pattern becomes slug flow. The flow pattern becomes annular flow when the gas flow rate continues to increase. Figure 4 shows the flow patterns change before and after the venturi tube under typical GVF.

Flow Data Analysis
In this experiment, the two-phase flow flows through the venturi tube, ECT data before and after the venturi tube are collected. The LBP algorithm is used to image the flow distributions. The ECT images vary a lot due to the noise in measurement data. The average ECT images were averaged by 100 pieces of ECT data, and the flow patterns tend to be stable and they are convenient for analysis. The following is the flow patterns before and after the venturi tube under typical working conditions. Figure 3 shows the flow patterns before and after the venturi tube under typical working conditions. Figure 3 shows the flow pattern under typical working conditions. It can be seen from the Figure 3 that, under, different oil and gas flow rate, the flow pattern in front of the venturi tube changes little, but after the oil-gas two-phase flow passes through the venturi tube, the flow pattern changes greatly. When the gas flow rate is small, the flow pattern is stratified flow. With the increase of gas flow rate, the flow pattern becomes slug flow. The flow pattern becomes annular flow when the gas flow rate continues to increase. Figure 4 shows the flow patterns change before and after the venturi tube under typical GVF.
From Figure 4, it can be seen that flow patterns change before and after the venturi tube when the GVF value changes from 0.2 to 0.9. When the GVF is less than 0.6, the flow patterns before the venturi tube is 90% stratified flow and 70% stratified flow, while the flow patterns after the venturi tube is slug flow. When the GVF is more than 0.6, the flow pattern diagram before the venturi tube is still stratified flow, but the flow pattern diagram after the venturi tube becomes annular flow. When the oil flow rate is more than 5 m 3 /h, the annular flow trend of the flow patterns after the venturi tube is more obvious. Based on this phenomenon, the CNN network is used to predict the oil flow rates and gas flow rates while using the ECT images as the input. From Figure 4, it can be seen that flow patterns change before and after the venturi tube when the GVF value changes from 0.2 to 0.9. When the GVF is less than 0.6, the flow patterns before the venturi tube is 90% stratified flow and 70% stratified flow, while the flow patterns after the venturi tube is slug flow. When the GVF is more than 0.6, the flow pattern diagram before the venturi tube is still stratified flow, but the flow pattern diagram after the venturi tube becomes annular flow. When the oil flow rate is more than 5 m 3 /h, the annular flow trend of the flow patterns after the venturi tube is more obvious. Based on this phenomenon, the CNN network is used to predict the oil flow rates and gas flow rates while using the ECT images as the input.

Flow Pattern Recognition and Prediction
In this paper, the flow patterns in front of the venturi tube, the flow patterns after the venturi tube, and the flow patterns merged before and after the venturi tube are respectively input into the network for prediction, and the relative error is compared. This paper uses the Inception V3 model in CNN to predict the flow rates under different conditions since the relationship between flow patterns and oil and gas flow rate is non-linear. The flow patterns in front of the venturi tube, the flow patterns after the venturi tube, and the flow patterns merged before and after the venturi tube were respectively trained to compare the predicted performance of oil flow rate, gas flow rates, and GVF.
Firstly, the flow patterns were obtained according to the LBP image reconstruction algorithm, and the corresponding GVF (gas void fraction) in the current flow patterns was calculated while using the Typical-ECT-image-based-GVF algorithm. We set the threshold to process the oil-gas

Flow Pattern Recognition and Prediction
In this paper, the flow patterns in front of the venturi tube, the flow patterns after the venturi tube, and the flow patterns merged before and after the venturi tube are respectively input into the network for prediction, and the relative error is compared. This paper uses the Inception V3 model in CNN to predict the flow rates under different conditions since the relationship between flow patterns and oil and gas flow rate is non-linear. The flow patterns in front of the venturi tube, the flow patterns after the venturi tube, and the flow patterns merged before and after the venturi tube were respectively trained to compare the predicted performance of oil flow rate, gas flow rates, and GVF.
Firstly, the flow patterns were obtained according to the LBP image reconstruction algorithm, and the corresponding GVF (gas void fraction) in the current flow patterns was calculated while using the Typical-ECT-image-based-GVF algorithm. We set the threshold to process the oil-gas two-phase flow imaging image. The threshold is set to 0.65, setting the pixel above the threshold (i.e., oil) as 1, and the pixel below the threshold (i.e., air) as 0. The ratio of the number of pixels of air to the total number of pixels is the gas void fraction (GVF) in the current state.
We use the Typical-ECT-image-based-GVF algorithm to predict the GVF and obtain the average relative error of the prediction. Figure 5 shows the relative error of predicted GVF from the ECT images.
From Figure 5 (the X-axis represents 52 working conditions, i.e., the range of oil flow rate is 1-10 m 3 /h, the range of gas flow rate is 20-150 m 3 /h, and the range of GVF is 0.25-0.95. The Y-axis represents the average relative error of each case) it can be seen that whether it is the flow patterns before the venturi tube, the flow patterns after the venturi tube, and the flow patterns before and after the venturi tube. The effect of Typical-ECT-image-based-GVF algorithm for predicting GVF is poor. This might be due to the low accuracy of the LBP algorithm. The LBP algorithm has better real-time performance, but the imaging accuracy is worse than that of various complex iterative algorithms. It affects the accuracy of the GVF measurements to some extent. two-phase flow imaging image. The threshold is set to 0.65, setting the pixel above the threshold (i.e., oil) as 1, and the pixel below the threshold (i.e., air) as 0. The ratio of the number of pixels of air to the total number of pixels is the gas void fraction (GVF) in the current state. We use the Typical-ECT-image-based-GVF algorithm to predict the GVF and obtain the average relative error of the prediction. Figure 5 shows the relative error of predicted GVF from the ECT images. From Figure 5 (the X-axis represents 52 working conditions, i.e., the range of oil flow rate is 1-10 m 3 /h, the range of gas flow rate is 20-150 m 3 /h, and the range of GVF is 0.25-0.95. The Y-axis represents the average relative error of each case) it can be seen that whether it is the flow patterns before the venturi tube, the flow patterns after the venturi tube, and the flow patterns before and after the venturi tube. The effect of Typical-ECT-image-based-GVF algorithm for predicting GVF is poor. This might be due to the low accuracy of the LBP algorithm. The LBP algorithm has better real-time performance, but the imaging accuracy is worse than that of various complex iterative algorithms. It affects the accuracy of the GVF measurements to some extent.
Meanwhile, the SVM algorithm is a commonly used algorithm for GVF prediction of oil-gas two-phase flow. The flow patterns that are obtained by linear projection algorithm (LBP) are input into the model, and the oil flow rate and gas flow rate corresponding to each flow pattern are respectively input, to find out the non-linear relationship between the flow patterns and oil flow rate, gas flow rate, and GVF. The oil flow rate and gas flow rates predicted from 10,000 pictures under each working condition were averaged, respectively. We compare the actual value of the oil flow rates and gas flow rates with the predicted value. Figures 6-8, respectively, show the relative errors in predicting the oil flow rate, gas flow rate, and GVF of oil-gas two-phase flows while using the SVM algorithm. For the prediction of oil flow rate, whether it is the flow patterns in front of the venturi tube, the flow pattern after the venturi tube, or the flow patterns before and after the venturi tube, the relative error is large at low flow rates, as can be seen from Figure 6. As the oil flow rate increases, the predicted relative error decreases. As can be seen from Figures 7 and 8, for the gas flow rate and GVF prediction, in the small gas flow rate, the relative error is large. This shows that the SVM algorithm is only suitable for the prediction of large oil and gas flow rate, which might be related to the limitations of the SVM algorithm itself. The principle of SVM algorithm is based on existing data, and the hyperplane is fitted to predict, which has certain limitations on high-dimensional data. The CNN algorithm is introduced to solve the relationship between high-dimensional data (flow pattern diagram pixels) and low-dimensional data (GVF and flow rates) to solve the problem. Meanwhile, the SVM algorithm is a commonly used algorithm for GVF prediction of oil-gas two-phase flow. The flow patterns that are obtained by linear projection algorithm (LBP) are input into the model, and the oil flow rate and gas flow rate corresponding to each flow pattern are respectively input, to find out the non-linear relationship between the flow patterns and oil flow rate, gas flow rate, and GVF. The oil flow rate and gas flow rates predicted from 10,000 pictures under each working condition were averaged, respectively. We compare the actual value of the oil flow rates and gas flow rates with the predicted value. Figures 6-8, respectively, show the relative errors in predicting the oil flow rate, gas flow rate, and GVF of oil-gas two-phase flows while using the SVM algorithm. For the prediction of oil flow rate, whether it is the flow patterns in front of the venturi tube, the flow pattern after the venturi tube, or the flow patterns before and after the venturi tube, the relative error is large at low flow rates, as can be seen from Figure 6. As the oil flow rate increases, the predicted relative error decreases. As can be seen from Figures 7 and 8, for the gas flow rate and GVF prediction, in the small gas flow rate, the relative error is large. This shows that the SVM algorithm is only suitable for the prediction of large oil and gas flow rate, which might be related to the limitations of the SVM algorithm itself. The principle of SVM algorithm is based on existing data, and the hyperplane is fitted to predict, which has certain limitations on high-dimensional data. The CNN algorithm is introduced to solve the relationship between high-dimensional data (flow pattern diagram pixels) and low-dimensional data (GVF and flow rates) to solve the problem.
The training model uses the Inception V3 network in a CNN algorithm. Since the input is image pixel data, the data dimension is high and the amount of data is large. With the Inception V3 network, large two-dimensional (2D) volumes can be integrated into two smaller convolutions. In the CNN model, there are 416,000 samples in the training set and 104,000 samples in the test set. The oil flow rates, gas flow rates, and GVF predicted by 10,000 images under each condition were averaged and then compared with the actual values. The oil flow rate, gas flow rate, and GVF under 52 conditions were predicted and the relative error was obtained. Figures 9-11, respectively, show the relative errors in predicting the oil flow rate, gas flow rate, and GVF of oil-gas two-phase flows while using the CNN algorithm. It can be seen from Figure 9 that using CNN algorithm to predict the oil flow rate, the prediction results of the merged flow patterns before and after the venturi tube are superior to those prediction results of the flow patterns before the venturi tube and the flow patterns after the venturi tube. It can be seen from Figures 10 and 11 that, while using the CNN algorithm to predict the gas flow rate and GVF, the prediction relative errors are less than 5% through the merged flow patterns before and after the venturi tube.          that using CNN algorithm to predict the oil flow rate, the prediction results of the merged flow patterns before and after the venturi tube are superior to those prediction results of the flow patterns before the venturi tube and the flow patterns after the venturi tube. It can be seen from Figure 10 and 11 that, while using the CNN algorithm to predict the gas flow rate and GVF, the prediction relative errors are less than 5% through the merged flow patterns before and after the venturi tube. . Figure 10. Relative error of gas flow rate with CNN algorithm. patterns before the venturi tube and the flow patterns after the venturi tube. It can be seen from Figure 10 and 11 that, while using the CNN algorithm to predict the gas flow rate and GVF, the prediction relative errors are less than 5% through the merged flow patterns before and after the venturi tube.  As can be found, the prediction accuracy of the CNN algorithm has been significantly improved when compared with the Typical-ECT-imaging-based-GVF algorithm and SVM algorithm. It can be seen that the CNN network is suitable for the regression of high-dimensional image data and greatly improved the predicted results. As can be found, the prediction accuracy of the CNN algorithm has been significantly improved when compared with the Typical-ECT-imaging-based-GVF algorithm and SVM algorithm. It can be seen that the CNN network is suitable for the regression of high-dimensional image data and greatly improved the predicted results.
The flow patterns after the venturi tube, and the merged flow patterns before and after the venturi tube, the average prediction relative error of the three sets of flow patterns is analyzed below to compare the flow patterns before the venturi tube.
From Tables 2-4, CNN algorithm can provide the most accurate prediction of gas flow rates and oil flow rates. Meanwhile, using the ECT data that were collected before and after the venturi tube can also improve the accuracy of the measurement of the flow rates. Among them, while using the CNN algorithm, the average relative error of oil flow rate prediction is 4.6%, the predicted relative error of gas flow rate is 1.4%, and the average relative error of GVF prediction is 1.6%.
In terms of the measurement of GVF by using the ECT sensor before the venturi tube with SVM algorithm, 90 percent results of 104,000 test samples are less than the relative error with 13.8%, and with CNN algorithm, 90 percent results are less than the relative error with 4.48%, it can be seen that the CNN algorithm is better than the SVM algorithm. When compared to the data before the venturi tube, the measurement of GVF by using the data after the venturi tube with CNN algorithm, 90 percent relative error of 104,000 test samples are less than 3.74%, and it can be seen that the prediction effect of the data after the venturi tube is better. 90 percent relative error of 104,000 test samples are less than 3.06% by using the mixed data before and after the venturi tube with CNN algorithm. It can be seen that the prediction effect of the merged flow patterns before and after the venturi tube is the best.
Finally, for oil flow rate prediction, the relative error of 90% is less than 11%; for gas flow rate prediction, the relative error of 95% is less than 3.6%, and that of 90% is less than 2.2%; and, for GVF prediction, the relative error of 95% is less than 3.3% and that of 90% is less than 3%.

Raw Capacitance Data (Comparative Experiment)
We use the original capacitance data as input to perform the flow prediction in order to compare with the experimental prediction results of the input of the flow pattern. The SVM algorithm and CNN algorithm were used to predict the oil content, gas content, and GVF, respectively. The eight-electrode ECT sensor generates 28 sets of capacitance values. First, the 28 sets of capacitance values are input to the SVM algorithm for flow prediction. The training data set is 8000 and the test data set is 2000. In the traditional SVM regression algorithm, the capacitance value needs to be normalized in order to compare with the experimental prediction results of the input of the flow pattern (if the normalization is not performed, the algorithm cannot converge). The prediction results are shown in Figure 12.
Finally, for oil flow rate prediction, the relative error of 90% is less than 11%; for gas flow rate prediction, the relative error of 95% is less than 3.6%, and that of 90% is less than 2.2%; and, for GVF prediction, the relative error of 95% is less than 3.3% and that of 90% is less than 3%.

Raw Capacitance Data (Comparative Experiment)
We use the original capacitance data as input to perform the flow prediction in order to compare with the experimental prediction results of the input of the flow pattern. The SVM algorithm and CNN algorithm were used to predict the oil content, gas content, and GVF, respectively. The eight-electrode ECT sensor generates 28 sets of capacitance values. First, the 28 sets of capacitance values are input to the SVM algorithm for flow prediction. The training data set is 8000 and the test data set is 2000. In the traditional SVM regression algorithm, the capacitance value needs to be normalized in order to compare with the experimental prediction results of the input of the flow pattern (if the normalization is not performed, the algorithm cannot converge). The prediction results are shown in Figure 12. It can be seen from Figure 12 that the prediction result of the SVM algorithm that is based on the original capacitance value is significantly worse than the prediction result of the CNN algorithm based on the flow pattern diagram. The average relative error of the SVM algorithm that is based on It can be seen from Figure 12 that the prediction result of the SVM algorithm that is based on the original capacitance value is significantly worse than the prediction result of the CNN algorithm based on the flow pattern diagram. The average relative error of the SVM algorithm that is based on the original capacitance value is 0.47. The SVM algorithm is sensitive to the parameter adjustment and the choice of the kernel function, and it has a poor effect on the regression problem.
Furthermore, we use the CNN algorithm with the original capacitance value as the input to perform flow rate prediction. The training set has a total of 416,000 and the test set has a total of 104,000. Figure 13 shows the flow rate prediction result. the original capacitance value is 0.47. The SVM algorithm is sensitive to the parameter adjustment and the choice of the kernel function, and it has a poor effect on the regression problem. Furthermore, we use the CNN algorithm with the original capacitance value as the input to perform flow rate prediction. The training set has a total of 416,000 and the test set has a total of 104,000. Figure 13 shows the flow rate prediction result. When comparing with the prediction results of the CNN algorithm based on the flow patterns, the prediction result of the CNN algorithm based on 28 original capacitance values is obviously poor, as can be seen from Figure 13. The average relative error of the CNN algorithm based on 28 original capacitance values is: 0.33. It can be seen that modeling and analysis that are based on the flow pattern diagram have better prediction results.
The CNN algorithm is suitable for information extraction and the fitting of two-dimensional data because of its application of a large number of convolution operations. For 28 capacitance When comparing with the prediction results of the CNN algorithm based on the flow patterns, the prediction result of the CNN algorithm based on 28 original capacitance values is obviously poor, as can be seen from Figure 13. The average relative error of the CNN algorithm based on 28 original capacitance values is: 0.33. It can be seen that modeling and analysis that are based on the flow pattern diagram have better prediction results.
The CNN algorithm is suitable for information extraction and the fitting of two-dimensional data because of its application of a large number of convolution operations. For 28 capacitance values in one dimension, the CNN algorithm has a very poor extraction effect on its effective information. Therefore, this paper reconstructs the flow pattern diagram that is based on 28 capacitance values, which makes the CNN algorithm extract features more efficiently. From a mathematical perspective, the purpose of this algorithm to reconstruct 28 capacitance values into a flow pattern is to make its representation more suitable for CNN algorithm to extract features.
The above is based on the analysis of the capacitance data of the dual ECT sensors before and after the venturi tube, and the prediction results for the capacitance data of a single ECT sensor are similar to those that are shown in Figure 13.
It can be seen that the prediction effect of using the flow pattern image as the input of the CNN model is better than that of the original capacitance value input to the CNN model. For the input of the flow pattern image, it can be seen that, whether it is the comparison of the average relative error or the comparison of the relative error of 90% measuring results, the best prediction effect can be achieved by predicting the merged flow patterns before and after the venturi tube by the CNN algorithm. This shows that the predictive accuracy of oil flow rate, gas flow rate, and GVF with the dual ECT sensors is better than the single ECT. The CNN algorithm is used to solve the relationship between high-dimensional data (pixels of the flow pattern diagram) and low-dimensional data (GVF and flow rate) that cannot be solved by traditional algorithms. The prediction effect is better when compared with traditional prediction algorithms.

Conclusions
It can be seen from the experiment that the prediction result of using the flow pattern image as the input of the CNN algorithm is much better than the prediction result of the input of the original capacitance value. Through the experiment, it can be seen that the flow patterns of oil-gas two-phase flow before and after venturi tube is different, with the different flow rates, the varying behavior will be different. The oil flow rate, gas flow rate, and GVF under current working conditions are predicted by the flow patterns change before and after the venturi tube. While considering the nonlinear relationship between flow pattern diagrams with flow rates, a convolutional neural network algorithm is proposed to predict gas and oil flow rate. The CNN model has accurate and stable performance. The experimental results show that the improved CNN model has higher prediction performance, the average relative error of oil flow rate is 4.6%; the average relative error of gas flow rate is 1.4%; and, the average relative error of GVF is 1.6%.
In summary, the CNN algorithm greatly improves the predictive accuracy of GVF. It is of great significance to accurately measure the parameters of oil-gas two-phase flow. Unfortunately, the CNN algorithm requires high computational force; at the present stage, it is unable to realize the rapid deployment of measurement devices in the industry, and it is also unable to convert them into portable devices. In addition, the ECT image reconstruction algorithm should be further improved to make its computational efficiency more in line with the needs of practical industrial applications. Therefore, this method is not easy to realize in real-time flow measurement in industrial field. In the future, we will conduct in depth research on the lightweight and embedded model.