Expression recognition method and system based on eight-element orthogonal ViT

Through the octuanion orthogonal ViT method, the problem of large parameters and redundant features in the facial expression recognition model is solved, and higher recognition accuracy and robustness are achieved. The octuanion operation is used to reduce the number of model parameters and Improved expression recognition performance.

CN118552998APending Publication Date: 2024-08-27HUAZHONG NORMAL UNIV
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410778438.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-17
Publication Date
2024-08-27

AI Technical Summary

Technical Problem

When the facial expression recognition model uses the ViT model, the number of parameters is large and there is feature redundancy when the pre-trained network extracts features, resulting in low recognition accuracy.

Method used

The orthogonal ViT method based on octonions is used to build an octonion orthogonal expression recognition neural network model, including an input layer, an octonion orthogonal feature decomposition module, an octonion orthogonal representation module and an octonion Vision Transformer. The module uses octuanion operations to reduce the number of model parameters, eliminate feature redundancy, and improve recognition accuracy.

Benefits of technology

On the basis of keeping the number of parameters low, the accuracy and generalization ability of expression recognition are improved, feature redundancy is effectively eliminated, and the robustness and recognition accuracy of the model are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118552998A
    Figure CN118552998A
Patent Text Reader

Abstract

The invention discloses an expression recognition method and system based on an eight-element orthogonal ViT, and the method comprises the steps: carrying out the preprocessing of an original expression image inputted by an input layer, inputting the preprocessed image into an eight-element orthogonal feature decomposition module, and obtaining seven groups of orthogonal sub-features; the eight-element orthogonal representation module constructs seven groups of orthogonal sub-features into an eight-element feature matrix through a designed eight-element orthogonal representation function; the Vision Transform module is used for sequentially carrying out channel patch coding, an octuon multi-head self-attention mechanism, an octuon convolution feed-forward network and an octuon multi-layer perceptron on the octuon feature matrix generated in the octuon orthogonal representation module so as to extract and process octuon features; the Vision Transform module is used for sequentially carrying out channel patch coding, an octuon multi-head self-attention mechanism, an octuon convolution feed-forward network and an octuon multi-layer perceptron on the octuon feature matrix generated in the octuon orthogonal representation module; and obtaining final expression probability output through a full-connection layer by using the octuon feature matrix. On the basis of ensuring the low parameter quantity of the model, the expression recognition precision under the natural condition is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of image classification of computer vision, and in particular relates to an expression recognition method and system based on octonion orthogonal ViT. Background Art

[0002] Facial expression recognition technology refers to the use of computers to analyze and identify facial expressions to determine individual emotions. This technology has a wide range of applications in computer vision, human-computer interaction, and psychology. With the continuous advancement of computer technology, facial expression recognition technology has gradually been introduced into the field of computer science.

[0003] In recent years, with the development of deep learning technology, neural networks have been increasingly used in the field of computer vision, covering image segmentation, expression recognition, object detection and many other aspects. These networks have achieved remarkable success in terms of accuracy, but this is accompanied by a sharp increase in model complexity, with the number of parameters growing from millions to tens of billions, and the amount of computation (measured in FLOPs) also increasing dramatically. Although larger networks tend to provide better performance, the improvement in accuracy is not always proportional to the size of the network. In some cases, the increase in network size does not significantly improve accuracy, reflecting the potential existence of information redundancy in various network structures, and this increased scale poses significant challenges to storage and transmission.

[0004] Vision Transformer (ViT) is a deep learning model based on the Transformer architecture, which excels in multiple computer vision fields such as facial expression recognition and object classification. Unlike traditional convolutional neural networks (CNNs), ViT processes images by splitting them into blocks and expanding them into sequences. Since ViT has no inherent prior knowledge of image features, it usually requires larger datasets for training and takes a long time to train. In addition, since the number of parameters is usually large, more computing resources are required for training and inference. Therefore, how to effectively combine the advantages of the network with the architecture of ViT to improve expression recognition performance and efficiency is one of the current important research directions.

[0005] Many works related to facial expression recognition extract features through pre-trained backbone networks. However, there may be feature redundancy in these networks, resulting in reduced classification and recognition accuracy. Summary of the invention

[0006] The main technical problem solved by the present invention is that when the facial expression recognition model is based on the ViT model, the number of parameters is often large and there is a problem of feature redundancy when the pre-training network extracts features, resulting in low recognition accuracy of some pictures after the final model is trained and a large number of model parameters. In the field of neural networks, there has been an increasing interest in the use of multidimensional domain-valued neural networks in recent years. Studies have shown that quaternion theory can effectively reveal the intrinsic relationship between various components and significantly reduce the number of parameters. Quaternion operations can consider the spatial dependency between channels during feature extraction. As another generalization of quaternions and complex numbers, octonions have been widely used in mathematical physics, especially electrodynamics, electromagnetism and quantum physics, and have also shown great potential in the field of neural networks.

[0007] The present invention provides an expression recognition method based on octonion orthogonal ViT, comprising the following steps:

[0008] Step 1, constructing an octonion orthogonal expression recognition neural network model, including an input layer, an octonion orthogonal feature decomposition module, an octonion orthogonal representation module, an octonion Vision Transformer module, and an output layer;

[0009] The original expression picture input by the input layer is preprocessed, and then the preprocessed picture is input into the feature extraction layer in the octonion orthogonal feature decomposition module to obtain a preliminary expression feature tensor. By adding a parallel convolution layer after the feature extraction layer and designing a corresponding loss function to fine-tune the feature extraction layer, the preliminary expression feature tensor output by the feature extraction layer is decomposed into seven groups of orthogonal sub-features.

