Visual detection model compression method, device and equipment suitable for oil and gas production operation and medium

By pruning, distilling, and quantizing the visual inspection model, a compressed model suitable for edge gateways is generated, which solves the problems of slow computing speed and large model size on edge computing devices, and realizes efficient and low-power visual inspection in oil and gas production operations.

CN122244186APending Publication Date: 2026-06-19CHINA UNIV OF PETROLEUM (BEIJING)
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHINA UNIV OF PETROLEUM (BEIJING)
Filing Date
2026-03-19
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

Existing deep learning-based detection models cannot be effectively deployed on edge computing devices in oil and gas production operations. They suffer from problems such as slow computing speed, large model size, and operator incompatibility, failing to meet the requirements of high efficiency, low power consumption, and high accuracy. Furthermore, model compression technology urgently needs breakthroughs in oil and gas field operation scenarios.

Method used

By training the original visual detection model, pruning is performed using preset regularization and batch normalization methods, and model distillation and quantization techniques are combined to generate a chip-type compressed model suitable for edge gateways. This model is then deployed in oil and gas production operation scenarios for visual-level safety monitoring.

Benefits of technology

It achieves high-efficiency computing speed and low power consumption at the edge, while maintaining no significant decrease in model accuracy, thus meeting the needs of intelligent video analysis in oil and gas production operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122244186A_ABST
    Figure CN122244186A_ABST
Patent Text Reader

Abstract

This application discloses a method, apparatus, equipment, and medium for compressing visual inspection models applicable to oil and gas production operations, relating to the field of model compression. The method includes: training an original visual inspection model using a preset dataset to obtain a target baseline model; pruning the target baseline model using a preset pruning method to obtain a target pruned model; performing model distillation on the target pruned model and determining the distillation loss generated by model distillation using a preset distillation loss function; jointly training the target pruned model using the distillation loss to obtain a distillation recovery model; quantizing the distillation recovery model based on the chip type corresponding to the edge gateway and a preset quantization algorithm; and deploying the obtained compressed target model to the edge gateway to utilize the deployed model for visual-level safety monitoring of the oil and gas production operation site. Thus, the compressed model can be deployed on the chip of the edge gateway, reducing power consumption while ensuring model accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of model compression, and in particular to a method, apparatus, equipment and medium for compressing visual inspection models suitable for oil and gas production operations. Background Technology

[0002] Oil and gas field companies utilize computer vision to build video analysis and detection models to identify unsafe behaviors by personnel (such as wearing safety clothing, leaving their posts, and entering dangerous areas) and unsafe conditions of equipment and facilities (such as liquid leaks and abnormal shutdowns of pumping units). Oil and gas field companies have tens of thousands of video surveillance channels on-site. Because video data has extremely high network bandwidth requirements, transmitting all video data back to a central server and then running algorithms on a computing server for analysis places very high demands on transmission bandwidth and the computing power of the central machine, significantly increasing costs. Therefore, storing data at the edge and using edge devices for data analysis and processing is crucial. This not only reduces bandwidth requirements but also makes the entire system more stable due to this distributed system design. Edge computing devices often have limited computing resources and high power consumption requirements, necessitating that the deep learning analysis and detection models running at the edge be small enough and have high computational efficiency while maintaining a certain level of accuracy.

[0003] Currently, deep learning-based detection models need to meet the requirements of high efficiency, low power consumption, and high accuracy in practical video intelligent analysis applications. However, due to issues such as slow computation speed, large model size, and incompatibility with edge computing devices, they cannot be ported to existing edge computing devices. Furthermore, key technical challenges such as algorithm pruning and model quantization applicable to oil and gas field operation scenarios during model compression urgently need to be overcome. This necessitates that intelligent video analysis models for oil and gas production operations minimize computational complexity and resource consumption, access more video channels, and maintain essentially the same accuracy within the constraints of computing resources. Summary of the Invention

[0004] In view of this, the purpose of this invention is to provide a method, apparatus, equipment, and medium for compressing visual inspection models suitable for oil and gas production operations. This allows the compressed model, derived from the detection algorithm, to be deployed on the chip of an edge gateway, fully utilizing hardware advantages to achieve higher computing speed and lower power consumption, while ensuring that model accuracy does not significantly decrease. The specific solution is as follows: In a first aspect, this application discloses a visual inspection model compression method applicable to oil and gas production operations, comprising: The original visual detection model is trained using a dataset of on-site monitoring of oil and gas production operations to obtain a target baseline model. The target baseline model is then pruned using a pre-defined regularization method and a batch normalization method to obtain a target pruned model. Based on the target baseline model, the target pruning model is distilled, and the distillation loss generated by the model distillation is determined by a preset distillation loss function. The target pruning model is then jointly trained using the distillation loss to obtain a distillation recovery model. The distillation recovery model is quantized based on the chip type corresponding to the industrial-grade edge gateway in the oil and gas production operation scenario and the preset quantization algorithm. The resulting target compressed model is then deployed to the industrial-grade edge gateway in the oil and gas production operation scenario to perform visual-level safety monitoring of the oil and gas production operation site using the deployed model.

