A method and system for view-independent facial expression recognition based on contrastive learning

Through the perspective-independent facial expression recognition method based on contrastive learning, using VI-FER network and multiple loss functions, the problem of low facial expression recognition accuracy in non-frontal views is solved, and more efficient perspective-independent feature learning and expression classification are achieved.

CN118430053BActive Publication Date: 2024-10-01EAST CHINA JIAOTONG UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410888221.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-04
Publication Date
2024-10-01
Estimated Expiration
2044-07-04

AI Technical Summary

Technical Problem

Facial expression recognition has low accuracy when dealing with non-frontal views, mainly due to feature differences caused by different viewing angles.

Method used

A perspective-independent facial expression recognition method based on contrastive learning is adopted, by constructing a VI-FER network, using supervised contrast loss, multi-view contrast loss and redundancy reduction loss sub-functions, combined with the final projection head and the intermediate projection head, to train the encoder to learn View-independent expression features and reduce redundancy and ambiguity in features.

Benefits of technology

The accuracy of facial expression recognition is improved, especially when processing non-frontal views, it can more effectively distinguish expression features unrelated to the learning view, and reduce recognition errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118430053B_ABST
    Figure CN118430053B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and system for view-independent facial expression recognition based on contrastive learning. The method comprises: adopting a supervised contrast loss sub-function to learn view-independent expression features using the proposed self-supervised contrast loss, then, a multi-view contrast loss sub-function to distinguish the view-independent features of each expression learned from other expressions to distinguish expression categories, further, since facial expressions usually have very subtle differences in the learned feature space, a redundancy reduction loss sub-function is added to reduce redundancy and correlation in the learned features, aiming to reduce ambiguity in the learned features, and finally, for the network structure, a final projection head is added after the final convolution block of the encoder to generate the final output embedding, and an intermediate projection head is added after the attention mechanism module and the feature fusion module of the encoder, and the use of the intermediate projection head is helpful to learn good features.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of facial expression recognition, and in particular relates to a viewpoint-independent facial expression recognition method and system based on contrastive learning. Background Art

[0002] Facial expression is an important form of non-verbal communication. Facial expression contains rich emotional information and is one of the external manifestations of human emotions. It plays an important role in communication between people. By observing a person's facial expression, one can perceive the other person's joy, anger, sorrow, and happiness. The method of automatically recognizing human emotions from the face is called facial expression recognition (FER). Facial expression recognition allows the system to understand and adapt to human reactions, thus playing a key role in human-computer interaction systems. However, FER remains a challenging task due to a series of problems such as the subtlety of expression display caused by facial movements. Therefore, a solution that can learn compact and decorrelated features is needed to achieve robust FER.

[0003] In real environments, face images are likely to be taken from different angles and do not always follow a clear and standard frontal view, which may lead to inaccurate facial expression recognition when processing non-frontal images with perspectives that are very different from those used during training. Summary of the invention

[0004] The present invention provides a view-independent facial expression recognition method and system based on contrastive learning, which are used to solve the technical problem that inaccurate facial expression recognition may occur when processing non-frontal images with greatly different view angles used in the training process.

[0005] In a first aspect, the present invention provides a view-independent facial expression recognition method based on contrastive learning, comprising:

[0006] Constructing a VI-FER network, wherein the VI-FER network comprises an encoder and a final projection head connected to the encoder, wherein the final projection head is a first shallow neural network having two fully connected layers, and the encoder comprises a first intermediate projection head and a second intermediate projection head;

[0007] Acquire at least one frontal facial expression image of a portrait and a first category label corresponding to the at least one frontal facial expression image to obtain a positive sample set, and acquire at least one non-frontal facial expression image of a portrait and a second category label corresponding to the at least one non-frontal facial expression image to obtain a negative sample set;

[0008] Respectively taking at least one frontal facial expression image in the positive sample set and at least one non-frontal facial expression image in the negative sample set as inputs of the VI-FER network, and taking the corresponding first category label and the second category label as outputs of the VI-FER network, training to obtain a final facial expression recognition model, wherein the target loss function of the facial expression recognition model includes a supervised contrast loss sub-function, a multi-view contrast loss sub-function, and a redundancy reduction loss sub-function;

[0009] The expression of the redundancy reduction loss sub-function is:

[0010] ,

[0011] In the formula, is the objective loss function of the VI-FER network, is the loss of the intermediate layers used to train the encoder attention module, is the loss of the intermediate layers used to train the encoder feature fusion module;

[0012] ,

[0013] In the formula, for or , is an irrelevant term, which is used to make the diagonal elements of the cross-correlation matrix equivalent to 1. is the loss function for compact feature learning, which is used to make the items outside the diagonal equivalent to 0. is a coefficient between 0 and 1, To reduce the comparison loss of redundant negative samples, To reduce the comparison loss of redundant positive samples;

[0014] ,

[0015] In the formula, is the batch size, To obtain an enhanced embedding, the dimension index of the embedding vector is i, To obtain an embedding based on another enhancement, the dimension index of the embedding vector is j;

[0016] ,

[0017] In the formula, is the number of negative sample pairs, It is the feature extraction function of the model, used to extract positive samples The characteristic representation of For extracting input negative samples The feature extraction function is To extract negative samples The feature extraction function is is a small constant used to prevent the denominator from being zero. is a positive sample with dimension i, is a negative sample with a dimension of j. For Negative samples of the same type, whose dimension is k;