[0010] The octonion orthogonal representation module constructs an octonion feature matrix from the seven groups of orthogonal sub-features through the octonion orthogonal representation function; the octonion feature matrix consists of a real part and seven imaginary parts, the real part is the average feature of the seven groups of orthogonal sub-features, and the imaginary parts correspond to the seven groups of orthogonal sub-features respectively;

[0011] In the octonion Vision Transformer module, the octonion feature matrix generated in the above octonion orthogonal representation module is sequentially subjected to the channel patch encoding submodule, the encoding submodule and the octonion multilayer perceptron submodule to extract and process the octonion features;

[0012] Pass the octonion feature matrix through the output layer to obtain the final expression probability output;

[0013] Step 2, constructing a data set to train the octonion orthogonal expression recognition neural network model in step 1, and calculating the loss value of the predicted expression label and the true label through the loss function during the training process;

[0014] Step 3, using the trained octonion orthogonal expression recognition neural network model to realize expression recognition.

[0015] Furthermore, the preprocessing method is to uniformly scale and standardize the original input expression picture, and perform data enhancement operations, and the data enhancement operations include random horizontal flipping and random vertical flipping.

[0016] Further, the processing of the octonion orthogonal eigendecomposition module is as follows;

[0017] First, the expression feature tensor F is extracted from the original image through the pre-trained ResNet-50 model; then, the feature tensor F is reduced in dimension through seven parallel 1×1 convolutional layers to obtain seven feature maps U i ; Next, for each U i Apply global average pooling and flattening operations to obtain the feature vector V i After that, the orthogonal loss L is calculated ortho , ensuring the independence between feature vectors; finally, by combining the cross entropy loss L CrossEntropy and the orthogonal loss L ortho , forming a combined loss function L; by minimizing the combined loss function L, fine-tuning the octonion orthogonal eigendecomposition module;

[0018] The ResNet-50 network model is pre-trained with the Ms-Celeb-1M dataset. During the training process, the parameters of ResNet-50 are fine-tuned in combination with the loss function, and preliminary expression features are extracted through ResNet-50.

[0019] Furthermore, the formula of the cross entropy loss function is:

[0020]

[0021] Where n represents the number of samples, y represents the true label, represents the predicted probability;

[0022] The formula of the orthogonal loss function is:

[0023]

[0024] Among them, ||·||2 represents the L2 norm, |·| represents the absolute value operator, n represents the number of eigenvectors, V i represents the feature vector;

[0025] The calculation formula of the combined loss function L is:

[0026] L=L CrossEntropy +λL ortho

[0027] Among them, λ is a hyperparameter used to balance the contribution of cross entropy loss and orthogonal loss in the entire loss function.

[0028] Furthermore, the function of the octonion orthogonal representation module is to construct the seven groups of orthogonal sub-features into an octonion feature matrix through the octonion orthogonal representation function, where the seven imaginary parts of the octonion are the seven groups of orthogonal sub-features, and the average feature is added as the real part of the octonion. The representation is as follows:

[0029]

[0030] O(x)=Ave(x)+F1(x)i+F2(x)j+F3(x)k+F4(x)e+F5(x)l+F6(x)m+F7(x)n

[0031] Where O(x) represents the octonion feature matrix, x refers to 7 orthogonal sub-features, F1(x), F2(x), F3(x), F4(x), F5(x), F6(x), F7(x) represent seven mutually orthogonal sub-features, Ave(x) represents the average feature, and i, j, k, e, l, m, n represent the 7 imaginary parts of the octonion.

[0032] Furthermore, the channel patch encoder module is used to divide the input feature map into multiple patches according to the channel dimension and perform position encoding to preserve the channel information and the spatial structure of the features; the dimension of the input feature map o is H×W×C, where H is the height, W is the width, and C is the number of channels;

[0033] Specifically, the input feature map is divided into multiple patches according to the channel dimension. Assuming that the dimension of the input feature map o is H×W×C, it is reshaped into a 2D patch That is, the dimension of each patch is C:

[0034] o′=Reshape(o,(H·W,C))

[0035] Among them, Reshape means reshaping or reconstruction;

[0036] Next, o′ is encoded into C sequences of length H·W, denoted as

[0037] o″=Encode(o′,(H·W))

[0038] Among them, Encode means encoding;

[0039] Finally, in order to preserve the position information of the channel, a one-dimensional position embedding p is generated H·W , and add it to o″:

[0040] o″′=o″+p H·W

[0041] Among them, o″′,o″,p H·W They are all octonion sequences;

[0042] The final output sequence o″′ will be input into the encoding submodule for further processing.

[0043] Furthermore, the encoding submodule includes an octonion multi-head self-attention mechanism module and two consecutive octonion convolutional feedforward network modules, and the entire encoding submodule is repeatedly executed several times;

[0044] The function of the octonion multi-head self-attention mechanism module is to use octonion operations to calculate multi-head self-attention to capture the global dependencies between features. The specific steps are as follows:

[0045] The input feature sequence o″′ passes through three separate octonion fully connected layers OFC q (·), OFC k (·), OFC v (·) are converted into octonion query Q, octonion key K and octonion value V respectively, and the formula is as follows:

[0046] Q=OFC q (o″′); K=OFC k (o″′); V=OFC v (o″′)

[0047] Next, use the Hamilton product to replace the scaled dot product in ViT and calculate the self-attention. The formula is as follows:

[0048]

