PTFE emulsion paraffin separation automatic detection method and device based on Vision-Transformer and reinforcement learning

Through the PatchRLNet model based on Vision-Transformer and reinforcement learning, the automated detection of the PTFE emulsion paraffin separation process is realized, which solves the low accuracy and safety hazards of manual visual inspection, and improves detection efficiency and product quality.

CN118736461APending Publication Date: 2024-10-01YANGTZE DELTA REGION INST (QUZHOU) UNIV OF ELECTRONIC SCI & TECH OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410817051.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-24
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

In the existing technology, PTFE emulsion paraffin separation detection relies on manual visual inspection, which has low accuracy, low efficiency and safety hazards, and is difficult to meet the needs of industrial production for rapid and accurate detection.

Method used

An automatic detection method based on Vision-Transformer and reinforcement learning is used to build a PatchRLNet model through video image collection and preprocessing. The PatchRLNet model, which combines reinforcement learning and Vision-Transformer, is used to realize automatic monitoring and abnormal detection of the paraffin separation process of PTFE emulsion. .

Benefits of technology

It achieves highly accurate liquid status detection and abnormal event monitoring, improves production efficiency and product quality, reduces the operating burden of staff, ensures the safety of the working environment, and promotes the level of automation and intelligence.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118736461A_ABST
    Figure CN118736461A_ABST
Patent Text Reader

Abstract

The invention discloses a PTFE emulsion paraffin separation automatic detection method and device based on Vision-Transform and reinforcement learning, and the method comprises the steps: collecting images from different visual angles, carrying out the preprocessing, and constructing a training set and a test set; the method comprises the following steps: constructing a PatchRLNet model used for separation and detection of the paraffin in the PTFE emulsion on the basis of Vision-Transform and reinforcement learning; performing iterative training on the PatchRLNet model by using the training set, and adjusting model parameters based on a cross entropy loss function to obtain a trained PatchRLNet model; and inputting the images in the test set into the trained PatchRLNet model to obtain a predicted image category. According to the invention, PTFE emulsion paraffin separation detection can be automatically and intelligently carried out, the detection accuracy is effectively improved, and the operation burden of workers is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of PTFE emulsion paraffin separation, and in particular to a PTFE emulsion paraffin separation automatic detection method and device based on Vision-Transformer and reinforcement learning. Background Art

[0002] Polytetrafluoroethylene (PTFE) emulsion is a liquid suspension system with polytetrafluoroethylene as the main component. This emulsion is well-known for its excellent lubrication properties. It can effectively reduce friction and prevent adhesion. It also has excellent non-stick properties, corrosion resistance and high-temperature stability. The lubricating properties of PTFE emulsion make it widely used in various fields, especially in the manufacture of non-stick coatings, lubricants, seals and certain plastic products. This emulsion is not only suitable for industrial production, but also plays a key role in food processing, medical equipment and other fields. Overall, PTFE emulsion provides users with reliable lubrication and protection solutions with its excellent performance, making it an ideal choice in a variety of application scenarios.

[0003] The paraffin separation of PTFE emulsion is of great significance and value in the fields of industry and application. First, the separation of these two components can improve the stability and purity of PTFE emulsion, ensuring its optimal performance in various applications. By removing impurities such as paraffin, it can not only improve the rheology of the emulsion, but also help ensure that the PTFE emulsion has consistent quality and characteristics when manufacturing products such as non-stick coatings, lubricants and seals. Secondly, the process of PTFE emulsion paraffin separation helps to optimize production efficiency, reduce waste and improve the controllability of the production line. Pure PTFE emulsion can be used more effectively in different industrial fields, thereby reducing manufacturing costs and improving product reliability and performance. In addition, the separation process can also meet the strict requirements for material purity and quality standards, especially in some fields with high requirements for material purity, such as medical devices and food processing. This allows PTFE emulsion to be used safely and reliably in these fields, providing a reliable basis for the production of related products. Therefore, PTFE emulsion paraffin separation not only has a significant impact on improving product performance and quality, but also plays an important economic and technical value in industrial production and application.

[0004] At present, the detection process of PTFE emulsion paraffin separation mainly relies on visual inspection by on-site staff. However, this method not only has low accuracy, but also poses a potential threat to the personal safety of on-site staff. First, since visual inspection is affected by the subjective factors of the human eye, there may be inconsistencies in subjective judgment, resulting in certain errors in the evaluation of the separation effect, which may affect the accurate grasp of product quality in production. Secondly, visual inspection may face the problem of inefficiency when dealing with large-scale production. Since manual inspection is time-consuming and susceptible to fatigue and attention fluctuations, it may lead to the inability to meet the needs of fast and accurate detection under high-volume conditions, thereby affecting production efficiency. In addition, for mixed liquids of paraffin and emulsion, visual inspection may also have the problem of missed detection, because the human eye has certain limitations and it is difficult to conduct a comprehensive inspection of subtle color differences. On the other hand, during the separation of PTFE emulsion paraffin, PTFE emulsion and paraffin liquid can reach 80 to 100 degrees Celsius and there is a risk of splashing, which may cause burns to on-site staff. At the same time, paraffin vapor is potentially harmful and may cause discomfort to the respiratory system, eyes, skin and central nervous system. In addition, the PTFE emulsion remaining in the pipeline may cause explosion risk after solidification, posing a serious threat to the life and property safety of on-site workers.

[0005] Artificial Intelligence (AI) is a discipline that studies how to make machines have human-like intelligent behavior. It covers a series of technologies and methods that aim to enable computer systems to simulate, understand, learn and perform tasks similar to human intelligence. The goal of artificial intelligence is to enable computer systems to have intelligent capabilities such as perception, reasoning, learning, planning, language processing, and visual recognition through algorithms and models, so that they can handle various complex tasks and problems. Among them, deep learning is an artificial intelligence machine learning method. Its uniqueness lies in the structure of multi-layer neural networks, which can learn and extract hierarchical features of data layer by layer. Its advantages include end-to-end learning, strong adaptability, excellent performance on large-scale data, and improved modeling capabilities for complex problems through hierarchical abstract representation. Deep learning methods have shown potential for application in many aspects in the chemical industry, including process optimization and control, quality prediction and control, material design and discovery, safety and environmental monitoring, and automated equipment operation and maintenance. By learning from large amounts of data, deep learning models provide effective tools for chemical production, improve production efficiency, product quality and safety, and also promote innovation and sustainable development of chemical engineering. The widespread application of this technology has brought smarter and more efficient production and management methods to the chemical industry.

[0006] In this application, a method and device for automatic detection of PTFE emulsion paraffin separation based on Vision-Transformer and reinforcement learning are proposed for the first time. The method aims to use deep learning methods to automatically monitor the liquid state of PTFE emulsion paraffin separation equipment and issue an alarm in time when various abnormal states are detected, so as to realize the automation and intelligence of PTFE emulsion industrial production paraffin separation engineering. Summary of the invention

[0007] The purpose of the present invention is to provide a PTFE emulsion paraffin separation automatic detection method and device based on Vision-Transformer and reinforcement learning in view of the deficiencies in the prior art.

[0008] The objective of the present invention is achieved through the following technical solutions: The first aspect of the embodiment of the present invention provides a PTFE emulsion paraffin separation automatic detection method based on Vision-Transformer and reinforcement learning, comprising the following steps:

[0009] (1) Recording videos of the PTFE emulsion paraffin separation process from different perspectives, collecting images from the videos at a collection rate, and adding image category labels to them; preprocessing the collected images, and randomly dividing the preprocessed images into a training set and a test set according to a certain ratio;

[0010] (2) Building a PatchRLNet model for PTFE emulsion paraffin separation detection based on Vision-Transformer and reinforcement learning;

[0011] (3) Use the training set to iteratively train the PatchRLNet model. During the training process, adjust the parameters of the PatchRLNet model based on the cross entropy loss function to obtain the trained PatchRLNet model;

[0012] (4) Input the images in the test set into the trained PatchRLNet model to obtain the predicted image category.

[0013] Furthermore, the image category labels include occlusion, paraffin, emulsion, and not working.

[0014] Furthermore, the preprocessing of the collected images specifically includes:

[0015] The collected images are resized to a standard size of 224*224; oversampling is performed on samples of categories with a small number; and data augmentation methods are used to perform random cropping, random rotation, random noise, random erasing, random brightness, and random contrast operations on the images.