[0005] Optionally, the step of training the original visual detection model using an oil and gas production operation site monitoring dataset to obtain the target benchmark model includes: An oil and gas production operation site monitoring dataset is generated based on preset oil and gas production operation site monitoring images. The original visual detection model is then trained using a preset deep learning framework and the oil and gas production operation site monitoring dataset to obtain the target benchmark model.

[0006] Optionally, the step of pruning the target baseline model using a preset regularization method and a batch normalization method to obtain the target pruned model includes: Determine several training norms corresponding to each layer of the target baseline model, perform sparse training on the several training norms, and then perform regularization training on the several training norms through the regularization function corresponding to the preset regularization method to obtain several trained norms. The training norms are eliminated based on a preset pruning threshold to remove those training norms that are less than the preset pruning threshold from the target baseline model, so as to obtain the pruned model. The pruned model is fine-tuned and restored using the oil and gas production operation site monitoring dataset to obtain the target pruned model.

[0007] Optionally, the step of performing model distillation on the target pruning model based on the target baseline model, and determining the distillation loss generated by model distillation through a preset distillation loss function, so as to jointly train the target pruning model through the distillation loss to obtain a distillation recovery model, includes: If the target pruning model is a classification model, then the target baseline model is used as the first teacher model, and the target pruning model is used as the first student model. The preset input data in the oil and gas production operation site monitoring dataset is input into the first teacher model, so that the first teacher model outputs a first soft label corresponding to the preset input data based on the preset first distillation temperature. The preset input data is input into the first student model so that the first student model outputs a second soft label corresponding to the preset input data based on the preset first distillation temperature, and outputs a hard label corresponding to the preset input data based on the preset second distillation temperature; Calculate the distillation loss between the first soft label and the second soft label, and calculate the supervision loss between the hard label and the real label corresponding to the preset input data; The distillation loss and the supervision loss are weighted and summed according to a preset first weight to obtain a first target loss. The target pruning model is then trained using the first target loss to obtain a distillation recovery model.

[0008] Optionally, the step of performing model distillation on the target pruning model based on the target baseline model, and determining the distillation loss generated by model distillation through a preset distillation loss function, so as to jointly train the target pruning model through the distillation loss to obtain a distillation recovery model, includes: If the target pruning model is a multi-task detection model, then the target baseline model is used as the second teacher model, and the target pruning model is used as the second student model. The preset input data in the oil and gas production operation site monitoring dataset is input into the second teacher model so that the second teacher model outputs the corresponding first classification output and first regression output. The preset input data in the oil and gas production operation site monitoring dataset is input into the second student model so that the second student model outputs the corresponding second classification output and second regression output; The soft target loss is calculated based on the first classification output and the second classification output, and the distance loss is calculated based on the first regression output and the second regression output. The classification loss is determined based on the second classification output by using a preset cross-entropy loss function, and the regression loss is determined based on the second regression output by using a preset smoothed average absolute error loss function. The KL divergence loss is determined based on the intermediate layer outputs of the second teacher model and the second student model. The soft target loss, distance loss, classification loss, regression loss, and KL divergence loss are weighted and summed according to a preset second weight to obtain a second target loss. The target pruning model is then trained using the second target loss to obtain a distillation recovery model.

[0009] Optionally, the distillation recovery model is quantized based on the chip type corresponding to the industrial-grade edge gateway in the oil and gas production operation scenario and a preset quantization algorithm. The resulting target compressed model is then deployed to the industrial-grade edge gateway in the oil and gas production operation scenario to perform visual-level safety monitoring of the oil and gas production operation site using the deployed model. This includes: The chip type corresponding to the industrial-grade edge gateway in the oil and gas production operation scenario is determined. If the chip type is a preset first type, the distillation recovery model is converted based on the model format corresponding to the chip type to obtain the converted model. The converted model is optimized using a floating-point network based on a preset first calibration dataset, and the optimized model is quantized to obtain a network graph in a preset format and a corresponding coefficient file. The network graph and coefficient file in the preset format are compiled to obtain a first target compression model, and the first target compression model is deployed to the industrial-grade edge gateway in the oil and gas production operation scenario to perform visual-level safety monitoring of the oil and gas production operation site using the deployed model.

[0010] Optionally, the distillation recovery model is quantized based on the chip type corresponding to the industrial-grade edge gateway in the oil and gas production operation scenario and a preset quantization algorithm. The resulting target compressed model is then deployed to the industrial-grade edge gateway in the oil and gas production operation scenario to perform visual-level safety monitoring of the oil and gas production operation site using the deployed model. This includes: Determine the chip type corresponding to the industrial-grade edge gateway in the oil and gas production operation scenario. If the chip type is a preset second type, then generate the calculation graph of the distillation recovery model. The computational graph is quantized and calibrated using a preset first calibration dataset, and a second target compression model is generated based on the calibrated computational graph. The second target compression model is deployed to the industrial-grade edge gateway in the oil and gas production operation scenario to perform visual-level safety monitoring of the oil and gas production operation site using the deployed model.