[0049] Among them, head j represents the jth head in the multi-head self-attention mechanism, and the attention function represents the process of calculating self-attention; the Composoftmax(·) operation represents the Softmax operation on each component of the octonion. Represents the Hamilton product, and then the self-attention is connected and mapped to a multi-head octonion matrix through an octonion fully connected layer OFC(·). The entire calculation process of the octonion multi-head self-attention mechanism module O-MHSA is expressed as:

[0050] MultiHead=OFC(Concat(head1,…,head j )),j=8

[0051] Where Concat(·) represents a concatenation operation.

[0052] Furthermore, the function of the octonion convolution feedforward network module is to perform further nonlinear transformation and feature extraction on the octonion features to enhance the expression ability and classification performance of the model. The specific steps are as follows:

[0053] The input features are normalized, and the formula is as follows:

[0054] X = LayerNorm(O MHSA )

[0055] Among them, O MHSA Represents the output features from the octonion multi-head self-attention mechanism module;

[0056] The normalized features are subjected to 3×3 octonion convolution and GELU activation operations, and the formula is as follows:

[0057] X conv =OConv(X)

[0058] X relu =GELU(LayerNorm(X conv ))

[0059] The activated features are transformed again through a 3×3 octonion convolution layer:

[0060] X out =OConv(X relu )

[0061] Finally, the output X of the octonion convolutional feedforward network module is out It is the feature after two 3×3 octonion convolutions, two layer normalizations and one GELU activation. The formula is as follows:

[0062] X out =OC-FFN(X)=OConv(GELU(LayerNorm(OConv(X))))

[0063] Where LayerNorm(·) represents layer normalization, OConv(·) represents 3×3 octonion convolution, GELU(·) is the activation operation, X and X out are the input and output of the octonion convolutional feed-forward network module.

[0064] Furthermore, the octonion multilayer perceptron submodule includes two consecutive 3×3 octonion convolution operations, which are repeated twice and then input into the final fully connected layer network to obtain the expression category output. The loss between the predicted value and the true value of the octonion Vision Transformer module is calculated through the cross entropy loss function, and the next training iteration is performed;

[0065] The formula for the octonion multilayer perceptron submodule is as follows:

[0066] X Flatten_out =Flatten(X out )

[0067] X Mlp_out =OMLP(X Flatten_out )=OConv(OConv(X Flatten_out ))

[0068] Among them, Flatten represents the flattening operation, OMLP is the octonion multi-layer perceptron, OConv is the 3×3 octonion convolution operation, X Flatten_out ,X Mlp_out They are the output of the flatten operation and the output of the octonion multilayer perceptron operation respectively.

[0069] The present invention also provides an expression recognition system based on octonion orthogonal ViT, comprising the following units:

[0070] A network model building unit, used to build an octonion orthogonal expression recognition neural network model, including an input layer, an octonion orthogonal feature decomposition module, an octonion orthogonal representation module, an octonion Vision Transformer module, and an output layer;

[0071] The original expression picture input by the input layer is preprocessed, and then the preprocessed picture is input into the feature extraction layer in the octonion orthogonal feature decomposition module to obtain a preliminary expression feature tensor. By adding a parallel convolution layer after the feature extraction layer and designing a corresponding loss function to fine-tune the feature extraction layer, the preliminary expression feature tensor output by the feature extraction layer is decomposed into seven groups of orthogonal sub-features.

[0072] The octonion orthogonal representation module constructs an octonion feature matrix from the seven groups of orthogonal sub-features through the octonion orthogonal representation function; the octonion feature matrix consists of a real part and seven imaginary parts, the real part is the average feature of the seven groups of orthogonal sub-features, and the imaginary parts correspond to the seven groups of orthogonal sub-features respectively;

[0073] In the octonion Vision Transformer module, the octonion feature matrix generated in the above octonion orthogonal representation module is sequentially subjected to the channel patch encoding submodule, the encoding submodule and the octonion multilayer perceptron submodule to extract and process the octonion features;

[0074] Pass the octonion feature matrix through the output layer to obtain the final expression probability output;

[0075] The network model training unit constructs a data set to train the octonion orthogonal expression recognition neural network model. During the training process, the loss function calculates the loss value of the predicted expression label and the real label;

[0076] The expression recognition unit is used to realize expression recognition by using the trained octonion orthogonal expression recognition neural network model.

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

[0078] (1) The present invention uses octonion operations to replace the operations in traditional Vision Transformer and expands the ViT model to the octonion domain. The proposed octonion Vision Transformer model can better represent the intrinsic connection between different elements. On the basis of greatly reducing the number of model parameters, it can improve the accuracy and generalization ability of expression recognition.

[0079] (2) In the present invention, by combining the orthogonal feature decomposition module, the octonion orthogonal representation module and the octonion Vision Transformer module, the pre-trained expression features are converted into orthogonal sub-features, which effectively eliminates feature redundancy and further improves the accuracy and robustness of expression recognition while maintaining a low number of model parameters. BRIEF DESCRIPTION OF THE DRAWINGS

[0080] Figure 1 is a model structure diagram of a facial expression recognition method according to an embodiment of the present invention; DETAILED DESCRIPTION

[0081] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention is further described in detail below with reference to the accompanying drawings and embodiments.