[0016] Furthermore, the PatchRLNet model includes a reinforcement learning model and a Vision-Transformer model, the reinforcement learning model includes a weight generator, and the Vision-Transformer model includes an Embedding module, a Vision-Transformer encoder and a classifier; wherein the weight generator includes a convolution layer and a pooling layer; the Embedding module includes a linear mapping layer, a position embedding layer and a category embedding layer; the Vision-Transformer encoder includes a plurality of consecutive Vision-Transformer encoding blocks, each of which includes a multi-head attention mechanism, a multi-layer perceptron block and a regularization layer in sequence, the multi-head attention mechanism includes a regularization layer and a multi-head self-attention layer, and the multi-layer perceptron block includes a linear transformation layer and a GeLU activation function; the classifier includes a fully connected layer and a ReLU activation function.

[0017] Furthermore, the processing flow of the PatchRLNet model specifically includes:

[0018] The preprocessed video image is divided and converted into an initial image sequence as the input of the PatchRLNet model. First, a weight matrix is ​​generated by the weight generator of the reinforcement learning model, in which each weight represents the attention of the PatchRLNet model to the corresponding patch in the Embedding module; the weight matrix is ​​multiplied by the corresponding patch sequence and then added and fused with the corresponding patch sequence to obtain the first image sequence as the input of the Vision-Transformer model;

[0019] The first image sequence passes through the linear mapping layer, position embedding layer and category embedding layer of the Embedding module in sequence to obtain the first image feature sequence; the first image feature sequence is then sent to the Vision-Transformer encoding block of the Vision-Transformer encoder, and first passes through the regularization layer and multi-head self-attention layer of the multi-head attention mechanism in sequence to obtain the second image feature sequence; the second image feature sequence is added and fused with the first image feature sequence to obtain a fused second image feature sequence; the fused second image feature sequence is then sent to the multi-layer perceptron block, and passes through the linear transformation layer and the GeLU activation function in sequence to obtain the third image feature sequence; the third image feature sequence is summed and fused to obtain the fourth image feature sequence; the fourth image feature sequence is then passed through the regularization layer to obtain the fifth image feature sequence;

[0020] The fifth image feature sequence output by the last Vision-Transformer encoding block is sent to the classifier, and passes through the fully connected layer and ReLU activation function in sequence to obtain the score corresponding to each image category. The image category corresponding to the maximum score is selected as the image category predicted by the PatchRLNet model.

[0021] Furthermore, the PatchRLNet model is iteratively trained using the training set, and the parameters of the PatchRLNet model are adjusted based on the cross entropy loss function during the training process to obtain a trained PatchRLNet model, specifically including:

[0022] The images in the training set are divided and converted into initial image sequences, which are input into the PatchRLNet model. First, a weight matrix is ​​generated by the weight generator of the reinforcement learning model. The weight matrix is ​​multiplied by the corresponding patch sequence and then added and fused with the corresponding patch sequence to obtain the first image sequence, which is used as the input of the Vision-Transformer model. The first image sequence is input into the Vision-Transformer model to obtain the predicted probability of the image category. The cross entropy loss function value is calculated according to the real image category label and the predicted probability of the image category in the training set. The parameters of the PatchRLNet model are optimized and adjusted by the reverse stochastic gradient descent method with the minimization of the cross entropy loss function value as the optimization goal. The above iterative training process is repeated until the preset number of iterative training times is reached or the cross entropy loss function value converges, and the trained PatchRLNet model is obtained.

[0023] Among them, when training the reinforcement learning model, the PPO-C strategy is used to train the weight generator and the corresponding evaluation network, and the reverse stochastic gradient descent method is used to optimize the alternative objective function, which is determined by the similarity constraint.

[0024] Furthermore, the expression of the cross entropy loss function is:

[0025]

[0026] Where, L CE represents the cross entropy loss function, y represents the true image category label, The predicted probability of the image category output by the PatchRLNet model;

[0027] The expression of the similarity constraint is:

[0028]

[0029] In the formula, is a similarity constraint, a represents the possible actions that the agent may take, s represents the state corresponding to the current environment, t represents the corresponding time step, θ represents the strategy currently selected by the agent, and θ σ represents the strategy selected by the agent in the previous step, a t represents the action chosen by the agent at time step t, s t represents the state of the agent at time step t, p θ (a t ||s t ) indicates that the agent is in the current strategy according to the state s t Select action a t The probability of Indicates that the agent is based on the state s under the previous strategy t Select action a t The probability of is the strategy ratio, is the advantage function and ε is a hyperparameter that represents the maximum allowed change in the policy ratio.

[0030] Furthermore, the agent is a weight generator for generating a weight matrix, the environment is a combination of a Vision-Transformer encoder and a classifier, the action is the weight matrix, the state is an input image of the Vision-Transformer model, and the reward is the output result of the classifier.

[0031] The second aspect of an embodiment of the present invention provides an automatic detection device for PTFE emulsion paraffin separation based on Vision-Transformer and reinforcement learning, comprising one or more processors and a memory, wherein the memory is coupled to the processor; wherein the memory is used to store program data, and the processor is used to execute the program data to realize the above-mentioned automatic detection method for PTFE emulsion paraffin separation based on Vision-Transformer and reinforcement learning.

[0032] A third aspect of an embodiment of the present invention provides a computer-readable storage medium having a program stored thereon, which, when executed by a processor, is used to implement the above-mentioned automatic detection method for PTFE emulsion paraffin separation based on Vision-Transformer and reinforcement learning.

[0033] Compared with the prior art, the present invention has the following beneficial effects:

[0034] (1) The present invention can highly accurately detect the liquid state and various abnormal events in the process of PTFE emulsion paraffin separation, significantly improve the efficiency and product quality of PTFE emulsion production, provide a reliable solution for automatic detection and abnormality handling in industrial production, and promote the automation level and production intelligence in related fields;

[0035] (2) The present invention can automatically and intelligently perform automatic detection of PTFE emulsion paraffin separation, which can not only improve the accuracy of detection, but also reduce the operating burden of the staff, thereby more effectively ensuring the safety of the working environment and the health of the staff;

[0036] (3) This paper proposes for the first time an innovative key feature search method based on Vision-Transformer and reinforcement learning, named PatchRLNet; through the interaction between the agent and the environment, reinforcement learning can formulate the best strategy based on the feedback of the environment; taking the key feature selection process as the benchmark of the reward, and taking the combination of Vision-Transformer encoder and classifier as the environment, a reinforcement learning framework with key feature extraction as the optimization goal is constructed, which can automatically select the key features for automatic detection of PTFE emulsion paraffin separation;

[0037] (4) The present invention combines the advantages of Vision-Transformer and reinforcement learning, and can not only extract the global features of PTFE emulsion paraffin separation detection by modeling the long-distance relationship of key features, but also generate adaptive attention for different patches in the Vision-Transformer embedding layer; by paying attention to different patches, it can avoid the impact of background and noise on the model in a complex environment, and stabilize the training dynamics of the model, thereby improving the training efficiency of the model; it provides a more effective solution for PTFE emulsion paraffin separation detection;

[0038] (5) The present invention can automatically detect the liquid state during the separation process of PTFE emulsion paraffin by further developing corresponding devices, thereby improving the intelligence and automation level of related fields. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 It is a framework diagram of the PatchRLNet model in the present invention;

[0040] Figure 2 It is a flow chart of the multi-modal PTFE emulsion paraffin separation automatic detection method of the present invention;

[0041] Figure 3 It is a schematic diagram of engineering control for automatic detection of PTFE emulsion paraffin separation in the present invention;

[0042] Figure 4 It is a trend diagram of the loss function change during the PatchRLNet training process in the present invention;

[0043] Figure 5 is the PatchRLNet class activation map in the present invention;

[0044] Figure 6 It is a structural schematic diagram of the automatic detection device for PTFE emulsion paraffin separation based on Vision-Transformer and reinforcement learning of the present invention. DETAILED DESCRIPTION

[0045] Here, exemplary embodiments will be described in detail, and examples thereof are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. Obviously, the drawings used in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can also be obtained based on these drawings without paying creative labor. The implementation methods described in the following exemplary embodiments do not represent all implementation methods consistent with the present invention.

[0046] The automatic detection method for PTFE emulsion paraffin separation based on Vision-Transformer and reinforcement learning of the present invention specifically comprises the following steps:

[0047] (1) Record the video of the PTFE emulsion paraffin separation process from different perspectives, collect images from the video at the acquisition rate, and add image category labels to them; preprocess the collected images, and randomly divide the preprocessed images into training sets and test sets according to proportion. Among them, the image category labels include occlusion, paraffin, emulsion, and unworked.