[0011] Secondly, this application discloses a visual inspection model compression device suitable for oil and gas production operations, comprising: The model pruning module is used to train the original visual detection model using the oil and gas production operation site monitoring dataset to obtain the target baseline model, and to prune the target baseline model using a preset regularization method and a batch normalization method to obtain the target pruned model. The model distillation module is used to perform model distillation on the target pruning model based on the target baseline model, and to determine the distillation loss generated by model distillation through a preset distillation loss function, so as to jointly train the target pruning model through the distillation loss to obtain a distillation recovery model; The model deployment module is used to quantize the distillation recovery model based on the chip type corresponding to the industrial-grade edge gateway in the oil and gas production operation scenario and the preset quantization algorithm, and deploy the obtained target compressed model to the industrial-grade edge gateway in the oil and gas production operation scenario, so as to use the deployed model to perform visual safety monitoring of the oil and gas production operation site.

[0012] Thirdly, this application discloses an electronic device, including: Memory, used to store computer programs; A processor is used to execute the computer program to implement the visual inspection model compression method applicable to oil and gas production operations as described above.

[0013] Fourthly, this application discloses a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the aforementioned visual inspection model compression method applicable to oil and gas production operations.

[0014] In this application, an original visual detection model can be trained using an oil and gas production operation site monitoring dataset to obtain a target baseline model. The target baseline model is then pruned using a preset regularization method and a batch normalization method to obtain a target pruned model. Based on the target baseline model, the target pruned model undergoes model distillation, and a preset distillation loss function is used to determine the distillation loss. This loss is then used to jointly train the target pruned model to obtain a distillation recovery model. The distillation recovery model is quantized based on the chip type corresponding to the industrial-grade edge gateway in the oil and gas production operation scenario and a preset quantization algorithm. The resulting target compressed model is then deployed to the industrial-grade edge gateway in the oil and gas production operation scenario to perform visual-level safety monitoring of the oil and gas production operation site.

[0015] Therefore, the method of this application allows for the training of an original visual detection model using a dataset of oil and gas production operation site monitoring. This trained model serves as a baseline model. Then, a pre-defined pruning method is used to prune the model. The pruned target model is then subjected to model distillation using the original visual detection model. After determining the distillation loss, the model is jointly trained using this loss to obtain a distillation recovery model. Next, the distillation recovery model is quantized using the chip type corresponding to the edge gateway and a pre-defined quantization algorithm. The resulting compressed target model is then deployed to the industrial-grade edge gateway in the oil and gas production operation scenario. This deployed model enables visual-level safety monitoring of the oil and gas production operation site. In this way, the model with compressed detection algorithm volume can be deployed on the edge gateway chip, fully utilizing hardware advantages to achieve higher computing speed and lower power consumption, while ensuring that model accuracy does not significantly decrease. Attached Figure Description

[0016] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0017] Figure 1 This application discloses a flowchart of a visual inspection model compression method applicable to oil and gas production operations. Figure 2 This is a timing diagram of a visual inspection model compression method for oil and gas production operations disclosed in this application. Figure 3 This is a schematic diagram of a channel pruning method disclosed in this application; Figure 4 This is a schematic diagram of a training parameter distribution disclosed in this application; Figure 5 This is a schematic diagram of a single-task model distillation disclosed in this application; Figure 6 This is a schematic diagram of an output probability distribution disclosed in this application; Figure 7 This is a schematic diagram of a multi-task model distillation disclosed in this application; Figure 8 This is a schematic diagram of a model quantization disclosed in this application; Figure 9 This is a schematic diagram illustrating another model quantization disclosed in this application; Figure 10This is a schematic diagram of a visual inspection model compression device suitable for oil and gas production operations disclosed in this application; Figure 11 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation

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

[0019] Currently, deep learning-based detection models need to meet the requirements of high efficiency, low power consumption, and high accuracy in practical video intelligent analysis applications. However, due to issues such as slow computation speed, large model size, and incompatibility with edge computing devices, they cannot be ported to existing edge computing devices. Furthermore, key technical challenges such as algorithm pruning and model quantization applicable to oil and gas field operation scenarios during model compression urgently need to be overcome. This necessitates that intelligent video analysis models for oil and gas production operations minimize computational complexity and resource consumption, access more video channels, and maintain essentially the same accuracy within the constraints of computing resources.

[0020] To overcome the aforementioned technical problems, this application discloses a visual inspection model compression method, apparatus, equipment, and medium applicable to oil and gas production operations. This method can deploy the compressed model of the inspection algorithm on the chip of the edge gateway to fully utilize hardware advantages, achieve higher computing speed and lower power consumption, while ensuring that the model accuracy does not decrease significantly.

[0021] See Figure 1 As shown, this embodiment of the invention discloses a visual inspection model compression method suitable for oil and gas production operations, comprising: Step S11: Train the original visual detection model using the oil and gas production operation site monitoring dataset to obtain the target baseline model, and prune the target baseline model using a preset regularization method and a batch normalization method to obtain the target pruned model.