[0082] The present invention discloses an expression recognition method based on octonion orthogonal ViT, which comprises the following steps: screening a human face expression data set in a natural environment, preprocessing an original expression picture inputted by an input layer, inputting the preprocessed picture into a feature extraction layer to obtain preliminary expression features; an octonion orthogonal feature decomposition module fine-tunes the network model of the feature extraction layer by adding parallel convolutional neural network branches and designing a corresponding orthogonal loss function, and decomposes the preliminary expression features outputted by the feature extraction layer into seven groups of orthogonal sub-features; an octonion orthogonal representation module constructs the seven groups of orthogonal sub-features into an octonion feature matrix through a designed octonion orthogonal representation function; in an octonion VisionTransformer module, the octonion feature matrix generated in the octonion orthogonal representation module is subjected to channel patch coding, octonion multi-head self-attention mechanism, octonion convolution feedforward network and octonion multi-layer perceptron in sequence to extract and process the extracted octonion features; the octonion feature matrix is ​​subjected to a fully connected layer to obtain a final expression probability output; the present invention uses octonion operations to replace traditional Vision The operations in the Transformer extend the ViT model to the octonion domain, effectively solving the problem of large number of parameters in the Vision Transformer skeleton network, and improving the accuracy of expression recognition by eliminating feature redundancy between pre-extracted features, as follows:

[0083] See also Figure 1 , an expression recognition method based on octonion orthogonal ViT provided by an embodiment of the present invention comprises:

[0084] S1. Obtain a training data set. The present invention uses the facial expression data sets RAF-DB, SFEW2.0 and AffectNet in natural environments, and uses numbers 0-6 to represent happiness, surprise, sadness, anger, disgust, fear and neutrality respectively.

[0085] S2, preprocessing the original expression picture;

[0086] Furthermore, in the present invention, the probabilities of random horizontal flipping and random vertical flipping in image preprocessing are set to 0.5 and 0.5 respectively, and the image size parameter set in image preprocessing image alignment is 224x224, which scales the input original expression image to 224x224 size; the parameters set for image normalization in image preprocessing, the mean of each channel on the RAF-DB dataset is set to 0.5758, 0.4500, and 0.4018 respectively, and the variance of each channel is set to 0.2089, 0.1914, and 0.1829 respectively, and the variance of each channel is set to 0.5758, 0.4500, and 0.4018 respectively on the SFEW dataset. The mean of each channel on the 2.0 dataset is set to 0.3385, 0.2257, and 0.1758, and the variance of each channel is set to 0.1381, 0.1120, and 0.1071, respectively. The mean of each channel on the AffectNet dataset is set to 0.5752, 0.4496, and 0.4013, and the variance of each channel is set to 0.2089, 0.1914, and 0.1829, respectively. The image normalization operation scales the pixel values ​​of the image to between (-1, 1), which can speed up the training and convergence of the model. In data enhancement, random flipping can enhance the robustness of the model to posture changes and local occlusion.

[0087] S3. First, the preprocessed image is input into the feature extraction layer in the octonion orthogonal feature decomposition module for feature extraction to obtain preliminary expression features.

[0088] The feature extraction layer in the present invention uses the ResNet-50 model pre-trained with the Ms-Celeb-1M dataset. During the training process, the training parameters of ResNet-50 are fine-tuned in combination with the loss function, and the preliminary expression feature tensor is extracted through ResNet-50. The pre-trained model can have good feature extraction capabilities. After feature extraction, the model can obtain high-level semantic information of the image, which is helpful for subsequent facial expression recognition tasks.

[0089] Then, seven parallel 1×1 convolutional layer branches are added after the feature extraction layer for feature compression; each 1×1 convolutional layer reduces the dimension of the feature through linear transformation, compressing the preliminary expression feature tensor F into seven lower-dimensional feature maps The value of i ranges from 1 to 7; this method effectively reduces the dimension of the feature while retaining important expression information.

[0090] Specifically, in the feature compression process, the dimension of the initial expression feature tensor F is 7×7×2048. After being processed by a 1×1 convolutional layer, the feature map U i The dimension becomes 7×7×64; Next, for each feature map U iApply a global average pooling operation to convert each 7×7×64 tensor into a 1×1×64 tensor, which is then converted into a feature vector by flattening. This transformation method not only effectively compresses the dimension of the feature vector, but also enhances the compactness and robustness of the feature representation.

[0091] Furthermore, in order to ensure the mathematical independence between these intermediate eigenvectors, the orthogonal eigendecomposition module introduces the orthogonality loss L ortho ; This loss function is implemented by calculating the ratio of the inner product between each pair of feature vectors and their L2 norm; the formula for orthogonal loss is:

[0092]

[0093] Among them, ||·||2 represents the L2 norm, |·| represents the absolute value operator, n represents the number of eigenvectors, V i Represents the feature vector; the introduction of orthogonal loss helps to capture more diverse features, reduce feature redundancy, and enhance the effectiveness and diversity of feature representation.

[0094] The formula for the cross entropy loss function is:

[0095]

[0096] Among them, n represents the number of samples, y represents the true label, represents the predicted probability.

[0097] Combined with the traditional cross entropy loss function L CrossEntropy And the orthogonal loss function L ortho , fine-tune the feature extraction layer ResNet-50 network model. The combined loss function is expressed as:

[0098] L=L CrossEntropy +λL ortho

[0099] Among them, λ = 0.2, which is used to balance the contribution of cross entropy loss and orthogonal loss in the entire loss function;

[0100] The fine-tuning steps are as follows:

[0101] First, the expression feature tensor F is extracted from the original image through the pre-trained ResNet-50 model; then, the feature tensor F is reduced in dimension through seven parallel 1×1 convolutional layers to obtain seven feature maps U i ; Next, for each U i Apply global average pooling and flattening operations to obtain the feature vector V i After that, the orthogonal loss L is calculated ortho, ensuring the independence between feature vectors; finally, by combining the cross entropy loss L CrossEntropy and the orthogonal loss L ortho , forming a combined loss function L; by minimizing the combined loss function L, the model is fine-tuned to optimize the feature extraction layer network model, thereby improving the recognition accuracy and generalization ability of the model.