[0018] ,

[0019] In the formula, is the number of positive sample pairs, For extracting input positive samples Feature extraction function;

[0020] The acquired real-time non-orthographic facial expression image is input into the facial expression recognition model, and the facial expression recognition model outputs an expression classification result corresponding to the real-time non-orthographic facial expression image.

[0021] In a second aspect, the present invention provides a view-independent facial expression recognition system based on contrastive learning, comprising:

[0022] A construction module is configured to construct a VI-FER network, wherein the VI-FER network includes an encoder and a final projection head connected to the encoder, wherein the final projection head is a first shallow neural network with two fully connected layers, and the encoder includes a first intermediate projection head and a second intermediate projection head;

[0023] An acquisition module is configured to acquire at least one frontal facial expression image of a portrait and a first category label corresponding to the at least one frontal facial expression image to obtain a positive sample set, and acquire at least one non-frontal facial expression image of a portrait and a second category label corresponding to the at least one non-frontal facial expression image to obtain a negative sample set;

[0024] A training module is configured to use at least one frontal facial expression image in the positive sample set and at least one non-frontal facial expression image in the negative sample set as inputs of the VI-FER network, and use the corresponding first category label and the second category label as outputs of the VI-FER network, to train and obtain a final facial expression recognition model, wherein the target loss function of the facial expression recognition model includes a supervised contrast loss sub-function, a multi-view contrast loss sub-function, and a redundancy reduction loss sub-function;

[0025] The expression of the redundancy reduction loss sub-function is:

[0026] ,

[0027] In the formula, is the objective loss function of the VI-FER network, is the loss of the intermediate layers used to train the encoder attention module, is the loss of the intermediate layers used to train the encoder feature fusion module;

[0028] ,

[0029] In the formula, for or , is an irrelevant term, which is used to make the diagonal elements of the cross-correlation matrix equivalent to 1. is the loss function for compact feature learning, which is used to make the items outside the diagonal equivalent to 0. is a coefficient between 0 and 1, To reduce the comparison loss of redundant negative samples, To reduce the comparison loss of redundant positive samples;

[0030] ,

[0031] In the formula, is the batch size, To obtain an enhanced embedding, the dimension index of the embedding vector is i, To obtain an embedding based on another enhancement, the dimension index of the embedding vector is j;

[0032] ,

[0033] In the formula, is the number of negative sample pairs, It is the feature extraction function of the model, used to extract positive samples The characteristic representation of For extracting input negative samples The feature extraction function is To extract negative samples The feature extraction function is is a small constant used to prevent the denominator from being zero. is a positive sample with dimension i, is a negative sample with a dimension of j. For Negative samples of the same type, whose dimension is k;

[0034] ,

[0035] In the formula, is the number of positive sample pairs, For extracting input positive samples Feature extraction function;

[0036] The output module is configured to input the acquired real-time non-orthographic facial expression image into the facial expression recognition model, and the facial expression recognition model outputs an expression classification result corresponding to the real-time non-orthographic facial expression image.

[0037] According to a third aspect, an electronic device is provided, comprising: at least one processor, and a memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform the steps of the view-independent facial expression recognition method based on contrastive learning of any embodiment of the present invention.

[0038] In a fourth aspect, the present invention further provides a computer-readable storage medium having a computer program stored thereon, wherein when the program instructions are executed by a processor, the processor executes the steps of the view-independent facial expression recognition method based on contrastive learning of any embodiment of the present invention.

[0039] The present application discloses a view-independent facial expression recognition method and system based on contrastive learning. The supervised contrast loss sub-function aims to learn view-independent expression features using the proposed self-supervised contrast loss. This loss combines different views of the same subject with specific expressions in the embedding space to learn view-independent features. Then, the multi-view contrast loss sub-function aims to distinguish the learned view-independent features of each expression from other expressions to distinguish expression categories. Furthermore, since facial expressions usually have very subtle differences in the learned feature space, a redundancy reduction loss sub-function is added to reduce the redundancy and correlation in the learned features, aiming to reduce the ambiguity in the learned features. Finally, for the network structure, a final projection head (a shallow neural network with two fully connected layers) is added after the final convolution block of the encoder to generate the final output embedding, and an intermediate projection head is added after the attention mechanism module and the feature fusion module of the encoder. The use of the intermediate projection head helps to learn good features. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0041] Figure 1A flowchart of a method for view-independent facial expression recognition based on contrastive learning provided by one embodiment of the present invention;

[0042] Figure 2 A flowchart of a view-independent facial expression recognition process according to a specific embodiment of the present invention;

[0043] Figure 3 A structural block diagram of a view-independent facial expression recognition system based on contrastive learning provided by one embodiment of the present invention;

[0044] Figure 4 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0045] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0046] See also Figure 1 , which shows a flowchart of a view-independent facial expression recognition method based on contrastive learning in the present application.

[0047] like Figure 1 As shown, the view-independent facial expression recognition method based on contrastive learning specifically includes the following steps:

[0048] Step S101, constructing a VI-FER network, wherein the VI-FER network includes an encoder and a final projection head connected to the encoder, wherein the final projection head is a first shallow neural network with two fully connected layers, and the encoder includes a first intermediate projection head and a second intermediate projection head.