[0048] Furthermore, the video of the PTFE emulsion paraffin separation process is recorded from different perspectives, images are collected from the video according to the acquisition rate, and image category labels are added to them, specifically including: using the research data of the real production process of a company's fluoropolymer division, the research data covers the real production process of the PTFE emulsion paraffin separation equipment of the PTFE production unit of the fluoropolymer division during a certain period of time. Two Hikvision MV-CU050-60GM 5 million pixel industrial array cameras were used to fully record the entire process of PTFE emulsion paraffin separation from two different perspectives. The lens used was ZX-SF0820C, which is an 8mm fixed-focus industrial vision lens. A total of 463 videos from two perspectives were collected. The collected video format is single-channel AVI, the resolution is 2592*1944, and the acquisition rate is 30 frames per second. Collecting images from the video at an acquisition rate of 30 frames per second can ensure that the collected image data has good reliability. In order to ensure the continuous and stable operation of the PTFE emulsion paraffin separation detection system in industrial scenarios, the image category labels include occlusion, paraffin, emulsion, and non-working. Among them, occlusion means that the camera is blocked by staff or other objects, causing the paraffin pipeline to be completely covered. The system will trigger an alarm mechanism when it detects that this state exists for a long time. All image category labels are marked by four staff members with more than three years of work experience and reviewed by two staff members with more than five years of work experience. In the end, 10,548 occluded images, 49,030 paraffin images, 77,134 emulsion images, and 99,418 non-working images were obtained from two perspectives. The richness and diversity of this dataset provides a solid data foundation and support for the relevant research in this application.

[0049] In this embodiment, the collected images are preprocessed, specifically including: adjusting the collected images to a standard size of 224*224, which can improve the processing speed of the PatchRLNet model and meet the needs of real scenes; oversampling a small number of category samples can solve the long-tail problem caused by the imbalance of sample sizes in different states, balance the number of samples in different states in the training data, help reduce the impact of data imbalance on the training of the PatchRLNet model, and ensure that the PatchRLNet model can effectively learn various states; in order to avoid over-fitting of the PatchRLNet model on the training data and the degradation of the generalization performance on unseen data due to oversampling, the data enhancement method is used to perform random cropping, random rotation, random noise, random erasing, random brightness and random contrast operations on the images, which can expand the diversity of training data, improve the generalization performance of the PatchRLNet model, and effectively improve the performance of the PatchRLNet model, so that it performs better when dealing with real complex scenes.

[0050] Specifically, since the paraffin emulsion industrial scene has complex noise, but the target is relatively clear around the pipe, random cropping can enable the PatchRLNet model to learn the invariance of the target position and improve the robustness of the PatchRLNet model to different target positions. Considering that the camera may be touched in real production scenes, causing the angle of the captured image to change, randomly rotating the image helps the PatchRLNet model learn the features of different angles and increase the robustness of the PatchRLNet model to rotation changes. In real production scenes, the temperature is high and solid condensation of PTFE may appear on the camera. Introducing random noise in the image can enable the PatchRLNet model to handle these noises and interferences more robustly. Although long-term complete occlusion will trigger the alarm mechanism, for unavoidable partial short-term occlusion, random erasure is used to simulate possible occlusion or loss, helping the PatchRLNet model learn robustness to partial information loss and increase the PatchRLNet model's ability to handle incomplete information. Finally, in order to make the PatchRLNet model adapt to complex environments under different lighting conditions, random brightness and random contrast are introduced to simulate real scenes.

[0051] Furthermore, the preprocessed images are randomly divided into training sets and test sets according to a ratio of 7:3, for example; of course, they can also be randomly divided into training sets and test sets according to other ratios, such as 8:2, etc.; the training set and the test set contain images and their corresponding image category labels.

[0052] (2) Based on Vision-Transformer and reinforcement learning, a PatchRLNet model for PTFE emulsion paraffin separation detection was constructed.

[0053] In the automatic detection method for PTFE emulsion paraffin separation proposed in the present invention, the Vision-Transformer model mainly includes three key parts: image division and embedding, position encoding and category embedding, and Vision-Transformer encoder, which together constitute the core structure of the model. First, the image division and embedding divides the input image into a set of non-overlapping square tiles, and embeds these tiles into a low-dimensional space to create an initial representation of the image, aiming to extract the local image features of the target, providing a basis for subsequent processes. Secondly, the Vision-Transformer model introduces position encoding to establish a positional relationship for image feature embedding, which helps the Vision-Transformer model understand the relative positions between different image divisions, so as to better capture the global contextual relationship. The introduction of position encoding enhances the Vision-Transformer model's perception of the spatial structure of image information; then, the image category label is encoded through category embedding and embedded into the image feature sequence obtained after position encoding, and the image feature sequence after category embedding is obtained. Finally, after image segmentation, embedding, position encoding, and category embedding, the image feature sequence is input into a Vision-Transformer encoder composed of multiple consecutive Vision-Transformer encoding blocks, which gradually extracts high-level semantic features of the target at different scales and levels; in this process, the self-attention sublayer of the Vision-Transformer encoding block uses a multi-head self-attention mechanism to calculate the relevance of patches at different positions to capture the global and local relationship between features. This enables the PatchRLNet model to learn and represent the semantic information of the input image more effectively.

[0054] In addition, considering that there may be multiple interference factors such as insufficient light, obstacle occlusion, and background clutter in the actual production process of the factory, these interference factors may cause the Vision-Transformer model to face the problem of too high feature dimension and too large complexity in the feature extraction process, making it difficult to effectively extract and analyze key information. In order to solve this problem, unlike the previous direct serial connection of each patch in the Embedding layer, reinforcement learning is introduced to provide an interpretable attention for each patch in the encoding sequence. Reinforcement learning will provide a weight for each patch in the encoding sequence, which represents the attention of the PatchRLNet model. The higher the attention, the more critical the features contained in the image. The attention can be obtained by using reinforcement learning on the preprocessed image. In this way, the Vision-Transformer model can pay more attention to key features and ignore the background environment and noise, thereby improving the feature extraction efficiency of the PatchRLNet model in complex scenes. In this process, a reinforcement learning framework for the input of the PatchRLNet model is integrated into the Vision-Transformer model. By dynamically adjusting the attention to different patches, the PatchRLNet model can improve its sensitivity to key information, thereby better coping with interference such as background environment and noise. This strategy of integrating reinforcement learning makes the Vision-Transformer model more adaptable and robust, thereby improving the accuracy and stability of automatic detection of PTFE emulsion paraffin separation.

[0055] In order to more comprehensively describe the PatchRLNet model constructed in this embodiment, the method described in the present invention will be introduced in two parts: First, focus on the application of reinforcement learning in enhancing key patch features. In this part, by introducing the reinforcement learning framework, an interpretable attention is provided for each patch of the PatchRLNet model, so that the PatchRLNet model can focus more on key features, thereby improving the efficiency of feature extraction in complex environments. This innovative method helps to solve a variety of problems that may be encountered in real production processes such as insufficient light, obstacle occlusion and background interference. Next, the application of the PatchRLNet model in PTFE emulsion and paraffin separation is introduced in detail. The PatchRLNet model is based on the Vision-Transformer model, and through the combination of key components such as image division and embedding, position encoding, category embedding and Vision-Transformer encoder, the global and local relations of target features are efficiently extracted. At the same time, the strategy of reinforcement learning is integrated to make the PatchRLNet model more adaptable and robust, thereby improving the accuracy and stability of automatic detection of PTFE emulsion and paraffin separation. These two parts together constitute a comprehensive description of the PatchRLNet model.

[0056] In this embodiment, the PatchRLNet model includes: a reinforcement learning model and a Vision-Transformer model, the reinforcement learning model includes a weight generator; the Vision-Transformer model includes an Embedding module, a Vision-Transformer encoder and a classifier; wherein the weight generator includes a convolution layer and a pooling layer; the Embedding module includes a linear mapping layer, a position embedding layer and a category embedding layer; the Vision-Transformer encoder includes a plurality of consecutive Vision-Transformer encoding blocks, each Vision-Transformer encoding block includes a multi-head attention mechanism, a multi-layer perceptron block and a regularization layer in sequence, the multi-head attention mechanism includes a regularization layer and a multi-head self-attention layer, and the multi-layer perceptron block includes a linear transformation layer and a GeLU activation function; the classifier includes a fully connected layer and a ReLU activation function.

[0057] It should be understood that adding the reinforcement learning model as a component to the Patch embedding process of the Vision-Transformer model can help the PatchRLNet model better focus on key features.