[0102] S4, the seven groups of orthogonal features U obtained by the above-mentioned fine-tuned octonion orthogonal feature decomposition module i Input into the octonion orthogonal representation module; the main function of the octonion orthogonal representation module is to construct seven groups of orthogonal sub-features into an octonion feature matrix through the octonion orthogonal representation function; in the octonion representation, an octonion consists of a real part and seven imaginary parts; in this module, the seven imaginary parts of the octonion correspond to seven groups of orthogonal sub-features respectively, and the real part is represented by the average value of these features; in this way, the intrinsic connection between the features can be better captured and represented.

[0103] Specifically, the input to the octonion orthogonal representation module is each set of orthogonal sub-features U i The dimension is 7×7×64. First, the seven groups of orthogonal sub-features are averaged to obtain the average feature Ave(x). The specific formula is as follows:

[0104]

[0105] Among them, Ave(x) represents the average feature, its dimension is 7×7×64, and x refers to the 7 orthogonal sub-features U i ; This step ensures the balance of features and helps to balance the contribution of different features when constructing the octonion. Next, the seven groups of orthogonal sub-features F1(x), F2(x), F3(x), F4(x), F5(x), F6(x), F7(x) are used as the seven imaginary parts of the octonion, and the average feature Ave(x) is used as the real part of the octonion to construct the octonion feature matrix O(x); The specific formula is as follows:

[0106] O(x)=Ave(x)+F1(x)i+F2(x)j+F3(x)k+F4(x)e+F5(x)l+F6(x)m+F7(x)n

[0107] Where O(x) represents the octonion feature matrix, F1(x), F2(x), F3(x), F4(x), F5(x), F6(x), F7(x) represent seven mutually orthogonal sub-features, and i, j, k, e, l, m, n represent the seven imaginary parts of the octonion.

[0108] Furthermore, in step S4, the output of the octonion orthogonal representation module is an octonion feature matrix O(x), whose dimension is 7×7×512; the octonion feature matrix contains a real part and seven imaginary parts, and the dimension of each part is 7×7×64; through this representation form, each group of orthogonal sub-features is effectively integrated, and the octonion feature matrix O(x) can effectively capture the intrinsic connection between different orthogonal sub-features, while maintaining the balance of features by introducing average features; this octonion representation form can not only enhance the diversity and expressiveness of features, but also improve the overall performance of the model while reducing redundancy, ensuring the high accuracy and generalization ability of the model in expression recognition tasks.

[0109] S5. Input the octonion feature matrix obtained above into the channel patch encoder module in the octonion Vision Transformer module; the main function of the channel patch encoder module is to divide the input feature map into multiple patches according to the channel dimension, and perform position encoding to retain the channel information and the spatial structure of the features; the dimension of the input feature map o is H×W×C, where H is the height, W is the width, and C is the number of channels.

[0110] Specifically, the input feature map is divided into multiple patches according to the channel dimension. Assuming the dimension of the input feature map o is H×W×C, it is reshaped into a 2D patch That is, the dimension of each patch is C:

[0111] o′=Reshape(o,(H·W,C))

[0112] Among them, Reshape means reshaping or reconstruction;

[0113] Next, o′ is encoded into C sequences of length H·W, denoted as

[0114] o″=Encode(o′,(H·W))

[0115] Among them, Encode means encoding;

[0116] Finally, in order to preserve the position information of the channel, the ready-made function in pytorch is used to generate a one-dimensional position embedding p H·W , and add it to o″:

[0117] o″′=o″+p H·W

[0118] Among them, o″′,o″,p H·W They are all octonion sequences.

[0119] The final output sequence o″′ will be input into the octonion multi-head self-attention module for further processing.

[0120] S6. Input the octonion sequence o″′ containing position information obtained above into the Encoder module in the octonion VisionTransformer module; each Encoder module includes an octonion multi-head self-attention mechanism module and two consecutive octonion convolutional feedforward network modules, and the entire Encoder module is repeated four times.

[0121] The main function of the octonion multi-head self-attention mechanism module is to use octonion operations to calculate multi-head self-attention to capture the global dependencies between features. The specific steps are as follows:

[0122] Specifically, the input feature sequence o″′ is passed through three separate octonion fully connected layers OFC q (·), OFC k (·), OFC v (·) are converted into octonion query Q, octonion key K and octonion value V respectively, and the formula is as follows:

[0123] Q=OFC q (o″′); K=OFC k (o″′); V=OFC v (o″′)

[0124] Next, use the Hamilton product to replace the scaled dot product in ViT and calculate the self-attention. The formula is as follows:

[0125]

[0126] Among them, head j represents the jth head in the multi-head self-attention mechanism, and the attention function represents the process of calculating self-attention; the Composoftmax(·) operation represents the normalized exponential function Softmax operation on each component of the octonion. Represents the Hamilton product, and then the self-attention is connected and mapped to a multi-head octonion matrix through an octonion fully connected layer OFC(·). The entire calculation process of the octonion multi-head self-attention mechanism module O-MHSA can be expressed as:

[0127] MultiHead=OFC(Concat(head1,…,head j )),j=8

[0128] Where Concat(·) represents a concatenation operation.

[0129] Furthermore, the octonion features extracted by the octonion multi-head self-attention mechanism module will be passed to the octonion convolutional feedforward network module for further processing; the octonion multi-head self-attention mechanism module can effectively capture the intrinsic connection between features while reducing the number of parameters and improving the computational efficiency and performance of the model.

[0130] The main function of the octonion convolution feedforward network module is to perform further nonlinear transformation and feature extraction on the octonion features to enhance the expression ability and classification performance of the model. The specific steps are as follows:

