Model training method, video generation method and related device
By introducing the loss value of image feature error and lip area correlation into the facial expression synthesis technology, and adjusting the model parameters, the problems of low lip shape definition and insufficient style personalization when generating facial images are solved, achieving higher quality and Personalized lip shape generation.
Patent Information
- Application Number
- CN202410431492.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-09
- Publication Date
- 2024-09-17
AI Technical Summary
In the existing facial expression synthesis technology, the lip shape definition of the generated facial image is low and the style is not personalized enough, and it is impossible to output the personal lip shape style of a specific object.
By obtaining sample images and sample audio, input the model for data processing, introduce a loss value that represents the image feature error and the correlation degree of the lip area, and adjust the model parameters to increase the processing attention of the lip area and generate a clearer and matching style. Facial images.
The image quality and lip shape clarity of the facial image are improved, making it more consistent with the lip shape style of a specific object, and solving the problems of low lip shape clarity and insufficient style personalization in the existing technology.
Smart Images

Figure CN118660209A
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence technology, and in particular to a model training method, a video generation method and related devices. Background Art
[0002] Driven by technologies such as artificial intelligence and virtual reality, facial expression synthesis technology has been widely used. It can be applied in film production, game development, virtual reality, remote communication and various other interactive applications.
[0003] In the related art, facial expressions are generally generated based on static images. Facial images generated based on this type of method can often only generate a general and low-resolution lip shape effect, which has the problems of low lip shape clarity and insufficient style personalization. Summary of the invention
[0004] The present invention provides a model training method, a video generation method and related devices.
[0005] In a first aspect, the present disclosure provides a model training method, the model training method comprising:
[0006] Acquire a sample image and a sample audio of a first object;
[0007] Inputting the sample image and the sample audio into a first model for data processing to obtain a facial image, wherein the lip shape included in the facial image corresponds to the first object and is synchronized with the sample audio in terms of timing;
[0008] Determine a first loss value and a second loss value according to the sample image and the facial image, wherein the first loss value represents an error in image features between the sample image and the facial image, and the second loss value represents a degree of correlation between the sample image and the lip region of the facial image;
[0009] Adjust parameters of the first model according to the first loss value and the second loss value.
[0010] In a second aspect, the present disclosure provides a video generation method, the video generation method comprising:
[0011] Acquire a first facial image and a target audio, wherein the first facial image is extracted from an original image of a first subject;
[0012] Inputting the first facial image and the target audio into a first model for image processing to obtain a second facial image, wherein the lip shape contained in the second facial image matches the lip shape of the first object and is synchronized with the target audio in terms of timing;
[0013] A target video is generated according to the second facial image, the original image and the target audio.
[0014] In a third aspect, the present disclosure provides a model training device, the model training device comprising:
[0015] A first acquisition unit, configured to acquire a sample image and a sample audio of a first object;
[0016] A first processing unit is configured to input the sample image and the sample audio into a first model for data processing to obtain a facial image, wherein a lip shape included in the facial image corresponds to the first object and is synchronized with the sample audio in terms of timing;
[0017] a determining unit, configured to determine a first loss value and a second loss value according to the sample image and the facial image, wherein the first loss value represents an error in image features between the sample image and the facial image, and the second loss value represents a correlation between the sample image and a lip region of the facial image;
[0018] An adjusting unit, configured to adjust parameters of the first model according to the first loss value and the second loss value.
[0019] In a fourth aspect, the present disclosure provides a video generation device, the video generation device comprising:
[0020] A second acquisition unit, configured to acquire a first facial image and a target audio, wherein the first facial image is extracted from an original image of the first object;
[0021] A second processing unit is configured to input the first facial image and the target audio into a first model for data processing to obtain a second facial image, wherein a lip shape included in the second facial image matches the lip shape of the first object and is synchronized with the target audio in terms of timing;
[0022] A generating unit is used to generate a target video according to the second facial image, the original image and the target audio.
[0023] In a fifth aspect, the present disclosure provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores one or more computer programs executable by the at least one processor, and one or more of the computer programs are executed by the at least one processor so that the at least one processor can execute the model training method of the first aspect or the video generation method of the second aspect.
[0024] In a sixth aspect, the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the model training method of the first aspect or the video generation method of the second aspect.
[0025] In the seventh aspect, the present disclosure provides a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the model training method of the first aspect or the video generation method of the second aspect.
[0026] In the embodiments provided by the present disclosure, after the sample image and the sample audio are input into the first model for data processing to obtain a facial image corresponding to the first object and containing a lip shape that is synchronized with the sample audio in time sequence, on the one hand, by introducing a first loss value that can characterize the error of the image features between the sample image and the facial image, the model can learn more image features, thereby improving the image quality of the facial image output by the model for data processing; on the other hand, by using the sample image and the sample audio of the first object as training data and introducing a second loss value that can characterize the degree of correlation between the sample image and the lip area of the facial image, the model can shift the focus to the lips during the training process, thereby learning more image features of the lip area, and then paying more attention to the processing of the lip area in the process of data processing and outputting the facial image, thereby outputting a facial image containing a clearer lip shape and matching the lip shape style of the first object, so as to solve the problems of low clarity of the lip shape contained and insufficient style personalization when generating facial images in the related art.
[0027] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the present disclosure and do not constitute a limitation of the present disclosure. The above and other features and advantages will become more apparent to those skilled in the art by describing detailed example embodiments with reference to the accompanying drawings, in which:
[0029] Figure 1 It is a schematic diagram of the training framework of the Wav2Lip model in the related art;
[0030] Figure 2 A flowchart of a model training method provided in an embodiment of the present disclosure;
[0031] Figure 3 A schematic diagram of a model training framework provided in an embodiment of the present disclosure;
[0032] Figure 4 A flowchart of a video generation method provided by an embodiment of the present disclosure;
[0033] Figure 5 A block diagram of a model training device provided in an embodiment of the present disclosure;
[0034] Figure 6 A block diagram of a video generating device provided by an embodiment of the present disclosure;
[0035] Figure 7 A block diagram of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0036] In order to enable those skilled in the art to better understand the technical solutions of the present disclosure, the exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0037] In the absence of conflict, the various embodiments of the present disclosure and the various features therein may be combined with each other.
[0038] As used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items.
[0039] The terms used herein are only used to describe specific embodiments and are not intended to limit the present disclosure. As used herein, the singular forms "a" and "the" are also intended to include plural forms, unless the context clearly indicates otherwise. It will also be understood that when the terms "including" and / or "made of" are used in this specification, the presence of the features, wholes, steps, operations, elements and / or components is specified, but the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof is not excluded. "Connected" or "connected" and similar words are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect.
[0040] In the technical solution disclosed in this disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals. The use of user data in this technical solution complies with relevant national laws and regulations (for example, the "Information Security Technology Personal Information Security Specification", etc.). For example: corresponding prescribed measures are taken for personal information access control; prescribed restrictions are imposed on the display of personal information; the purpose of using personal information does not exceed the scope of direct or reasonable association; when using personal information, clear identity orientation is eliminated to avoid precise positioning of specific individuals.
[0041] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by those of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and the present disclosure, and will not be interpreted as having an idealized or overly formal meaning unless explicitly defined as such herein.
[0042] When generating facial images (also called facial expression images), data processing can generally be performed based on deep learning models such as the Wav2Lip model or the FistOrder Motion Model to generate facial images. The following takes the Wav2Lip model as an example to briefly explain how to train the model in related technologies.
[0043] Please see Figure 1 , which is a training diagram of the Wav2Lip model in the related art. Figure 1 As shown in FIG. 1 , the input of the Wav2Lip model includes: an original image and a corresponding original audio, wherein the original image is a multi-frame facial image with a resolution of 96*96 extracted from a continuous multi-frame video frame of any user's speaking video, for example, 5 facial images extracted from 5 continuous video frames, such as Figure 1 As shown, the original image includes a facial image with the lower half (i.e., the lip area) masked, and may also include multiple random reference frames randomly extracted from the user's video, where the random reference frames are the facial images of the lower half that are not masked, wherein during the model training process, the random reference frames are used to provide prior information for the model, and the original audio is the audio corresponding to the original image extracted from the speaking video, for example, it may be audio synchronized with the duration of 5 consecutive video frames.
[0044] Please continue to see Figure 1The Wav2Lip model includes a generator for generating facial images and two discriminators corresponding to the generator; wherein the generator may include an image encoder, an audio encoder and a decoder, wherein the image encoder performs image encoding on the original image to output facial image features, the audio encoder performs audio encoding on the original audio to output voice features, and the decoder is responsible for decoding the splicing features corresponding to the facial image features and voice features to generate a generated image with a resolution of 96*96 whose lip shape is synchronized with the original audio in time sequence.
[0045] The discriminator includes a lip synchronization discriminator and a visual quality discriminator. The lip synchronization discriminator determines whether the lip movements in the generated image are synchronized with the audio based on the original audio, and the visual quality discriminator determines whether the image quality of the generated image is realistic based on the original image and the generated image.
[0046] During the model training process, the model parameters can be adjusted until the model converges based on the L1 reconstruction loss between the generated image and the original image, the synchronization loss obtained after discrimination by the lip synchronization discriminator, and the binary cross entropy loss obtained after discrimination by the visual quality discriminator. Among them, the L1 reconstruction loss can be, for example, a loss value calculated based on the L1 loss function, also known as the mean absolute error (MAQ, Mean Abs Error), which is used to characterize the pixel-level error between the generated image and the original image.
[0047] However, when image generation is performed based on image processing models such as the Wav2Lip model, image generation can only be performed at low resolution, such as 96*96 resolution. Therefore, the facial images generated by them generally have the problem of insufficient clarity. In addition, the training process mainly relies on the L1 reconstruction loss to adjust the model parameters, but the L1 reconstruction loss is usually calculated based on the entire image, and the lip area is only a small part of the entire image. This makes it impossible for the model to focus on the lip details, resulting in insufficient lip clarity in the facial images generated by the model and insufficient personalization of the lip shape style. That is, it can only output a general lip shape effect without the personal style of a specific object.
[0048] In view of this, in an embodiment of the present disclosure, during the model training process, after the sample image and the sample audio are input into the first model for data processing to obtain a facial image corresponding to the first object and containing a lip shape that is synchronized in time with the sample audio, on the one hand, by introducing a first loss value that can characterize the error of image features between the sample image and the facial image, the model can learn more image features, thereby improving the image quality of the facial image output by the model for data processing; on the other hand, by using the sample image and the sample audio of the first object as training data and introducing a second loss value that can characterize the degree of correlation between the sample image and the lip area of the facial image, the model can shift the focus to the lips during the training process, thereby learning more image features of the lip area, and then paying more attention to the processing of the lip area in the process of data processing and outputting the facial image, thereby outputting a facial image containing a clearer lip shape and matching the lip shape style of the first object, so as to solve the problems of low clarity of the lip shape contained and insufficient style personalization when generating facial images in the related art.
[0049] Please see Figure 2 and Figure 3 , which are respectively a flow chart of a model training method provided in an embodiment of the present disclosure, and a schematic diagram of a model training framework provided in an embodiment of the present disclosure. The method can be applied to an electronic device, which can be a server or a terminal device, without special limitation here.
[0050] like Figure 2 As shown, the model training method provided by the embodiment of the present disclosure may include the following steps S201-S204, which are described in detail below.
[0051] Step S201, obtaining a sample image and a sample audio of a first object;
[0052] Step S202: Input the sample image and the sample audio into the first model for data processing to obtain a facial image, wherein the lip shape included in the facial image corresponds to the first object and is synchronized with the sample audio in terms of timing.
[0053] The first object may be any object including lips.
[0054] The first object may be a user. For example, in the scenario of making an animation video, if you want the speaking style of the virtual person in the animation video to be consistent with the speaking style of a specific user user01, that is, the lip shape is consistent with the lip shape of user01, then user01 may be regarded as the first object in the embodiment of the present disclosure. For another example, in the intelligent customer service scenario in the financial consumption field, if you want the digital customer service to respond to user questions based on the speaking style of a specific user user02, then user02 may be regarded as the first object in the embodiment of the present disclosure.
[0055] The first object may also be an animal such as a cat or a dog. For example, in the scenario of making an animation video, if you want the lip movements of a cartoon cat, cartoon dog, etc. in the animation video to be consistent with the lip movements of a popular physical cat or physical dog in reality, then the physical cat or physical dog may be regarded as the first object in the embodiment of the present disclosure.
[0056] Of course, in actual implementation, the first object can be set as needed and is not specifically limited here.
[0057] It should be noted that before executing step S201, i.e., obtaining the sample image and sample audio of the first object, it is necessary to obtain the authorization and consent of the first object. For example, if the first object is a user, it is necessary to first obtain the authorization and consent of the user to use its sample image and sample audio. Furthermore, it is also necessary to obtain the authorization and consent of the user to generate a facial image consistent with the user's lip style based on the first model trained with its sample image and sample audio, and use it for image processing and / or video generation processing; it is understandable that, in the case where the first object is a user, if the user does not agree to use its image and audio as sample image and sample audio, it is necessary to stop executing step S201. In addition, if the first object is an animal, such as a physical cat, physical dog, or other animal, it is necessary to execute step S201 with the authorization and consent of the user to whom the first object belongs.
[0058] It should also be noted that, unless otherwise specified, the subsequent description of this disclosure will take the first object as the user, the sample image as the facial image containing the user's speaking action, and the sample audio as the user's speaking audio as an example for explanation.
[0059] See also Figure 3 The sample image and the sample audio may be a facial image and a speech audio of the first subject extracted from a speech video of the first subject. It should be noted that the sample image and the sample audio are synchronized in time sequence, that is, if the sample image is a facial image obtained according to the fifth video frame in the speech video of the first subject, and if the time range corresponding to the fifth video frame in the video is from time t1 to time t2, the sample audio is the audio from time t1 to time t2 in the speech video.
[0060] It should also be noted that the sample image can be multiple images. Specifically, the sample image can be multiple facial images obtained after facial recognition and extraction processing of m consecutive frames of the speaking video of the first object, where m is greater than 1, for example, m can be 5.
[0061] For example, for the speaking video video01 of the first subject, first, the video01 can be segmented to obtain 10 consecutive frames of images, and the audio file wav01 corresponding to vide001 can be separated; secondly, the s3fd model or other facial image recognition and extraction models can be used to perform facial image recognition and extraction on the 10 consecutive frames of images to obtain 10 facial images corresponding to the 10 consecutive frames of images, namely, {img10, img11, …, img19}; thirdly, the 10 facial images are scaled, namely, resized to a preset size, such as 10 facial images with a resolution of 96*96, namely, {img20, img21, …, img29}; finally, if during the model training process, the sample image input at one time is the facial image corresponding to 5 consecutive video frames, then {img2 0,img21,img22,img23,img24} are the 5 facial images corresponding to the first 5 video frames to construct sample image 1, and sample image 2 is constructed according to the 5 facial images corresponding to the last 5 video frames {img25,img26,img27,img28,img29}, and wav01 is split to obtain the audio wav02 corresponding to the first 5 video frames and the audio wav03 corresponding to the last 5 video frames. Wav02 is used as the sample audio 1 corresponding to sample image 1, and wav03 is used as the sample audio 2 corresponding to sample image 2. Then the training set {<{img20,img21,img22,img23,img24},wav02>,<{img25,img26,img27,img28,img29},wav03>} can be constructed.
[0062] It should be noted that the speaking video of the first object refers to a video obtained by recording the speaking action of the first object. In some embodiments, in the process of extracting sample audio from the speaking video of the first object, in order to avoid the recording device and / or environmental noise affecting the model training during the recording of the speaking video, after the speaking video is recorded, the speaking video can be first subjected to audio separation and noise reduction processing to obtain the first audio after the noise reduction processing, and the sample audio is obtained based on the first audio; in addition, considering that there may be a situation where the audio and the picture are not synchronized in the recorded speaking video, therefore, after the speaking video is recorded, an audio and picture synchronization model can also be used, for example, the model in Syncnet python can be used to perform audio and picture synchronization processing on the speaking video.
[0063] The first model may be a pre-trained Wav2Lip model. Of course, the first model may also be other pre-trained image processing models for generating facial images, such as a Fist Order Motion Model model or other similar models. In the embodiments disclosed herein, unless otherwise specified, the first model is taken as an example of a pre-trained Wav2Lip model.
[0064] It should be noted that, when the first model is a pre-trained Wav2Lip model, the construction process of the existing Wav2Lip model sample image can be referred to in the process of constructing the sample image. For example, if the first model is a Wav2Lip model, when constructing the sample image 1 according to {img20, img21, img22, img23, img24}, the sample image 1 may include the original 5 facial images, and may also include the lower half of the 5 facial images, that is, the facial image obtained after masking the area containing the lips, and the detailed processing process will not be repeated here.
[0065] The facial image may be an image generated after the first model performs data processing on the sample image and the sample audio. The lip shape contained in the facial image corresponds to the first object. Specifically, the lip shape contained in the facial image matches the lip shape of the first object. In layman's terms, it may mean that the mouth shape in the facial image is consistent with the mouth shape of the first object, for example, details such as the size of the mouth and whether teeth are shown when speaking are consistent.
[0066] Step S203, determining a first loss value and a second loss value according to the sample image and the generated image, wherein the first loss value represents the error of the image features between the sample image and the facial image, and the second loss value represents the correlation between the sample image and the lip region of the facial image;
[0067] Step S204: adjust the parameters of the first model according to the first loss value and the second loss value.
[0068] Taking the initial first model as the pre-trained Wav2Lip model as an example, when training this type of model in the related art, the parameters of the model are generally adjusted based on the L1 reconstruction loss between the generated facial image and the original image used for training. Since the L1 reconstruction algorithm is usually based on the L1 loss function, that is, the loss of the generated facial image and the original image is calculated based on the mean absolute difference between the two, the focus of existing model training is usually on the overall image rather than on a certain local detail. This means that when the existing image processing model generates facial images, its lip shape style is often a more general style, and it is unable to simulate the style of a specific object.
[0069] See also Figure 3 In the embodiment of the present disclosure, considering that in the field of facial image generation, if the lip shapes contained in the generated facial image are all universal lip shapes, it will usually cause a visual feeling of unreal image, affecting the user's perception. Therefore, after the sample image and the sample audio are input into the first model for data processing to obtain a facial image corresponding to the first object and containing a lip shape that is synchronized with the sample audio in time sequence, the embodiment of the present disclosure, on the one hand, introduces a first loss value that can characterize the error of image features between the sample image and the facial image, so that the model can learn more image features, thereby improving the image quality of the facial image output by the model through image processing; on the other hand, by further introducing a second loss value that can characterize the correlation between the sample image and the lip area of the facial image, that is, by introducing the lip area as a region of interest (ROI) and calculating the correlation between the sample image and the facial image in this area as the loss value, the model can shift the focus to the lips during the training process, thereby being able to learn more image features of the lip area, and then paying more attention to the processing of the lip area in the process of outputting the facial image through image processing, thereby outputting a facial image containing a clearer lip shape and matching the lip shape style of the first object.
[0070] After obtaining the first loss value and the second loss value, the parameters of the first model can be adjusted and optimized based on the first loss value and the second loss value to meet the preset convergence conditions. The first model that meets the preset convergence conditions is used to generate a facial image, and the lip shape included can be clearer and matches the lip shape style of the first object, that is, a more personalized facial image, thereby improving the user experience.
[0071] It should be noted that the preset convergence condition can be set as needed. For example, the preset convergence condition can be that the total loss value of the model does not exceed a preset threshold, or that the training round reaches a preset round threshold (epoch). No special limitation is made here.
[0072] It can be seen that based on the training method of the embodiment of the present disclosure, by introducing a first loss value that can characterize the error of image features between the sample image and the facial image, the model can learn more image features, thereby improving the image quality of the facial image output by the model for data processing; at the same time, by using the sample image and sample audio of the first object as training data, and introducing a second loss value that can characterize the degree of correlation between the sample image and the lip area of the facial image, the model can shift the focus to the lips during the training process, thereby being able to learn more image features of the lip area, and then paying more attention to the generation of the lip area in the process of data processing and outputting the facial image, thereby outputting a facial image with clearer lip shape and matching the style of the first user, so as to solve the problems of low lip shape clarity and insufficient stylization in the image when generating facial images in the related art.
[0073] In some embodiments, in step S203, determining the first loss value according to the sample image and the facial image may include:
[0074] Step S2031, extracting a first image feature of the sample image, and extracting a second image feature of the facial image;
[0075] Step S2032: determine a first loss value based on the first image feature and the second image feature.
[0076] In the embodiment of the present disclosure, the first image feature and the second image feature can be obtained by performing image feature extraction processing on the sample image and the facial image respectively based on a preset image feature extraction model, wherein the preset image feature extraction model can be any deep convolutional neural network model, for example, a vgg16 model. Figure 3 As shown, in actual implementation, after the first model processes the sample image and the sample audio to output a facial image, the sample image and the facial image can be input into the vgg16 model to respectively extract the deep image features of the two to obtain the first image feature and the second image feature. Thereafter, in the process of determining the first loss value, the mean square error (MSE) between the first image feature and the second image feature can be obtained as the first loss value.
[0077] L vgg represents the first loss value, X represents the second image feature, and Y represents the first image feature, then the first loss value L vgg It can be obtained by the following formula:
[0078]
[0079] Where n represents the sum of the features of the first image and the elements in the second image, X i and Y i Represent the i-th element of X and Y respectively, i≤n.
[0080] In some embodiments, in step S203, determining the second loss value according to the sample image and the generated image includes:
[0081] Step S2033, extracting a first lip image from the sample image, and extracting a second lip image from the facial image;
[0082] Step S2034, determining a first Gramian matrix corresponding to the first lip image, and determining a second Gramian matrix corresponding to the second lip image;
[0083] Step S2035: determine a second loss value according to the first Gramian matrix and the second Gramian matrix.
[0084] In some embodiments, extracting the first lip image from the sample image in step S2033 may include: performing lip key point detection processing on the sample image to obtain multiple lip key points, wherein the lip key points represent the boundary position of the lip area in the sample image; and extracting the first lip image from the sample image based on the multiple lip key points.
[0085] In actual implementation, extracting the first lip image from the sample image based on multiple lip key points may include: obtaining a minimum circumscribed matrix of the multiple lip key points in the sample image, and obtaining an image within the minimum circumscribed matrix in the sample image as the first lip image.
[0086] The multiple lip key points can be obtained in the following way: performing key point detection processing on the sample image based on the face detector and feature point detector in the dlib library to obtain the multiple lip key points; of course, this is only an example, and in actual implementation, the lip key points can also be obtained by performing key point detection processing on the sample image based on other key point detection methods, and no special limitation is made here.
[0087] Based on the same principle, the second lip image can be extracted from the facial image; then, the first lip image can be converted into a pytorch tensor P, and the second lip image can be converted into a pytorch tensor Q, wherein the size of the pytorch tensor P and the pytorch tensor Q can be n*c*(h*w), wherein n is the preset batch number, and its value can be 32, for example, and c is the number of channels. For example, when the sample image and the facial image are color images, the number of channels c can be 3, and h and w are the height and width of the sample image and the facial image, respectively. Then, G represents the first Gram matrix, and the first Gram matrix can be obtained by the following formula:
[0088]
[0089] Among them, P T is the transposed matrix of P, and c*h*w is the number of elements in each channel of P.
[0090] Similarly, the second Gram matrix g can be obtained; then, the second loss value L ROI It can be obtained by the following formula:
[0091]
[0092] Where m represents the sum of the elements in the tensor Q, i≤m, G i and i Represent the i-th element of G and g respectively.
[0093] Since the Gram matrix can measure the relationship between corresponding features in each dimension of two feature maps, reflecting the closeness and correlation between different features, therefore, based on the first Gram matrix and the second Gram matrix, the style matching degree between the lip area in the facial image and the lip area in the sample image can be measured, that is, a second loss value characterizing the correlation degree of the lip areas contained in the two is obtained, and the model parameters are adjusted based on the second loss value, so that the model can pay more attention to the generation quality of the lip area in the facial image, thereby generating a high-definition lip area, so that the lip shape contained in the facial image is more in line with the lip shape of the first object used.
[0094] Please continue to see Figure 3In some embodiments, the first model may include an image encoder, an audio encoder, and a decoder. Taking the first model as a pre-trained Wav2Lip model as an example, the image encoder may be an encoder for image encoding in the generator of the Wav2Lip model, and the audio encoder may be an encoder for audio encoding in the generator of the Wav2Lip model; the decoder may be used to perform image decoding processing on the concatenated features of the encoding features output by the image encoder and the audio encoder to output a corresponding facial image.
[0095] In this implementation, the data processing in step S202 may include:
[0096] Step S2021, performing image coding processing on the sample image to obtain a first coding feature;
[0097] Step S2022, performing audio encoding processing on the sample audio to obtain a second encoding feature;
[0098] Step S2023, concatenating the first coding feature and the second coding feature to obtain a sample concatenated feature;
[0099] Step S2024, decoding the sample splicing features to obtain a facial image.
[0100] In actual implementation, the image encoding process can be performed on the sample image based on the image encoder in the first model. The image encoder can be a stack of residual convolution layers, which can be used to encode the sample image to obtain a first encoding feature; the audio encoding process can be performed on the sample audio based on the audio encoder in the first model. The audio encoder can be a stack of 2D convolution layers, which can be used to encode the sample audio to obtain a second encoding feature; the sample splicing feature can be decoded based on the decoder in the first model to generate a facial image. The decoder can be, for example, a stack of transposed convolution layers.
[0101] After obtaining the first coding feature and the second coding feature, the splicing of the first coding feature and the second coding feature in step S2023 may be: splicing the first coding feature and the second coding feature into a larger sample splicing feature based on a contat method; based on this feature splicing method, information from different input sources can be fused, so that the model can comprehensively learn the feature information of multiple input sources, and then generate a more realistic generated image with a lip shape that better matches the lip shape of the first object.
[0102] In some embodiments, in step S204, adjusting the parameters of the first model according to the first loss value and the second loss value may include: adjusting the parameters of the decoder according to the first loss value and the second loss value, and the parameters of the image encoder and the audio encoder remain unchanged.
[0103] For example, in the case where the first model is a pre-trained Wav2Lip model or other image processing model, since the model is a pre-trained model, the image encoder and audio encoder contained therein are usually optimal. Therefore, in order to improve the model training speed, in the disclosed embodiment, the parameters of the image encoder and the audio encoder may not be adjusted. Instead, the parameters of the fixed image encoder and the audio encoder may be considered unchanged, and only the parameters of the decoder may be adjusted during the model training process, so that the decoder can decode and generate a facial image containing a lip shape that matches the lip shape of the first object.
[0104] See also Figure 3 In some embodiments, after obtaining the facial image in step S202, the method may further include: determining whether the lip shape contained in the facial image is synchronized with the sample audio in terms of timing based on the sample audio and the facial image, and obtaining a first discrimination result; performing image authenticity discrimination processing based on the sample image and the facial image, and obtaining a second discrimination result.
[0105] Specifically, the first model may also include a first discriminator and a second discriminator. Taking the first model as a pre-trained Wav2Lip model as an example, the first discriminator may be, for example, a lip sync discriminator for determining whether the lip shape contained in the generated facial image is synchronized with the input audio in timing, and the second discriminator may be, for example, a visual quality discriminator for determining whether the generated facial image is authentic; the sample audio and facial image may be input into the first discriminator to obtain the above-mentioned first discrimination result, and the sample image and facial image may be input into the second discriminator to obtain the second discriminator.
[0106] In addition, in the above method, adjusting the parameters of the first model according to the first loss value and the second loss value in the above step S204 may include: adjusting the parameters of the first model according to the first loss value, the second loss value, the first discrimination result and the second discrimination result.
[0107] The first discrimination result may include a first result value and a third loss value, wherein the first result value may be a value used to indicate whether the lip shape contained in the facial image and the sample audio are synchronized in timing, for example, "1" may be used to indicate that the two are synchronized, and "0" may be used to indicate that the two are not synchronized, and the third loss value L may be used to indicate whether the lip shape contained in the facial image and the sample audio are synchronized in timing. syncIt can characterize the synchronization error between the two. The calculation method of the third loss value can, for example, refer to the calculation processing of the loss value in the existing Wav2Lip model, which will not be repeated here.
[0108] The second discrimination result may include a fourth loss value, and may also include a second result value used to indicate whether the facial image is real, wherein the fourth loss value, for example, may be a binary cross entropy loss value or a logarithmic loss value between the facial image and the sample image, and is not specifically limited here.
[0109] The step of adjusting the parameters of the first model according to the first loss value, the second loss value, the first discrimination result and the second discrimination result may include: adjusting the parameters of the decoder of the first model according to the first loss value, the second loss value, the third loss value and the fourth loss value, while the parameters of the image encoder and the audio encoder of the first model remain unchanged.
[0110] It can be understood that in actual implementation, the L1 reconstruction loss between the facial image and the sample image can also be used as the fifth loss value to adjust the parameters of the model based on the first loss value, the second loss value, the third loss value, the fourth loss value and the fifth loss value.
[0111] For example, L l1 The fifth loss value is represented by L vgg Represents the first loss value, L ROI The second loss value is represented by L sync represents the third loss value, and L gen represents the fourth loss value. Since the first, second and fifth loss values all represent the reconstruction loss between the facial image and the sample image, the reconstruction loss L recon =L l1 +L vgg +L ROI , the total loss L of the first model total It can be expressed using the following formula:
[0112] L total =(1-S w -S g )*L recon +S w *L sync +S g *L gen ;
[0113] Among them, S w and S g They respectively represent the weights of the third loss value and the fourth loss value, and their values can be set as needed and are not specifically limited here.
[0114] Corresponding to the above embodiment, the present disclosure also provides a video generation method, please refer to Figure 4 , which is a flow chart of a video generation method provided by an embodiment of the present disclosure. The method can be applied to an electronic device, which can be a server or a terminal device, and is not particularly limited here.
[0115] like Figure 4 As shown, the video generation method provided by the embodiment of the present disclosure may include the following steps S401-S403:
[0116] Step S401, obtaining a first facial image and a target audio, wherein the first facial image is extracted from an original image of a first object;
[0117] Step S402, inputting the first facial image and the target audio into the first model for data processing to obtain a second facial image;
[0118] The lip shape included in the second facial image matches the lip shape of the first object and is synchronized with the target audio in terms of timing, and the first model is obtained according to the model training method of the embodiment of the present disclosure;
[0119] Step S403, generating a target video according to the second facial image, the original image and the target audio.
[0120] The original image may be an image containing the facial region of the first object. For example, the original image may be a video frame extracted from a speaking video of the first object, or may be a single static image containing the facial region of the first object, which is not particularly limited here.
[0121] The first facial image can be obtained by extracting the facial region of the first object from the original image. For example, the first facial image can be obtained by performing facial image recognition and extraction processing on the original image using an s3fd model or other facial image recognition and extraction models.
[0122] The target audio may be any audio data, that is, may be audio data to be synthesized in the target video.
[0123] By inputting the first facial image and the target audio into the first model trained based on any of the above-mentioned model training methods for data processing, one or more second facial images can be obtained, the lip shape of which matches the lip shape of the first object and is synchronized with the target audio in time sequence. By resizing the second facial image into a third facial image with the same size as the original first facial image, and then pasting the third facial image back to the original image one by one, a target video can be generated in which the speaking style matches the first object when speaking the target audio and the lip area is clearer.
[0124] For example, in the field of animation, if it is desired that a virtual animated character in an animated video narrates a target audio in the speaking style of user01, a first model for generating a facial image of user01 can be trained based on the model training method of an embodiment of the present disclosure. After the first model is trained, first, a facial image faceimg01 of the virtual animated character is extracted from an original animation image oriimg01 containing the facial area of the virtual animated character; secondly, the facial image faceimg01 is resized from the original size 1 to a preset size, such as 96*96 resolution to obtain faceimg02; and thirdly, faceimg02 and the target audio deswav are input to the video. Enter the first model for data processing to obtain multi-frame faceimg03, wherein the lip shape contained in the multi-frame faceimg03 will match the lip shape of user01 and be synchronized with the target audio deswav in terms of timing; secondly, resize the multi-frame faceimg03 with a resolution of 96*96 to size 1 again to obtain multi-frame faceimg04; finally, by pasting the multi-frame faceimg04 back to the original animation image oriimg01, a multi-frame animation image desimg01 can be obtained, and based on desimg01, an animation video containing a virtual animation character telling the target audio in the speaking style of user01 can be generated. Of course, this is only an example to illustrate the video generation method of the embodiment of the present disclosure. In actual implementation, the video generation method can also be applied to other fields, and no special limitation is made here.
[0125] It can be seen that based on the video generation method provided by the embodiment of the present disclosure, since when performing facial generation processing, the first model trained by the model training method based on the embodiment of the present disclosure is used to perform the processing to obtain a second facial image, and since the first loss value and the second loss value are introduced in the model training process, the model can pay more attention to the generation processing of the lip area in the facial image, thereby generating a second facial image with higher definition and a lip shape that matches the lip shape of the first object and is synchronized with the target audio in timing. The second facial image generated in this way is synthesized back into the original image of the first object, thereby generating a target video that contains a lip shape style that matches the first object and is synchronized with the target audio in timing.
[0126] It can be understood that the above-mentioned various method embodiments mentioned in the present disclosure can be combined with each other to form a combined embodiment without violating the principle logic. Due to space limitations, the present disclosure will not repeat them. It can be understood by those skilled in the art that in the above-mentioned method of the specific implementation method, the specific execution order of each step should be determined according to its function and possible internal logic.
[0127] In addition, the present disclosure also provides a model training device, a video generating device, an electronic device, a computer-readable storage medium, and a computer program product, all of which can implement any model training method or video generation method provided by the present disclosure. The corresponding technical solutions and descriptions are referred to in the corresponding records of the method part and will not be repeated here.
[0128] Figure 5 A block diagram of a model training device provided in an embodiment of the present disclosure.
[0129] Reference Figure 5 , an embodiment of the present disclosure provides a model training device, the model training device 500 includes: a first acquisition unit 501, a processing unit 502, a determination unit 503 and an adjustment unit 504.
[0130] The first acquisition unit 501 is used to acquire a sample image and a sample audio of a first object;
[0131] The first processing unit 502 is used to input the sample image and the sample audio into the first model for data processing to obtain a facial image, wherein the lip shape included in the facial image corresponds to the first object and is synchronized with the sample audio in terms of timing;
[0132] The determining unit 503 is used to determine a first loss value and a second loss value according to the sample image and the facial image, wherein the first loss value represents an error in image features between the sample image and the facial image, and the second loss value represents a correlation between the sample image and the lip region of the facial image;
[0133] The adjusting unit 504 is used to adjust the parameters of the first model according to the first loss value and the second loss value.
[0134] In some embodiments, when determining the first loss value based on the sample image and the facial image, the determination unit 503 can be used to: extract the first image feature of the sample image, and extract the second image feature of the facial image; and determine the first loss value based on the first image feature and the second image feature.
[0135] In some embodiments, when determining the second loss value based on the sample image and the facial image, the determination unit 503 can be used to: extract a first lip image from the sample image, and extract a second lip image from the facial image; determine a first Grammar matrix corresponding to the first lip image, and determine a second Grammar matrix corresponding to the second lip image; and determine the second loss value based on the first Grammar matrix and the second Grammar matrix.
[0136] In some embodiments, when performing data processing, the first processing unit 502 can be used to: perform image encoding processing on the sample image to obtain a first encoding feature; perform audio encoding processing on the sample audio to obtain a second encoding feature; splice the first encoding feature and the second encoding feature to obtain a sample splicing feature; and decode the sample splicing feature to obtain a facial image.
[0137] In some embodiments, the first model includes an image encoder, an audio encoder and a decoder; when the adjustment unit 504 adjusts the parameters of the first model according to the first loss value and the second loss value, it can be used to: adjust the parameters of the decoder according to the first loss value and the second loss value, and the parameters of the image encoder and the audio encoder remain unchanged.
[0138] In some embodiments, the device 500 further includes a discrimination unit, which can be used to: determine whether the lip shape contained in the facial image is synchronized with the sample audio in time sequence based on the sample audio and the facial image, and obtain a first discrimination result; perform image authenticity discrimination processing based on the sample image and the facial image, and obtain a second discrimination result. In this embodiment, when the adjustment unit 504 adjusts the parameters of the first model according to the first loss value and the second loss value, it can be used to: adjust the parameters of the first model according to the first loss value, the second loss value, the first discrimination result, and the second discrimination result.
[0139] It can be seen that based on the model training device provided by the embodiment of the present disclosure, after the processing unit inputs the sample image and the sample audio into the first model for data processing to obtain a facial image corresponding to the first object and containing a lip shape that is synchronized with the sample audio in time sequence, on the one hand, by introducing a first loss value that can characterize the error of the image features between the sample image and the facial image, the model can learn more image features, thereby improving the image quality of the facial image output by the model for data processing; on the other hand, by using the sample image and the sample audio of the first object as training data and introducing a second loss value that can characterize the degree of correlation between the sample image and the lip area of the facial image, the model can shift the focus to the lips during the training process, thereby learning more image features of the lip area, and then paying more attention to the processing of the lip area in the process of data processing and outputting the facial image, thereby outputting a facial image containing a clearer lip shape and matching the lip shape style of the first object, so as to solve the problems of low clarity of the lip shape contained and insufficient style personalization when generating facial images in the related art.
[0140] Figure 6 A block diagram of a video generating device provided in an embodiment of the present disclosure.
[0141] Reference Figure 6The embodiment of the present disclosure provides a video generating device, the video generating device 600 includes: a second acquiring unit 601, a second processing unit 602 and a generating unit 603.
[0142] The second acquisition unit 601 is used to acquire a first facial image and a target audio, wherein the first facial image is extracted from an original image of a first object;
[0143] The second processing unit 602 is used to input the first facial image and the target audio into a first model for data processing to obtain a second facial image, wherein the lip shape contained in the second facial image matches the lip shape of the first object and is synchronized with the target audio in terms of timing, and the first model is obtained according to the model training method described in the first aspect above;
[0144] The generating unit 603 is configured to generate a target video according to the second facial image, the original image and the target audio.
[0145] It can be seen that the video generating device provided by the embodiment of the present disclosure, because when performing facial generation processing, the first model trained by the model training device based on the embodiment of the present disclosure is used to perform the processing to obtain a second facial image, and because the first loss value and the second loss value are introduced in the model training process, the model can pay more attention to the generation processing of the lip area in the facial image, thereby generating a second facial image with higher definition and a lip shape that matches the lip shape of the first object and is synchronized with the target audio in timing. The second facial image generated in this way is synthesized back into the original image of the first object, so as to generate a target video with a lip shape style that matches the first object and is synchronized with the target audio in timing.
[0146] Figure 7 A block diagram of an electronic device provided in an embodiment of the present disclosure.
[0147] Reference Figure 7 An embodiment of the present disclosure provides an electronic device, which includes: at least one processor 701; at least one memory 702, and one or more I / O interfaces 703, connected between the processor 701 and the memory 702; wherein the memory 702 stores one or more computer programs that can be executed by the at least one processor 701, and the one or more computer programs are executed by the at least one processor 701 so that the at least one processor 701 can execute the above-mentioned model training method or video generation method.
[0148] Each module in the above electronic device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0149] The present disclosure also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the above-mentioned model training method or video generation method when executed by a processor. The computer-readable storage medium may be a volatile or non-volatile computer-readable storage medium.
[0150] The embodiments of the present disclosure also provide a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above-mentioned model training method or video generation method.
[0151] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In a hardware implementation, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or may be implemented as hardware, or may be implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable storage medium, which may include a computer storage medium (or a non-transitory medium) and a communication medium (or a temporary medium).
[0152] As is known to those of ordinary skill in the art, the term computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable program instructions, data structures, program modules or other data). Computer storage media include, but are not limited to, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), static random access memory (SRAM), flash memory or other memory technology, portable compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. In addition, it is known to those of ordinary skill in the art that communication media typically contain computer-readable program instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and may include any information delivery medium.
[0153] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0154] The computer program instructions for performing the operation of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be customized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.
[0155] The computer program product described herein may be implemented in hardware, software, or a combination thereof. In one optional embodiment, the computer program product is embodied as a computer storage medium, and in another optional embodiment, the computer program product is embodied as a software product, such as a software development kit (SDK), etc.
[0156] Various aspects of the present disclosure are described herein with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer-readable program instructions.
[0157] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0158] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0159] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the specified logical function. In some alternative implementations, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or action, or can be implemented with a combination of special hardware and computer instructions.
[0160] Example embodiments have been disclosed herein, and although specific terms are employed, they are used and should be interpreted only in a general illustrative sense and not for limiting purposes. In some instances, it will be apparent to those skilled in the art that, unless otherwise expressly noted, features, characteristics, and / or elements described in conjunction with a particular embodiment may be used alone or in combination with features, characteristics, and / or elements described in conjunction with other embodiments. Therefore, those skilled in the art will appreciate that various changes in form and detail may be made without departing from the scope of the present disclosure as set forth in the appended claims.
Claims
1. A model training method, characterized in that: include: Acquire a sample image and a sample audio of a first object; Inputting the sample image and the sample audio into a first model for data processing to obtain a facial image, wherein a lip shape included in the facial image corresponds to the first object and is synchronized with the sample audio in terms of time sequence; Determining a first loss value and a second loss value based on the sample image and the facial image, wherein the first loss value represents an error in image features between the sample image and the facial image, and the second loss value represents a degree of correlation between the sample image and the lip region of the facial image; Adjust parameters of the first model according to the first loss value and the second loss value.
2. The method according to claim 1, characterized in that The determining of a first loss value according to the sample image and the facial image includes: extracting a first image feature of the sample image, and extracting a second image feature of the facial image; The first loss value is determined based on the first image feature and the second image feature.
3. The method according to claim 1, characterized in that The determining of a second loss value according to the sample image and the facial image includes: extracting a first lip image from the sample image, and extracting a second lip image from the facial image; determining a first Gramian matrix corresponding to the first lip image, and determining a second Gramian matrix corresponding to the second lip image; The second loss value is determined according to the first Gramian matrix and the second Gramian matrix.
4. The method according to claim 1, wherein The data processing includes: Performing image coding processing on the sample image to obtain a first coding feature; Performing audio encoding processing on the sample audio to obtain a second encoding feature; Splicing the first coding feature and the second coding feature to obtain a sample splicing feature; The sample splicing features are decoded to obtain the facial image.
5. The method according to claim 1, characterized in that The first model includes an image encoder, an audio encoder, and a decoder; and adjusting parameters of the first model according to the first loss value and the second loss value includes: The parameters of the decoder are adjusted according to the first loss value and the second loss value, and the parameters of the image encoder and the audio encoder remain unchanged.
6. The method according to claim 4, characterized in that The method further comprises: determining, based on the sample audio and the facial image, whether a lip shape included in the facial image is synchronized with the sample audio in terms of time sequence, to obtain a first determination result; Performing image authenticity discrimination processing based on the sample image and the facial image to obtain a second discrimination result; The adjusting the parameters of the first model according to the first loss value and the second loss value includes: Adjust the parameters of the first model according to the first loss value, the second loss value, the first discrimination result, and the second discrimination result.
7. A video generation method, characterized in that: include: Acquire a first facial image and target audio, wherein the first facial image is extracted from an original image of a first subject; Inputting the first facial image and the target audio into a first model for data processing to obtain a second facial image, wherein the lip shape contained in the second facial image matches the lip shape of the first subject and is synchronized with the target audio in terms of timing; A target video is generated according to the second facial image, the original image and the target audio.
8. A model training device, characterized in that: The device comprises: a first acquiring unit, configured to acquire a sample image and a sample audio of a first object; a first processing unit, configured to input the sample image and the sample audio into a first model for data processing to obtain a facial image, wherein a lip shape included in the facial image corresponds to the first object and is synchronized with the sample audio in terms of timing; a determining unit, configured to determine a first loss value and a second loss value based on the sample image and the facial image, wherein the first loss value represents an error in image features between the sample image and the facial image, and the second loss value represents a degree of correlation between the sample image and the lip region of the facial image; An adjusting unit, configured to adjust parameters of the first model according to the first loss value and the second loss value.
9. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores one or more computer programs executable by the at least one processor, and the one or more computer programs are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the computer program implements the method according to any one of claims 1 to 7.
11. A computer program product, characterized in that The invention comprises a computer-readable code or a non-volatile computer-readable storage medium carrying the computer-readable code, wherein when the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the method according to any one of claims 1 to 7.
Citation Information
Cited By
Lip shape synchronization method and system based on multiple reference frames and controllable style
CN119815096A
