Method and device for generating facial emotion image, readable storage medium, and terminal
By encoding and fusing the target emotion text and audio, and combining the pre-trained model to generate facial emotion images, it solves the problems of high data collection costs and unnatural emotions in the existing technology, and achieves the generation of natural and expected emotional states.
Patent Information
- Application Number
- CN202311057116.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-21
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2043-08-21
AI Technical Summary
When the existing technology generates facial emotion videos, it is necessary to collect a large amount of emotional training data, which is costly and the generated emotional states are not natural enough and may even be too extreme, affecting the user experience.
By encoding the target emotional text and input audio, the emotional feature vector and speech feature vector are obtained. After fusion, the pre-trained expression prediction model and image mapping model are input to generate a facial emotion image. Multiple loss functions are used for iterative training to ensure The generated emotional state of the face is more natural and in line with expectations.
The cost of data collection is reduced, and the generated facial emotion images show more natural emotional states, avoid extreme emotions, and improve the user experience.
Smart Images

Figure CN117218224B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of facial emotion image generation, and in particular to a facial emotion image generation method and device, a readable storage medium, and a terminal. Background Art
[0002] With the rapid development of deep learning technology, the task of generating audio-driven facial emotion images (or videos) has also made great progress in recent years.
[0003] In the prior art, for the task of generating emotional facial videos, the method usually adopted is to train a preset model by collecting video data of the speaker in different emotional states, such as happy, sad, surprised, angry, etc., as training data. Under the setting of such training data, the trained model can synthesize the emotions appearing in the training data.
[0004] However, on the one hand, the above method is limited by the need to collect a large amount of emotional training data, which is costly; on the other hand, when collecting video data of different emotions, in order to reflect the diversity and richness of emotions, some unnatural or relatively extreme emotional states will be selected, which may easily lead to the generated facial emotion video showing an unnatural emotional state or even too extreme, affecting the user experience. Summary of the invention
[0005] The technical problem solved by the embodiments of the present invention is how to make the emotional state expressed by the generated facial emotion image more natural and in line with expectations.
[0006] To solve the above technical problems, an embodiment of the present invention provides a method for generating facial emotion images, comprising the following steps: respectively encoding the target emotion text and the input audio to obtain an emotion feature vector and a speech feature vector sequence; respectively fusing the emotion feature vector with each speech feature vector in the speech feature vector sequence to obtain a fused feature vector sequence; inputting the fused feature vector sequence into a pre-trained expression prediction model to obtain a first facial expression vector sequence; rendering based on the first facial expression vector sequence and the second facial expression vector sequence to obtain a rendered facial image sequence, wherein the second facial expression vector sequence is determined based on an original facial image sequence that is time-series aligned with the speech feature vector sequence; inputting the rendered facial image sequence and the emotion feature vector into a pre-trained image mapping model to generate a facial emotion image sequence.
[0007] Optionally, the emotion feature vector is fused with each speech feature vector in the speech feature vector sequence to obtain a fused feature vector sequence, including: keeping the temporal sequence of the speech feature vectors unchanged, splicing the emotion feature vector with each speech feature vector to obtain multiple splicing vectors; and determining the fused feature vector sequence based on each splicing vector.
[0008] Optionally, determining the fused feature vector sequence based on each splicing vector includes: performing linear mapping on each splicing vector respectively, and using the linear mapping result as the fused feature vector sequence.
[0009] Optionally, concatenating the emotion feature vector with each speech feature vector respectively includes: for each speech feature vector, inserting the emotion feature vector as a whole into a position after the last code of the speech feature vector.
[0010] Optionally, before inputting the fused feature vector sequence into the pre-trained expression prediction model, the method further comprises: encoding the sample emotion text and the sample audio respectively to obtain a sample emotion feature vector and a sample voice feature vector sequence, and then respectively fusing the sample emotion feature vector with each sample voice feature vector to obtain a fused sample feature vector sequence; constructing a training data set using the fused sample feature vector sequence and the facial expression vector label corresponding to each fused sample feature vector therein; using the target loss function, inputting the training data set into the model to be optimized for iterative training to obtain the pre-trained expression prediction model and the pre-trained image mapping model, wherein the model to be optimized comprises an expression prediction model and an image mapping model;
[0011] In each round of iterative training, the training data set is input into the expression prediction model to obtain the first facial expression sample vector sequence of the current round, and then rendering is performed based on the first facial expression sample vector sequence and the second facial expression sample vector sequence to obtain a rendered sample facial image sequence, and then the rendered sample facial image sequence and the sample emotion feature vector are input into the image mapping model to generate the current round of sample facial emotion image sequence; wherein the second facial expression sample vector sequence is determined based on the original sample facial image sequence that is time-aligned with the sample speech feature vector sequence.
[0012] Optionally, the target loss function is obtained by weighted summing up the pixel difference constraint loss function, the expression difference constraint loss function and the emotion type constraint loss function; during the iterative training process, the pixel difference constraint loss function is used to iteratively optimize the parameters of the image mapping model, the expression difference constraint loss function is used to iteratively optimize the parameters of the expression prediction model, and the emotion type constraint loss function is used to iteratively optimize the parameters of the expression prediction model and the image mapping model.
[0013] Optional, one or more of the following:
[0014] The pixel difference constraint loss function is expressed by the following expression:
[0015]
[0016] Among them, L v represents the pixel difference constraint loss function, R i represents the i-th pixel of the original sample face image, represents the i-th pixel of the sample facial emotion image generated by the image mapping model, I represents the total number of pixels, represents the jth element in the image features extracted from the original sample face image, represents the jth element in the image feature extracted from the sample facial emotion image generated by the image mapping model, J represents the total number of elements in the image feature, ||x|| represents the norm of x, and N represents the total number of images in the generated sample facial emotion image sequence;
[0017] The expression difference constraint loss function is expressed by the following expression:
[0018] Among them, L p represents the expression difference constraint loss function, p i represents the i-th element of the annotated expression vector of the original sample face image, that is, the i-th element of the face expression vector label, represents the i-th element of the first facial expression sample vector output by the expression prediction model, N p represents the total number of elements in the first facial expression sample vector, and N represents the total number of vectors in the first facial expression sample vector sequence predicted by the expression prediction model, that is, the total number of images in the generated sample facial emotion image sequence;
[0019] The emotion type constraint loss function is expressed by the following expression:
[0020] Among them, L erepresents the emotion type constraint loss function, y represents the probability corresponding to the true emotion of the original sample face image, represents the probability distribution of emotion types obtained by performing emotion type recognition on the generated sample facial emotion images, and N represents the total number of images in the generated sample facial emotion image sequence.
[0021] Optionally, the emotion type to which the target emotion text belongs is consistent with the emotion type to which the input audio belongs.
[0022] Optionally, the original facial image sequence time-aligned with the speech feature vector sequence is obtained by sampling a video belonging to the same speaker as the input audio; each frame of facial image in the original facial image sequence corresponds one-to-one to each speech feature vector in the speech feature vector sequence.
[0023] Optionally, each second facial expression vector in the second facial expression vector sequence is selected from one or more of the following: a facial personality vector, a facial texture vector, a facial rotation vector, and a facial scale scaling vector.
[0024] An embodiment of the present invention also provides a facial emotion image generation device, including: an encoding module, used to encode the target emotion text and the input audio respectively to obtain an emotion feature vector and a speech feature vector sequence; a vector fusion module, used to fuse the emotion feature vector with each speech feature vector in the speech feature vector sequence respectively to obtain a fused feature vector sequence; an expression coefficient prediction module, used to input the fused feature vector sequence into a pre-trained expression prediction model to obtain a first facial expression vector sequence; a rendering module, used to render based on the first facial expression vector sequence and the second facial expression vector sequence to obtain a rendered facial image sequence, wherein the second facial expression vector sequence is determined based on an original facial image sequence that is time-series aligned with the speech feature vector sequence; a facial emotion image generation module, used to input the rendered facial image sequence and the emotion feature vector into a pre-trained image mapping model to generate a facial emotion image sequence.
[0025] An embodiment of the present invention further provides a readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned method for generating a facial emotion image are executed.
[0026] An embodiment of the present invention further provides a terminal, comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and the processor executes the steps of the above-mentioned facial emotion image generation method when running the computer program.
[0027] Compared with the prior art, the technical solution of the embodiment of the present invention has the following beneficial effects:
[0028] In the prior art, training data is constructed by collecting a large number of emotional videos, which is costly and easily leads to the emotional state of the generated facial emotion videos being difficult to control, showing unnatural or even extreme emotional states. In contrast, this implementation scheme introduces target emotional text. On the one hand, the target emotional text is easier to obtain than a large amount of video training data, and the data occupies significantly less space, which is less costly. On the other hand, it attempts to influence the first facial expression vector (or expression coefficient) containing emotional information through the target emotional text, thereby influencing and constraining the emotions or expression states reflected by the final generated facial emotion image sequence, which can not only achieve the editability of the emotional state, but also make the emotional state reflected by the generated facial emotion image sequence relatively natural.
[0029] Furthermore, the constraint of the target emotional text is reflected in two core processes: one is the process of predicting the first facial expression vector sequence based on the pre-trained expression prediction model, and the input fusion feature vector sequence contains the emotional features of the target emotional text; the other is the process of generating a facial emotional image sequence based on the image mapping model, and the emotional feature vector obtained based on the target emotional text is used as one of the model input data. Therefore, through the dual constraints of the target emotional text, it helps to make the emotional state of the generated facial emotional image sequence more natural and in line with expectations, avoiding extreme emotional states.
[0030] Further, based on each splicing vector, the fused feature vector sequence is determined, including: linear mapping each splicing vector, and using the linear mapping result as the fused feature vector sequence. In an embodiment of the present invention, on the basis of vector fusion using a vector splicing method, the splicing vector is further linearly mapped, so that deep fusion between vectors can be achieved, which is helpful for subsequently obtaining a first facial expression vector (also referred to as a first expression coefficient) sequence that is more consistent with the target emotional text and the emotional features contained in the input audio, thereby making the emotional state expressed by the generated facial emotional image sequence meet expectations.
[0031] Furthermore, in an embodiment of the present invention, during the iterative training of the model to be optimized including the expression prediction model and the image mapping model, the target loss function used is obtained by weighted summing the pixel difference constraint loss function, the expression difference constraint loss function and the emotion type constraint loss function; wherein the pixel difference constraint loss function is used to iteratively optimize the parameters of the image mapping model, the expression difference constraint loss function is used to iteratively optimize the parameters of the expression prediction model, and the emotion type constraint loss function is used to iteratively optimize the parameters of the expression prediction model and the image mapping model. Compared with the use of a single loss function, this embodiment helps to improve the training effect by comprehensively adopting a plurality of loss functions with different constraint functions, and respectively using them to optimize different model parameters. Furthermore, the weight values of each loss function can be appropriately set according to actual needs to improve the pertinence and refinement of the training, and obtain a more optimized model, thereby obtaining a more expected facial emotion image. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 is a flow chart of a method for generating a facial emotion image in an embodiment of the present invention;
[0033] Figure 2 is a partial flow chart of another method for generating facial emotion images in an embodiment of the present invention;
[0034] Figure 3 is a schematic diagram of the structure of a model to be optimized and its training process in an embodiment of the present invention;
[0035] Figure 4 It is a structural schematic diagram of a facial emotion image generating device in an embodiment of the present invention. DETAILED DESCRIPTION
[0036] In order to make the above-mentioned objects, features and beneficial effects of the present invention more obvious and easy to understand, specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0037] Reference Figure 1 , Figure 1 1 is a flow chart of a method for generating a facial emotion image in an embodiment of the present invention. The method may include steps S11 to S14:
[0038] Step S11: Encode the target emotion text and the input audio respectively to obtain an emotion feature vector and a speech feature vector sequence;
[0039] Step S12: fusing the emotion feature vector with each speech feature vector in the speech feature vector sequence to obtain a fused feature vector sequence;
[0040] Step S13: inputting the fused feature vector sequence into a pre-trained expression prediction model to obtain a first facial expression vector sequence;
[0041] Step S14: Rendering is performed based on the first facial expression vector sequence and the second facial expression vector sequence to obtain a rendered facial image sequence, wherein the second facial expression vector sequence is determined based on an original facial image sequence that is time-series aligned with the speech feature vector sequence;
[0042] Step S15: inputting the rendered facial image sequence and the emotion feature vector into a pre-trained image mapping model to generate a facial emotion image sequence.
[0043] In the specific implementation of step S11, the target situation text can be represented by a preset emotional text template. For example, a template of "a{}talking face" is used, where "{}" is filled with a set emotional tag, including but not limited to words or phrases describing emotions such as happy, angry, sad, surprise, etc., to obtain the target emotional text.
[0044] The emotion tag is used to indicate the emotion type. Specifically, the emotion tag "happy" indicates happiness, the emotion tag "angry" indicates anger, the emotion tag "sad" indicates sadness, and the emotion tag "surprise" indicates surprise. Generally speaking, the emotion tag contained in a single target emotion text usually indicates only a single emotion type, that is, the single target emotion text belongs to a single emotion type.
[0045] Specifically, the emotion type can be used to represent multiple types of emotions, for example, it can be divided more finely, on this basis each emotion type can have a one-to-one corresponding emotion label; or, the emotion type can also be used to represent basic types of emotions, such as joy, anger, sadness, and fear, on this basis each emotion type can have multiple corresponding emotion labels.
[0046] In a specific implementation, the emotion tags contained in the target emotion text can be set according to the actual scene requirements. For example, the user can set appropriate emotion tags according to personal needs or expectations. Thus, under the guidance or constraints of the target emotion text, a facial emotion video that meets the user's expected emotion / expression state can be obtained.
[0047] Furthermore, the emotion type to which the target emotion text belongs is consistent with the emotion type to which the input audio belongs.
[0048] For example, if the emotion type of the target emotion text is "happy", then the emotion type of the input audio is also "happy". In a specific implementation, the input audio can be input into a pre-trained emotion prediction model to obtain a corresponding emotion label as the emotion label in the target emotion text. In this way, the generated facial emotion image can be consistent with the real emotion of the speaker contained in the input voice, thereby obtaining a facial emotion video with empathy.
[0049] In a specific implementation, the target emotional text can be input into a pre-trained text encoder for encoding to obtain a text encoder with a dimension of 1×d t The emotional feature vector (or text encoding vector) of t Represents the length of the emotion feature vector or the number of codes contained in the emotion feature vector.
[0050] The text encoder may adopt a constrained language-image pre-training (CLIP) encoder, or a bidirectional encoder representation from transformers (BERT) encoder or a global vector (Glove) encoder. Accordingly, the emotional text template may also adopt other appropriate forms.
[0051] The input audio may be the audio recorded by the user or the speaker to be tested during the speaking process. The input audio may be input into a pre-trained audio coding model for encoding to obtain an audio codec with a dimension of N×d a A speech feature vector sequence, wherein N represents the total number of frames of speech features in the speech feature vector sequence, d a Indicates the length of each frame of speech features in the speech feature vector sequence or the number of codes contained in each frame of speech features. The audio coding model may be, for example, a second generation FastSpeech2 model. The speech features of each frame in the speech feature vector sequence have a time sequence.
[0052] In the specific implementation of step S12, the emotion feature vector is fused with each speech feature vector in the speech feature vector sequence to obtain a fused feature vector sequence.
[0053] Furthermore, the step S12 may specifically include: keeping the temporal sequence of the speech feature vectors unchanged, splicing the emotion feature vector with each speech feature vector respectively to obtain a plurality of spliced vectors; and determining the fused feature vector sequence based on each spliced vector.
[0054] Furthermore, based on each splicing vector, determining the fused feature vector sequence includes: performing linear mapping on each splicing vector respectively, and using the linear mapping result as the fused feature vector sequence.
[0055] In an embodiment of the present invention, based on the vector fusion method of vector splicing, the spliced vectors are linearly mapped, so that deep fusion between vectors can be achieved, which is helpful for subsequently obtaining a first facial expression vector (also called a first expression coefficient) sequence that is more consistent with the emotional characteristics contained in the target emotional text and the input audio, thereby making the emotional state expressed by the generated facial emotion image sequence meet expectations.
[0056] Furthermore, the emotion feature vector is concatenated with each speech feature vector respectively, including: for each speech feature vector, the emotion feature vector is inserted as a whole into the position after the last code of the speech feature vector.
[0057] In an embodiment of the present invention, the temporal sequence of the speech feature vector is kept unchanged during the splicing process, and the original emotional feature information contained in the speech feature vector can be retained. Furthermore, this embodiment is integrally inserted into the position after the last code of the speech feature vector. Compared with the distributed and random insertion method, it can avoid the original emotional feature information in the emotional feature vector and the speech feature vector from being changed, so that the emotional features contained in the first facial expression vector sequence obtained subsequently are consistent with the emotional features contained in the target emotional text and the input audio, thereby making the emotional state expressed by the generated facial emotional image sequence meet expectations.
[0058] In the specific implementation of step S13, the fused feature vector sequence is input into a pre-trained expression prediction model to obtain a first facial expression vector sequence.
[0059] Specifically, the pre-trained expression prediction model can be obtained by training an existing expression coefficient prediction model. The expression prediction model can include an encoder and a decoder. The main function of the encoder is to encode the input data, for example, b×w×d aThe input data of dimension b is processed by a multi-layer convolutional network for dimension increase, where b represents the number of frames sent in each batch, and w represents the length of the truncated window; the main function of the decoder is to reduce the dimension of the input data through a multi-layer convolutional network, and then send the output result to the fully connected layer to obtain the first facial expression vector sequence.
[0060] The first facial expression vector sequence includes a plurality of first facial expression coefficients in a time sequence. Since the first facial expression coefficients are usually in a vector form, they can also be called first facial expression vectors.
[0061] In the specific implementation of step S14, rendering is performed based on the first facial expression vector sequence and the second facial expression vector sequence to obtain a rendered facial image sequence, wherein the second facial expression vector sequence is determined based on an original facial image sequence that is time-aligned with the speech feature vector sequence.
[0062] Specifically, each second facial expression vector in the second facial expression vector sequence can be obtained in the following manner: inputting each frame of facial image in the original facial image sequence into a three-dimensional deformable face model (3DMorphable Face Model, 3DMM for short) to obtain the second facial expression vector (also referred to as the second facial expression coefficient) corresponding to each frame of facial image.
[0063] Without limitation, the second facial expression vector may be selected from one or more of the following: a facial personality vector, a facial texture vector, a facial rotation vector, and a facial scale scaling vector.
[0064] Among them, the face personality vector and the face texture vector can also be respectively called the face personality coefficient and the face texture coefficient, which are used to describe the appearance characteristics of the face. Specifically, the former mainly characterizes the personality characteristics of the face, and the latter is mainly used to characterize the texture characteristics of the face.
[0065] The face rotation vector and face scale vector may also be respectively referred to as face rotation coefficient and face scale coefficient, which are used to describe the geometric structure of the face. Specifically, the former mainly represents the degree of rotation of the face, and the latter is mainly used to represent the degree of reduction or enlargement of the face.
[0066] Furthermore, the original facial image sequence time-aligned with the speech feature vector sequence is obtained by sampling a video belonging to the same speaker as the input audio; each frame of facial image in the original facial image sequence corresponds one-to-one to each speech feature vector in the speech feature vector sequence.
[0067] As a non-limiting example, an original face image sequence P containing n frames of face images can be expressed as {P(t1 ),P(t 2 ),P(t 3 ),……P(t n )}, the speech feature vector sequence D containing n frames of speech features can be expressed as {d(t 1 ),d(t 2 ),d(t 3 ),……d(t n )}, where P(t 1 )~P(t n ) represents the face images of the first to nth frames, d(t 1 )~d(t n ) represents the speech features of the first frame to the nth frame. 1 )~P(t n ) and d(t 1 )~d(t n ) correspond one to one, and the corresponding face images and speech features are time-series aligned.
[0068] In an embodiment of the present invention, during the facial image rendering process, not only the first expression vector sequence predicted based on the fused feature vector sequence is used, but also the second expression vector sequence determined by sampling the original facial image sequence based on the video of the same speaker is combined. Since the first expression vector sequence incorporates the emotional features of the target emotional text and the emotional features contained in the input audio recorded during the speaker's speech, the second expression vector sequence includes the emotional features contained in the video recorded during the speaker's speech. Therefore, the rendered facial image sequence can accurately express the emotional state indicated by the target emotional text and be consistent with the actual emotional state of the speaker (or user) during the speech.
[0069] It should be noted that the original facial image sequence that is time-aligned with the speech feature vector sequence can also be obtained in other appropriate ways, for example, a standard facial image series formed by a plurality of frames of standard facial images can be used, and the standard facial image can refer to a facial image that can reflect the common or average features of most human faces. In addition, the correspondence between the facial images in the original facial image sequence and the time-aligned speech feature vectors in the speech feature vector sequence can vary according to the needs of the actual application scenario, for example, it can be a one-to-many or many-to-one relationship.
[0070] In a specific implementation of step S15, the rendered facial image sequence and the emotion feature vector are input into a pre-trained image mapping model to generate a facial emotion image sequence.
[0071] Specifically, each frame of rendered facial image (also referred to as skinned image) in the rendered facial image sequence can be input into a first network layer comprising a multi-layer convolutional network for dimensionality upscaling processing, and then the result of the dimensionality upscaling processing can be input into a second network layer comprising a multi-layer convolutional network for dimensionality reduction processing to generate multiple frames of facial emotion images corresponding to the multiple frames of rendered facial images as the facial emotion image sequence.
[0072] In a specific implementation, during the dimensionality reduction and dimensionality increase processing, the emotional feature vector obtained based on the target emotional text is introduced to guide the generation of emotional face images. The emotional feature vector can be fused with the output of each convolution layer respectively, and then input into the next convolution layer. Specifically, the AdaIn fusion method can be adopted, wherein the basic principle of AdaIn can be expressed by the formula:
[0073]
[0074] Among them, f m represents the averaging function, f δ represents the variance calculation function, f β and f α It is generally represented as two different fully connected networks, where x represents the output vector of each convolutional layer, y represents the emotion feature vector, and AdaIn(x, y) represents the fusion result of the emotion feature vector and the output vector of each convolutional layer.
[0075] Reference Figure 2 , Figure 2 is a partial flow chart of another method for generating a facial emotion image in an embodiment of the present invention. The another method for generating a facial emotion image may include Figure 1 The steps S11 to S15 shown in the illustrated embodiment may further include steps S21 to S23, wherein steps S21 to S23 may be performed before step S13.
[0076] In step S21, the sample emotion text and the sample audio are encoded respectively to obtain a sample emotion feature vector and a sample speech feature vector sequence, and then the sample emotion feature vector is fused with each sample speech feature vector to obtain a fused sample feature vector sequence.
[0077] For the scheme of encoding the sample emotion text and the sample audio respectively and performing vector fusion in step S21, see Figure 1 The relevant description contents of step S11 to step S12 in the illustrated embodiment are executed and will not be repeated here.
[0078] In step S22, a training data set is constructed using the fused sample feature vector sequence and the facial expression vector label corresponding to each fused sample feature vector.
[0079] Among them, the facial expression vector label corresponding to each fused sample feature vector can be the facial expression vector label of the original sample face image with the fused sample feature vector time-series aligned (that is, the labeled expression vector, also called the facial expression coefficient label).
[0080] In step S23, the target loss function is used to input the training data set into the model to be optimized for iterative training to obtain the pre-trained expression prediction model and the pre-trained image mapping model, and the model to be optimized includes the expression prediction model and the image mapping model.
[0081] Reference Figure 3 , Figure 3 3 is a schematic diagram of the structure of a model to be optimized and its training process in an embodiment of the present invention. The model to be optimized 30 shown includes an expression prediction model 31 and an image mapping model 32.
[0082] In each round of iterative training, the training data set is input into the expression prediction model 31 of the model to be optimized 30 to obtain the first facial expression sample vector sequence of the current round, and then rendering is performed based on the first facial expression sample vector sequence and the second facial expression sample vector sequence to obtain a rendered sample facial image sequence, and then the rendered sample facial image sequence and the sample emotion feature vector are input into the image mapping model 32 of the model to be optimized 30 to generate the sample facial emotion image sequence of the current round.
[0083] The second facial expression sample vector sequence is determined based on a sample facial image sequence that is time-series aligned with the sample speech feature vector sequence.
[0084] Furthermore, the target loss function is obtained by weighted summing up the pixel difference constraint loss function, the expression difference constraint loss function and the emotion type constraint loss function; during the iterative training process, the pixel difference constraint loss function is used to iteratively optimize the parameters of the image mapping model 32, the expression difference constraint loss function is used to iteratively optimize the parameters of the expression prediction model 31, and the emotion type constraint loss function is used to iteratively optimize the parameters of the expression prediction model 31 and the image mapping model 32.
[0085] Specifically, the pixel difference constraint loss function can be expressed by the following expression:
[0086]
[0087] Among them, Lv represents the pixel difference constraint loss function, R i represents the i-th pixel of the original sample face image, represents the i-th pixel of the sample facial emotion image generated by the image mapping model, I represents the total number of pixels, represents the jth element in the image features extracted from the original sample face image, represents the jth element in the image feature extracted from the sample facial emotion image generated by the image mapping model, J represents the total number of elements in the image feature, ||x|| represents the norm of x, and N represents the total number of images in the generated sample facial emotion image sequence; wherein the image feature can be extracted using a pre-trained feature extraction network (for example, VGG-19).
[0088] In an embodiment of the present invention, the pixel difference function not only includes the pixel difference between the original sample facial image and the sample facial emotion image generated by the model, but also includes the image feature difference between the two. Thus, compared with only introducing pixel differences, this embodiment helps to further improve the training effect by introducing double differences, and helps to obtain facial emotion images that are closer to actual facial images in the subsequent reasoning stage.
[0089] The expression difference constraint loss function can be expressed by the following expression:
[0090]
[0091] Among them, L p represents the expression difference constraint loss function, p i represents the i-th element of the annotated expression vector of the original sample face image, that is, the i-th element of the face expression vector label, represents the i-th element of the first facial expression sample vector output by the expression prediction model, N p represents the total number of elements in the first facial expression sample vector, and N represents the total number of vectors in the first facial expression sample vector sequence predicted by the expression prediction model, that is, the total number of images in the generated sample facial emotion image sequence;
[0092] The emotion type constraint loss function is expressed by the following expression:
[0093] Among them, L e represents the emotion type constraint loss function, y represents the probability corresponding to the true emotion of the original sample face image, represents the probability distribution of emotion types obtained by performing emotion type recognition on the generated sample facial emotion images, and N represents the total number of images in the generated sample facial emotion image sequence.
[0094] The above-mentioned loss functions have their own constraint functions during the model training process. Specifically, the pixel difference constraint loss function is mainly used to constrain the pixel difference between the sample facial emotion image generated by the image mapping model and the original sample facial image, the expression difference constraint loss function is mainly used to constrain the difference between the expression coefficient (i.e., the first facial expression sample vector) generated by the expression prediction model and the expression coefficient (i.e., the facial expression vector label) of the original sample facial image, and the emotion type constraint loss function is used to constrain the difference between the emotion type of the sample facial emotion image generated by the entire model to be optimized and the target emotion type.
[0095] The original sample face image is aligned one-to-one with the sample face emotion image generated by the model in time sequence. In a specific implementation, the original sample face image can be obtained by sampling a video of the same speaker as the sample audio.
[0096] Wherein, the target emotion type may be the emotion type of the original sample facial image that is time-series aligned with the generated sample facial emotion image, and the probability value of the target emotion type may be set to 1. The emotion type of the sample facial emotion image may be obtained by identifying using a pre-trained emotion recognition model. Specifically, the emotion recognition model may output an emotion type probability distribution of the sample facial emotion image, and the emotion type probability distribution includes probability values of the sample facial emotion image belonging to various emotion types. Wherein, the probability value of each emotion type in the emotion type probability distribution may be between the interval (0,1), and the sum of the probability values of each emotion type is equal to 1.
[0097] In an embodiment of the present invention, during the iterative training of the model 30 to be optimized including the expression prediction model 31 and the image mapping model 32, the target loss function used is obtained by weighted summing the above three loss functions. Compared with the use of a single loss function for model training, this embodiment adopts a variety of loss functions in combination, and can appropriately set the weight value of each loss function according to actual needs, and use them to optimize different model parameters respectively. In this way, the pertinence and refinement of the training can be improved, and a more optimized pre-trained expression prediction model and pre-trained image mapping model can be obtained.
[0098] Reference Figure 4 , Figure 4 : is a schematic diagram of the structure of a facial emotion image generation device in an embodiment of the present invention. The facial emotion image generation device may include:
[0099] The encoding module 41 is used to encode the target emotion text and the input audio to obtain an emotion feature vector and a speech feature vector sequence;
[0100] A vector fusion module 42, used to fuse the emotion feature vector with each speech feature vector in the speech feature vector sequence to obtain a fused feature vector sequence;
[0101] An expression coefficient prediction module 43, used for inputting the fused feature vector sequence into a pre-trained expression prediction model to obtain a first facial expression vector sequence;
[0102] A rendering module 44, configured to perform rendering based on the first facial expression vector sequence and the second facial expression vector sequence to obtain a rendered facial image sequence, wherein the second facial expression vector sequence is determined based on an original facial image sequence that is time-sequentially aligned with the speech feature vector sequence;
[0103] The facial emotion image generation module 45 is used to input the rendered facial image sequence and the emotion feature vector into a pre-trained image mapping model to generate a facial emotion image sequence.
[0104] For the principle, specific implementation and beneficial effects of the facial emotion image generation device, please refer to the previous article and Figures 1 to 3 The related description about the method for generating facial emotion images shown is not repeated here.
[0105] The embodiment of the present invention further provides a readable storage medium, such as a computer readable storage medium, on which a computer program is stored, and the computer program is executed by a processor. Figure 1 to Figure 2 The steps of the method for generating a facial emotion image are shown. The computer-readable storage medium may include a non-volatile memory or a non-transitory memory, and may also include an optical disk, a mechanical hard disk, a solid-state hard disk, etc.
[0106] Specifically, in the embodiment of the present invention, the processor may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0107] It should also be understood that the memory in the embodiments of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM) and direct rambus RAM (DR RAM).
[0108] The embodiment of the present invention further provides a terminal, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and the processor executes the above-mentioned Figures 1 to 3The steps of the method for generating facial emotion images are shown. The terminal may include but is not limited to terminal devices such as mobile phones, computers, tablet computers, etc., and may also be a server, a cloud platform, etc.
[0109] It should be understood that the term "and / or" in this article is only a description of the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article indicates that the associated objects before and after are in an "or" relationship.
[0110] The "plurality" appearing in the embodiments of the present application refers to two or more.
[0111] The first, second, etc. descriptions appearing in the embodiments of the present application are only used for illustration and distinction of the description objects. There is no order, nor do they indicate any special limitation on the number of devices in the embodiments of the present application, and cannot constitute any limitation on the embodiments of the present application.
[0112] It should be pointed out that the serial numbers of the steps in this embodiment do not limit the execution order of the steps.
[0113] Although the present invention is disclosed as above, the present invention is not limited thereto. Any person skilled in the art can make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the scope defined by the claims.
Claims
1. A method for generating a facial emotion image, characterized in that: include: Encode the target emotional text and the input audio respectively to obtain an emotional feature vector and a speech feature vector sequence; Fusing the emotion feature vector with each speech feature vector in the speech feature vector sequence to obtain a fused feature vector sequence; Inputting the fused feature vector sequence into a pre-trained expression prediction model to obtain a first facial expression vector sequence; Rendering is performed based on the first facial expression vector sequence and the second facial expression vector sequence to obtain a rendered facial image sequence, wherein the second facial expression vector sequence is determined based on an original facial image sequence that is time-sequentially aligned with the speech feature vector sequence; Inputting the rendered facial image sequence and the emotion feature vector into a pre-trained image mapping model to generate a facial emotion image sequence; Before inputting the fused feature vector sequence into the pre-trained expression prediction model, the method further includes: Encoding the sample emotion text and the sample audio respectively to obtain a sample emotion feature vector and a sample speech feature vector sequence, and then fusing the sample emotion feature vector with each sample speech feature vector respectively to obtain a fused sample feature vector sequence; A training data set is constructed using a fusion sample feature vector sequence and a facial expression vector label corresponding to each fusion sample feature vector; Using a target loss function, inputting the training data set into the model to be optimized for iterative training to obtain the pre-trained expression prediction model and the pre-trained image mapping model, wherein the model to be optimized includes the expression prediction model and the image mapping model; Wherein, in each round of iterative training, the training data set is input into the expression prediction model to obtain the first facial expression sample vector sequence of the current round, and then rendering is performed based on the first facial expression sample vector sequence and the second facial expression sample vector sequence to obtain a rendered sample facial image sequence, and then the rendered sample facial image sequence and the sample emotion feature vector are input into the image mapping model to generate a sample facial emotion image sequence of the current round; The second facial expression sample vector sequence is determined based on an original sample facial image sequence that is time-series aligned with the sample speech feature vector sequence.
2. The method according to claim 1, characterized in that The emotion feature vector is respectively fused with each speech feature vector in the speech feature vector sequence to obtain a fused feature vector sequence, including: Keeping the temporal sequence of the speech feature vectors unchanged, the emotion feature vector is concatenated with each speech feature vector respectively to obtain a plurality of concatenated vectors; Based on each concatenated vector, the fused feature vector sequence is determined.
3. The method according to claim 2, characterized in that Determining the fused feature vector sequence based on each splicing vector includes: Linear mapping is performed on each concatenated vector, and the linear mapping result is used as the fused feature vector sequence.
4. The method according to claim 2 or 3, characterized in that: The emotion feature vector is concatenated with each speech feature vector respectively, including: For each speech feature vector, the emotion feature vector is inserted as a whole into the position after the last code of the speech feature vector.
5. The method according to claim 1, characterized in that The target loss function is obtained by weighted summing the pixel difference constraint loss function, the expression difference constraint loss function and the emotion type constraint loss function; During the iterative training process, the pixel difference constraint loss function is used to iteratively optimize the parameters of the image mapping model, the expression difference constraint loss function is used to iteratively optimize the parameters of the expression prediction model, and the emotion type constraint loss function is used to iteratively optimize the parameters of the expression prediction model and the image mapping model.
6. The method according to claim 5, characterized in that Meet one or more of the following: The pixel difference constraint loss function is expressed by the following expression: Among them, L v represents the pixel difference constraint loss function, R i represents the i-th pixel of the original sample face image, represents the i-th pixel of the sample facial emotion image generated by the image mapping model, I represents the total number of pixels, represents the jth element in the image features extracted from the original sample face image, represents the jth element in the image feature extracted from the sample facial emotion image generated by the image mapping model, J represents the total number of elements in the image feature, ‖x|| represents the norm of x, and N represents the total number of images in the generated sample facial emotion image sequence; The expression difference constraint loss function is expressed by the following expression: Among them, L p represents the expression difference constraint loss function, p i represents the i-th element of the annotated expression vector of the original sample face image, that is, the i-th element of the face expression vector label, represents the i-th element of the first facial expression sample vector output by the expression prediction model, N p represents the total number of elements in the first facial expression sample vector, and N represents the total number of vectors in the first facial expression sample vector sequence predicted by the expression prediction model, that is, the total number of images in the generated sample facial emotion image sequence; The emotion type constraint loss function is expressed by the following expression: Among them, L e represents the emotion type constraint loss function, y represents the probability corresponding to the true emotion of the original sample face image, represents the probability distribution of emotion types obtained by performing emotion type recognition on the generated sample facial emotion images, and N represents the total number of images in the generated sample facial emotion image sequence.
7. The method according to claim 1, characterized in that The emotion type of the target emotion text is consistent with the emotion type of the input audio.
8. The method according to claim 1, characterized in that: The original face image sequence that is time-sequentially aligned with the speech feature vector sequence is obtained by sampling a video of the same speaker as the input audio; Each frame of face image in the face image sequence corresponds one-to-one to each speech feature vector in the speech feature vector sequence.
9. The method according to claim 1 or 8, characterized in that: Each second facial expression vector in the second facial expression vector sequence is selected from one or more of the following: Face personality vector, face texture vector, face rotation vector, face scale vector.
10. A facial emotion image generation device, characterized in that: include: An encoding module, used for encoding the target emotion text and the input audio respectively to obtain an emotion feature vector and a speech feature vector sequence; A vector fusion module, used for fusing the emotion feature vector with each speech feature vector in the speech feature vector sequence to obtain a fused feature vector sequence; An expression coefficient prediction module, used for inputting the fused feature vector sequence into a pre-trained expression prediction model to obtain a first facial expression vector sequence; A rendering module, configured to perform rendering based on the first facial expression vector sequence and the second facial expression vector sequence to obtain a rendered facial image sequence, wherein the second facial expression vector sequence is determined based on an original facial image sequence that is time-sequentially aligned with the speech feature vector sequence; A facial emotion image generation module, used for inputting the rendered facial image sequence and the emotion feature vector into a pre-trained image mapping model to generate a facial emotion image sequence; Before inputting the fused feature vector sequence into the pre-trained expression prediction model, the facial emotion image generating device further performs: Encoding the sample emotion text and the sample audio respectively to obtain a sample emotion feature vector and a sample speech feature vector sequence, and then fusing the sample emotion feature vector with each sample speech feature vector respectively to obtain a fused sample feature vector sequence; A training data set is constructed using a fusion sample feature vector sequence and a facial expression vector label corresponding to each fusion sample feature vector; Using a target loss function, inputting the training data set into the model to be optimized for iterative training to obtain the pre-trained expression prediction model and the pre-trained image mapping model, wherein the model to be optimized includes the expression prediction model and the image mapping model; Wherein, in each round of iterative training, the training data set is input into the expression prediction model to obtain the first facial expression sample vector sequence of the current round, and then rendering is performed based on the first facial expression sample vector sequence and the second facial expression sample vector sequence to obtain a rendered sample facial image sequence, and then the rendered sample facial image sequence and the sample emotion feature vector are input into the image mapping model to generate a sample facial emotion image sequence of the current round; The second facial expression sample vector sequence is determined based on an original sample facial image sequence that is time-series aligned with the sample speech feature vector sequence.
11. A readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for generating a facial emotion image according to any one of claims 1 to 9 are executed.
12. A terminal comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, characterized in that: When the processor runs the computer program, the steps of the method for generating a facial emotion image according to any one of claims 1 to 9 are executed.