[0049] In this step, VI-FER (VI: view; FER: facial expression recognition) contains an encoder, which includes an image preprocessing module, a feature extraction module, an attention mechanism module, a feature fusion module, and an encoder output module. A final projection head (a shallow neural network with two fully connected layers) is added after the final convolutional block of the encoder to generate the final output embedding. In addition to the final projection head, two intermediate projection heads are connected to the end of the attention mechanism module and the feature fusion module of the encoder. The intermediate projection head is a shallow neural network composed of a convolutional layer, an adaptive average pooling layer, and two fully connected layers. The use of multiple layers of projection heads helps to learn good features.

[0050] Image preprocessing module: Improve the formula of adaptive histogram equalization (CLAHE) contrast enhancement, introduce more complex nonlinear transformation and parameterized adjustment. You can use a learnable adjustment function or neural network to dynamically adjust the contrast of the image, making the details in the image clearer:

[0051] ,

[0052] In the formula, For images enhanced using the improved CLAHE, is the input image or feature, CLAHE is the adaptive histogram equalization function, To use CLAHE for contrast enhancement, are the parameters of CLAHE, is a nonlinear transformation function, are the parameters of the nonlinear transformation function;

[0053] Feature extraction module: adopts an improved residual network (ResNet) structure, adds more residual blocks, and increases the channel attention mechanism to extract richer and more semantically rich feature representations:

[0054] ,

[0055] In the formula, is the extracted feature map, For the improved residual network model, is the parameter set of the residual network, including the weights and biases of each residual block and attention mechanism;

[0056] Attention mechanism module: Introduce a multi-scale self-attention mechanism so that the model can learn the attention weights at different scales. The formula is:

[0057] ,

[0058] ,

[0059] In the formula, is the output of the multi-scale self-attention module, The function is used to normalize the attention coefficient to a probability distribution. is a fully connected layer, which is used to extract the feature map Mapped to the dimension of the attention coefficient, is the ReLU activation function, is the global average pooling operation, is the weight matrix;

[0060] Feature fusion module: uses the skip connection improved formula of dense connection structure to fuse shallow features with deep features:

[0061] ,

[0062] In the formula, is the output representation of the feature fusion module, is the weight matrix of RGB, is the feature representation of RGB, is the weight matrix of the depth image, is the feature representation of the depth image, is the weight matrix of the attention feature, is the bias vector, for Activation function;

[0063] Encoder output module: Introducing a more complex structural conditional generator to generate output based on specific conditional information. This improvement can make the encoder more flexible and able to generate output that meets specific conditions.

[0064] ,

[0065] In the formula, For multi-modal generated images, is a random noise input, is conditional information;

[0066] The final projection head is a shallow neural network with two fully connected layers and can be represented as:

[0067] ,

[0068] In the formula, is the output feature representation of the final convolutional block of the encoder, is the final output of the projection head, It consists of a fully connected layer + activation function (ReLU) + pooling layer. It consists of fully connected layers;

[0069] The expression of the first intermediate projection head is:

[0070] ,

[0071] In the formula, is the output of the first intermediate projection head, is the first convolutional layer and the first adaptive average pooling layer, is the first fully connected layer and the first activation function, is the output feature of the attention mechanism module;

[0072] The expression of the second intermediate projection head is:

[0073] ,

[0074] In the formula, is the output of the second intermediate projection head, is the second convolutional layer and the second adaptive average pooling layer, is the second fully connected layer and the second activation function, is the output feature of the feature fusion module.

[0075] Step S102, obtaining at least one frontal facial expression image of the portrait and a first category label corresponding to the at least one frontal facial expression image to obtain a positive sample set, and obtaining at least one non-frontal facial expression image of the portrait and a second category label corresponding to the at least one non-frontal facial expression image to obtain a negative sample set.

[0076] In this step, see Figure 2 ,Data collection: Use appropriate data collection tools (such as webcams, cameras, etc.) to collect face image data related to the task. (1) Selection of positive samples xi: Select images belonging to the front view from the labeled dataset as positive samples xi. (2) Selection of negative samples xj: Select images that do not belong to the same category as the positive samples or do not have the target features from the dataset as negative samples xj. Therefore, all views except the front view can be selected. Negative sample images should have a certain difference from positive samples so that the model can learn a better classification decision boundary.

[0077] Data labeling: Label the collected image data and mark the categories or feature information of positive and negative samples. This can be done manually or automatically using a predefined algorithm. For positive samples xi and negative samples xj, the labeling process is usually as follows: (1) Label the positive sample xi: Mark the positive category label as xi, indicating that the model should learn the features that distinguish this category from other categories. (2) Label the negative sample xj: Mark the negative category label as xj, indicating that the model should learn to distinguish the difference between positive and negative categories to avoid confusion. The labeled sample data and the corresponding label information are stored and managed. Databases or standard data storage formats (such as CSV, JSON, etc.) can be used for management to ensure data accessibility and consistency.

[0078] Data preprocessing: Preprocess the collected image data, including image resizing, grayscale, normalization, etc., to facilitate subsequent feature extraction and model training. The following is the specific process and related formulas of data preprocessing.