[0058] In this embodiment, the processing flow of the PatchRLNet model is as follows: Figure 1As shown in the figure, the preprocessed video image is divided and converted into an initial image sequence as the input of the PatchRLNet model. First, it passes through the weight generator Generator (G) of the reinforcement learning model to generate a weight matrix, in which each weight represents the attention of the PatchRLNet model to the corresponding patch in the Embedding module; the weight matrix is ​​multiplied by the corresponding patch sequence and then added and fused with the corresponding patch sequence to obtain the first image sequence as the input of the Vision-Transformer model. The first image sequence passes through the linear mapping layer, position embedding layer and category embedding layer of the Embedding module in sequence to obtain the first image feature sequence; the first image feature sequence is then sent to the Vision-Transformer encoding block of the Vision-Transformer encoder, and first passes through the regularization layer and multi-head self-attention layer of the multi-head attention mechanism in sequence to obtain the second image feature sequence; the second image feature sequence is added and fused with the first image feature sequence to obtain the fused second image feature sequence; the fused second image feature sequence is then sent to the multi-layer perceptron block, and passes through the linear transformation layer and GeLU activation function in sequence to obtain the third image feature sequence; the third image feature sequence is fused to obtain the fourth image feature sequence; the fourth image feature sequence is then passed through the regularization layer to obtain the fifth image feature sequence. The fifth image feature sequence output by the last Vision-Transformer encoding block is sent to the classifier, and passes through the fully connected layer and ReLU activation function in sequence to obtain the score corresponding to each image category, and the image category corresponding to the maximum score is selected as the image category predicted by the PatchRLNet model.

[0059] Specifically, the preprocessed video image is represented as X image ∈R c×h×w , whose shape is h×w, h and w represent the height and width of the image respectively, and the number of channels is c; since the expected input of the Vision-Transformer encoder is a shape of (x1, x2, …, x n ), so the input video image is divided into n 2 patches and convert them into the initial image sequence X = (x 11 ,x 12 ,…,x 1n ,…,x nn ),in The initial image sequence X is the input of the PatchRLNet model. It should be understood that each image will be divided into n patches when entering the Vision-Transformer model. Through reinforcement learning, a weight matrix W representing the degree of attention to each patch is obtained. The weight matrix W reflects the importance of each patch when the PatchRLNet model processes the input image, which in turn affects the extraction and understanding of the image features by the PatchRLNet model. This weight matrix is ​​obtained through model learning to better adapt to different tasks and the characteristics of the input image. Its acquisition method is expressed as:

[0060] W=G(state)

[0061] In the formula, state is the input, G is the weight generator, and W∈R n×n For the initial image sequence X = (x 11 ,x 12 ,…,x 1n ,…,x nn ), and then use reinforcement learning to get the first image sequence X * , expressed as:

[0062]

[0063] In the formula, w ij represents the element in the i-th row and j-th column of the weight matrix W, which is between -1 and 1; X ij Denotes the first image sequence X * When w ij = -1, the value of the element in the patch sequence will be set to 0, and the content of this part of the patch will be regarded as background or noise and discarded; when w ij = 1, the value of the elements in the patch sequence will be strengthened. At this time, the content of this part of the patch is regarded as the key feature and the features of this part are extracted and analyzed to complete the selection of key features. This weight matrix adjustment mechanism allows the PatchRLNet model to selectively focus on specific areas in the image, thereby more flexibly adapting to different tasks and scenarios. In this way, the PatchRLNet model can more accurately distinguish and utilize important visual information when processing input images.

[0064] Studies have shown that the first image sequence X * =(X 11 ,X 12 ,…,X 1n ,…,X nn) as the input of the Vision-Transformer model can effectively reduce the computational complexity of the PatchRLNet model. However, since each patch in the input sequence is processed in parallel, unlike the recurrent neural network (RNN) input, there is a sequential relationship. Therefore, it is necessary to add position embedding to each dimension of the first image sequence to obtain an optimized image sequence; the first image sequence passes through the linear mapping layer and position embedding layer of the Embedding module in turn to obtain the image sequence Z after embedding the position information, which is expressed as:

[0065] Z=(X1+PE1,X2+PE2,…,X m +PE m )

[0066] Where, PE k =(PE(pos k ,0),PE(pos k ,1),…,PE(pos k ,d model -1)), k∈(1,2,…,n 2 ),pos k Indicates the patch at the kth position, PE k represents the kth position information, d model Represents vector PE k The dimension of m represents the position number of PatchX and vector PE. The position information is expressed as:

[0067]

[0068] It can be seen that for a certain dimension of the position information vector, it can be expressed as a linear combination with the position, that is, the position vector contains relative position information. Therefore, the Vision-Transformer model can capture the relationship between global and local features through the self-attention mechanism when processing image blocks. The image sequence Z after embedding the position information is then encoded through the category embedding layer and embedded into the image sequence Z obtained after position encoding, obtaining the first image feature sequence Z * .

[0069] The first image feature sequence Z after embedding position information and category information *The input is sent to the Vision-Transformer encoder, which consists of multiple continuously connected Vision-Transformer encoding blocks. These Vision-Transformer encoding blocks gradually extract the high-level semantic features of the input image feature sequence through a combination of multi-head self-attention mechanism and multi-layer perceptron blocks. In this process, the self-attention mechanism enables the PatchRLNet model to dynamically focus on image patches at different positions, thereby capturing the complex relationship between global and local features in the image.

[0070] By embedding the first image feature sequence Z with position information and category information * The Vision-Transformer encoding block is sent to the PatchRLNet model, so that the PatchRLNet model can better understand the overall structure and local details of the image and realize effective feature extraction of the input image. The entire process provides a rich and abstract image representation for the PatchRLNet model through the organic combination of the Vision-Transformer encoding block, providing strong support for the execution of subsequent tasks. At this stage, richer and more comprehensive image information can be obtained, which helps the PatchRLNet model to understand and process the input data more accurately. At this time, the first image feature sequence Z * Send it to the multi-head attention mechanism, and then go through the regularization layer and the multi-head self-attention layer to get:

[0071] Z′=MSA(LN(Z * ))+Z *

[0072] In the formula, LN represents the regularization layer; MSA represents the multi-head self-attention layer; Z′ is the fused second image feature sequence, which is the output of the multi-head attention mechanism. * Mapped to three learnable weight matrices w Q , w K , w V , so we can get the corresponding variable Q = Xw Q , K = Xw K and V=Xw V On this basis, Q, K, and V are evenly divided into h parts according to the number of heads and put into h self-attentions respectively to get the final result:

[0073]

[0074] Among them, d k is the dimension of K.

[0075] The multi-layer perceptron block is mainly composed of two linear transformation layers and a GeLU activation function. The fused second image feature sequence Z′ passes through the multi-layer perceptron block and obtains:

[0076] Z″=MLP(Z′)+Z′

[0077] Where MLP represents the multi-layer perceptron block, and Z″ is the fourth image feature sequence. Here, MLP performs linear transformation and GeLU activation on the sequence Z′ embedded with position information, and then adds it to the original sequence Z′. This operation enables the PatchRLNet model to further learn and extract high-level semantic features and make more accurate predictions for the final classification task. Through this organic combination, the Vision-Transformer model can make full use of the self-attention mechanism and multi-layer perceptron to capture, learn and integrate the global and local features of the input image.

[0078] Then the fourth image feature sequence is passed through the regularization layer to obtain the fifth image feature sequence Y, which is expressed as:

[0079] Y=LN(Z″)

[0080] In each Vision-Transformer encoding block, multiple multi-head attention sub-layers and multi-layer perceptron blocks are used to extract features of the input image sequence. Finally, the class token extracted from the last Vision-Transformer encoding block is used as the input of the classifier, that is, the output of the last Vision-Transformer encoding block is used as the input of the classifier to predict the possible scores of each image category. Throughout the process, the PatchRLNet model extracts key features from the input image through the synergy of the weight generator and the Vision-Transformer encoder, and predicts the image category through the classifier. This end-to-end architecture enables the system to effectively learn and apply visual information, providing a solid foundation for the prediction of image category scores.

[0081] Finally, the classifier includes a fully connected layer and a ReLU activation function, using the category token Y(0), which is the first element X of the fifth image feature sequence Y class Instead of using the extracted image features as the input of the classifier, the fifth image feature sequence Y passes through the fully connected layer and the ReLU activation function in sequence to obtain the score corresponding to each image category, and the image category corresponding to the maximum score is selected as the image category predicted by the PatchRLNet model.

[0082] (3) Use the training set to iteratively train the PatchRLNet model. During the training process, adjust the parameters of the PatchRLNet model based on the cross entropy loss function to obtain the trained PatchRLNet model.