[0131] The input features are normalized, and the formula is as follows:

[0132] X = LayerNorm(O MHSA )

[0133] Among them, X and X out Represents the input and output of the octonion convolutional feedforward network module OC-FFN, O MHSA Represents the output features from the octonion multi-head self-attention mechanism module;

[0134] The normalized features are subjected to 3×3 octonion convolution and GELU activation operations, and the formula is as follows:

[0135] X conv =OConv(X)

[0136] X relu =GELU(LayerNorm(X conv ))

[0137] The activated features are transformed again through a 3×3 octonion convolution layer:

[0138] X out =OConv(X relu )

[0139] Finally, the output X of the octonion convolutional feedforward network module is out It is the feature after two 3×3 octonion convolutions, two layer normalizations and one GELU activation process to enhance the ability to capture local features. The formula is as follows:

[0140] X out =OC-FFN(X)=OConv(GELU(LayerNorm(OConv(X))))

[0141] Where LayerNorm(·) represents layer normalization, OConv(·) represents 3×3 octonion convolution, GELU(·) is the activation operation, X and X out are the input and output of the octonion convolutional feed-forward network module.

[0142] The entire Encoder module in the Octonion Vision Transformer includes an Octonion multi-head self-attention mechanism module and two Octonion convolutional feedforward network modules, which are repeated four times. Through this structural design, the Octonion convolutional feedforward network module can effectively capture local features and enhance the model's expressiveness and classification performance. Combined with the Octonion multi-head self-attention mechanism, the Octonion Vision Transformer model can effectively capture the intrinsic connections between features while reducing the number of parameters and improving computational efficiency and performance.

[0143] S7, the octonion feature X obtained by the above Encoder module out After flattening, the data is input into the octonion multilayer perceptron module. Each octonion multilayer perceptron module includes two consecutive 3×3 octonion convolution operations, and the octonion multilayer perceptron module is repeated twice. Then it is input into the final fully connected layer network to obtain the expression category output. The loss between the predicted value and the true value of the octonion Vision Transformer module is calculated through the cross entropy loss function, and the next training iteration is performed.

[0144] Furthermore, the formula of the octonion multilayer perceptron module is as follows:

[0145] X Flatten_out =Flatten(X out )

[0146] X Mlp_out =OMLP(X Flatten_out )=OConv(OConv(X Flatten_out ))

[0147] Among them, OMLP is an octonion multilayer perceptron, OConv is a 3×3 octonion convolution operation, X Flatten_out , X Mlp_out They are the output of the flattening operation of this layer and the output of the octonion multilayer perceptron operation.

[0148] Finally, the final output X Mlp_out After inputting into the fully connected layer, the predicted expression label is obtained.

[0149] The accuracy of the method of the present invention obtained by the model proposed in this patent on the RAF-DB and Affect datasets is compared with other expression recognition algorithms RAN-ResNet18, SCN, VTFF, MA-Net, PSR, DMUE, DAN, and QOT. The results are shown in Table 1:

[0150] Table 1. Comparison of expression recognition algorithm experimental results

[0151] method RAF-DB Accuracy Affect (7-cls) accuracy Parameter quantity RAN-ResNet18 86.90 59.50 11.19M SCN 87.03 60.23 11.18M VTFF 88.14 61.85 51.80M MA-Net 88.40 64.53 50.54M PSR 88.98 63.77 20.24M DMUE 89.42 63.11 78.40M DAN 89.70 65.69 19.72M Method of the present invention 90.43 67.74 6.69M

[0152] It can be seen from Table 1 that the expression recognition method proposed in the present invention has higher accuracy than the common expression recognition algorithms RAN-ResNet18, SCN, VTFF, MA-Net, PSR, DMUE, DAN, and QOT, and requires the least number of parameters.

[0153] In summary, the octonion Vision Transformer proposed in the present invention uses octonion operations to replace the operations in the traditional Vision Transformer (ViT), expands the ViT model to the octonion domain, and can improve the accuracy and generalization ability of expression recognition on the basis of greatly reducing the number of ViT model parameters. In the present invention, by combining the octonion orthogonal feature decomposition module, the octonion orthogonal feature representation module and the octonion Vision Transformer module, the feature redundancy in the pre-extracted features is effectively eliminated, and the accuracy and robustness of expression recognition are further improved while maintaining the low number of model parameters.

[0154] In another embodiment, the present invention also provides an expression recognition system based on octonion orthogonal ViT, comprising the following units:

[0155] A network model building unit, used to build an octonion orthogonal expression recognition neural network model, including an input layer, an octonion orthogonal feature decomposition module, an octonion orthogonal representation module, an octonion Vision Transformer module, and an output layer;

[0156] The original expression picture input by the input layer is preprocessed, and then the preprocessed picture is input into the feature extraction layer in the octonion orthogonal feature decomposition module to obtain a preliminary expression feature tensor. By adding a parallel convolution layer after the feature extraction layer and designing a corresponding loss function to fine-tune the feature extraction layer, the preliminary expression feature tensor output by the feature extraction layer is decomposed into seven groups of orthogonal sub-features.

[0157] The octonion orthogonal representation module constructs an octonion feature matrix from the seven groups of orthogonal sub-features through the octonion orthogonal representation function; the octonion feature matrix consists of a real part and seven imaginary parts, the real part is the average feature of the seven groups of orthogonal sub-features, and the imaginary parts correspond to the seven groups of orthogonal sub-features respectively;

[0158] In the octonion Vision Transformer module, the octonion feature matrix generated in the above octonion orthogonal representation module is sequentially subjected to the channel patch encoding submodule, the encoding submodule and the octonion multilayer perceptron submodule to extract and process the octonion features;