[0079] Image resizing: Image resizing is to ensure that all image inputs have the same size, which is a basic requirement when deep learning models process images. Common resizing methods include cropping and resizing. (1) Crop: Cropping an image to a fixed size, retaining the center of the image or the area of ​​interest, often used to process images of different sizes. (2) Resize: Scale the image to a fixed size in proportion, often used to unify the image to the input size accepted by the model.

[0080] Image Enhancement: The enhancement module for generating positive samples is a very important component of contrastive training. The choice of the enhancement module is crucial to the final performance of the model. In the method of the present invention, the enhancement is random adjustment cropping (RC), random color jittering (CJ), random horizontal flipping (HF), random Gaussian blurring (GB), and random grayscale scaling (GS). The enhancement module uses random flipping and random blurring (with a probability of 0.5) and random grayscale scaling (with a probability of 0.2). For random cropping, the cropping area is selected between 0.2 and 1. For color jittering, the brightness, saturation, and contrast are randomly changed, with coefficients randomly selected between 0.4 and 1, while the change coefficient of hue is randomly selected between 0.2 and 1.

[0081] Although augmentation was helpful in the comparison pre-processing stage, less augmentation was used in the fine-tuning stage. In the pre-processing stage, all the above augmentations were used. In the fine-tuning stage, only random resize crops and horizontal flipping were used. Finally, no augmentation was used at all when testing the model.

[0082] Grayscale: Grayscale operation converts color images into grayscale images, reduces the number of image channels, reduces computational complexity, and retains the main features of the image. This application method improves the grayscale formula:

[0083] ,

[0084] Where R(x,y), G(x,y), and B(x,y) represent the pixel values ​​of the red, green, and blue channels of the image at the (x,y) coordinates, respectively; Gray(x,y) is the pixel value of the grayscale image at the (x,y) coordinates.

[0085] Normalization: Normalization is to scale the pixel values ​​of an image so that they fall within a specific range, such as [0,1] or [-1,1], and perform mean-variance normalization on the image. This normalization method can adjust the pixel values ​​of an image according to the mean and standard deviation, so that the image data has zero mean and unit variance, which helps to improve the stability and convergence speed of model training. The improved normalization formula used is:

[0086] A color image, denoted as I, contains three channels: red channel R, green channel G, and blue channel B. For each channel, the mean and variance It can be calculated as:

[0087] ,

[0088] ,

[0089] Where M and N are the height and width of the image respectively. Represents the pixel value of the cth channel at position (i, j) of the image.

[0090] Then, the mean variance normalization operation is performed on each channel of the image:

[0091] ,

[0092] in, is the normalized pixel value, is a small constant (e.g. 10−8) used to prevent division by zero errors. This allows each channel of the image to be within the range of mean 0 and variance 1, which helps accelerate the model training process and improve the stability of the model. This normalization operation is often used to preprocess image data in deep learning models.

[0093] Step S103, respectively using at least one frontal facial expression image in the positive sample set and at least one non-frontal facial expression image in the negative sample set as inputs of the VI-FER network, and using the corresponding first category label and the second category label as outputs of the VI-FER network, training to obtain a final facial expression recognition model, wherein the target loss function of the facial expression recognition model includes a supervised contrast loss sub-function, a multi-view contrast loss sub-function, and a redundancy reduction loss sub-function.

[0094] In this step, the objective loss function of the facial expression recognition model is expressed as:

[0095] ,

[0096] In the formula, is the objective loss function of the facial expression recognition model, is the multi-view contrast loss sub-function, is the supervised contrast loss sub-function, is the coefficient of the supervised contrast loss sub-function, is the coefficient of the multi-view contrast loss sub-function, is the coefficient of the redundancy loss sub-function.

[0097] Through experiments, we adjust the hyperparameter values ​​many times and get =0.4, =0.3 and = 0.6 gives the best result.

[0098] Specifically, the expression of the redundancy reduction loss subfunction is:

[0099] ,

[0100] In the formula, is the objective loss function of the VI-FER network, is the loss of the intermediate layers used to train the encoder attention module, is the loss of the intermediate layers used to train the encoder feature fusion module;

[0101] ,

[0102] In the formula, for or , is an irrelevant term, which is used to make the diagonal elements of the cross-correlation matrix equivalent to 1. is the loss function for compact feature learning, which is used to make the items outside the diagonal equivalent to 0. is a coefficient between 0 and 1, To reduce the comparison loss of redundant negative samples, To reduce the comparison loss of redundant positive samples;

[0103] ,

[0104] In the formula, is the batch size, To obtain an enhanced embedding, the dimension index of the embedding vector is i, To obtain an embedding based on another enhancement, the dimension index of the embedding vector is j;

[0105] ,

[0106] In the formula, is the number of negative sample pairs, It is the feature extraction function of the model, used to extract positive samples The characteristic representation of For extracting input negative samples The feature extraction function is To extract negative samples The feature extraction function is is a small constant used to prevent the denominator from being zero. is a positive sample with dimension i, is a negative sample with a dimension of j. For Negative samples of the same type, whose dimension is k;

[0107] ,

[0108] In the formula, is the number of positive sample pairs, For extracting input positive samples Feature extraction function;

[0109] The expression of the supervised contrast loss subfunction is:

[0110] ,

