Global and local feature facial expression recognition method based on attention replacement
By using a combination of displacement attention and residual multi-scale modules in facial expression recognition, global and local features are extracted and fused, which solves the problems of occlusion and pose changes in static facial expression recognition, and improves recognition accuracy and robustness. Great sex.
Patent Information
- Application Number
- CN202410734763.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-07
- Publication Date
- 2024-09-17
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing static facial expression recognition methods only consider spatial information and have low computational complexity but are difficult to effectively handle occlusion and pose changes, resulting in limited recognition performance.
A global and local feature facial expression recognition method based on displacement attention is adopted. The residual multi-scale module extracts global features and the displacement attention module extracts local features, and fuses them at the decision-making level to reduce the impact of occlusion and pose changes, and improve Recognition robustness.
It improves the accuracy and robustness of facial expression recognition, enhances the representation and generalization capabilities of the network model, and significantly improves the recognition success rate in real environments.
Smart Images

Figure FT_1 
Figure FT_6 
Figure FT_2
Abstract
Description
Technical Field
[0001] The invention relates to a facial expression recognition method, in particular to a global and local feature facial expression recognition method based on permuted attention. Background Art
[0002] Facial expression is an important and natural form of emotional communication for humans, which can better reflect emotional information than language and action. Therefore, the capture, recognition and analysis of facial expressions have been widely used in human-computer interaction, security protection, consumer payment, medical diagnosis and other fields. In particular, automatic facial expression recognition (FER) has become a hot topic in research with the development of computer vision and artificial intelligence technology, which classifies the emotional representation in images, image sequences or videos as a typical facial expression. Based on the spatiotemporal feature representation of facial expressions, FER can be divided into static FER and dynamic FER. Although dynamic FER improves performance by training sequence data, learning the features of sequence data and analyzing the temporal dependence of sequence data, static FER, which only considers spatial information, is widely used due to its low computational complexity, simple data processing and convenient training. With the rapid improvement of hardware processing power and the rapid development of deep neural network technology, deep learning-based methods are increasingly becoming the dominant method for facial expression recognition. Summary of the invention
[0003] The present invention proposes a global and local feature facial expression recognition method based on permutation attention, which uses the permutation attention mechanism to extract local features and uses the residual multi-scale module to perform multi-scale extraction of global features to recognize facial expressions of human faces.
[0004] The global and local feature facial expression recognition method based on permuted attention described in the present invention first adopts a residual network to pre-extract the input image to obtain a pre-extracted feature map, and then obtains global and local feature vectors through the upper and lower parts of the feature map respectively, and fuses them at the decision level to obtain the final classification. Among them, the residual multi-scale module described in the present invention extracts global features through channel segmentation feature mapping through different numbers of convolution blocks, thereby reducing the influence of occlusion, posture change and other problems. The permuted attention module described in the present invention extracts local features by strengthening the connection between different dimensions, and guides the spatial split features to concentrate on the significant area of FER. The obtained global features and local features are fused by the decision-level fusion layer after passing through the fully connected layer respectively. BRIEF DESCRIPTION OF THE DRAWINGS
[0005] Figure 1 It is the overall network model structure diagram of the present invention; Figure 2This is a structural diagram of the residual multi-scale network model of the present invention; Figure 3 This is a structural diagram of the network model of the replacement attention mechanism of the present invention; Figure 4 It is a confusion matrix diagram of the present invention on the test set of the FER2013 data set; Figure 5 It is a confusion matrix diagram of the present invention on the test set of the RAF-DB data set; Figure 6 This is a confusion matrix diagram of the present invention on the test set of the AffectNe dataset. DETAILED DESCRIPTION
[0006] The present invention will be further described in detail below in conjunction with the accompanying drawings.
[0007] The overall network structure model structure of the present invention is as follows Figure 1 As shown in the figure, the pre-extraction block is used to obtain the intermediate layer feature map with appropriate dimension size for further operation, including a two-dimensional convolution layer and two basic blocks of the classic network structure ResNet18. Inspired by Res2Net, the multi-scale block extracts global features through channel segmentation feature maps through different numbers of convolution blocks, thereby reducing the impact of occlusion, pose change and other problems. The permutation attention block extracts local features by strengthening the connection between different dimensions, guiding the spatial split features to concentrate on the salient area of FER. The obtained global features and local features are fused by the decision-level fusion layer after passing through the fully connected layer respectively.
[0008] The residual multi-scale module of the present invention is as follows Figure 2 As shown in the figure, the input feature map X first passes through a 3×3 convolution block to adjust the input feature map channel to a multiple of n, so that the feature map can be evenly divided into n groups according to the channel dimension, and each group of feature maps is recorded as , where i\in \left [ {1,n} \right ] and .Then Through the channel attention module, Each channel feature map in is weighted so that the attention of each branch is focused on the more important channel. The channel attention function is recorded as . Then, After extracting features through 3×3 convolution blocks, the residual structure is combined with Fusion, so that the last branch contains the features extracted by connecting different numbers of 3×3 convolutional blocks in series. Since different numbers of convolution blocks in series have different convolution receptive fields and different scales of feature extraction, each branch contains feature descriptions of different scales. Through this multi-scale feature extraction of the input feature map, the feature representation ability and the robustness of the network model are enhanced.
[0009] In order to improve the generalization ability of each branch, the present invention embeds the residual structure into the sequential architecture to retain the original feature information. In addition, for the input of the first branch and the input of the last branch In terms of the number of feature extractions, in order to ensure that each branch contains rich multi-scale features, the present invention embeds a symmetrical structure in the network model so that each set of feature maps The feature information can be extracted relatively fully without being affected by the branch order. The output of each branch As shown in formula (1).
[0010] {Y}_{k}=\sum ^{k}_{i=1} {{f}^{(k+1-i)}}\left [ {{G}_{i}({X}_{i})} \right ]+{G}_{k}({X}_{k}) Formula (1) Among them, k represents the kth branch, , Represent the input and output feature maps of the kth branch respectively. Represents each group of feature maps The number of 3×3 convolutional blocks passed, The more 3×3 convolution blocks are passed, the larger the scale of the extracted features is. Output feature map of each branch Perform concatenation operation on the channel dimension, as shown in formula (2). Represents a concatenation operation in the channel dimension.
[0011] Formula (2) The two output feature maps obtained by the symmetric structure are added and averaged, and finally the original input and network output are fused through the residual structure to obtain the overall network output. The overall network output is shown in formula (3), where , i\in \left [ {1,n} \right ] and , is the output of the symmetric network.
[0012] Y=\frac {\left [ {{Y}_{1}\cup {Y}_{2}\cup ...\cup {Y}_{n}} \right ]+\left [ {{Y}^{'}_{1}\cup {Y}^{'}_{2}\cup ...\cup {Y}^{'}_{n}} \right ]} {2} Formula (3) The replacement attention mechanism network model of the present invention is as follows Figure 3 As shown, the input feature map , where C, H and W represent the number of channels, height and width of the input feature map respectively. The input feature map is first compressed by global average pooling and global maximum pooling to compress the dimension of the input feature map from C×H×W to C×1×1, and the descriptor of each channel is obtained. Then, the one-dimensional vector composed of the obtained descriptors will pass through two fully connected layers to obtain the attention matrix of the channel dimension. Finally, the attention matrix is multiplied with the input feature map X in the channel dimension to highlight the channel containing key information. The output result is recorded as .
[0013] In the spatial attention module part, the present invention establishes cross-dimensional interdependencies. It will pass through a three-branch network consisting of an upper branch, a middle branch, and a lower branch. The middle branch is the same spatial attention module as CBAM. By compressing the feature map in the channel dimension, the spatial descriptor of the feature map can be obtained, which is the connection of the 1×H×W feature map after global average pooling and global maximum pooling in the channel dimension. The calculation formula of the spatial (HW) descriptor is shown in formula (4).
[0014] {X}_{C-pool}=maxpool\left [ {G(X)} \right ]+avgpool\left [ {G(X)} \right ] Formula (4) in, Represents the output of channel dimension compression. The data dimension of the spatial descriptor is , and then the spatial attention matrix is obtained through convolution operation and then combined with the Sigmoid function Multiply them to emphasize the areas with more effective information in the spatial dimension.
[0015] The upper branch is similar to the middle branch, but the descriptor of this branch is obtained by compressing W. To achieve this, First, through the transposition operation, from The data dimension is transposed to Data dimension, denoted as . Then The W dimension is compressed by global average pooling and global maximum pooling and concatenated by W. Then the CH dimension descriptor is obtained, which is convolved to obtain the CH dimension attention matrix, which is compressed by the Sigmoid function and combined with Multiply by the W dimension to obtain the output feature map after CH dimension attention processing, and then transpose the data dimension of the output feature map to the data dimension of the original feature map for the next step of processing. In this way, the interaction relationship between the C dimension and the H dimension is established. The final output of this branch is shown in formula (5).
[0016] Formula (5) in, represents the Sigmoid activation function, Represents broadcast element-wise multiplication.
[0017] Similarly, the CW dimension descriptor of the lower branch is obtained by compressing the H dimension. from The data dimension is transposed to After the data dimension is transformed, the next branch network adds CW dimension attention to the input feature map to establish the interaction relationship between C dimension and W dimension. The output calculation process is shown in formula (6).
[0018] {Y}^{T}_{H-pool}=\left [ {\sigma ({G(X)}^{T}_{H-pool})\times {G(X)}^{T}} \right ]^{T} Formula (6) After obtaining the outputs of the three branches, the three output feature maps are averaged element-wise to obtain the overall output of the attention network, as shown in formula (7).
[0019] Y=\frac {1} {3}\left \{{\sigma ({G(X)}_{C-pool\,})\times G(X)+\left [ {\sigma ({G(X)}^{T}_{W-pool})\times {G(X)}^{T}} \right ]^{T}+\left [ {\sigma ({G(X)}^{T}_{H-pool})\times {G(X)}^{T}} \right ]^{T}} \right \} Formula (7) By establishing connections between different dimensions, the attention network can more comprehensively exert two-dimensional attention influence on the feature map, which helps to improve the robustness of the network model and the recognition success rate of facial expression recognition tasks in real environments.
[0020] In order to verify the performance of the present invention, the proposed method is experimented on the Fer2013 dataset, the RAF-DB dataset, and the AffectNet dataset. The Fer2013 dataset is collected through an online platform and consists of 35,886 facial images, each of which has a resolution of 48×48 grayscale images. Among them, there are 28,708 training images, 3,589 public test images, and 3,589 private test images, which are saved in CSV file format. Seven basic emotions are displayed in the facial images: anger, disgust, fear, happiness, neutrality, sadness, and surprise. The confusion matrix of the present invention on the test set of the fer2013 dataset is as follows: Figure 4 As shown, the horizontal axis represents the true label, the vertical axis represents the predicted label, the numbers in the grid represent the probability of predicting the corresponding expression, the elements on the main diagonal are correctly identified samples, and the darker the color, the higher the recognition accuracy of the sample.
[0021] The RAF-DB dataset includes a large number of diverse facial images collected in real environments, which contain 7 basic emotions and 12 complex emotions. The present invention uses the 7 basic emotion datasets in RAF-DB for experiments, of which 12,271 images are used as training data and 3,068 images are used as test data. The confusion matrix of the present invention on the test set of the RAF-DB dataset is as follows: Figure 5 As shown, the horizontal axis represents the true label, the vertical axis represents the predicted label, the numbers in the grid represent the probability of predicting the corresponding expression, the elements on the main diagonal are correctly identified samples, and the darker the color, the higher the recognition accuracy of the sample.
[0022] AffectNet dataset: The AffectNet dataset is the largest facial recognition dataset to date, which contains more than 1 million facial images collected from the Internet by querying three major search engines using 1,250 emotion-related keywords in 6 different languages. There are 8 emotion classes in the AffectNet dataset, and in addition to the 7 basic emotions, a contemptuous facial expression category is added. In order to reduce the experimental time while verifying the excellence of the model, we selected 37,553 images from the training folder as training data and 4,000 images from the test folder as test data. The confusion matrix of the present invention on the test set of the AffectNet dataset is shown as follows: Figure 5As shown, the horizontal axis represents the true label, the vertical axis represents the predicted label, the numbers in the grid represent the probability of predicting the corresponding expression, the elements on the main diagonal are correctly identified samples, and the darker the color, the higher the recognition accuracy of the sample.
[0023] In the data preprocessing stage, due to the differences in the shapes of the above datasets used in our experiments, the facial images are uniformly normalized to 224×224 for facial expressions. The resized images will undergo a series of image augmentation operations such as random horizontal flipping, random rotation, and random cropping to expand the dataset and avoid overfitting. In the training stage, we set the data loader size to 64, which results in a training time of about 180 seconds per epoch. The cross entropy loss function is used to quantify the difference between the network's prediction and the true label. We use ResNet-18 as the backbone of the network and use the stochastic gradient descent (SGD) optimizer to update the weights and bias parameters of the model with a momentum of 0.9. The initial learning rate is set to 0.001, and we use an equal interval strategy to adjust the learning rate by setting the step size to 20 and gamma to 0.3, which means that the learning rate is reduced to 30% of its current value every 20 epochs. To ensure a fair comparison, the entire experiment is trained under the same experimental settings. The code is implemented using the Pytorch toolbox on the Pycharm platform, using two NVIDIA GeForce RTX 3090 GPUs. The number of parameters of MPA-Net is 59.129M, and the FLOPs is 4.581G.
Claims
1. A global and local feature facial expression recognition method based on permuted attention, characterized in that Use the residual multi-scale network structure and the permutation attention mechanism module to extract global and local features and perform feature fusion. The specific information is as follows: (1) The residual multi-scale network structure described above is characterized in that, when the step size and the convolution kernel size are the same, the input tensor is passed through different numbers of serial convolution blocks to extract features of different scales. Specifically, the input feature map X is first passed through a 3×3 convolution block to adjust the input feature map channel to a multiple of n, thereby evenly dividing the feature map into n groups according to the channel dimension, and each group of feature maps is recorded as ,in and ,Then Through the channel attention module, Each channel feature map in is weighted so that the attention of each branch is focused on the more important channel. The channel attention function is recorded as , then, After extracting features through 3×3 convolution blocks, the residual structure is combined with Fusion, so that the last branch contains the features extracted by connecting different numbers of 3×3 convolutional blocks in series. Since different numbers of convolution blocks in series have different convolution receptive fields and different scales of feature extraction, each branch contains feature descriptions of different scales. Through this multi-scale feature extraction of the input feature map, the feature representation ability and the robustness of the network model are enhanced. In order to improve the generalization ability of each branch, the present invention embeds the residual structure into the sequential architecture to retain the original feature information. In addition, for the input of the first branch and the input of the last branch In terms of the number of feature extractions, in order to ensure that each branch contains rich multi-scale features, the present invention embeds a symmetrical structure in the network model so that each set of feature maps The feature information can be extracted relatively fully without being affected by the order of branches. The output results of each branch As shown in formula (1), Formula (1) Among them, k represents the kth branch, , Represent the input and output feature maps of the kth branch respectively, Represents each group of feature maps The number of 3×3 convolutional blocks passed, The more 3×3 convolution blocks are passed, the larger the scale of the extracted features is, and the output feature map of each branch is Perform concatenation operation on the channel dimension, as shown in formula (2), where represents the concatenation operation in the channel dimension, Formula (2) The two output feature maps obtained by the symmetric structure are averaged after addition, and finally the original input and network output are fused through the residual structure to obtain the overall network output. The overall network output is shown in formula (3), where , and , is the output of the symmetric network; Formula (3) (2) The permutation attention mechanism module is characterized in that the input feature map is permuted to different dimensions so as to pass through the permutation attention network branches of different dimensions, specifically: the input feature map , where C, H and W represent the number of channels, height and width of the input feature map respectively. The input feature map is first compressed by global average pooling and global maximum pooling to compress the dimension of the input feature map from C×H×W to C×1×1 to obtain the descriptor of each channel. Then, the one-dimensional vector composed of the obtained descriptors will pass through two fully connected layers to obtain the attention matrix of the channel dimension. Finally, the attention matrix is multiplied with the input feature map X in the channel dimension to highlight the channel containing key information. The output result is recorded as In the spatial attention module, the present invention establishes a cross-dimensional interdependence relationship. It will pass through a three-branch network consisting of an upper branch, a middle branch, and a lower branch. The middle branch is the same spatial attention module as CBAM. By compressing the feature map in the channel dimension, the spatial descriptor of the feature map can be obtained, that is, the connection of the 1×H×W feature map after global average pooling and global maximum pooling in the channel dimension. The calculation formula of the spatial (HW) descriptor is shown in formula (4). Formula (4) in, Represents the output of channel dimension compression, and the data dimension of the spatial descriptor is , and then the spatial attention matrix is obtained through convolution operation and then combined with the Sigmoid function Multiply to emphasize the area with more effective information in the spatial dimension, The upper branch is similar to the middle branch, but the descriptor of this branch is obtained by compressing W. To achieve this, First, through the transposition operation, from The data dimension is transposed to Data dimension, denoted as , and then The descriptor is compressed along the W dimension by global average pooling and global maximum pooling and concatenated by W, and then the CH dimension descriptor is obtained. After convolution, the descriptor obtains the CH dimension attention matrix, which is compressed by the Sigmoid function and combined with Multiply by the W dimension to obtain the output feature map after CH dimension attention processing, and then transpose the data dimension of the output feature map to the data dimension of the original feature map for the next step of processing. In this way, the interaction relationship between the C dimension and the H dimension is established. The final output of this branch is shown in formula (5). Formula (5) in, represents the Sigmoid activation function, represents broadcast element-wise multiplication, Similarly, the CW dimension descriptor of the lower branch is obtained by compressing the H dimension. from The data dimension is transposed to After the data dimension is transformed, the CW dimension attention is added to the input feature map through the lower branch network to establish the interaction relationship between the C dimension and the W dimension. The output calculation process is shown in formula (6). Formula(6) After obtaining the outputs of the three branches, the three output feature maps are averaged at the element level to obtain the overall output of the TDAM network, as shown in formula (7): Formulas (7) By establishing connections between different dimensions, the attention network can exert a more comprehensive two-dimensional attention influence on the feature map.
Citation Information
Patent Citations
Facial expression recognition method based on multi-scale feature extraction and multi-attention mechanism modeling
CN113420703A
Facial expression recognition method based on attention mechanism
CN116543443A
Face and situational emotion recognition method based on attention mechanism
CN117636426A
Cited By
Emotion recognition method based on global feature and local feature fusion network
CN119339420A
Image classification method and system based on improved lightweight channel attention mechanism
CN120451621A