[0159] Pass the octonion feature matrix through the output layer to obtain the final expression probability output;

[0160] The network model training unit constructs a data set to train the octonion orthogonal expression recognition neural network model. During the training process, the loss function calculates the loss value of the predicted expression label and the real label;

[0161] The expression recognition unit is used to realize expression recognition by using the trained octonion orthogonal expression recognition neural network model.

[0162] The specific implementation method of each module is the same as each step and will not be described in detail in the present invention.

[0163] The above-mentioned embodiments further express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the invention patent. It should be pointed out that for those skilled in the art, several variations and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.

Claims

1. Expression recognition method based on octonion orthogonal ViT, It is characterized in that The steps include: Step 1, constructing an octonion orthogonal expression recognition neural network model, including an input layer, an octonion orthogonal feature decomposition module, an octonion orthogonal representation module, an octonion Vision Transformer module, and an output layer; The original expression picture input by the input layer is preprocessed, and then the preprocessed picture is input into the feature extraction layer in the octonion orthogonal feature decomposition module to obtain a preliminary expression feature tensor. By adding a parallel convolution layer after the feature extraction layer and designing a corresponding loss function to fine-tune the feature extraction layer, the preliminary expression feature tensor output by the feature extraction layer is decomposed into seven groups of orthogonal sub-features. The octonion orthogonal representation module constructs an octonion feature matrix from the seven groups of orthogonal sub-features through the octonion orthogonal representation function; the octonion feature matrix consists of a real part and seven imaginary parts, the real part is the average feature of the seven groups of orthogonal sub-features, and the imaginary parts correspond to the seven groups of orthogonal sub-features respectively; In the octonion Vision Transformer module, the octonion feature matrix generated in the above octonion orthogonal representation module is sequentially subjected to the channel patch encoding submodule, the encoding submodule and the octonion multilayer perceptron submodule to extract and process the octonion features; Pass the octonion feature matrix through the output layer to obtain the final expression probability output; Step 2, constructing a data set to train the octonion orthogonal expression recognition neural network model in step 1, and calculating the loss value of the predicted expression label and the true label through the loss function during the training process; Step 3, using the trained octonion orthogonal expression recognition neural network model to realize expression recognition.

2. The expression recognition method based on octonion orthogonal ViT as claimed in claim 1, Features: The preprocessing method is to uniformly scale and standardize the original input expression picture, and perform data enhancement operations, wherein the data enhancement operations include random horizontal flipping and random vertical flipping.

3. The expression recognition method based on octonion orthogonal ViT as claimed in claim 1, Features: The processing process of the octonion orthogonal eigendecomposition module is as follows; First, the expression feature tensor F is extracted from the original image through the pre-trained ResNet-50 model; Then, the feature tensor F is reduced in dimension through seven parallel 1×1 convolutional layers to obtain seven feature maps U i ; Next, for each U i Apply global average pooling and flattening operations to obtain the feature vector V i After that, the orthogonal loss L is calculated ortho , ensuring the independence between feature vectors; finally, by combining the cross entropy loss L CrossEntropy and the orthogonal loss L ortho , forming a combined loss function L; by minimizing the combined loss function L, fine-tuning the octonion orthogonal eigendecomposition module; The ResNet-50 network model is pre-trained with the Ms-Celeb-1M dataset. During the training process, the parameters of ResNet-50 are fine-tuned in combination with the loss function, and preliminary expression features are extracted through ResNet-50.

4. The expression recognition method based on octonion orthogonal ViT as claimed in claim 3, Features: The formula of the cross entropy loss function is: Where n represents the number of samples, y represents the true label, represents the predicted probability; The formula of the orthogonal loss function is: Among them, ||·|| 2 represents the L2 norm, |·| represents the absolute value operator, n represents the number of eigenvectors, and vi represents the eigenvector; The calculation formula of the combined loss function L is: L=L CrossEntropy +λL ortho Among them, λ is a hyperparameter used to balance the contribution of cross entropy loss and orthogonal loss in the entire loss function.

5. The expression recognition method based on octonion orthogonal ViT as claimed in claim 1, Features: The function of the octonion orthogonal representation module is to construct an octonion feature matrix by using the octonion orthogonal representation function to transform the seven groups of orthogonal sub-features. The seven imaginary parts of the octonion are the seven groups of orthogonal sub-features, and the average feature is added as the real part of the octonion. The representation is as follows: O(x)=Ave(x)+F 1 (x)i+F 2 (x)j+F 3 (x)k+F 4 (x)e+F 5 (x)l+F 6 (x)m+F 7 (x)n Where O(x) represents the octonion feature matrix, x refers to the 7 orthogonal sub-features, F 1 (x), F 2 (x), F 3 (x), F 4 (x), F 5 (x), F 6 (x), F 7 (x) represents seven mutually orthogonal sub-features, Ave(x) represents the average feature, and i, j, k, e, l, m, and n represent the seven imaginary parts of the octonion.

6. The expression recognition method based on octonion orthogonal ViT as claimed in claim 1, Features: The function of the channel patch encoder module is to divide the input feature map into multiple patches according to the channel dimension and perform position encoding to preserve the channel information and the spatial structure of the features; the dimension of the input feature map o is H×W×C, where H is the height, W is the width, and C is the number of channels; Specifically, the input feature map is divided into multiple patches according to the channel dimension. Assuming that the dimension of the input feature map o is H×W×C, it is reshaped into a 2D patch That is, the dimension of each patch is C: o′=Reshape(o, (H·W, C)) Among them, Reshape means reshaping or reconstruction; Next, o′ is encoded into C sequences of length H·W, denoted as o″=Encode(o′,(H·W)) Among them, Encode means encoding; Finally, in order to preserve the position information of the channel, a one-dimensional position embedding p is generated H·W , and add it to o″: o″′=o″+p H·W Among them, o″′, o″, p H·W They are all octonion sequences; The final output sequence o″′ will be input into the encoding submodule for further processing.