[0111] In the formula, is the supervised contrast loss sub-function, is the similarity score between different views of the same expression, is the similarity score between different expressions, is a hyperparameter that controls the weight of negative samples. is a hyperparameter that controls the boundary value of negative samples. is the number of positive sample pairs, is the temperature parameter, which is used to control the smoothness of the similarity distribution.

[0112] The expression of the multi-view contrast loss subfunction is:

[0113] ,

[0114] In the formula, is the multi-view contrast loss sub-function, is the weight of sample pair (i, j), is an indicator function, which means that when i is not equal to j, the value is 1, otherwise it is 0, which is used to filter out the same sample pairs. is another indicator function, which means that when the characteristic function values ​​of sample i and sample j are equal, the value is 1, otherwise it is 0, which is used to ensure that samples with the same characteristic function value can be captured. is the view-independent index of the image, Positive sample and negative samples The similarity between

[0115] ,

[0116] In the formula, Positive sample The final projected embedding vector, Negative samples The final projected embedding vector, is the index of the second enhanced image;

[0117] ,

[0118] In the formula, is the number of images with the same view-independent index.

[0119] Step S104, inputting the acquired real-time non-orthographic facial expression image into the facial expression recognition model, and the facial expression recognition model outputs an expression classification result corresponding to the real-time non-orthographic facial expression image.

[0120] In summary, the method of the present application, the supervised contrast loss sub-function aims to utilize the proposed self-supervised contrast loss to learn view-independent expression features. This loss combines different views of the same subject with specific expressions in the embedding space to learn view-independent features. Then, the multi-view contrast loss sub-function aims to distinguish the learned view-independent features of each expression from other expressions to distinguish expression categories. Furthermore, since facial expressions usually have very subtle differences in the learned feature space, a redundancy reduction loss sub-function is added to reduce the redundancy and correlation in the learned features, aiming to reduce the ambiguity in the learned features. Finally, for the network structure, a final projection head (a shallow neural network with two fully connected layers) is added after the final convolution block of the encoder to generate the final output embedding, and an intermediate projection head is added after the attention mechanism module and the feature fusion module of the encoder. The use of the intermediate projection head helps to learn good features.

[0121] See also Figure 3 , which shows a structural block diagram of a view-independent facial expression recognition system based on contrastive learning in the present application.

[0122] like Figure 3 As shown, the viewpoint-independent facial expression recognition system 200 includes a construction module 210 , an acquisition module 220 , a training module 230 and an output module 240 .

[0123] The construction module 210 is configured to construct a VI-FER network, wherein the VI-FER network includes an encoder and a final projection head connected to the encoder, wherein the final projection head is a first shallow neural network having two fully connected layers, and the encoder includes a first intermediate projection head and a second intermediate projection head;

[0124] The acquisition module 220 is configured to acquire at least one frontal facial expression image of a portrait and a first category label corresponding to the at least one frontal facial expression image to obtain a positive sample set, and acquire at least one non-frontal facial expression image of a portrait and a second category label corresponding to the at least one non-frontal facial expression image to obtain a negative sample set;

[0125] The training module 230 is configured to respectively use at least one frontal facial expression image in the positive sample set and at least one non-frontal facial expression image in the negative sample set as inputs of the VI-FER network, and use the corresponding first category label and the second category label as outputs of the VI-FER network, to train and obtain a final facial expression recognition model, wherein the target loss function of the facial expression recognition model includes a supervised contrast loss sub-function, a multi-view contrast loss sub-function, and a redundancy reduction loss sub-function;

[0126] The expression of the redundancy reduction loss sub-function is:

[0127] ,

[0128] In the formula, is the objective loss function of the VI-FER network, is the loss of the intermediate layers used to train the encoder attention module, is the loss of the intermediate layers used to train the encoder feature fusion module;

[0129] ,

[0130] In the formula, for or , is an irrelevant term, which is used to make the diagonal elements of the cross-correlation matrix equivalent to 1. is the loss function for compact feature learning, which is used to make the items outside the diagonal equivalent to 0. is a coefficient between 0 and 1, To reduce the comparison loss of redundant negative samples, To reduce the comparison loss of redundant positive samples;

[0131] ,

[0132] In the formula, is the batch size, To obtain an enhanced embedding, the dimension index of the embedding vector is i, To obtain an embedding based on another enhancement, the dimension index of the embedding vector is j;

[0133] ,

[0134] In the formula, is the number of negative sample pairs, It is the feature extraction function of the model, used to extract positive samples The characteristic representation of For extracting input negative samples The feature extraction function is To extract negative samples The feature extraction function is is a small constant used to prevent the denominator from being zero. is a positive sample with dimension i, is a negative sample with a dimension of j. For Negative samples of the same type, whose dimension is k;

[0135] ,

[0136] In the formula, is the number of positive sample pairs, For extracting input positive samples Feature extraction function;

[0137] The output module 240 is configured to input the acquired real-time non-orthographic facial expression image into the facial expression recognition model, and the facial expression recognition model outputs an expression classification result corresponding to the real-time non-orthographic facial expression image.

[0138] It should be understood that Figure 3 Modules and references documented in Figure 1 Therefore, the operations and features described above for the method and the corresponding technical effects are also applicable to Figure 3 The modules in it will not be described in detail here.

[0139] In some other embodiments, the embodiments of the present invention further provide a computer-readable storage medium having a computer program stored thereon, wherein when the program instructions are executed by a processor, the processor is caused to execute the view-independent facial expression recognition method based on contrastive learning in any of the above method embodiments;