[0022] In this embodiment, as Figure 2As shown, the first step is to train the original visual detection model using a pre-defined dataset to obtain the target benchmark model. Specifically, this requires processing using the original floating-point model training module, which is fundamental to all compression operations. The core task is to train a high-precision, uncompressed original teacher model using a high-quality business dataset. Specifically, mainstream deep learning frameworks such as PyTorch are used for object detection tasks (e.g., YOLOv5, RetinaNet), and the model is fully trained on a dataset constructed from real-world business scenarios, namely oil and gas field well site monitoring videos, to obtain a robust benchmark model that provides knowledge for subsequent pruning and distillation. Specifically, an oil and gas production operation site monitoring dataset needs to be generated based on pre-defined oil and gas production operation site monitoring images, and the original visual detection model is trained using the pre-defined deep learning framework and the oil and gas production operation site monitoring dataset to obtain the target benchmark model. The preset deep learning framework uses PyTorch. The oil and gas production operation site monitoring dataset consists of 10,000 images of well site pumping units, randomly divided into training and validation sets at a 9:1 ratio. Original visual detection models are trained on both sets. In this embodiment, the original visual models used are Yolov5-Large and RetinaNet50, but other models can also be used as the original models, selected according to requirements. The trained target benchmark model is typically used as the subsequent teacher model.

[0023] Furthermore, such as Figure 2 As shown, pruning is required for the target benchmark model. Specifically, this can be achieved using an L1+BN channel pruning module, aiming to significantly reduce model parameters and computational cost through structured pruning. It integrates L1 regularized sparse training with a batch normalization (BN) layer scaling factor pruning strategy. First, during the fine-tuning training phase, the scaling factor of the BN layer is used in the loss function. An L1 regularization term is introduced to guide the channel-level importance parameters to become sparsity-oriented. Then, the channels are sorted according to the magnitude of their γ values ​​after training, and systematic pruning is performed. By using channels with smaller values ​​and their associated convolutional kernels, the model structure is directly altered, resulting in a lighter and more compact pruned model. This effectively removes structural redundancy from the model. Therefore, it is first necessary to determine several training norms corresponding to each layer of the target baseline model. (Scale factor) It should be noted that, To ensure that parameters stabilize as training progresses, these parameters are used as pruning criteria to accurately reflect the importance of each channel. Since current CNN (Convolutional Neural Network) models typically include a batch normalization (BN) layer after convolutions, based on the principle of batch normalization, the corresponding parameters for each layer are used... The magnitude of the value is used to prune the convolutional layer with Batch Normalization (BN), achieving the benefits of BN in network training without introducing too many additional layers and computational overhead. Then, several training norms need to be regularized using a predefined regularization function to obtain several trained norms. It should be noted that, according to... Figure 3 It can be seen that when pruning, The smaller the value, the better the pruning effect, especially in the BN layer of a trained network. The value will not ideally tend towards a small value, which can significantly impact the pruning effect. Therefore, by adding L1 regularization during network training, this is forced... During training, it is constantly forced towards 0, and the regularization function corresponding to L1 regularization is as follows: ; in, Let i be the true value of the i-th sample. Let w be the j-th feature of the i-th sample, w be the set of all parameters to be optimized, and λ be the regularization factor.

[0024] Furthermore, after processing with regular expressions, according to Figure 4 As shown, as the training process continues, the number of trainable parameters in the network that approach zero increases continuously. Therefore, network pruning can be performed based on... The L1 norm of the value is used to prune the corresponding layer. Furthermore, several post-training norms can be removed based on a preset pruning threshold. This removes several post-training norms from the target baseline model that are less than the preset pruning threshold, resulting in a pruned model. Finally, the pruned model is fine-tuned and retrained using an oil and gas production operation site monitoring dataset to obtain the target pruned model. In this way, by combining regularized pruning with batch normalization pruning to remove redundant parameters, the model size and computational load can be reduced without compromising the accuracy of the visual analysis model for oil and gas field scenarios, while effectively ensuring the detection accuracy of small targets in the scene, such as valve leaks and gas detectors.

[0025] Step S12: Perform model distillation on the target pruning model based on the target baseline model, and determine the distillation loss generated by model distillation through a preset distillation loss function, so as to jointly train the target pruning model through the distillation loss to obtain the distillation recovery model.

[0026] In this embodiment, model distillation is required for the target part-time model. Specifically, such as... Figure 2 As shown, inter-layer and output knowledge distillation modules are required for processing, employing a "teacher-student" distillation framework. The target pruned model output from the previous module is used as the student model, and the target baseline model is used as the teacher model. It should be noted that, depending on the type of the target baseline model, two processing methods can be used: classification models and detection models.

[0027] When the target baseline model is a classification model, the distillation process is as follows: Figure 5 As shown, the target baseline model is used as the first teacher model, and the target pruned model is used as the first student model. Preset input data from the oil and gas production operation site monitoring dataset is then input into the first teacher model. This allows the first teacher model to output first soft labels (soft labels) corresponding to the preset first distillation temperature and the preset input data. Next, the preset input data is input into the first student model. This allows the first student model to output second soft labels (soft preds) corresponding to the preset first distillation temperature and the preset input data, and also outputs hard labels (hard preds) corresponding to the preset second distillation temperature and the preset input data. It should be noted that the preset first distillation temperature t can be set according to requirements, while the preset second distillation temperature is fixed at 1.