[0083] Specifically, the images in the training set are divided and converted into initial image sequences and input into the PatchRLNet model. First, the weight matrix is ​​generated by the weight generator of the reinforcement learning model. The weight matrix is ​​multiplied by the corresponding patch sequence and then added and fused with the corresponding patch sequence to obtain the first image sequence as the input of the Vision-Transformer model. The first image sequence is input into the Vision-Transformer model to obtain the predicted probability of the image category; the cross entropy loss function value is calculated according to the real image category label and the predicted probability of the image category in the training set; the cross entropy loss function value is minimized as the optimization goal, and the parameters of the PatchRLNet model are optimized and adjusted by the reverse stochastic gradient descent method; the above iterative training process is repeated until the preset number of iterative training times is reached or the cross entropy loss function value converges, and the trained PatchRLNet model is obtained. Among them, when training the reinforcement learning model, the PPO-C (Proximal Policy Optimization-Clip) strategy is used to train the weight generator and the corresponding evaluation network, and the reverse stochastic gradient descent method is used to optimize the alternative objective function, which is determined by the similarity constraint.

[0084] It should be understood that in order to ensure that the reinforcement learning framework can generate a suitable weight matrix for the image sequence, the PPO-C strategy is used to train the weight generator and the corresponding evaluation network. PPO is a new type of policy gradient method for reinforcement learning. It samples data by interacting with the reinforcement learning environment and optimizes an alternative objective function using reverse stochastic gradient descent. The PPO strategy introduces similarity constraints to avoid the distance between the output policy and the target policy in importance sampling being too large.

[0085] Furthermore, the expression of the cross entropy loss function is:

[0086]

[0087] Where, L CE represents the cross entropy loss function, y represents the true image category label, The predicted probability of the image category output by the PatchRLNet model. The cross entropy loss function represents the difference between the actual image category label and the predicted probability.

[0088] Furthermore, the similarity constraint is expressed as:

[0089]

[0090] In the formula, is a similarity constraint, a represents the possible actions that the agent may take, s represents the state corresponding to the current environment, t represents the corresponding time step, θ represents the strategy currently selected by the agent, and θ σ represents the strategy selected by the agent in the previous step, a t represents the action chosen by the agent at time step t, s t represents the state of the agent at time step t, p θ (a t ||s t ) indicates that the agent is in the current strategy according to the state s t Select action a t The probability of Indicates that the agent is based on the state s under the previous strategy t Select action a t The probability of is the strategy ratio, is the advantage function and ε is a hyperparameter that represents the maximum allowed change in the policy ratio.

[0091] It should be noted that in reinforcement learning, the agent is the weight generator used to generate the weight matrix, the environment is the combination of the Vision-Transformer encoder and the classifier, the action is the weight matrix, the state is the input image of the Vision-Transformer model, and the reward is the output result of the classifier.

[0092] Furthermore, in Figure 1In the reinforcement learning framework shown, the Vision-Transformer model, the weight generator, and the reinforcement learning strategy are organically combined. The reinforcement learning model includes a weight generator. In reinforcement learning, the weight generator used to generate the weight matrix is ​​regarded as an intelligent agent, which interacts with the environment and selects the best action to maximize the expected reward; the environment is represented by a combination of the Vision-Transformer encoder and the classifier. This innovative reinforcement learning framework design enables the reinforcement learning model to dynamically adjust the weights during learning to more effectively focus on key features and improve performance in complex production environments. Consider a standard reinforcement learning formula, which can be expressed as a tuple<S,A,T,r,π> , where S is the observation space, A is the action space, T is the transition function that generates the next state from the current state-action pair, r is the reward function that evaluates the current behavior, and the goal of the process is to learn a strategy π that maximizes the expected return reward. The combination of the Vision-Transformer encoder and the classifier is regarded as the environment for reinforcement learning, and a weight generator of an Embedding block embedded in the Vision-Transformer model is regarded as an agent. The reinforcement learning process is regarded as the interaction process between the combination of the Vision-Transformer encoder and the classifier and the weight generator. In this setting, the input image of the Vision-Transformer model is regarded as a state, and the weight generator outputs a weight matrix based on the input state and the current environment, and uses it as the action of reinforcement learning to select appropriate key features. The combination of the Vision-Transformer encoder and the classifier feeds back rewards based on the actions, and serves as the basis for updating the weight generator, where the reward is defined as the output of the classifier. Use M=<S,A,T,r,π> To represent the decision-making process of the generator, and use F(θ; Sa) = <θ; Sa; ra> to represent the classification process of the combination of the Vision-Transformer encoder and the classifier. The reward function calculated by the generator is:

[0093] r=r a -benchmark

[0094] Among them, benchmark is a basic standard for reinforcement learning, which is used to provide positive rewards and negative rewards for reinforcement learning. In reinforcement learning, positive rewards are positive feedback for the good behavior of the agent, prompting it to repeat effective strategies, while negative rewards are punishments for bad behaviors, guiding the agent to adjust its strategy to avoid adverse results. Positive rewards guide learning towards the desired goal, while negative rewards help the agent avoid bad strategies, and together they encourage the agent to learn adaptive strategies. The design of reward signals is a key factor affecting the success of reinforcement learning algorithms. It adjusts the balance between exploration and exploitation of the agent and drives it to learn effective behaviors in different environments.

[0095] Other key changes are as follows:

[0096]

[0097] In this scenario, the generator (A) makes further decisions based on the reward and the previous policy π. At the same time, the state is always the input image of the Vision-Transformer model, so the transformation function T remains as an input that is never affected by the action. On the other hand, for the Vision-Transformer model, it is processed by weighting different patches of the image. Let μ be the initial 2D sequence of the input image after partitioning and embedding, and w is the weight distribution generated by the agent. Therefore, it can be expressed as:

[0098] S a =μ×w

[0099] Finally, state S a Together with the position embedding and category information, it is integrated into the Vision-Transformer encoder. In this process, the state S a It is integrated into the Vision-Transformer encoder, taking into account both the position information and the category information of the image. The PatchRLNet model uses the output of the weight generator to focus on individual image patches by assigning attention scores. Ultimately, these scores are multiplied by the weight distribution of specific image patches to amplify or weaken their influence, thereby achieving feature selection and playing a key role.

[0100] In summary, by introducing reinforcement learning in the Embedding block of the Vision-Transformer network, the key feature selection process was successfully implemented, effectively avoiding the interference of the environment and noise. This ensures that the PatchRLNet model can better capture the global features of the target and pay more attention to key features. This mechanism helps to improve the adaptability of the PatchRLNet model to complex environments and noise, making it more robust in various application scenarios. Overall, this strategy introduced by reinforcement learning has injected more powerful feature selection capabilities into the Vision-Transformer model, laying a solid foundation for the successful execution of image classification tasks.

[0101] (4) Input the images in the test set into the trained PatchRLNet model to obtain the predicted image category, thus obtaining the separation detection results of emulsion paraffin.

[0102] In this embodiment, PTFE emulsion paraffin separation automatic detection is performed based on multimodality: In the real PTFE emulsion production scene, there are a lot of environmental background and noise interference, especially potential occlusion, which may seriously affect the detection performance of the PatchRLNet model. In order to avoid this problem, a multimodal mechanism is introduced in the PTFE emulsion paraffin separation automatic detection system to ensure that the PatchRLNet model can continue to operate stably. By collecting video images on both sides of the PTFE emulsion paraffin separation device, the impact of various interferences on the detection of the PatchRLNet model can be effectively reduced, thereby improving the robustness of the PatchRLNet model. At the same time, these two perspectives can also provide more comprehensive information for the PatchRLNet model. Combining information from different perspectives, more data support can be provided for the classification of the PatchRLNet model, thereby improving the detection performance of the PatchRLNet model. This multimodal mechanism enables the PatchRLNet model to more comprehensively understand and explain the complex situation in the environment, and better adapt to various challenges in actual production. By comprehensively utilizing information from different perspectives, the reliability and performance of the PTFE emulsion paraffin separation automatic detection system in complex scenarios are effectively improved.

[0103] like Figure 2As shown in the figure, the process of automatic detection of PTFE emulsion paraffin separation based on multimodality is demonstrated. The image sequences X1 and X2 acquired from two different points are respectively used as the input of two PatchRLNet models, where PatchRLNet model 1 and PatchRLNet model 2 have the same structure and are trained independently. On this basis, the output of the PatchRLNet model is modified and used as different branches of the classifier to achieve the integration of the two. Specifically, the latent representations of X1 and X2 obtained through the backbone structure of PatchRLNet model 1 and PatchRLNet model 2 are added together, and the generated new image category label is input into the classifier to obtain the final result.

[0104] It is easy to understand that Figure 2 As shown, two PatchRLNet models are trained together to realize emulsion paraffin separation detection based on two modalities; of course, three PatchRLNet models can also be trained together to realize emulsion paraffin separation detection based on three modalities.