[0140] As an implementation mode, the computer-readable storage medium of the present invention stores computer-executable instructions, and the computer-executable instructions are configured as follows:

[0141] Constructing a VI-FER network, wherein the VI-FER network comprises an encoder and a final projection head connected to the encoder, wherein the final projection head is a first shallow neural network having two fully connected layers, and the encoder comprises a first intermediate projection head and a second intermediate projection head;

[0142] Acquire at least one frontal facial expression image of a portrait and a first category label corresponding to the at least one frontal facial expression image to obtain a positive sample set, and acquire at least one non-frontal facial expression image of a portrait and a second category label corresponding to the at least one non-frontal facial expression image to obtain a negative sample set;

[0143] Respectively taking at least one frontal facial expression image in the positive sample set and at least one non-frontal facial expression image in the negative sample set as inputs of the VI-FER network, and taking the corresponding first category label and the second category label as outputs of the VI-FER network, training to obtain a final facial expression recognition model, wherein the target loss function of the facial expression recognition model includes a supervised contrast loss sub-function, a multi-view contrast loss sub-function, and a redundancy reduction loss sub-function;

[0144] The expression of the redundancy reduction loss sub-function is:

[0145] ,

[0146] In the formula, is the objective loss function of the VI-FER network, is the loss of the intermediate layers used to train the encoder attention module, is the loss of the intermediate layers used to train the encoder feature fusion module;

[0147] ,

[0148] In the formula, for or , is an irrelevant term, which is used to make the diagonal elements of the cross-correlation matrix equivalent to 1. is the loss function for compact feature learning, which is used to make the items outside the diagonal equivalent to 0. is a coefficient between 0 and 1, To reduce the comparison loss of redundant negative samples, To reduce the comparison loss of redundant positive samples;

[0149] ,

[0150] In the formula, is the batch size, To obtain an enhanced embedding, the dimension index of the embedding vector is i, To obtain an embedding based on another enhancement, the dimension index of the embedding vector is j;

[0151] ,

[0152] In the formula, is the number of negative sample pairs, It is the feature extraction function of the model, used to extract positive samples The characteristic representation of For extracting input negative samples The feature extraction function is To extract negative samples The feature extraction function is is a small constant used to prevent the denominator from being zero. is a positive sample with dimension i, is a negative sample with a dimension of j. For Negative samples of the same type, whose dimension is k;

[0153] ,

[0154] In the formula, is the number of positive sample pairs, For extracting input positive samples Feature extraction function;

[0155] The acquired real-time non-orthographic facial expression image is input into the facial expression recognition model, and the facial expression recognition model outputs an expression classification result corresponding to the real-time non-orthographic facial expression image.

[0156] The computer-readable storage medium may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required by at least one function; the data storage area may store data created according to the use of the view-independent facial expression recognition system based on contrastive learning, etc. In addition, the computer-readable storage medium may include a high-speed random access memory, and may also include a memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the computer-readable storage medium may optionally include a memory remotely arranged relative to the processor, and these remote memories may be connected to the view-independent facial expression recognition system based on contrastive learning via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0157] Figure 4 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention, such as Figure 4 As shown, the device includes: a processor 310 and a memory 320. The electronic device may also include: an input device 330 and an output device 340. The processor 310, the memory 320, the input device 330 and the output device 340 may be connected via a bus or other means. Figure 4 In the example, the connection via bus is taken as an example. The memory 320 is the above-mentioned computer-readable storage medium. The processor 310 executes various functional applications and data processing of the server by running the non-volatile software programs, instructions and modules stored in the memory 320, that is, the perspective-independent facial expression recognition method based on contrastive learning of the above-mentioned method embodiment is realized. The input device 330 can receive input digital or character information, and generate key signal input related to user settings and function controls of the perspective-independent facial expression recognition system based on contrastive learning. The output device 340 may include display devices such as display screens.

[0158] The electronic device can execute the method provided by the embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not described in detail in this embodiment, please refer to the method provided by the embodiment of the present invention.

[0159] As an implementation mode, the electronic device is applied to a view-independent facial expression recognition system based on contrastive learning, and is used for a client, comprising: at least one processor; and a memory connected to the at least one processor in communication; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can:

[0160] Constructing a VI-FER network, wherein the VI-FER network comprises an encoder and a final projection head connected to the encoder, wherein the final projection head is a first shallow neural network having two fully connected layers, and the encoder comprises a first intermediate projection head and a second intermediate projection head;

[0161] Acquire at least one frontal facial expression image of a portrait and a first category label corresponding to the at least one frontal facial expression image to obtain a positive sample set, and acquire at least one non-frontal facial expression image of a portrait and a second category label corresponding to the at least one non-frontal facial expression image to obtain a negative sample set;

[0162] Respectively taking at least one frontal facial expression image in the positive sample set and at least one non-frontal facial expression image in the negative sample set as inputs of the VI-FER network, and taking the corresponding first category label and the second category label as outputs of the VI-FER network, training to obtain a final facial expression recognition model, wherein the target loss function of the facial expression recognition model includes a supervised contrast loss sub-function, a multi-view contrast loss sub-function, and a redundancy reduction loss sub-function;