[0028] It should be noted that classification models typically use a softmax layer after the classification output. The softmax layer's function is to convert the network's output into a probability distribution. For example, the output of the layer preceding the softmax layer might be... Then the probability distribution after softmax is: : ; Where T represents the distillation temperature, T is usually set to 1 for normal training (non-distillation), while a higher T value is typically set for distillation training, thereby allowing the network to achieve the desired results. Figure 6 The output probability distribution shown is the soft target. The hard target is generally the class to be classified, while other non-predicted classes have values ​​of 0. The soft target transforms the hard target into a probability distribution, giving non-predicted classes a probability value as well. The soft target was calculated. Then the derivative with respect to the loss is: ; If the temperature is set relatively high, then the following approximation can be obtained from the above formula: ; if and Since all values ​​have a mean of 0, the above can be further simplified to: ; When the temperature T is very high, the optimization function is approximately: Temperature affects the student model's focus on negative labels during training. At lower temperatures, less attention is paid to negative labels, especially those significantly below average; at higher temperatures, the correlation with negative labels increases, leading the student model to focus more on them. In reality, negative labels contain some information, especially those with significantly higher-than-average probabilities. However, the training process of the teacher model dictates that the probability values ​​of negative labels are relatively low, and the lower the value, the less reliable the information. Therefore, temperature selection requires comparative experiments. Essentially, when you want to learn more information from negative labels, the temperature should be higher; when you want to reduce interference from negative labels, the temperature should be lower. Finally, in the entire knowledge distillation process, the temperature is first raised, and then restored to a "low temperature" (T=1) during the testing phase, thereby extracting the knowledge from the original model.