7. The expression recognition method based on octonion orthogonal ViT as claimed in claim 6, Features: The encoding submodule includes an octonion multi-head self-attention mechanism module and two consecutive octonion convolutional feedforward network modules. The entire encoding submodule is repeated several times; The function of the octonion multi-head self-attention mechanism module is to use octonion operations to calculate multi-head self-attention to capture the global dependencies between features. The specific steps are as follows: The input feature sequence o″′ passes through three separate octonion fully connected layers OFC q (·), OFC k (·), OFC v (·) are converted into octonion query Q, octonion key K and octonion value y respectively, and the formula is as follows: Q=OFC q (o″′);K=OFC k (o″′);V=OFC v (the"') Next, use the Hamilton product to replace the scaled dot product in ViT and calculate the self-attention. The formula is as follows: Among them, head j represents the jth head in the multi-head self-attention mechanism, and the attention function represents the process of calculating self-attention; the Composoftmax(·) operation represents the Softmax operation on each component of the octonion. Represents the Hamilton product, and then the self-attention is connected and mapped to a multi-head octonion matrix through an octonion fully connected layer OFC(·). The entire calculation process of the octonion multi-head self-attention mechanism module O-MHSA is expressed as: MultiHead=OFC(Concat(head 1 ,...,head j )),j=8 Where Concat(·) represents a concatenation operation.

8. The expression recognition method based on octonion orthogonal ViT as claimed in claim 7, Features: The function of the octonion convolution feedforward network module is to perform further nonlinear transformation and feature extraction on the octonion features to enhance the expression ability and classification performance of the model. The specific steps are as follows: The input features are normalized, and the formula is as follows: X=LayerNorm(O MHSA ) Among them, O MHSA Represents the output features from the octonion multi-head self-attention mechanism module; The normalized features are subjected to 3×3 octonion convolution and GELU activation operations, and the formula is as follows: X conv =OConv(X) X relu =GELU(LayerNorm(X conv )) The activated features are transformed again through a 3×3 octonion convolution layer: X out =OConv(X relu ) In summary, the output X of the octonion convolution feedforward network module OC-FFN out It is the feature after two 3×3 octonion convolutions, two layer normalizations and one GELU activation. The formula is as follows: X out =OC-FFN(X)=OConv(GELU(LayerNorm(OConv(X)))) Where LayerNorm(·) represents layer normalization, OConv(·) represents 3×3 octonion convolution, GELU(·) is the activation operation, X and X out are the input and output of the octonion convolutional feed-forward network module.

9. The expression recognition method based on octonion orthogonal ViT as claimed in claim 8, Features: The octonion multilayer perceptron submodule includes two consecutive 3×3 octonion convolution operations. The octonion multilayer perceptron submodule is repeated twice and then input into the final fully connected layer network to obtain the expression category output. The loss between the predicted value and the true value of the octonion Vision Transformer module is calculated through the cross entropy loss function, and the next training iteration is performed; The formula for the octonion multilayer perceptron submodule is as follows: X Flatten_out =Flatten(X out ) X Mlp_out =OMLP(X Flatten_out )=OConv(OConv(X Flatten_out )) Among them, Flatten represents the flattening operation, OMLP is the octonion multi-layer perceptron, OConv is the 3×3 octonion convolution operation, X Flatten_out ,X Mlp_out They are the output of the flatten operation and the output of the octonion multilayer perceptron operation respectively.

10. Expression recognition system based on octonion orthogonal ViT, It is characterized in that The following units are included: A network model building unit, used to build an octonion orthogonal expression recognition neural network model, including an input layer, an octonion orthogonal feature decomposition module, an octonion orthogonal representation module, an octonion Vision Transformer module, and an output layer; The original expression picture input by the input layer is preprocessed, and then the preprocessed picture is input into the feature extraction layer in the octonion orthogonal feature decomposition module to obtain a preliminary expression feature tensor. By adding a parallel convolution layer after the feature extraction layer and designing a corresponding loss function to fine-tune the feature extraction layer, the preliminary expression feature tensor output by the feature extraction layer is decomposed into seven groups of orthogonal sub-features. The octonion orthogonal representation module constructs an octonion feature matrix from the seven groups of orthogonal sub-features through the octonion orthogonal representation function; the octonion feature matrix consists of a real part and seven imaginary parts, the real part is the average feature of the seven groups of orthogonal sub-features, and the imaginary parts correspond to the seven groups of orthogonal sub-features respectively; In the octonion Vision Transformer module, the octonion feature matrix generated in the above octonion orthogonal representation module is sequentially subjected to the channel patch encoding submodule, the encoding submodule and the octonion multilayer perceptron submodule to extract and process the octonion features; Pass the octonion feature matrix through the output layer to obtain the final expression probability output; The network model training unit constructs a data set to train the octonion orthogonal expression recognition neural network model. During the training process, the loss function calculates the loss value of the predicted expression label and the real label; The expression recognition unit is used to realize expression recognition by using the trained octonion orthogonal expression recognition neural network model.

Citation Information

Cited By

  • Space intelligent watershed hydrology and water quality multivariable prediction method based on quaternion time-frequency multi-scale

    CN120822194A