[0163] The expression of the redundancy reduction loss sub-function is:

[0164] ,

[0165] In the formula, is the objective loss function of the VI-FER network, is the loss of the intermediate layers used to train the encoder attention module, is the loss of the intermediate layers used to train the encoder feature fusion module;

[0166] ,

[0167] In the formula, for or , is an irrelevant term, which is used to make the diagonal elements of the cross-correlation matrix equivalent to 1. is the loss function for compact feature learning, which is used to make the items outside the diagonal equivalent to 0. is a coefficient between 0 and 1, To reduce the comparison loss of redundant negative samples, To reduce the comparison loss of redundant positive samples;

[0168] ,

[0169] In the formula, is the batch size, To obtain an enhanced embedding, the dimension index of the embedding vector is i, To obtain an embedding based on another enhancement, the dimension index of the embedding vector is j;

[0170] ,

[0171] In the formula, is the number of negative sample pairs, It is the feature extraction function of the model, used to extract positive samples The characteristic representation of For extracting input negative samples The feature extraction function is To extract negative samples The feature extraction function is is a small constant used to prevent the denominator from being zero. is a positive sample with dimension i, is a negative sample with a dimension of j. For Negative samples of the same type, whose dimension is k;

[0172] ,

[0173] In the formula, is the number of positive sample pairs, For extracting input positive samples Feature extraction function;

[0174] The acquired real-time non-orthographic facial expression image is input into the facial expression recognition model, and the facial expression recognition model outputs an expression classification result corresponding to the real-time non-orthographic facial expression image.

[0175] Through the description of the above implementation modes, those skilled in the art can clearly understand that each implementation mode can be implemented by means of software plus a necessary general hardware platform, or of course by hardware. Based on such an understanding, the above technical solution can essentially or in other words be embodied in the form of a software product that contributes to the prior art. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or some parts of the embodiment.

[0176] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. 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 view-independent facial expression recognition method based on contrastive learning, characterized in that: include: Constructing a VI-FER network, wherein the VI-FER network comprises an encoder and a final projection head connected to the encoder, wherein the final projection head is a first shallow neural network with two fully connected layers, and the encoder comprises an image preprocessing module, a feature extraction module, an attention mechanism module, a first intermediate projection head connected to the attention mechanism module, a feature fusion module, a second intermediate projection head connected to the feature fusion module, and an encoder output module; The expression of the first intermediate projection head is: , In the formula, is the output of the first intermediate projection head, is the first convolutional layer and the first adaptive average pooling layer, is the first fully connected layer and the first activation function, is the output feature of the attention mechanism module; The expression of the second intermediate projection head is: , In the formula, is the output of the second intermediate projection head, is the second convolutional layer and the second adaptive average pooling layer, is the second fully connected layer and the second activation function, is the output feature of the feature fusion module; Acquire at least one frontal facial expression image of a portrait and a first category label corresponding to the at least one frontal facial expression image to obtain a positive sample set, and acquire at least one non-frontal facial expression image of a portrait and a second category label corresponding to the at least one non-frontal facial expression image to obtain a negative sample set; Respectively taking at least one frontal facial expression image in the positive sample set and at least one non-frontal facial expression image in the negative sample set as inputs of the VI-FER network, and taking the corresponding first category label and the second category label as outputs of the VI-FER network, training to obtain a final facial expression recognition model, wherein the target loss function of the facial expression recognition model includes a supervised contrast loss sub-function, a multi-view contrast loss sub-function, and a redundancy reduction loss sub-function; The expression of the redundancy reduction loss sub-function is: , In the formula, is the objective loss function of the VI-FER network, is the loss of the intermediate layers used to train the encoder attention module, is the loss of the intermediate layers used to train the encoder feature fusion module; , In the formula, for or , is an irrelevant term, which is used to make the diagonal elements of the cross-correlation matrix equivalent to 1. is the loss function for compact feature learning, which is used to make the items outside the diagonal equivalent to 0. is a coefficient between 0 and 1, To reduce the comparison loss of redundant negative samples, To reduce the comparison loss of redundant positive samples; , In the formula, is the batch size, To obtain an enhanced embedding, the dimension index of the embedding vector is i, To obtain an embedding based on another enhancement, the dimension index of the embedding vector is j; , In the formula, is the number of negative sample pairs, It is the feature extraction function of the model, used to extract positive samples The characteristic representation of For extracting input negative samples The feature extraction function is To extract negative samples The feature extraction function is is a small constant used to prevent the denominator from being zero. is a positive sample with dimension i, is a negative sample with a dimension of j. For Negative samples of the same type, whose dimension is k; , In the formula, is the number of positive sample pairs, For extracting input positive samples Feature extraction function; The expression of the supervised contrast loss subfunction is: , In the formula, is the supervised contrast loss sub-function, is the similarity score between different views of the same expression, is the similarity score between different expressions, is a hyperparameter that controls the weight of negative samples. is a hyperparameter that controls the boundary value of negative samples. is the number of positive sample pairs, is the temperature parameter, which is used to control the smoothness of the similarity distribution; The expression of the multi-view contrast loss sub-function is: , In the formula, is the multi-view contrast loss sub-function, is the weight of the sample pair (i, j), is an indicator function, which means that when i is not equal to j, the value is 1, otherwise it is 0, which is used to filter out the same sample pairs. is another indicator function, which means that when the characteristic function values ​​of sample i and sample j are equal, the value is 1, otherwise it is 0, which is used to ensure that samples with the same characteristic function value can be captured. is the view-independent index of the image, Positive sample and negative samples The similarity between , In the formula, Positive sample The final projected embedding vector, Negative samples The final projected embedding vector, is the index of the second enhanced image; , In the formula, is the number of images with the same view-independent index; The acquired real-time non-orthographic facial expression image is input into the facial expression recognition model, and the facial expression recognition model outputs an expression classification result corresponding to the real-time non-orthographic facial expression image.