[0029] Finally, the distillation loss between the first and second soft labels needs to be calculated. It also calculates the supervised loss between the hard labels and the ground truth labels corresponding to the preset input data. Then, based on the preset first weight ( The distillation loss and the supervision loss are weighted and summed to obtain the first objective loss, Loss. This first objective loss is then used to train the objective pruning model to obtain the distillation recovery model. .

[0030] On the other hand, if the target benchmark model is a multi-task detection model, then the target benchmark model needs to be used as the second teacher model and the target pruning model needs to be used as the second student model. Then as Figure 7As shown, preset input data from the oil and gas production operation site monitoring dataset is input into the second teacher model, so that the second teacher model outputs corresponding first classification output and first regression output. Then, preset input data from the oil and gas production operation site monitoring dataset is input into the second student model, so that the second student model outputs corresponding second classification output and second regression output. The soft target loss is calculated based on the first classification output and the second classification output. The distance loss is calculated based on the first regression output and the second regression output. Then, the classification loss is determined based on the second classification output using a preset cross-entropy loss function. The regression loss is determined based on the second regression output using a preset smoothed average absolute error loss function. The KL divergence loss is determined based on the intermediate layer outputs of the second teacher model and the second student model. According to the preset second weight ( The second target loss is obtained by weighted summation of the soft target loss, the distance loss, the classification loss, the regression loss, and the KL divergence loss. The target pruning model is then trained using the second target loss to obtain the distillation recovery model. In this way, the knowledge from the teacher's model is used to guide the training of the student model, allowing the student model to maintain high accuracy while reducing its size. Through distillation techniques, the knowledge of the original model can be preserved to some extent, improving the model compression effect.

[0031] Step S13: Quantize the distillation recovery model based on the chip type corresponding to the industrial-grade edge gateway in the oil and gas production operation scenario and the preset quantization algorithm, and deploy the obtained target compressed model to the industrial-grade edge gateway in the oil and gas production operation scenario so as to use the deployed model to perform visual safety monitoring of the oil and gas production operation site.

[0032] In this embodiment, the distillation recovery model after distillation needs to be quantified. Specifically, such as... Figure 2 As shown, a model quantization module is required for processing, which involves converting model parameters from floating-point numbers to integers or fixed-point numbers with fewer bits, reducing the model's storage and computational overhead. Specifically, two quantization scenarios are needed depending on the chip type.

[0033] If the chip type corresponding to the industrial-grade edge gateway in the oil and gas production operation scenario is the preset first type, that is, the computing power Sophon chip, then as follows Figure 8The distillation recovery model needs to be converted based on the model format corresponding to the chip type to obtain the converted model, that is, the ONNX format model is converted to the fp32umodel intermediate type format. Then, the converted model is optimized by floating-point network according to the preset first calibration dataset, and the optimized model is quantized to obtain the network graph and corresponding LMDB (Lightning Memory-Mapped Database) coefficient file in the preset format. Finally, the network graph and coefficient file in the preset format are compiled to compile them into bmodel type to obtain the first target compressed model. The first target compressed model is then deployed to the industrial-grade edge gateway in the oil and gas production operation scenario to use the deployed model for visual safety monitoring of the oil and gas production operation site.

[0034] If the industrial-grade edge gateway in an oil and gas production operation scenario uses the preset first type of chip, i.e., the Atlas chip, then due to the closed-source nature of the Atlas toolchain, it is necessary to continue using the standard quantization process provided by the toolchain. Specifically, for example... Figure 9 As shown, a computational graph of the distillation recovery model needs to be generated. This graph is then quantized and calibrated using a pre-set first calibration dataset. Based on the calibrated graph, a second target compressed model is compiled and generated. This second target compressed model is then deployed to an industrial-grade edge gateway in an oil and gas production operation scenario to perform visual-level safety monitoring of the oil and gas production site. This converts model parameters from floating-point numbers to fewer integers or fixed-point numbers, reducing the model's storage and computational overhead. Quantization techniques allow for greater compression without significantly sacrificing model performance.

[0035] Therefore, the method of this application allows for the training of an original visual detection model using a dataset of oil and gas production operation site monitoring. This trained model serves as a baseline model. Then, a pre-defined pruning method is used to prune the model. The pruned target model is then subjected to model distillation using the original visual detection model. After determining the distillation loss, the model is jointly trained using this loss to obtain a distillation recovery model. Next, the distillation recovery model is quantized using the chip type corresponding to the edge gateway and a pre-defined quantization algorithm. The resulting compressed target model is then deployed to the industrial-grade edge gateway in the oil and gas production operation scenario. This deployed model enables visual-level safety monitoring of the oil and gas production operation site. In this way, under the constraints of edge computing hardware resources for well site applications in the oil industry, effective compression of the video intelligent analysis model can be achieved, increasing the deployment feasibility of the model at the edge, reducing computational costs, increasing operational efficiency, and ultimately achieving the goal of cost reduction and efficiency improvement.

[0036] See Figure 10 As shown, this embodiment of the invention discloses a visual inspection model compression device suitable for oil and gas production operations, comprising: The model pruning module 11 is used to train the original visual detection model using the oil and gas production operation site monitoring dataset to obtain the target benchmark model, and to prune the target benchmark model using a preset regularization method and a batch normalization method to obtain the target pruned model. The model distillation module 12 is used to perform model distillation on the target pruning model based on the target baseline model, and to determine the distillation loss generated by model distillation through a preset distillation loss function, so as to jointly train the target pruning model through the distillation loss to obtain a distillation recovery model; The model deployment module 13 is used to quantify the distillation recovery model based on the chip type corresponding to the industrial-grade edge gateway in the oil and gas production operation scenario and the preset quantization algorithm, and deploy the obtained target compressed model to the industrial-grade edge gateway in the oil and gas production operation scenario so as to use the deployed model to perform visual safety monitoring of the oil and gas production operation site.

[0037] In this embodiment, the original visual detection model can be trained using a dataset of oil and gas production operation site monitoring. The trained model serves as a baseline model. Then, a preset pruning method is used to prune the model. The pruned target model is then subjected to model distillation using the original visual detection model. After determining the distillation loss, the model is jointly trained using this loss to obtain a distillation recovery model. Next, the distillation recovery model is quantized using the chip type corresponding to the edge gateway and a preset quantization algorithm. The resulting compressed target model is then deployed to the industrial-grade edge gateway in the oil and gas production operation scenario. This deployed model enables visual-level safety monitoring of the oil and gas production operation site. In this way, the model with compressed detection algorithm size can be deployed on the edge gateway chip, fully utilizing hardware advantages to achieve higher computing speed and lower power consumption, while ensuring that model accuracy does not significantly decrease.

[0038] In some embodiments, the model pruning module 11 may specifically include: The first model training unit is used to generate an oil and gas production operation site monitoring dataset based on preset oil and gas production operation site monitoring images, and to train the original visual detection model according to the preset deep learning framework and the oil and gas production operation site monitoring dataset to obtain the target benchmark model.

[0039] In some embodiments, the model pruning module 11 may specifically include: The second model training unit is used to determine several training norms corresponding to each layer of the target baseline model, perform sparsity training on the several training norms, and then perform regularization training on the several training norms through the regularization function corresponding to the preset regularization method to obtain several trained norms. The model pruning unit is used to remove the plurality of post-training norms based on a preset pruning threshold, so as to remove the threshold to be removed from the plurality of post-training norms that are less than the preset pruning threshold from the target benchmark model, so as to obtain the pruned model. The model recovery unit is used to fine-tune and recover the pruned model using the oil and gas production operation site monitoring dataset to obtain the target pruned model.

[0040] In some embodiments, the model distillation module 12 may specifically include: The first model determination unit is used to, if the target pruning model is a classification model, take the target baseline model as the first teacher model and the target pruning model as the first student model. The first label output unit is used to input the preset input data in the oil and gas production operation site monitoring dataset into the first teacher model, so that the first teacher model outputs the first soft label corresponding to the preset input data based on the preset first distillation temperature. The second label output unit is used to input the preset input data into the first student model, so that the first student model outputs a second soft label corresponding to the preset input data based on the preset first distillation temperature, and outputs a hard label corresponding to the preset input data based on the preset second distillation temperature; The first loss calculation unit is used to calculate the distillation loss between the first soft label and the second soft label, and to calculate the supervision loss between the hard label and the real label corresponding to the preset input data; The first distillation recovery unit is used to perform a weighted summation of the distillation loss and the supervision loss according to a preset first weight to obtain a first target loss, and to train the target pruning model using the first target loss to obtain a distillation recovery model.

[0041] In some embodiments, the model distillation module 12 may specifically include: The second model determination unit is used to, if the target pruning model is a multi-task detection model, use the target baseline model as the second teacher model and the target pruning model as the second student model. The first model output unit is used to input the preset input data in the oil and gas production operation site monitoring dataset into the second teacher model, so that the second teacher model outputs the corresponding first classification output and first regression output. The second model output unit is used for the student model so that the second student model can output the corresponding second classification output and second regression output; The second loss calculation unit is used to calculate the soft target loss based on the first classification output and the second classification output, and to calculate the distance loss based on the first regression output and the second regression output; The third loss calculation unit is used to determine the classification loss based on the second classification output by using a preset cross-entropy loss function, and to determine the regression loss based on the second regression output by using a preset smoothed average absolute error loss function. The fourth loss calculation unit is used to determine the KL divergence loss based on the intermediate layer outputs of the second teacher model and the second student model. The second distillation recovery unit is used to perform a weighted summation of the soft target loss, the distance loss, the classification loss, the regression loss, and the KL divergence loss according to a preset second weight to obtain a second target loss, and to train the target pruning model using the second target loss to obtain a distillation recovery model.

[0042] In some embodiments, the model deployment module 13 may specifically include: The format conversion unit is used to determine the chip type corresponding to the industrial-grade edge gateway in the oil and gas production operation scenario. If the chip type is a preset first type, the distillation recovery model is converted based on the model format corresponding to the chip type to obtain the converted model. The model quantization unit is used to perform floating-point network optimization on the converted model based on a preset first calibration dataset, and to quantize the optimized model to obtain a network graph in a preset format and a corresponding coefficient file. The first model deployment unit is used to compile the network graph of the preset format and the coefficient file to obtain the first target compressed model, and deploy the first target compressed model to the industrial-grade edge gateway in the oil and gas production operation scenario, so as to use the deployed model to perform visual-level safety monitoring of the oil and gas production operation site.

[0043] In some embodiments, the model deployment module 13 may specifically include: The computation graph generation unit is used to determine the chip type corresponding to the industrial-grade edge gateway in the oil and gas production operation scenario. If the chip type is a preset second type, the computation graph of the distillation recovery model is generated. The model compilation unit is used to quantize and calibrate the computation graph using a preset first calibration dataset, and compile and generate a second target compressed model based on the obtained calibrated computation graph. The second model deployment unit is used as a gateway to perform visual-level safety monitoring of oil and gas production sites using the deployed model.

[0044] Furthermore, embodiments of this application also disclose an electronic device, Figure 11 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application.

[0045] Figure 11 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. Specifically, the electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the visual inspection model compression method for oil and gas production operations disclosed in any of the foregoing embodiments. Furthermore, the electronic device 20 in this embodiment may specifically be an electronic computer.

[0046] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.

[0047] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.

[0048] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the visual inspection model compression method for oil and gas production operations disclosed in any of the foregoing embodiments, the computer program 222 may further include computer programs capable of performing other specific tasks.

[0049] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned visual inspection model compression method applicable to oil and gas production operations. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.

[0050] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.

[0051] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0052] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0053] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0054] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A method for compressing visual inspection models suitable for oil and gas production operations, characterized in that, include: The original visual detection model is trained using a dataset of on-site monitoring of oil and gas production operations to obtain a target baseline model. The target baseline model is then pruned using a pre-defined regularization method and a batch normalization method to obtain a target pruned model. Based on the target baseline model, the target pruning model is distilled, and the distillation loss generated by the model distillation is determined by a preset distillation loss function. The target pruning model is then jointly trained using the distillation loss to obtain a distillation recovery model. The distillation recovery model is quantized based on the chip type corresponding to the industrial-grade edge gateway in the oil and gas production operation scenario and the preset quantization algorithm. The resulting target compressed model is then deployed to the industrial-grade edge gateway in the oil and gas production operation scenario to perform visual-level safety monitoring of the oil and gas production operation site using the deployed model.