[0105] On the basis of the PatchRLNet model, by introducing multimodal data, the detection accuracy, stability and robustness of the PTFE emulsion paraffin separation model are further improved, mainly in terms of comprehensive information acquisition, accuracy improvement, strong adaptability and high real-time performance. Images from different perspectives provide more complete information for the model. For PTFE emulsion paraffin separation detection, this means that the PatchRLNet model can comprehensively consider information from different perspectives, thereby improving the accuracy and reliability of detection. Secondly, the application of multiple perspectives can reduce the impact of defects or errors in a single perspective through mutual correction, thereby further improving the accuracy of the detection results. Secondly, the multimodal detection system has strong adaptability and can be applied to detection needs under different environments and conditions. For the separation detection of PTFE emulsion paraffin, it may face changes in temperature, humidity, etc. The multimodal system can better adapt to these changes and ensure the stability of the detection. Finally, the multimodal detection system can process multiple information at the same time to improve the speed and efficiency of detection. In the separation detection of PTFE emulsion paraffin, real-time acquisition of multiple information can make the monitoring process faster and respond to changes in a timely manner.

[0106] In other embodiments, PTFE emulsion paraffin separation detection is achieved through engineering control, and the PatchRLNet model designed for automatic detection of PTFE emulsion paraffin separation is encapsulated as an operational device and applied in the real production process. Its availability and stability in the real production environment are ensured. The application of this system will help improve production efficiency, reduce costs, and ensure quality control in the production process. The operation process of the PTFE emulsion paraffin separation detection system is as follows: Figure 3 shown.

[0107] In the actual PTFE emulsion production process, the lens may be blocked due to the work needs of the on-site staff. In order to avoid continuous alarms caused by short-term blockages, a counting mechanism is set for the blockage. When the output status is displayed as blocked for 90 consecutive times (that is, within 5 seconds) (indicating that the lens is blocked by some unexpected objects), the system will issue an alarm. Otherwise, the counting will be restarted. Similarly, only when it is found that the overflowed liquid is PTFE emulsion within 3 consecutive seconds, the system will issue an alarm to remind the staff to close the valve. These counting mechanisms are set according to actual needs to ensure that the system can respond appropriately when facing various situations that may occur on site. This flexibility allows the system to be adjusted in different application scenarios to meet the needs of specific applications. This intelligent alarm and control mechanism helps to improve the safety and controllability of the production process.

[0108] In the PTFE emulsion engineering control process, statistical analysis of the output results of the PatchRLNet model can provide an in-depth understanding of the current status of PTFE emulsion production. This comprehensive information analysis helps improve the detection performance of the model and avoid errors caused by relying solely on a single image. This innovative engineering control process provides companies with a more comprehensive and reliable means of production monitoring, thereby optimizing the production process and ensuring improved product quality and efficiency.

[0109] Exemplarily, the PyTorch framework is used, and eight GeForce RTX 3080 graphics cards are used to train the PatchRLNet model. The total number of training rounds is 100, the batch size is fixed to 256, and the initial learning rate is 0.1. In the 25th, 50th, and 75th training rounds, the learning rate is reduced and decayed to 0.1 times the original. Such a training setting helps the PatchRLNet model gradually learn the details of specific tasks during training, and improves the sensitivity of the PatchRLNet model to data by adjusting the learning rate. The choice of batch size can effectively balance the training speed and memory requirements. The careful adjustment of this training strategy helps to ensure that the model achieves better convergence and generalization performance during training.

[0110] The detection performance of the PatchRLNet model was deeply verified using the Accuracy, Average Accuracy, and Micro-Average F1 Score indicators to ensure its reliable accuracy and generalization ability. Among them, accuracy is a simple and intuitive performance metric that is commonly used for classification problems. It represents the proportion of samples correctly predicted by the PatchRLNet model to the total number of samples, and its calculation method is as follows:

[0111]

[0112] Accuracy is an evaluation of the overall classification performance. It measures the accuracy of the PatchRLNet model's classification by calculating the correctness of all samples. This metric is intuitive and easy to understand, and provides important information for evaluating the overall performance of the PatchRLNet model in classification tasks. When performing validation, accuracy is used as a basic performance metric to ensure reliable performance in sample classification.

[0113] However, the accuracy is easily affected by the imbalance of sample categories. When the number of samples in a certain state is large but the accuracy is low, while the accuracy of samples in other states is high, the overall accuracy is usually low. Conversely, when the number of samples in a certain state is large and the accuracy is high, while the accuracy of samples in other states is low, the overall accuracy may be high. This shows that using only accuracy cannot fairly measure the performance of the PatchRLNet model under sample imbalance data. On the contrary, the average accuracy is an important performance indicator, which is particularly suitable for evaluating the overall effect of the PatchRLNet model in object detection or information retrieval tasks. Since it is a relative metric rather than an absolute metric, this makes it possible to still evaluate the performance of the model well when the samples are unbalanced. In comparison, the average accuracy is an indicator that comprehensively considers the performance of each category, which can be formalized as:

[0114]

[0115] Among them, Accuracy i is the accuracy of the samples in the ith category.

[0116] The micro-average F1 score is one of the performance evaluation indicators in multi-class classification problems. It calculates the F1 score by comprehensively considering the sum of true positives, false positives, and false negatives for each class. The advantage of the micro-average F1 score is that it treats each class equally and places more emphasis on overall performance. This makes it suitable for multi-class classification problems with an imbalanced class distribution, where some classes may be more important than others. Its mathematical form is:

[0117]

[0118] Among them, total true positives, total false positives, and total false negatives represent the sum of true positives, false positives, and false negatives in all categories, respectively. The micro-averaged F1 score provides an overall measure of the performance of the PatchRLNet model, taking into account the overall effect in dealing with imbalanced categories.

[0119] The results are shown in Tables 1 and 2, which respectively show the comparison between the Vision-Transformer model and the current mainstream convolutional neural network on the PTFE emulsion paraffin separation test queues at two different points. The indicators used include Params, GFlops, mAP and accuracy. Among them, the smaller the Params and GFlops, the smaller the hardware requirements of the model, while the higher the mAP and accuracy, the better the performance of the model. It can be observed that both the traditional convolutional neural network model and the Vision-Transformer model have relatively similar performances in terms of mAP and accuracy, which shows that effective data preprocessing can effectively alleviate the situation of sample imbalance. On the other hand, compared with the traditional convolutional neural network, the Vision-Transformer model can obtain higher accuracy and average accuracy in most cases. This shows that in the detection of PTFE emulsion paraffin separation, extracting more global features can significantly improve the performance of the detection model. On all convolutional neural network models, at least 5.06% and 5.% average accuracy improvements, as well as 4.81% accuracy improvements and 3.91% micro-average F1 score improvements were obtained. At the same time, by comparing the results of VIT-L-16 and VIT-B-16, it can be found that for PTFE emulsion paraffin separation detection, models with too large parameters cannot achieve better results. This is because there are only four classifications in the task and the scene is relatively fixed. When the model parameters are too large, the model may not be well trained. This observation suggests that it is important to choose a model of appropriate size in a specific task to balance performance and computational efficiency.

[0120] Table 1: Performance comparison between Vision-Transformer and traditional convolutional neural network at the first point

[0121] Model Params GFlops Average accuracy Accuracy Micro-average F1 score ResNet152 5.81M 11.60 78.77±3.90 79.85±4.04 79.42±5.02 DensenNet201 18.10M 4.39 80.92±3.84 80.40±3.83 79.78±4.37 DPN131 76.58M 16.17 79.41±3.58 80.56±3.72 79.19±4.49 SE_ResNet152 64.78M 11.39 80.41±3.15 82.50±3.67 79.13±3.95 VIT-L-16 303.31M 59.73 82.34±3.98 84.17±4.43 81.50±3.51 VIT-B-16 85.80M 16.88 85.47±4.09 87.31±5.73 85.65±3.34

[0122] Table 2: Performance comparison between Vision-Transformer and traditional convolutional neural network at the second point

[0123] Model Params GFlops Average accuracy Accuracy Micro-average F1 score ResNet152 5.81M 11.60 73.41±3.42 73.28±4.05 73.59±3.84 DensenNet201 18.10M 4.39 74.12±3.25 74.11±3.66 74.83±3.97 DPN131 76.58M 16.17 74.39±4.18 75.52±3.98 74.96±3.70 SE_ResNet152 64.78M 11.39 76.37±4.23 78.93±4.58 77.12±4.25 VIT-L-16 303.31M 59.73 78.81±4.52 82.03±5.01 80.61±4.54 VIT-B-16 85.80M 16.88 82.15±5.76 83.95±5.22 81.03±4.45