2. A method for view-independent facial expression recognition based on contrastive learning according to claim 1, characterized in that: The expression of the objective loss function of the facial expression recognition model is: , In the formula, is the objective loss function of the facial expression recognition model, is the multi-view contrast loss sub-function, is the supervised contrast loss sub-function, is the coefficient of the supervised contrast loss sub-function, is the coefficient of the multi-view contrast loss sub-function, is the coefficient of the redundancy loss sub-function.

3. A view-independent facial expression recognition system based on contrastive learning, characterized in that: include: A construction module is configured to construct a VI-FER network, wherein the VI-FER network includes an encoder and a final projection head connected to the encoder, wherein the final projection head is a first shallow neural network with two fully connected layers, and the encoder includes an image preprocessing module, a feature extraction module, an attention mechanism module, a first intermediate projection head connected to the attention mechanism module, a feature fusion module, a second intermediate projection head connected to the feature fusion module, and an encoder output module; The expression of the first intermediate projection head is: , In the formula, is the output of the first intermediate projection head, is the first convolutional layer and the first adaptive average pooling layer, is the first fully connected layer and the first activation function, is the output feature of the attention mechanism module; The expression of the second intermediate projection head is: , In the formula, is the output of the second intermediate projection head, is the second convolutional layer and the second adaptive average pooling layer, is the second fully connected layer and the second activation function, is the output feature of the feature fusion module; An acquisition module is configured to acquire at least one frontal facial expression image of a portrait and a first category label corresponding to the at least one frontal facial expression image to obtain a positive sample set, and acquire at least one non-frontal facial expression image of a portrait and a second category label corresponding to the at least one non-frontal facial expression image to obtain a negative sample set; A training module is configured to use at least one frontal facial expression image in the positive sample set and at least one non-frontal facial expression image in the negative sample set as inputs of the VI-FER network, and use the corresponding first category label and the second category label as outputs of the VI-FER network, to train and obtain a final facial expression recognition model, wherein the target loss function of the facial expression recognition model includes a supervised contrast loss sub-function, a multi-view contrast loss sub-function, and a redundancy reduction loss sub-function; The expression of the redundancy reduction loss sub-function is: , In the formula, is the objective loss function of the VI-FER network, is the loss of the intermediate layers used to train the encoder attention module, is the loss of the intermediate layers used to train the encoder feature fusion module; , In the formula, for or , is an irrelevant term, which is used to make the diagonal elements of the cross-correlation matrix equivalent to 1. is the loss function for compact feature learning, which is used to make the items outside the diagonal equivalent to 0. is a coefficient between 0 and 1, To reduce the comparison loss of redundant negative samples, To reduce the comparison loss of redundant positive samples; , In the formula, is the batch size, To obtain an enhanced embedding, the dimension index of the embedding vector is i, To obtain an embedding based on another enhancement, the dimension index of the embedding vector is j; , In the formula, is the number of negative sample pairs, It is the feature extraction function of the model, used to extract positive samples The characteristic representation of For extracting input negative samples The feature extraction function is To extract negative samples The feature extraction function is is a small constant used to prevent the denominator from being zero. is a positive sample with dimension i, is a negative sample with a dimension of j. For Negative samples of the same type, whose dimension is k; , In the formula, is the number of positive sample pairs, For extracting input positive samples Feature extraction function; The expression of the supervised contrast loss subfunction is: , In the formula, is the supervised contrast loss sub-function, is the similarity score between different views of the same expression, is the similarity score between different expressions, is a hyperparameter that controls the weight of negative samples. is a hyperparameter that controls the boundary value of negative samples. is the number of positive sample pairs, is the temperature parameter, which is used to control the smoothness of the similarity distribution; The expression of the multi-view contrast loss sub-function is: , In the formula, is the multi-view contrast loss sub-function, is the weight of the sample pair (i, j), is an indicator function, which means that when i is not equal to j, the value is 1, otherwise it is 0, which is used to filter out the same sample pairs. is another indicator function, which means that when the characteristic function values ​​of sample i and sample j are equal, the value is 1, otherwise it is 0, which is used to ensure that samples with the same characteristic function value can be captured. is the view-independent index of the image, Positive sample and negative samples The similarity between , In the formula, Positive sample The final projected embedding vector, Negative samples The final projected embedding vector, is the index of the second enhanced image; , In the formula, is the number of images with the same view-independent index; The output module is configured to input the acquired real-time non-orthographic facial expression image into the facial expression recognition model, and the facial expression recognition model outputs an expression classification result corresponding to the real-time non-orthographic facial expression image.

4. An electronic device, characterized in that: include: At least one processor, and a memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method described in any one of claims 1 to 2.

5. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 2 is implemented.