2. The visual inspection model compression method applicable to oil and gas production operations according to claim 1, characterized in that, The process of training the original visual detection model using a dataset of oil and gas production operation site monitoring to obtain the target benchmark model includes: An oil and gas production operation site monitoring dataset is generated based on preset oil and gas production operation site monitoring images. The original visual detection model is then trained using a preset deep learning framework and the oil and gas production operation site monitoring dataset to obtain the target benchmark model.

3. The visual inspection model compression method for oil and gas production operations according to claim 1, characterized in that, The step of pruning the target baseline model using a preset regularization method and a batch normalization method to obtain the target pruned model includes: Determine several training norms corresponding to each layer of the target baseline model, perform sparse training on the several training norms, and then perform regularization training on the several training norms through the regularization function corresponding to the preset regularization method to obtain several trained norms. The training norms are eliminated based on a preset pruning threshold to remove those training norms that are less than the preset pruning threshold from the target baseline model, so as to obtain the pruned model. The pruned model is fine-tuned and restored using the oil and gas production operation site monitoring dataset to obtain the target pruned model.

4. The visual inspection model compression method applicable to oil and gas production operations according to claim 1, characterized in that, The step of performing model distillation on the target pruning model based on the target baseline model, and determining the distillation loss generated by model distillation through a preset distillation loss function, and then jointly training the target pruning model using the distillation loss to obtain a distillation recovery model, includes: If the target pruning model is a classification model, then the target baseline model is used as the first teacher model, and the target pruning model is used as the first student model. The preset input data in the oil and gas production operation site monitoring dataset is input into the first teacher model, so that the first teacher model outputs a first soft label corresponding to the preset input data based on the preset first distillation temperature. The preset input data is input into the first student model so that the first student model outputs a second soft label corresponding to the preset input data based on the preset first distillation temperature, and outputs a hard label corresponding to the preset input data based on the preset second distillation temperature; Calculate the distillation loss between the first soft label and the second soft label, and calculate the supervision loss between the hard label and the real label corresponding to the preset input data; The distillation loss and the supervision loss are weighted and summed according to a preset first weight to obtain a first target loss. The target pruning model is then trained using the first target loss to obtain a distillation recovery model.