[0124] Traditional convolutional neural networks and Vision-Transformer models fail to achieve sufficient accuracy in PTFE emulsion paraffin separation detection. This is mainly because there are rich environmental backgrounds and noise in actual industrial production scenarios, which causes the model's attention to be distracted to other objects, thus significantly affecting its detection performance. In order to alleviate the impact of environmental background and noise on the model, we introduced a reinforcement learning framework into the embedding layer of the Vision Transformer network. We built a novel model, named PatchRLNet, which aims to limit the model's attention to key area features by strengthening or weakening the weights of image patches. Taking VIT-B-16 as the benchmark model and based on the test queue of PTFE emulsion paraffin separation detection, including the first and second perspectives, we verified the performance of the Vision-Transformer model and the PatchRLNet model. The specific results are shown in Tables 3 and 4.

[0125] Table 3: Performance comparison of the first point Vision-Transformer and PatchRLNet models

[0126] Model Params GFlops Average accuracy Accuracy Micro-average F1 score VIT-B-16 85.80M 16.88 85.47±4.09 87.31±5.73 85.65±3.34 PatchRLNet 85.80M 16.88 98.00±1.04 98.69±1.06 98.71±1.12

[0127] Table 4: Performance comparison of Vision-Transformer and PatchRLNet models at the second point

[0128] Model Params GFlops Average accuracy Accuracy Micro-average F1 score VIT-B-16 85.80M 16.88 82.15±5.76 83.95±5.22 81.03±4.45 PatchRLNet 85.80M 16.88 95.02±2.88 96.73±2.40 96.14±2.08

[0129] With the number of parameters remaining the same, PatchRLNet achieved an average accuracy improvement of 12.53% and 12.87% in the two perspectives, an accuracy improvement of 11.38% and 12.56%, and a micro-average F1 score improvement of 13.06% and 15.11% respectively compared to the original VIT-B-16. In addition, it is worth noting that the stability of the model is significantly improved, which is reflected in the reduction of model accuracy fluctuations. These results verify the potential application of reinforcement learning in key feature selection.

[0130] The cross entropy loss function is used as the criterion for evaluating model performance. During the model training process, the loss curves of the PatchRLNet model and the standard Vision-Transformer model on the training set and the test set are visualized. Figure 4As shown in Figure 2. Using an initial learning rate of 0.1 and applying a learning rate reduction with a decay factor of 0.2 at the 35th and 70th epochs, it can be observed that although the PatchRLNet model is unstable in the initial training dynamics and has a lower test accuracy than the standard Vision-Transformer model, it quickly converges and surpasses the latter's performance (PatchRLNet experienced an instantaneous increase in training loss in the first 10 epochs). This phenomenon can be explained from two aspects. First, the introduction of the reinforcement learning framework requires more time to adjust the model's parameters at the beginning of training to ensure a well-balanced integration of the reinforcement learning framework and the Vision-Transformer network. Second, thanks to the reinforcement learning framework that helps the Vision-Transformer network avoid interference from environmental background and noise, the PatchRLNet model exhibits more stable training dynamics and better resistance to overfitting. In addition, it can be clearly observed that the training and test curves of the PatchRLNet model are smoother and more stable in the later stages of training. The experimental results fully demonstrate the effectiveness and reliability of the method described in this paper, which combines reinforcement learning with Vision-Transformer, not only improving the accuracy of the model, but also stabilizing the training dynamics of the PatchRLNet model. This further confirms the important role of reinforcement learning in key feature selection and provides strong support for the PatchRLNet model in complex environments.

[0131] Class Activation Mapping is a technique that projects the weights of the output layer back to the feature map to visualize the attention on the image. This method can truly reflect the model's attention area. The results of the PatchRLNet model and the Vision-Transformer model on the PTFE emulsion paraffin separation test queue are visualized using class activation mapping, as shown below: Figure 5As shown. In the figure, the darker the color, the higher the model's attention to the area. It can be observed that the PatchRLNet model mainly focuses on the key target areas in the image, such as the outflow point of the PTFE emulsion and the high-temperature paraffin solution, while the Vision-Transformer shows attention in many irrelevant areas. In occluded and idle states, the PatchRLNet model shows almost the same attention, such as attention to the edges of the solidified PTFE emulsion and the paraffin reservoir, indicating its continuous attention to key features. In contrast, the focus of Vision-Transformer varies greatly and lacks certain interpretability. These experimental results clearly demonstrate the effectiveness of the PatchRLNet model proposed in this study in selecting key features and reducing background environment and noise interference, thereby meeting the needs of high-precision pattern recognition in complex scenes.

[0132] Combined with multimodal data, the performance of the proposed PTFE emulsion paraffin separation automatic detection system was verified on the merged PTFE emulsion paraffin separation detection test set. In the end, an accuracy of 99.12% and an average accuracy of 99.46% were achieved. In other words, the PatchRLNet model for PTFE emulsion paraffin separation detection can be successfully applied to real industrial production scenarios. Finally, combined with the paraffin separation engineering control of PTFE emulsion, the PTFE emulsion paraffin separation detection model was encapsulated as a system and applied to the real production process of a production base to realize the automatic control of PTFE emulsion paraffin separation. By investigating and counting the results of 7 days of production activities, it can be found that within a week, the system can accurately detect all abnormal situations and issue alarms.

[0133] In summary, the present invention applies deep learning technology to the automatic detection task of paraffin separation of PTFE emulsion for the first time, and innovatively proposes a method and device for automatic detection of paraffin separation of PTFE emulsion based on Vision-Transformer and reinforcement learning, realizing automation and intelligence in the field of paraffin separation of PTFE emulsion.

[0134] First, the present invention uses Vision-Transformer as the infrastructure of the PatchRLNet model. Compared with traditional convolutional neural networks, Vision-Transformer has its unique advantages. It introduces a self-attention mechanism, which enables the PatchRLNet model to dynamically focus on image patches at different positions, thereby capturing image relationships globally and avoiding the local receptive field limitations in traditional convolutional neural networks. Vision-Transformer is more flexible than the sliding window operation of convolutional neural networks by dividing the input image into multiple patches and processing them in parallel. In addition, Vision-Transformer is insensitive to the size of the input image, and maintains the relative position information between image patches through position embedding, which is suitable for images of different sizes. With a smaller number of parameters, Vision-Transformer is more scalable when processing large-scale images and high-resolution images. In addition, the sequence processing idea of ​​Vision-Transformer also makes it suitable for sequence data, such as natural language processing tasks. Overall, Vision-Transformer brings global modeling capabilities and stronger adaptability to image processing tasks through a unique architectural design. In the PTFE emulsion paraffin separation task, Vision-Transformer can capture the global features of the target by modeling the long-range relationships of key features, thereby effectively reducing the impact of environmental and background noise in the complex scene of PTFE emulsion paraffin separation.

[0135] Secondly, by introducing a reinforcement learning framework, the present invention establishes a high correlation between the key feature selection process and the PatchRLNet model input, thereby reducing the tight coupling with the PatchRLNet model parameters. By embedding the reinforcement learning framework in the Embedding block of Vision-Transformer, the PatchRLNet model can focus on the key features of the target more accurately while ignoring the surrounding environment and background noise. This PatchRLNet model also has an adaptive key feature selection mechanism to ensure that the PatchRLNet model can flexibly adapt to changes in input data. Through this innovation, the present invention can improve the performance of Vision-Transformer in complex scenarios, enabling it to train more efficiently and better cope with images with a lot of noise.

[0136] See also Figure 6An embodiment of the present invention provides an automatic detection device for PTFE emulsion paraffin separation based on Vision-Transformer and reinforcement learning, comprising one or more processors and a memory, wherein the memory is coupled to the processor; wherein the memory is used to store program data, and the processor is used to execute the program data to implement the automatic detection method for PTFE emulsion paraffin separation based on Vision-Transformer and reinforcement learning in the above embodiment.

[0137] The embodiment of the automatic detection device for PTFE emulsion paraffin separation based on Vision-Transformer and reinforcement learning of the present invention can be applied to any device with data processing capability, and the device with data processing capability can be a device or apparatus such as a computer. The device embodiment can be implemented through software, or through hardware or a combination of software and hardware. Taking software implementation as an example, as a device in a logical sense, it is formed by the processor of any device with data processing capability in which it is located reading the corresponding computer program instructions in the non-volatile memory into the internal memory for execution. From the hardware level, if Figure 6 As shown, it is a hardware structure diagram of any device with data processing capability where the automatic detection device for PTFE emulsion paraffin separation based on Vision-Transformer and reinforcement learning of the present invention is located, except Figure 6 In addition to the processor, memory, network interface, and non-volatile memory shown, any device with data processing capabilities in which the apparatus in the embodiments is located may also include other hardware, generally based on the actual functions of the device with data processing capabilities, which will not be described in detail.

