Facial emotion recognition method, device, computer equipment and storage medium
Through face detection and interception of video data, combined with the convolutional neural network-long and short-term recurrent neural network model, the problem of insufficient information in a single frame in facial emotion recognition is solved and the accuracy of recognition is improved.
Patent Information
- Application Number
- CN201811183763.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2018-10-11
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2038-10-11
AI Technical Summary
In the existing technology, in facial emotion recognition, a single frame cannot accurately reflect the facial emotion changes in the video, resulting in poor recognition accuracy.
By obtaining the video data to be detected, extract the face image and use the face detection algorithm to detect the target face area. After intercepting the video, input the intercepted video data into the convolutional neural network-long and short-term recurrent neural network model for recognition, and obtain Facial emotion information.
It improves the accuracy of facial emotion recognition, avoids the problem of insufficient information in a single frame, and directly recognizes video data to enhance the accuracy of recognition.
Smart Images

Figure CN109508638B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of micro-expression recognition, and in particular to a facial emotion recognition method, device, computer equipment and storage medium. Background Art
[0002] With the continuous development of artificial intelligence technology, micro-expression recognition technology is used as an auxiliary tool or auxiliary means in many fields. However, at present, when detecting micro-expressions on the face, most of them are detected through a single image or a single frame in a video. However, facial emotions have a changing process, and a single frame cannot accurately reflect the facial emotions in the video. Therefore, the recognition accuracy of facial emotion recognition is poor. Summary of the invention
[0003] The embodiments of the present invention provide a facial emotion recognition method, apparatus, computer equipment and storage medium to solve the problem of low recognition accuracy in the facial emotion recognition process.
[0004] A facial emotion recognition method, comprising:
[0005] Acquire video data to be detected, and extract at least one face image to be detected from the video data to be detected;
[0006] Using a face detection algorithm to detect the face image to be detected, and obtaining N target face image regions of the video data to be detected, where N is a positive integer;
[0007] Performing video interception on the video data to be detected according to the N target face image regions to obtain N video data of faces to be identified;
[0008] The N face video data to be identified are input into the facial emotion recognition model for identification to obtain the N facial emotion information in the video data to be detected, wherein the facial emotion recognition model is trained by using a convolutional neural network-long short-time recursive neural network model.
[0009] A facial emotion recognition device, comprising:
[0010] A module for acquiring video data to be detected, used to acquire video data to be detected and extract at least one face image to be detected from the video data to be detected;
[0011] A target face image region acquisition module is used to detect the face image to be detected using a face detection algorithm to obtain N target face image regions of the video data to be detected, where N is a positive integer;
[0012] A module for capturing video data of faces to be identified, used for capturing the video data to be detected according to the N target face image areas to obtain N video data of faces to be identified;
[0013] The facial emotion information acquisition module is used to input the N face video data to be identified into the facial emotion recognition model for identification, and obtain the N facial emotion information in the video data to be detected, wherein the facial emotion recognition model is trained using a convolutional neural network-long short-time recursive neural network model.
[0014] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned facial emotion recognition method when executing the computer program.
[0015] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the above-mentioned facial emotion recognition method.
[0016] In the above-mentioned facial emotion recognition method, device, computer equipment and storage medium, first obtain the video data to be detected, extract the face image to be detected from the video data to be detected; use the face detection algorithm to detect the face image to be detected, and obtain N target face image areas, where N is a positive integer; according to the N target face image areas, the video data to be detected is intercepted to obtain N face video data to be identified; the N face video data to be identified are input into the facial emotion recognition model for identification, and the N face emotion information in the video to be detected is obtained, wherein the facial emotion recognition model is trained by using the convolutional neural network-long short-time recurrent neural network model. By intercepting the face video data to be identified according to the target face image area in the video data to be detected, the accuracy of intercepting each face video data to be identified is guaranteed, and the facial emotion recognition model for subsequent identification is trained by using the convolutional neural network-long short-time recurrent neural network model. This method directly identifies the video data, avoids the lack of information represented by a single frame, and ensures the accuracy of facial emotion recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0018] Figure 1is a schematic diagram of an application environment of a facial emotion recognition method according to an embodiment of the present invention;
[0019] Figure 2 is an example diagram of a method for recognizing facial emotions in one embodiment of the present invention;
[0020] Figure 3 is another example diagram of a method for recognizing facial emotions in one embodiment of the present invention;
[0021] Figure 4 is another example diagram of a method for recognizing facial emotions in one embodiment of the present invention;
[0022] Figure 5 is another example diagram of a method for recognizing facial emotions in one embodiment of the present invention;
[0023] Figure 6 is another example diagram of a method for recognizing facial emotions in one embodiment of the present invention;
[0024] Figure 7 is a principle block diagram of a facial emotion recognition device in one embodiment of the present invention;
[0025] Figure 8 is another principle block diagram of a facial emotion recognition device in one embodiment of the present invention;
[0026] Fig. 9 is another principle block diagram of a facial emotion recognition device in one embodiment of the present invention;
[0027] Fig.10 is a schematic diagram of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0028] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions 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.
[0029] The facial emotion recognition method provided by the embodiment of the present invention can be applied in the following aspects: Figure 1In an application environment, the client (computer device) communicates with the server through a network. The client sends the video data to be detected to the server, and the server uses a face detection algorithm to detect the face image to be detected to obtain N target face image areas; according to the N target face image areas, the video data to be detected is intercepted to obtain N face video data to be identified; finally, the N face video data to be identified are input into the face emotion recognition model for identification to obtain N face emotion information in the video to be detected. Among them, the client (computer device) can be but is not limited to various personal computers, laptops, smart phones, tablet computers and portable wearable devices. The server can be implemented with an independent server or a server cluster consisting of multiple servers.
[0030] In one embodiment, if Figure 2 As shown, a method for facial emotion recognition is provided, and the method is applied in Figure 1 The server in the example is used as an example to illustrate the following steps:
[0031] S10: Acquire video data to be detected, and extract at least one face image to be detected from the video data to be detected.
[0032] The video data to be detected is original video data. Optionally, the video data to be detected can be video data containing facial images of people collected in real time by the client using its video acquisition tool, or can be video data collected and saved in advance by the client, or can be video data directly uploaded or sent to the client locally. The client sends the video data to be detected to the server, and the server obtains the video data to be detected.
[0033] The face image to be detected is image data containing a person's face image extracted from the video data to be detected. Optionally, there is at least one face image to be detected, and the image that best represents the face position of the person in the video data to be detected is extracted from the video data to be detected as the face image to be detected. Optionally, multiple face images can be extracted from the video data to be detected, and then the most representative face image can be selected from them as the face image to be detected. Specifically, an image in which all the face images are facing forward can be selected from the multiple face images as the face image to be detected. The detection of the face orientation can be achieved by pre-training the corresponding neural network model to obtain a face orientation recognition model. That is, a large amount of image data representing different face orientations is annotated and then input into a neural network model for training, so as to obtain a face orientation recognition model.
[0034] In a specific embodiment, there are at least two facial images to be detected, and multiple facial images are extracted from the video data to be detected as the facial images to be detected to improve the accuracy of subsequent emotion recognition. Preferably, any two stages can be selected from the initial stage, the middle stage and the stage in the video data to be detected, and one facial image can be extracted from each stage as the facial image to be detected. It can be understood that the number of facial images to be detected can be more, that is, the more facial images to be detected, the higher the accuracy of subsequent emotion recognition of the video data to be detected, but the server-side calculation complexity will also be higher, and the specific number can be set according to the needs of different application scenarios. If the focus is on recognition accuracy, the number of facial images to be detected can be increased, and if the focus is on recognition efficiency, the number of facial images to be detected can be appropriately reduced.
[0035] Specifically, the server can extract the face image to be detected from the video data to be detected by screenshot. The process of obtaining the face image to be detected can be implemented by OpenCV, which provides a simple and easy-to-use framework to extract image frames from video files. Exemplarily, the VideoCapture class is used to perform video reading and writing operations. First, the cap=cv2.VideoCapture() function in the VideoCapture class is used to display the corresponding video data to be detected, and then the cap.read() function in the VideoCapture class is used to read the video data to be detected at a preset frame rate. The cap.read() function has two return values: ret and frame. Among them, ret is a Boolean value. If the read frame is correct, True is returned. If the video data to be detected has been read to the end, its return value is False, that is, the return value of the cap.read() function can be used to determine whether the video data to be detected has been read. Frame is the currently captured image, which can be a three-dimensional matrix.
[0036] S20: Using a face detection algorithm to detect the face image to be detected, and obtaining N target face image regions of the video data to be detected, where N is a positive integer.
[0037] Among them, the face detection algorithm is a detection algorithm that selects the face area from the image data. Specifically, the face detection algorithm can adopt a face detection algorithm based on feature extraction, a face detection algorithm based on a neural network, or a face detection algorithm based on deep learning. The face image to be detected is detected by a preset face detection algorithm, and the face area in the face image to be detected is detected, so as to obtain the target face area. N is the number of target face areas included in the face image to be detected, and N is a positive integer. It can be understood that the target face area can be of various types, such as: circular, rectangular or square, etc., which can be set according to actual needs. Preferably, the target face image area is rectangular.
[0038] S30: Capture the video data to be detected according to the N target face image regions to obtain N video data of faces to be recognized.
[0039] After obtaining N target face regions, video capture is performed in the video data to be detected according to each target face region, and N video data of faces to be identified are obtained. Specifically, if a target face region is a rectangular frame A, the video data corresponding to the rectangular frame A is captured in the video data to be detected to obtain a video data of faces to be identified. In this way, the capture is repeated to obtain N video data of faces to be identified.
[0040] In a specific implementation, the filter function in FFmpeg can be used to achieve video capture of the video data to be detected. Among them, FFmpeg is a set of open source computer programs that can be used to record and convert digital audio and video, and can convert them into streams. The crop function in the filter is used to achieve video capture of the video data to be detected. Specifically, the video capture of the video data to be detected is achieved according to the target face image area through crop=width:height:x:y. Among them, width and height represent the size after cropping, and x:y represents the upper left corner coordinates of the cropped area. That is, the area of video capture is determined by the size and upper left corner coordinates of the face image area, thereby achieving video capture of the video data to be detected according to N target face image areas.
[0041] S40: Inputting N face video data to be identified into a facial emotion recognition model for identification, and obtaining N facial emotion information in the video data to be detected, wherein the facial emotion recognition model is trained by using a convolutional neural network-long short-time recursive neural network model.
[0042] Among them, the facial emotion recognition model is a network model obtained by pre-training, which is used to recognize the facial emotions in the face video data to be recognized, and output a recognition result, that is, facial emotion information. Exemplarily, the facial emotion information is happiness, sadness, fear, anger, surprise, disgust or contempt. The facial emotion recognition model can determine the probability value of the face in the input video data corresponding to the preset multiple emotions. If the probability value of a certain emotion exceeds the corresponding preset threshold, the emotion corresponding to the input video data is obtained, which is the facial emotion information. For example, in this embodiment, the emotions in the micro-expression recognition model can be set to 7 kinds of happiness, sadness, fear, anger, surprise, disgust and contempt. Specifically, a large amount of video data representing these 7 emotions can be collected in advance for annotation to form a video data set, and then the corresponding neural network model or classifier is selected for training to finally obtain the facial emotion recognition model.
[0043] Specifically, the facial emotion recognition model is trained by using a convolutional neural network-long short-time recurrent neural network model. The convolutional neural network-long short-time recurrent neural network model is a model obtained by combining a convolutional neural network model with a long short-time recurrent neural network model. It can be understood that the convolutional neural network-long short-time recurrent neural network model is equivalent to a model formed by connecting a convolutional neural network with a long short-time recurrent neural network model.
[0044] Convolutional Neural Network (CNN) is a locally connected network. Compared with a fully connected network, its biggest features are local connectivity and weight sharing. For a certain pixel p in an image, the closer the pixels are to pixel p, the greater the influence on it (local connectivity). In addition, according to the statistical characteristics of natural images, the weight of a certain area can also be used for another area, that is, weight sharing. Weight sharing can be understood as convolution kernel sharing. In a convolutional neural network (CNN), a convolution kernel can be convolved with a given image to extract an image feature, and different convolution kernels can extract different image features. Due to the local connectivity of the convolutional neural network, the complexity of the model is reduced, which can improve the efficiency of model training; and due to the weight sharing of the convolutional neural network, the convolutional neural network can learn in parallel, further improving the efficiency of model training.
[0045] The long-short term memory (LSTM) model is a time recursive neural network model suitable for processing and predicting important events with time series and relatively long time series intervals and delays. The LSTM model has a time memory function. In this embodiment, the long-short term memory model is used to train the extracted features to reflect the long-term memory ability of the data and improve the accuracy of model recognition.
[0046] In this step, N to-be-recognized face video data are respectively input into the facial emotion recognition model for recognition, that is, the N facial emotion information in the to-be-detected video is obtained.
[0047] In this embodiment, firstly, the video data to be detected is obtained, and at least one face image to be detected is extracted from the video data to be detected; the face detection algorithm is used to detect the face image to be detected, and N target face image regions of the video data to be detected are obtained, wherein N is a positive integer; the video data to be detected is intercepted according to the N target face image regions, and N face video data to be identified are obtained; the N face video data to be identified are input into the face emotion recognition model for identification, and N face emotion information in the video to be detected is obtained, wherein the face emotion recognition model is obtained by training with a convolutional neural network-long short-time recurrent neural network model. By intercepting the face video data to be identified according to the target face image region in the video data to be detected, the accuracy of intercepting each face video data to be identified is ensured, and the face emotion recognition model for subsequent identification is obtained by training with a convolutional neural network-long short-time recurrent neural network model, and the video data is directly identified, which avoids the lack of information represented by a single frame, and further ensures the accuracy of face emotion recognition.
[0048] In one embodiment, there are at least two facial images to be detected. Figure 3 As shown, a face detection algorithm is used to detect the face image to be detected, and N target face image regions of the video data to be detected are obtained, which specifically includes the following steps:
[0049] S21: using a face detection algorithm to detect each face image to be detected, and obtaining N initial face image regions of each face image to be detected.
[0050] In this step, a face detection algorithm is first used to detect each face image to be detected, and N initial face image regions of each face image to be detected are obtained.
[0051] S22: using a face recognition algorithm to identify N initial face image regions of each face image to be detected, and obtaining a user identifier for each initial face image region.
[0052] Among them, the user identifier is a unique identifier used to distinguish different users. Specifically, the user identifier can be a mobile phone number, an ID card number or a unique identifier assigned by the system to different users. Optionally, the unique identifier can be composed of at least one of numbers, letters, text or symbols. The face recognition algorithm refers to a recognition algorithm used to compare different face images and obtain a comparison result. Specifically, the face recognition algorithm can be implemented by a recognition algorithm based on geometric features, a recognition algorithm based on local feature analysis, a recognition algorithm based on feature faces, a recognition algorithm based on neural networks or a recognition algorithm based on elastic models. Optionally, a face image library can be pre-set to store the corresponding user identifier and reference face image, and then the N initial face image areas of each face image to be detected are respectively identified with each reference face image in the face image library using a face recognition algorithm, and the user identifier corresponding to the reference face image with the highest matching degree is used as the user identifier of the corresponding initial face image area.
[0053] In a specific embodiment, a corresponding user identification is assigned to each initial face image region of the first face image to be detected, and then each initial face image region and the corresponding user identification in the first face image to be detected are used as a face image library. Specifically, the first face image to be detected can be determined according to the time sequence of the image in the video data to be detected, for example, the face image to be detected that is the first in the time sequence is selected as the first face image to be detected. Each initial face image region of the subsequent face images to be detected is identified with the face image library, and the user identification with the highest matching degree in the face image library is used as the user identification of the corresponding initial face image region. The recognition process of one of the images can be reduced, thereby improving the recognition efficiency.
[0054] S23: Integrate the image regions of the initial face images corresponding to the same user identifier in the face images to be detected to obtain N target face image regions of the video data to be detected.
[0055] In this step, the face image areas of the same user ID in different face images to be detected are integrated with the user ID as a unit to obtain the target face image area. After the face image areas corresponding to N user IDs are integrated, N target face image areas are obtained. Image area integration refers to the process of summarizing and calculating a plurality of initial face image areas to ensure that the obtained target face image areas can better reflect the face information of the corresponding user, thereby ensuring the accuracy of subsequent recognition. Specifically, the face image areas of the same user ID can be averaged. Exemplarily, if the face image area is a rectangular area, the four vertex coordinates of each face image area are obtained, and the vertex coordinates at the same position are summed and averaged to obtain four averaged vertex coordinates. According to these four averaged vertex coordinates, the target face image area is constructed.
[0056] In a specific embodiment, the face image area with the same user ID is maximized. Exemplarily, if the face image area is a rectangular area, the four vertex coordinates of each face image area are obtained, and the vertex coordinates at the same position are taken as the limit value. That is, all vertex coordinates are selected to ensure that the target face image area obtained is the largest. Exemplarily, if the lower left corner of the image is taken as the origin position, it can be understood that for the upper left vertex coordinate of each face image area, the value with the smallest horizontal coordinate and the value with the largest vertical coordinate are taken as the upper left vertex coordinate of the target face image area. For the upper right vertex coordinate of each face image area, the value with the largest horizontal coordinate and the value with the largest vertical coordinate are taken as the upper right vertex coordinate of the target face image area. For the lower left vertex coordinate of each face image area, the value with the smallest horizontal coordinate and the value with the smallest vertical coordinate are taken as the lower left vertex coordinate of the target face image area. For the lower right vertex coordinate of each face image area, the value with the largest horizontal coordinate and the value with the smallest vertical coordinate are taken as the lower left vertex coordinate of the target face image area. The target face image area thus formed can better ensure the integrity of face information and the accuracy of subsequent recognition.
[0057] In this embodiment, a face detection algorithm is first used to detect each face image to be detected, and N initial face image regions of each face image to be detected are obtained; then a face recognition algorithm is used to identify the N initial face image regions of each face image to be detected, and a user identifier of each initial face image region is obtained; finally, the initial face image regions corresponding to the same user identifier in the face image to be detected are respectively integrated into the image region to obtain N target face image regions. The target face region determined in the above manner can better ensure the accuracy of subsequent facial emotion recognition.
[0058] In one embodiment, if Figure 4 As shown, after the step of inputting N to-be-recognized face video data into the face emotion recognition model for recognition and obtaining the N face emotion information in the to-be-detected video, the face emotion recognition method further includes the following steps:
[0059] S50: Counting the emotion information of N faces in the video to be detected to obtain emotion statistical information.
[0060] Among them, the emotion statistical information refers to the statistical information reflecting the emotion types corresponding to different faces in the video to be detected. Optionally, the emotion statistical information can reflect the number of all different emotions, or reflect the proportion of a specific emotion. Specifically, after obtaining N facial emotion information in the video data to be detected, each type of facial emotion information in the N facial emotion information is counted to obtain the number of each type of facial emotion information, which constitutes the emotion statistical information.
[0061] S60: Obtaining a preset emotion detection rule, and testing the emotion statistical information according to the preset emotion detection rule to obtain emotion recognition information of the video data to be detected.
[0062] The preset emotion detection rule is a pre-set detection rule, which can be customized according to different application scenarios. The preset emotion detection rule can be obtained from the client or from the database in the server. For example, if it is necessary to detect whether the happy emotion in the video data to be detected exceeds 80%, the preset emotion detection rule can be used to detect whether the number of happy facial emotion information in the emotion statistics is more than 80% of all facial emotion information. Then, based on the test results, the emotion recognition information is output. Specifically, the emotion recognition information can be the result of reaching or not reaching the indicator, or it can be the number corresponding to a specific emotion, which can be set according to actual needs.
[0063] In this embodiment, emotion statistical information is obtained by counting the emotion information of N faces in the video data to be detected; and a preset emotion detection rule is obtained, and the emotion statistical information is tested according to the preset emotion detection rule to obtain emotion recognition information of the video data to be detected. The emotion statistical information is tested according to the preset emotion detection rule to obtain the emotion recognition information of the video data to be detected, so as to more intuitively and clearly reflect the emotion recognition result of the video data to be detected.
[0064] In one embodiment, if Figure 5 As shown, before the step of inputting N to-be-recognized face video data into the face emotion recognition model for detection to obtain the N face emotion information in the to-be-detected video data, the face emotion recognition method further includes the following steps:
[0065] S41: Acquire original video sample data, wherein each original video sample data has been sample labeled.
[0066] Among them, the original video sample data is open source video data obtained from a data set disclosed by the Internet or a third-party organization / platform, which includes original video sample data corresponding to various facial emotions, and each original video sample data has been labeled. For example, the original video sample data A is labeled with "happy" accordingly.
[0067] S42: Perform video frame segmentation and face detection processing on each original video sample data to obtain a training face image.
[0068] The training face picture is a picture containing human facial features obtained by performing video framing and face detection on the original video sample data. Since the facial emotion recognition model in this embodiment is trained based on micro-expression features, it is necessary to perform video framing and face detection on the original video sample data to obtain a picture containing human facial features, namely the training face picture, so that the training face picture can be used for model training, so that the facial emotion recognition model can extract micro-expression features based on the training face picture, and perform deep learning to improve the recognition accuracy of the facial emotion recognition model.
[0069] S43: Grouping the training face images according to a preset number to obtain target training data, each target training data including M consecutive frames of training face images.
[0070] Among them, grouping is performed according to a preset number to obtain at least one group of target training data, so that each group of target training data contains M consecutive frames of training face pictures, so as to obtain the changes in facial micro-expression features from the M consecutive frames of training face pictures, so that the training face pictures have time sequence, thereby increasing the accuracy of the facial emotion recognition model.
[0071] In this embodiment, the range of the preset number can be set to [50, 200]. The reason is that if the training face pictures with less than 50 frames are used as a group of training data in the training set, the change process of the facial features of a person lying cannot be shown due to too few training face pictures, resulting in low recognition accuracy of the facial emotion recognition model. If the training face pictures with more than 200 frames are used as a group of training data in the training set, the model training time will be too long, reducing the efficiency of model training. In this embodiment, the model training is performed according to every 100 frames of training face pictures as a group of training data, thereby improving the training efficiency of the model and the recognition accuracy of the trained facial emotion recognition model.
[0072] S44: Input the target training data into the convolutional neural network-long short-time recurrent neural network model for training to obtain a facial emotion recognition model.
[0073] After obtaining the target training data, the target training data is input into the convolutional neural network-long short-time recurrent neural network model for training, so as to obtain the facial emotion recognition model.
[0074] In this embodiment, since the training is performed on the target training data, i.e., the training face pictures of continuous M frames, it is necessary to extract features from the training face pictures, and the convolutional neural network model is a neural network commonly used for picture feature extraction. Due to the weight sharing and local connectivity of the convolutional neural network, the efficiency of model training is greatly increased. In this embodiment, the features of each frame of the training face picture are closely related to the features of the training face pictures of the two frames before and after, so the long-short time recursive neural network model is used to train the extracted face features to reflect the long-term memory ability of the data and improve the accuracy of the model. Due to the weight sharing and local connectivity of the convolutional neural network, and the advantage that the long-short time recursive neural network model can reflect the long-term memory ability of the data, the efficiency of the training of the facial emotion recognition model obtained by training the convolutional neural network-long-short time recursive neural network model and the accuracy of the facial emotion recognition model are greatly increased.
[0075] In one embodiment, Figure 6 As shown, the target training data is input into the convolutional neural network-long short-time recurrent neural network model for training to obtain a facial emotion recognition model, which specifically includes the following steps:
[0076] S441: Initialize the model parameters of the convolutional neural network-long short-time recurrent neural network model.
[0077] Among them, initializing the convolutional neural network-long short-time recurrent neural network model refers to pre-initializing the model parameters of the convolutional neural network model (i.e., convolution kernel and bias) and the model parameters in the LSTM model (i.e., the connection weights between layers). The convolution kernel refers to the weight of the convolutional neural network. When the training data is input, it will be multiplied by a weight, i.e., the convolution kernel, and then the output of the neuron is obtained, which reflects the importance of the training data. The bias is a linear component used to change the range of the weight multiplied by the input. Based on the determined convolution kernel, bias, and the connection weights between the layers in the LSTM model, the model training process can be completed.
[0078] S442: Use a convolutional neural network to extract features from the target training data to obtain facial features.
[0079] The facial features are obtained by extracting features from the target training data in the training set, i.e., N consecutive frames of training face images, using a convolutional neural network. Specifically, the convolutional neural network is used to extract features from the target training data in the training set. Specifically, the calculation formula of the convolution operation includes Among them, * represents the convolution operation; x j represents the jth input feature map; y j represents the jth output feature map; w ij is the convolution kernel (weight) between the i-th input feature map and the j-th output feature map; b j Represents the bias term of the jth output feature map. Then, the maximum pooling downsampling is used to downsample the convolution feature map to achieve dimensionality reduction of the feature map. The calculation formula is: Among them, y j It represents the i-th output spectrum in the downsampling process (i.e., the feature map after downsampling). Each neuron in the downsampling process is obtained by local sampling of the i-th input spectrum (the feature map after convolution) using a downsampling frame of S*S, that is, the input spectrum is downsampled S times, where the specific value of S can be set according to the actual sampling needs; m and n respectively represent the step size of the downsampling frame movement.
[0080] S443: Inputting facial features into the long-short time recursive neural network model for training to obtain a facial emotion recognition model.
[0081] Specifically, the LSTM model is a type of neural network model with long-term memory capability, and has a three-layer network structure of an input layer, a hidden layer, and an output layer. Among them, the input layer is the first layer of the LSTM model, which is used to receive external signals, that is, responsible for receiving facial features carrying a temporal state. In this embodiment, since the training face picture has temporal sequence, the facial features obtained after the training face picture is processed in step S442 also have temporal sequence, so that it can be applied in the LSTM model, so that the LSTM model obtains facial features carrying a temporal state. The output layer is the last layer of the LSTM model, which is used to output signals, that is, responsible for outputting the calculation results of the LSTM model. The hidden layer is each layer in the LSTM model except the input layer and the output layer, which is used to process the input facial features and obtain the calculation results of the LSTM model. Among them, the original risk control model is a model obtained by iterating the facial features carrying a temporal state using the LSTM model for multiple times until convergence. It can be understood that using the LSTM model to train the extracted facial features enhances the temporal nature of the original risk control model obtained, thereby improving the accuracy of the facial emotion recognition model.
[0082] In this embodiment, the output layer of the LSTM model uses Softmax (regression model) for regression processing, which is used to classify the output weight matrix. Softmax (regression model) is a classification function commonly used in neural networks. It maps the output of multiple neurons to the interval [0,1], which can be understood as probability. It is simple and convenient to calculate, so as to perform multi-classification output and make its output result more accurate.
[0083] In this embodiment, the convolutional neural network-long short-time recursive neural network model is first initialized, so that the target training data in the training set is trained based on the convolutional neural network model to obtain facial features, and then the acquired facial features are input into the LSTM model for training. This process does not require manual feature extraction. It only requires the training face image to be directly input into the convolutional neural network-long short-time recursive neural network model, and the model can extract features by itself, thereby improving the model training efficiency.
[0084] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0085] In one embodiment, a facial emotion recognition device is provided, which corresponds one-to-one to the facial emotion recognition method in the above embodiment. Figure 7 As shown, the facial emotion recognition device includes a to-be-detected video data acquisition module 10, a target face image region acquisition module 20, a to-be-identified face video data interception module 30 and a facial emotion information acquisition module 40. The functional modules are described in detail as follows:
[0086] The to-be-detected video data acquisition module 10 is used to acquire the to-be-detected video data and extract at least one to-be-detected face image from the to-be-detected video data;
[0087] The target face image region acquisition module 20 is used to detect the face image to be detected using a face detection algorithm to obtain N target face image regions, where N is a positive integer;
[0088] The to-be-recognized face video data interception module 30 is used to intercept the to-be-detected video data according to the N target face image regions to obtain N to-be-recognized face video data of the to-be-detected video data;
[0089] The facial emotion information acquisition module 40 is used to input the N face video data to be identified into the facial emotion recognition model for identification, and obtain the N facial emotion information in the video data to be detected, wherein the facial emotion recognition model is trained using a convolutional neural network-long short-time recursive neural network model.
[0090] Preferably, there are at least two facial images to be detected; Figure 8 As shown, the target facial image region acquisition module 20 includes an initial facial image region acquisition unit 21 , an initial facial image region recognition unit 22 and a target facial image region acquisition unit 23 .
[0091] An initial face image region acquisition unit 21 is used to detect each face image to be detected using a face detection algorithm to obtain N initial face image regions of each face image to be detected;
[0092] An initial face image region identification unit 22, configured to identify the N initial face image regions of each of the face images to be detected by using a face recognition algorithm, and obtain a user identifier for each initial face image region;
[0093] The target face image region acquisition unit 23 is used to integrate the initial face image regions corresponding to the same user identifier in the face image to be detected into image regions to obtain N target face image regions of the video data to be detected.
[0094] Preferably, if Fig. 9 As shown, the facial emotion recognition device also includes an emotion statistical information acquisition module 50 and an emotion recognition information acquisition module 60.
[0095] The emotion statistics information acquisition module 50 is used to collect statistics of emotion information of N faces in the video data to be detected to obtain emotion statistics information;
[0096] The emotion recognition information acquisition module 60 is used to acquire preset emotion detection rules, and to test the emotion statistical information according to the preset emotion detection rules to obtain the emotion recognition information of the video data to be detected.
[0097] Preferably, the facial emotion recognition device also includes an original video sample data acquisition module, a training face picture acquisition module, a target training data acquisition module and a facial emotion recognition model acquisition module.
[0098] The original video sample data acquisition module is used to acquire original video sample data, wherein each original video sample data has been sample labeled.
[0099] The training face image acquisition module is used to perform video frame segmentation and face detection processing on each original video sample data to obtain a training face image.
[0100] The target training data acquisition module is used to group the training face images according to a preset number to obtain target training data, each of which includes M consecutive frames of training face images.
[0101] The facial emotion recognition model acquisition module is used to input the target training data into the convolutional neural network-long short-time recursive neural network model for training to obtain the facial emotion recognition model.
[0102] Preferably, the facial emotion recognition model acquisition module includes a model parameter initialization unit, a facial feature acquisition unit and a facial emotion recognition model acquisition unit.
[0103] The model parameter initialization unit is used to initialize the model parameters of the convolutional neural network-long short-time recurrent neural network model.
[0104] The facial feature acquisition unit is used to extract features from target training data using a convolutional neural network to acquire facial features.
[0105] The facial emotion recognition model acquisition unit is used to input facial features into the long-short time recursive neural network model for training to obtain the facial emotion recognition model.
[0106] For the specific definition of the facial emotion recognition device, please refer to the definition of the facial emotion recognition method above, which will not be repeated here. Each module in the above facial emotion recognition device can be implemented in whole or in part by software, hardware and a combination thereof. The above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0107] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig.10 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data used in the above-mentioned facial emotion recognition method. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a facial emotion recognition method is implemented.
[0108] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0109] Acquire video data to be detected, and extract at least one face image to be detected from the video data to be detected;
[0110] Using a face detection algorithm to detect the face image to be detected, and obtaining N target face image regions of the video data to be detected, where N is a positive integer;
[0111] Performing video interception on the video data to be detected according to the N target face image regions to obtain N video data of faces to be identified;
[0112] The N face video data to be identified are input into the facial emotion recognition model for identification to obtain the N facial emotion information in the video data to be detected, wherein the facial emotion recognition model is trained by using a convolutional neural network-long short-time recursive neural network model.
[0113] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0114] Acquire video data to be detected, and extract at least one face image to be detected from the video data to be detected;
[0115] Using a face detection algorithm to detect the face image to be detected, and obtaining N target face image regions of the video data to be detected, where N is a positive integer;
[0116] Performing video interception on the video data to be detected according to the N target face image regions to obtain N video data of faces to be identified;
[0117] The N face video data to be identified are input into the facial emotion recognition model for identification to obtain the N facial emotion information in the video data to be detected, wherein the facial emotion recognition model is trained by using a convolutional neural network-long short-time recursive neural network model.
[0118] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0119] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0120] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such 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, and should all be included in the protection scope of the present invention.
Claims
1. A facial emotion recognition method, characterized in that: include: Acquire video data to be detected, and extract at least one face image to be detected from the video data to be detected; Using a face detection algorithm to detect the face image to be detected, and obtaining N target face image regions of the video data to be detected, where N is a positive integer; Performing video interception on the video data to be detected according to the N target face image regions to obtain N video data of faces to be identified; The N face video data to be identified are input into the facial emotion recognition model for identification to obtain the N facial emotion information in the video data to be detected, wherein the facial emotion recognition model is trained by using a convolutional neural network-long short-time recursive neural network model.
2. The facial emotion recognition method according to claim 1, characterized in that: The number of the face images to be detected is at least two; The method of using a face detection algorithm to detect the face image to be detected to obtain N target face image regions of the video data to be detected specifically includes the following steps: Using a face detection algorithm to detect each of the face images to be detected, and obtaining N initial face image regions of each of the face images to be detected; Using a face recognition algorithm to identify N initial face image regions of each face image to be detected, and obtaining a user identifier for each initial face image region; The initial face image regions corresponding to the same user identifier in the face image to be detected are integrated into the image region to obtain N target face image regions of the video data to be detected.
3. The facial emotion recognition method according to claim 1, characterized in that: After the step of inputting the N face video data to be identified into the face emotion recognition model for identification to obtain the N face emotion information in the video to be detected, the face emotion recognition method further comprises the following steps: Collecting statistics on N facial emotion information of individuals in the video data to be detected to obtain emotion statistical information; A preset emotion detection rule is obtained, and the emotion statistical information is checked according to the preset emotion detection rule to obtain emotion recognition information of the video data to be detected.
4. The facial emotion recognition method according to claim 1, characterized in that: Before the step of inputting the N face video data to be identified into the face emotion recognition model for detection to obtain the N face emotion information in the video data to be detected, the face emotion recognition method further includes the following steps: Obtaining original video sample data, wherein each of the original video sample data has been sample labeled; Performing video frame segmentation and face detection processing on each of the original video sample data to obtain a training face image; The training face images are grouped according to a preset number to obtain target training data, each of which includes M consecutive frames of the training face images; The target training data is input into a convolutional neural network-long short-time recurrent neural network model for training to obtain a facial emotion recognition model.
5. The facial emotion recognition method according to claim 4, characterized in that: The target training data is input into a convolutional neural network-long short-term recurrent neural network model for training to obtain a facial emotion recognition model, specifically comprising the following steps: Initialize the model parameters of the convolutional neural network-long short-time recurrent neural network model; Using a convolutional neural network to extract features from the target training data to obtain facial features; The facial features are input into a long-short time recursive neural network model for training to obtain the facial emotion recognition model.
6. A facial emotion recognition device, characterized in that: include: A module for acquiring video data to be detected, used to acquire video data to be detected and extract at least one face image to be detected from the video data to be detected; A target face image region acquisition module is used to detect the face image to be detected using a face detection algorithm to obtain N target face image regions of the video data to be detected, where N is a positive integer; A module for capturing video data of faces to be identified, used for capturing the video data to be detected according to the N target face image areas to obtain N video data of faces to be identified; The facial emotion information acquisition module is used to input the N face video data to be identified into the facial emotion recognition model for identification, and obtain the N facial emotion information in the video data to be detected, wherein the facial emotion recognition model is trained using a convolutional neural network-long short-time recursive neural network model.
7. The facial emotion recognition device according to claim 6, characterized in that: The number of the face images to be detected is at least two; the target face image region acquisition module comprises: An initial face image region acquisition unit, used to detect each face image to be detected using a face detection algorithm to obtain N initial face image regions of each face image to be detected; An initial face image region identification unit, used to identify N initial face image regions of each face image to be detected by using a face recognition algorithm, and obtain a user identifier of each initial face image region; The target face image region acquisition unit is used to integrate the initial face image regions corresponding to the same user identifier in the face image to be detected into image regions to obtain N target face image regions of the video data to be detected.
8. The facial emotion recognition device according to claim 6, characterized in that: The facial emotion recognition device also includes: An emotion statistics information acquisition module is used to collect statistics of emotion information of N faces in the video data to be detected to obtain emotion statistics information; The emotion recognition information acquisition module is used to obtain preset emotion detection rules, and to test the emotion statistical information according to the preset emotion detection rules to obtain the emotion recognition information of the video data to be detected.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the facial emotion recognition method as described in any one of claims 1 to 5 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the facial emotion recognition method as claimed in any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Method and device for identifying terrorist suspects based on videos
CN106934382A
Emotion recognition in video conferencing
CN107636684A
Video face emotion recognition method, medium and device
CN108491764A
Mood detection method and apparatus
CN108563978A
Emotional information provision method and device in video conferencing participants
KR1020160083566A