5. The visual inspection model compression method for oil and gas production operations according to claim 1, characterized in that, The step of performing model distillation on the target pruning model based on the target baseline model, and determining the distillation loss generated by model distillation through a preset distillation loss function, and then jointly training the target pruning model using the distillation loss to obtain a distillation recovery model, includes: If the target pruning model is a multi-task detection model, then the target baseline model is used as the second teacher model, and the target pruning model is used as the second student model. The preset input data in the oil and gas production operation site monitoring dataset is input into the second teacher model so that the second teacher model outputs the corresponding first classification output and first regression output. The preset input data in the oil and gas production operation site monitoring dataset is input into the second student model so that the second student model outputs the corresponding second classification output and second regression output; The soft target loss is calculated based on the first classification output and the second classification output, and the distance loss is calculated based on the first regression output and the second regression output. The classification loss is determined based on the second classification output by using a preset cross-entropy loss function, and the regression loss is determined based on the second regression output by using a preset smoothed average absolute error loss function. The KL divergence loss is determined based on the intermediate layer outputs of the second teacher model and the second student model. The soft target loss, distance loss, classification loss, regression loss, and KL divergence loss are weighted and summed according to a preset second weight to obtain a second target loss. The target pruning model is then trained using the second target loss to obtain a distillation recovery model.

6. The visual inspection model compression method for oil and gas production operations according to claim 1, characterized in that, The distillation recovery model is quantized based on the chip type corresponding to the industrial-grade edge gateway in the oil and gas production operation scenario and a preset quantization algorithm. The resulting target compressed model is then deployed to the industrial-grade edge gateway in the oil and gas production operation scenario to perform visual-level safety monitoring of the oil and gas production operation site using the deployed model. This includes: The chip type corresponding to the industrial-grade edge gateway in the oil and gas production operation scenario is determined. If the chip type is a preset first type, the distillation recovery model is converted based on the model format corresponding to the chip type to obtain the converted model. The converted model is optimized using a floating-point network based on a preset first calibration dataset, and the optimized model is quantized to obtain a network graph in a preset format and a corresponding coefficient file. The network graph and coefficient file in the preset format are compiled to obtain a first target compression model, and the first target compression model is deployed to the industrial-grade edge gateway in the oil and gas production operation scenario to perform visual-level safety monitoring of the oil and gas production operation site using the deployed model.

7. The visual inspection model compression method for oil and gas production operations according to any one of claims 1 to 6, characterized in that, The distillation recovery model is quantized based on the chip type corresponding to the industrial-grade edge gateway in the oil and gas production operation scenario and a preset quantization algorithm. The resulting target compressed model is then deployed to the industrial-grade edge gateway in the oil and gas production operation scenario to perform visual-level safety monitoring of the oil and gas production operation site using the deployed model. This includes: Determine the chip type corresponding to the industrial-grade edge gateway in the oil and gas production operation scenario. If the chip type is a preset second type, then generate the calculation graph of the distillation recovery model. The computational graph is quantized and calibrated using a preset first calibration dataset, and a second target compression model is generated based on the calibrated computational graph. The second target compression model is deployed to the industrial-grade edge gateway in the oil and gas production operation scenario to perform visual-level safety monitoring of the oil and gas production operation site using the deployed model.

8. A visual inspection model compression device suitable for oil and gas production operations, characterized in that, include: The model pruning module is used to train the original visual detection model using the oil and gas production operation site monitoring dataset to obtain the target baseline model, and to prune the target baseline model using a preset regularization method and a batch normalization method to obtain the target pruned model. The model distillation module is used to perform model distillation on the target pruning model based on the target baseline model, and to determine the distillation loss generated by model distillation through a preset distillation loss function, so as to jointly train the target pruning model through the distillation loss to obtain a distillation recovery model; The model deployment module is used to quantize the distillation recovery model based on the chip type corresponding to the industrial-grade edge gateway in the oil and gas production operation scenario and the preset quantization algorithm, and deploy the obtained target compressed model to the industrial-grade edge gateway in the oil and gas production operation scenario, so as to use the deployed model to perform visual safety monitoring of the oil and gas production operation site.

9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the visual inspection model compression method for oil and gas production operations as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, Used to store a computer program, wherein the computer program, when executed by a processor, implements the visual inspection model compression method for oil and gas production operations as described in any one of claims 1 to 7.