[0138] The implementation process of the functions and effects of each unit in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.

[0139] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of the present invention. Ordinary technicians in this field can understand and implement it without paying creative work.

[0140] An embodiment of the present invention also provides a computer-readable storage medium having a program stored thereon. When the program is executed by a processor, the automatic detection method for PTFE emulsion paraffin separation based on Vision-Transformer and reinforcement learning in the above embodiment is implemented.

[0141] The computer-readable storage medium may be an internal storage unit of any device with data processing capability described in any of the aforementioned embodiments, such as a hard disk or a memory. The computer-readable storage medium may also be any device with data processing capability, such as a plug-in hard disk, a smart media card (SMC), an SD card, a flash card, etc. equipped on the device. Furthermore, the computer-readable storage medium may also include both an internal storage unit of any device with data processing capability and an external storage device. The computer-readable storage medium is used to store the computer program and other programs and data required by any device with data processing capability, and may also be used to temporarily store data that has been output or is to be output.

[0142] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A PTFE emulsion paraffin separation automatic detection method based on Vision-Transformer and reinforcement learning, characterized in that: The following steps are involved: (1) Recording videos of the PTFE emulsion paraffin separation process from different perspectives, collecting images from the videos at a collection rate, and adding image category labels to them; preprocessing the collected images, and randomly dividing the preprocessed images into a training set and a test set according to a certain ratio; (2) Building a PatchRLNet model for PTFE emulsion paraffin separation detection based on Vision-Transformer and reinforcement learning; (3) Use the training set to iteratively train the PatchRLNet model. During the training process, adjust the parameters of the PatchRLNet model based on the cross entropy loss function to obtain the trained PatchRLNet model; (4) Input the images in the test set into the trained PatchRLNet model to obtain the predicted image category.

2. The automatic detection method for PTFE emulsion paraffin separation based on Vision-Transformer and reinforcement learning according to claim 1, characterized in that, The image category labels include occluded, paraffin, emulsion, and unworked.

3. The PTFE emulsion paraffin separation automatic detection method based on Vision-Transformer and reinforcement learning according to claim 1, characterized in that, The preprocessing of the collected images specifically includes: The collected images are resized to a standard size of 224*224; oversampling is performed on samples of categories with a small number; and data augmentation methods are used to perform random cropping, random rotation, random noise, random erasing, random brightness, and random contrast operations on the images.

4. The automatic detection method for PTFE emulsion paraffin separation based on Vision-Transformer and reinforcement learning according to claim 1, characterized in that, The PatchRLNet model includes a reinforcement learning model and a Vision-Transformer model, the reinforcement learning model includes a weight generator, and the Vision-Transformer model includes an Embedding module, a Vision-Transformer encoder and a classifier; wherein the weight generator includes a convolution layer and a pooling layer; the Embedding module includes a linear mapping layer, a position embedding layer and a category embedding layer; the Vision-Transformer encoder includes a plurality of consecutive Vision-Transformer encoding blocks, each of which includes a multi-head attention mechanism, a multi-layer perceptron block and a regularization layer in sequence, the multi-head attention mechanism includes a regularization layer and a multi-head self-attention layer, the multi-layer perceptron block includes a linear transformation layer and a GeLU activation function; the classifier includes a fully connected layer and a ReLU activation function.

5. The automatic detection method for PTFE emulsion paraffin separation based on Vision-Transformer and reinforcement learning according to claim 4, characterized in that, The processing flow of the PatchRLNet model specifically includes: The preprocessed video image is divided and converted into an initial image sequence as the input of the PatchRLNet model. First, a weight matrix is ​​generated by the weight generator of the reinforcement learning model, in which each weight represents the attention of the PatchRLNet model to the corresponding patch in the Embedding module; the weight matrix is ​​multiplied by the corresponding patch sequence and then added and fused with the corresponding patch sequence to obtain the first image sequence as the input of the Vision-Transformer model; The first image sequence passes through the linear mapping layer, position embedding layer and category embedding layer of the Embedding module in sequence to obtain the first image feature sequence; the first image feature sequence is then sent to the Vision-Transformer encoding block of the Vision-Transformer encoder, and first passes through the regularization layer and multi-head self-attention layer of the multi-head attention mechanism in sequence to obtain the second image feature sequence; the second image feature sequence is added and fused with the first image feature sequence to obtain a fused second image feature sequence; the fused second image feature sequence is then sent to the multi-layer perceptron block, and passes through the linear transformation layer and the GeLU activation function in sequence to obtain the third image feature sequence; the third image feature sequence is summed and fused to obtain the fourth image feature sequence; the fourth image feature sequence is then passed through the regularization layer to obtain the fifth image feature sequence; The fifth image feature sequence output by the last Vision-Transformer encoding block is sent to the classifier, and passes through the fully connected layer and ReLU activation function in sequence to obtain the score corresponding to each image category. The image category corresponding to the maximum score is selected as the image category predicted by the PatchRLNet model.

6. The automatic detection method for PTFE emulsion paraffin separation based on Vision-Transformer and reinforcement learning according to claim 1, characterized in that: The PatchRLNet model is iteratively trained using the training set, and the parameters of the PatchRLNet model are adjusted based on the cross entropy loss function during the training process to obtain a trained PatchRLNet model, specifically including: The images in the training set are divided and converted into initial image sequences, which are input into the PatchRLNet model. First, a weight matrix is ​​generated by the weight generator of the reinforcement learning model. The weight matrix is ​​multiplied by the corresponding patch sequence and then added and fused with the corresponding patch sequence to obtain the first image sequence, which is used as the input of the Vision-Transformer model. The first image sequence is input into the Vision-Transformer model to obtain the predicted probability of the image category. The cross entropy loss function value is calculated according to the real image category label and the predicted probability of the image category in the training set. The parameters of the PatchRLNet model are optimized and adjusted by the reverse stochastic gradient descent method with the minimization of the cross entropy loss function value as the optimization goal. The above iterative training process is repeated until the preset number of iterative training times is reached or the cross entropy loss function value converges, and the trained PatchRLNet model is obtained. Among them, when training the reinforcement learning model, the PPO-C strategy is used to train the weight generator and the corresponding evaluation network, and the reverse stochastic gradient descent method is used to optimize the alternative objective function, which is determined by the similarity constraint.

7. The automatic detection method for PTFE emulsion paraffin separation based on Vision-Transformer and reinforcement learning according to claim 6, characterized in that: The expression of the cross entropy loss function is: Where, L CE represents the cross entropy loss function, y represents the true image category label, The predicted probability of the image category output by the PatchRLNet model; The expression of the similarity constraint is: In the formula, is a similarity constraint, a represents the possible actions taken by the agent, s represents the state corresponding to the current environment, t represents the corresponding time step, θ represents the strategy currently selected by the agent, and θ σ represents the strategy selected by the agent in the previous step, a t represents the action chosen by the agent at time step t, s t represents the state of the agent at time step t, p θ (a t ||s t ) indicates that the agent is in the current strategy according to the state s t Select action a t The probability of Indicates that the agent is in the previous strategy according to the state s t Select action a t The probability of is the strategy ratio, A θσ is the advantage function and ε is a hyperparameter that represents the maximum allowed change in the policy ratio.

8. The automatic detection method for PTFE emulsion paraffin separation based on Vision-Transformer and reinforcement learning according to claim 7, characterized in that: The agent is a weight generator for generating a weight matrix, the environment is a combination of a Vision-Transformer encoder and a classifier, the action is the weight matrix, the state is the input image of the Vision-Transformer model, and the reward is the output result of the classifier.

9. A PTFE emulsion paraffin separation automatic detection device based on Vision-Transformer and reinforcement learning, comprising one or more processors and memories, characterized in that: The memory is coupled to the processor; wherein the memory is used to store program data, and the processor is used to execute the program data to implement the automatic detection method for PTFE emulsion paraffin separation based on Vision-Transformer and reinforcement learning as described in any one of claims 1-8.

10. A computer-readable storage medium, characterized in that: A program is stored thereon, and when the program is executed by a processor, it is used to implement the automatic detection method for PTFE emulsion paraffin separation based on Vision-Transformer and reinforcement learning as described in any one of claims 1-8.

Citation Information

Patent Citations

  • Grid self-attention facial expression recognition method based on supervised comparative learning

    CN117351550A

  • Method for detecting urine formed elements based on deep learning and context relation

    US20240153272A1