Model training method, video generation method, and electronic device

By extracting video features from multiple encoders and combining them with a diffusion model and decoder for training, the problem of insufficient feature dimension in video generation models is solved, resulting in more realistic videos.

CN118966284BActive Publication Date: 2026-11-27CHINA UNITED NETWORK COMM GRP CO LTD +2
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410954798.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-16
Publication Date
2026-11-27
Estimated Expiration
2044-07-16

AI Technical Summary

Technical Problem

The encoders in existing video generation models lack sufficient dimensionality when extracting video features, resulting in videos that are not realistic enough.

Method used

Multiple encoders are used to extract image representation vectors, temporal feature vectors, and dynamic feature vectors from the sampled video. These vectors are then trained using a diffusion model and a decoder, and the parameters of the diffusion model and decoder are adjusted to improve the dimensionality of the feature information.

Benefits of technology

The amount of training data was reduced, the dimensionality of image encoding feature information was increased, and the generated video was more realistic.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118966284B_ABST
    Figure CN118966284B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a model training method, a video generation method and an electronic device. The method comprises: obtaining a sample video, and pre-training a plurality of encoders using the sample video; wherein each encoder is trained using a self-supervised learning method based on a different preset task; each preset feature of the sample video is extracted using each trained encoder, and a first latent space vector corresponding to the sample video is obtained by weighted summation; a diffusion model is used to add noise and denoising processing to the first latent space vector to obtain a second latent space vector; a decoder is used to decode and video conversion processing on the second latent space vector to obtain a corresponding predicted video; and parameters of the diffusion model and the decoder are adjusted according to the sample video and the predicted video until a trained diffusion model and decoder are obtained. The method is used to reduce the amount of training data, and can improve the dimension of video encoding feature information and improve the quality of generated video.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence (AI) technology, and in particular to a model training method, a video generation method, and an electronic device. Background Technology

[0002] Currently, videos with high realism and dynamic effects can be generated using video generation models.

[0003] Video generation models typically include an encoder, which extracts video features. In related technologies, the encoder in a video generation model usually employs a variational autoencoder (VAE). The VAE extracts some feature data from the video to obtain the latent space variables of the video, and then uses a decoder to map the latent space variables back to the original data space, thereby realizing the data generation and reconstruction process.

[0004] In practical applications, it has been found that VAEs still suffer from insufficient dimensionality in the features extracted from videos during video encoding. To address the issue of traditional VAEs failing to extract effective video features, videos with specific transformations can be used as supervisory signals for training the encoder. However, this training method requires prior knowledge to determine effective features and involves numerous video or image transformations, resulting in a significant workload. Summary of the Invention

[0005] This application provides a model training method, a video generation method, and an electronic device to reduce the amount of training data and improve the dimensionality of image coding feature information.

[0006] In a first aspect, embodiments of this application provide a model training method, wherein the model includes multiple encoders, a diffusion model, and a decoder, and the method includes:

[0007] Acquire sampled videos and use them to pre-train multiple encoders; each encoder is trained using a self-supervised learning method based on a different preset task; each trained encoder is used to extract different preset features from the sampled videos.

[0008] Each pre-set feature of the sampled video is extracted using the trained encoders, and the pre-set features are weighted and summed to obtain the first latent space vector corresponding to the sampled video.

[0009] The first latent space vector is denoised and dedenoised using a diffusion model to obtain the second latent space vector.

[0010] The second latent space vector is decoded using a decoder to obtain the corresponding predicted embedding vector; and the predicted embedding vector is then subjected to video conversion processing to obtain the corresponding predicted video.

[0011] Based on the sampled video and the predicted video, adjust the parameters of the diffusion model and the decoder until a well-trained diffusion model and decoder are obtained.

[0012] In one possible implementation, the diffusion model includes a forward diffusion network and a backward diffusion network;

[0013] The first latent space vector is denoised and then denoised using a diffusion model to obtain the second latent space vector, which includes:

[0014] The first latent space vector is input into the forward diffusion network so that the forward diffusion network adds noise to the first latent space vector;

[0015] After a preset number of noise addition processes, the noise vector corresponding to the first latent space vector is obtained;

[0016] The noise vector is input into the backdiffusion network so that the backdiffusion network subtracts the predicted noise from the noise vector;

[0017] After a preset number of denoising processes, the second latent space vector is obtained.

[0018] In one possible implementation, the predicted noise is obtained based on the guiding conditions in the backdiffusion network;

[0019] The method also includes:

[0020] Obtain the generation conditions and encode them to obtain the generation condition code;

[0021] Generative conditional encoding is added to the backdiffusion network in the form of cross-attention as a guiding condition for the backdiffusion model.

[0022] In one possible implementation, the predicted embedding vector is subjected to video transformation processing to obtain the corresponding predicted video, including:

[0023] The predicted embedding vector is reverse-embedded to obtain the set of second pixel blocks corresponding to the predicted embedding vector.

[0024] Based on a preset sorting method, the second pixel block set is arranged and stitched together to obtain the corresponding predicted video.

[0025] In one possible implementation, pre-training multiple encoders using sampled video includes:

[0026] Each video frame of the sampled video is divided into blocks to obtain multiple pixel blocks, and these multiple pixel blocks are sorted in a preset order to obtain the first set of pixel blocks corresponding to the sampled video.

[0027] The first set of pixel blocks is processed by vector embedding to obtain the corresponding sampled video embedding vector;

[0028] Each encoder is trained using the sampled video embedding vectors to obtain trained encoders; each trained encoder is then used to extract different preset features from the sampled video based on the sampled video embedding vectors.

[0029] In one possible implementation, the encoder in the model includes a first encoder, a second encoder, and a third encoder;

[0030] The first encoder is used to extract the image representation vector of the sampled video;

[0031] The second encoder is used to extract the temporal feature vector of the sampled video;

[0032] The third encoder is used to extract the dynamic feature vector of the sampled video.

[0033] In one possible implementation, the training method for the first encoder includes:

[0034] The sampled video embedding vector is input into the first encoder to obtain the image representation vector corresponding to the sampled video.

[0035] The image representation vector is decoded using the first decoder corresponding to the first encoder to obtain the reconstructed video corresponding to the sampled video;

[0036] Based on the differences between the reconstructed video and the sampled video, the parameters of the first encoder and the first decoder are adjusted to obtain the trained first encoder and the first decoder.

[0037] In one possible implementation, the training method for the second encoder includes:

[0038] The sampled video embedding vector is input into the second encoder to obtain the temporal feature vector corresponding to the sampled video.

[0039] The temporal feature vector is decoded using a sequence prediction network to obtain the predicted sequence code of the video frames corresponding to the sampled video.

[0040] Based on the difference between the video frame sequence code and the video frame predicted sequence code of the sampled video, the parameters of the second encoder and the sequence prediction network are adjusted to obtain the trained second encoder and sequence prediction network.

[0041] In one possible implementation, the training method for the third encoder includes:

[0042] The embedded vector of the sampled video is input into the third encoder to obtain the dynamic feature vector corresponding to the sampled video; the dynamic feature vector is used to characterize the motion speed features and dynamic object features of the sampled video.

[0043] The dynamic feature vector and the target frame velocity are input into the image difference prediction network to obtain the corresponding predicted image difference.

[0044] Based on the difference between the predicted image difference and the ground truth image difference of the sampled video, the parameters of the third encoder and the image difference prediction network are adjusted to obtain the trained third encoder and image difference prediction network.

[0045] Secondly, embodiments of this application provide a model training apparatus, wherein the model includes multiple encoders, a diffusion model, and a decoder, and the apparatus includes:

[0046] The acquisition module is used to acquire sampled videos and pre-train multiple encoders using the sampled videos. Each encoder is trained using a self-supervised learning method based on a different preset task. The trained encoders are then used to extract different preset features from the sampled videos.

[0047] The pre-training module is used to extract each preset feature of the sampled video using each trained encoder, and to sum the preset features by weight to obtain the first latent space vector corresponding to the sampled video.

[0048] The diffusion module is used to add and remove noise to the first latent space vector using a diffusion model to obtain the second latent space vector.

[0049] The decoding module is used to decode the second latent space vector using a decoder to obtain the corresponding predicted embedding vector; and to perform video conversion processing on the predicted embedding vector to obtain the corresponding predicted video.

[0050] The adjustment module is used to adjust the parameters of the diffusion model and decoder based on the sampled video and the predicted video until a well-trained diffusion model and decoder are obtained.

[0051] Thirdly, embodiments of this application provide a video generation method, including:

[0052] Obtain a conditional description for generating the video, which includes at least one of the following: text description, image description, and video description;

[0053] The condition description is encoded to obtain the condition code;

[0054] Using conditional coding as a guiding condition, and employing the diffusion model of the first aspect and / or various possible implementations of the first aspect as described above, the random noise is back-diffused to obtain the corresponding third latent space vector.

[0055] The third latent space vector is decoded and video converted using the decoder described in the first aspect and / or various possible implementations of the first aspect to obtain the video corresponding to the condition description.

[0056] Fourthly, embodiments of this application provide a video generation apparatus, including:

[0057] The condition acquisition module is used to acquire the condition description for generating the video. The condition description includes at least one of the following: text description, image description, and video description.

[0058] The condition encoding module is used to encode the condition description to obtain the condition code;

[0059] The diffusion processing module is used to perform backdiffusion processing on random noise using conditional coding as a guiding condition and a diffusion model as described in the first aspect and / or various possible implementations of the first aspect, to obtain the corresponding third latent space vector.

[0060] The video conversion module is used to decode and convert the third latent space vector using the decoder described in the first aspect and / or various possible implementations of the first aspect, to obtain the video corresponding to the condition description.

[0061] Fifthly, embodiments of this application provide an electronic device, including: a memory and a processor;

[0062] The memory stores computer-executed instructions;

[0063] The processor executes computer execution instructions stored in the memory, causing the processor to perform the first aspect and / or various possible implementations of the first aspect as described above.

[0064] In a sixth aspect, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the first aspect and / or various possible implementations of the first aspect.

[0065] In a seventh aspect, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the first aspect and / or various possible implementations of the first aspect.

[0066] The model training method, video generation method, and electronic device provided in this application embodiment first use sampled videos to complete task-based pre-training of multiple encoders, and then use the pre-trained encoders to train the decoder and diffusion model. The diffusion model and decoder are used to generate predicted videos based on the weighted vectors extracted by the encoders. Then, the parameters of the diffusion model and decoder are adjusted according to the difference between the sampled videos and the predicted videos to obtain the trained diffusion model and decoder. This approach reduces the amount of training data and improves the dimensionality of image coding feature information. Attached Figure Description

[0067] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0068] Figure 1 A schematic diagram illustrating the scenario for the video generation method provided in this application;

[0069] Figure 2 A flowchart illustrating the model training method provided in this application;

[0070] Figure 3 A schematic diagram of the training process of the first encoder in the model training method provided in this application;

[0071] Figure 4 A training architecture diagram of the first encoder in the model training method provided in this application;

[0072] Figure 5 A training architecture diagram of the second encoder in the model training method provided in this application;

[0073] Figure 6 A training architecture diagram of the third encoder in the model training method provided in this application;

[0074] Figure 7 A flowchart illustrating the video generation method provided in this application;

[0075] Figure 8 A schematic diagram of the structure of the model training device provided in this application;

[0076] Figure 9 A schematic diagram of the structure of the electronic device provided in this application.

[0077] The accompanying drawings have illustrated specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to specific embodiments. Detailed Implementation

[0078] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0079] Figure 1 A scene illustration of the video generation method provided in this application, such as... Figure 1 As shown, in a specific application scenario of this application, the user inputs the conditions for video generation through terminal 120. Terminal 120 communicates with server 140 via wired or wireless network. Server 140 is equipped with a video generation algorithm (i.e., the video generation method in this application), which calculates and generates the video, then transmits the video back to terminal 120 for display. Terminal 120 can be various types of terminals such as personal computers, personal mobile phones, and in-vehicle computers.

[0080] In existing technologies, video generation methods suffer from insufficient feature extraction dimensions due to limitations in the models and training methods employed. The model training method provided in this application uses a pre-trained encoder to train the decoder and diffusion model. Multiple encoders are used to extract image representation vectors, temporal feature vectors, and dynamic feature vectors from the sampled video. The diffusion model and decoder generate a predicted video based on the weighted vectors extracted by the encoders. Furthermore, the parameters of the diffusion model and decoder are adjusted based on the difference between the sampled video and the predicted video to obtain a well-trained diffusion model and decoder. This method solves the technical problem in existing technologies where the generated video lacks realism due to insufficient feature extraction dimensions by the encoder.

[0081] The technical solution of this application and how it solves the above-mentioned technical problems will be described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will be described below with reference to the accompanying drawings.

[0082] Figure 2 A flowchart illustrating the model training method provided in this application is shown below. Figure 2 As shown, the method includes:

[0083] S201. Acquire sampled videos and use the sampled videos to pre-train multiple encoders; wherein, each encoder is trained using a self-supervised learning method based on different preset tasks; each trained encoder is used to extract different preset features from the sampled videos.

[0084] Specifically, sampled videos, also known as sample videos, are datasets used to train video generation models. A sampled video consists of multiple consecutive video frames (images), and the encoder extracts the feature vectors from the video.

[0085] The model training method provided in this application employs multiple encoders to extract different feature vectors from the sampled video. These video feature vectors can include various types, depending on the feature extraction method and application scenario. For example, they can include color feature vectors, texture feature vectors, shape feature vectors, semantic feature vectors, spatiotemporal feature vectors, etc. Those skilled in the art can select different feature vectors based on specific work requirements, pre-set corresponding training tasks, and train different encoders respectively, so that the trained encoders can extract the corresponding feature vectors.

[0086] S202. Use each trained encoder to extract each preset feature of the sampled video, and sum the preset features by weight to obtain the first latent space vector corresponding to the sampled video.

[0087] In one possible implementation, pre-training multiple encoders using sampled video may include the following steps:

[0088] S2021. Divide each video frame of the sampled video into blocks to obtain multiple pixel blocks, and sort the multiple pixel blocks in a preset order to obtain the first pixel block set corresponding to the sampled video.

[0089] Specifically, the sampled video consists of multiple consecutive video frames, each containing multiple pixel blocks. Therefore, each video frame can be divided into blocks to obtain multiple pixel blocks. Furthermore, these pixel blocks can be arranged in spatial and temporal order to obtain a pixel block sequence, also known as the first pixel block set; this sequence includes multiple pixel blocks arranged in a preset order.

[0090] S2022. Perform vector embedding processing on the first pixel block set to obtain the corresponding sampled video embedding vector.

[0091] Vector embedding refers to the process of mapping an object (such as text, image, audio, etc.) to a low-dimensional vector space, and the result is called an embedding vector. Specifically, by processing a sampled video through vector embedding, a sampled video embedding vector can be obtained.

[0092] S2023. Train each encoder using the sampled video embedding vector to obtain trained encoders; each trained encoder is used to extract different preset features of the sampled video based on the sampled video embedding vector.

[0093] After multiple encoders extract different feature vectors from the sampled video, a weighted sum can be performed to obtain the first latent space vector corresponding to the sampled video. The latent space vector is a high-dimensional, dense vector that can contain latent semantic information of the sampled video.

[0094] S203. Use the diffusion model to add and remove noise to the first latent space vector to obtain the second latent space vector.

[0095] In one possible implementation, the diffusion model includes a forward diffusion network and a backward diffusion network;

[0096] The process of adding and denoising noise to the first latent space vector using a diffusion model to obtain the second latent space vector may include the following steps:

[0097] 1. Input the first latent space vector into the forward diffusion network so that the forward diffusion network adds noise to the first latent space vector.

[0098] 2. After a preset number of noise addition processes, the noise vector corresponding to the first latent space vector is obtained.

[0099] 3. Input the noise vector into the backdiffusion network so that the backdiffusion network subtracts the predicted noise from the noise vector.

[0100] 4. After a preset number of denoising processes, the second latent space vector is obtained.

[0101] Specifically, the diffusion model is a neural network model whose operation includes a forward process and a backward process. For an input vector, such as a first latent space vector, the forward process continuously mixes Gaussian noise into the first latent space vector, i.e., noise addition. After a preset number of noise additions, the resulting vector can be considered a noise vector. Then, the backward process denoises this noise vector, continuously subtracting noise based on preset conditions to restore the second latent space vector.

[0102] S204. Use a decoder to decode the second latent space vector to obtain the corresponding predicted embedding vector; and perform video conversion processing on the predicted embedding vector to obtain the corresponding predicted video.

[0103] Specifically, the decoder works in tandem with the encoder, reconstructing the predicted video from the second latent space vector. Ideally, when the decoder and diffusion model are fully trained, the predicted video should be identical to the sampled video, or differ only by a preset threshold. However, after processing by an incompletely trained diffusion model and decoder, the predicted video may differ significantly from the sampled video.

[0104] In one possible implementation, performing video transformation processing on the predicted embedding vector to obtain the corresponding predicted video may include the following steps:

[0105] 1. Perform reverse embedding processing on the predicted embedding vector to obtain the set of second pixel blocks corresponding to the predicted embedding vector.

[0106] 2. Based on the preset sorting method, the second pixel block set is arranged and stitched together to obtain the corresponding predicted video.

[0107] The predicted embedding vector is obtained by the decoder from the second latent space vector and is similar to the sampled video embedding vector. After inverse embedding processing, the embedding vector can be restored to the corresponding original target, such as an image or text. In this embodiment, the sampled video embedding vector is obtained by embedding from the first set of pixel blocks, so the predicted embedding vector can be restored to the second set of pixel blocks. Furthermore, the first set of pixel blocks is obtained by segmenting and sorting the sampled video. By arranging and concatenating the second set of pixel blocks in the same order, the corresponding predicted video can be obtained.

[0108] S205. Based on the sampled video and the predicted video, adjust the parameters of the diffusion model and the decoder until a well-trained diffusion model and decoder are obtained.

[0109] Specifically, a loss function can be constructed based on the difference between the sampled video and the predicted video, and then gradient backpropagation can be performed based on the loss function to adjust the parameters in the diffusion model and the decoder, so that the predicted video generated by the diffusion model and the decoder based on the first latent space vector becomes closer and closer to the sampled video.

[0110] The model training method provided in this application training method trains the decoder and diffusion model using a pre-trained encoder. Multiple encoders are used to extract image representation vectors, temporal feature vectors, and dynamic feature vectors from the sampled video. The diffusion model and decoder are used to generate a predicted video based on the weighted vectors extracted by the encoders. The parameters of the diffusion model and decoder are then adjusted based on the difference between the sampled video and the predicted video to obtain a trained diffusion model and decoder. This method reduces the amount of training data and improves the dimensionality of image encoding feature information.

[0111] In one possible implementation, the predicted noise in the diffusion model is obtained based on the guiding conditions in the backdiffusion network. The model training method provided in this application also includes:

[0112] S2001. Obtain the generation conditions and encode them to obtain the generation condition code.

[0113] S2002. The generation conditional encoding is added to the backdiffusion network in the form of cross-attention as a guiding condition for the backdiffusion model.

[0114] Specifically, generation conditions can be guiding conditions used to instruct video generation models to generate videos, and can include, but are not limited to, text conditions, image conditions, and video conditions. For example, when the generation condition is a text condition, a text encoder can be used to encode the text condition to obtain the corresponding text encoding. The encodings of multiple conditions together constitute the generation condition encoding.

[0115] Furthermore, the generative conditional encoding can be added to the backdiffusion network using cross-attention to obtain the guiding conditions for the backdiffusion model. This allows the backdiffusion model to generate predicted noise based on these guiding conditions.

[0116] In one possible implementation, the encoder in the model includes a first encoder, a second encoder, and a third encoder;

[0117] The first encoder is used to extract the image representation vector of the sampled video;

[0118] The second encoder is used to extract the temporal feature vector of the sampled video;

[0119] The third encoder is used to extract the dynamic feature vector of the sampled video.

[0120] The pre-trained encoder can be used to extract image representation vectors, temporal feature vectors, and dynamic feature vectors, respectively. The image representation vector primarily represents the image features of the video, the temporal feature vector primarily represents the order between video frames, and the dynamic feature vector primarily represents the motion speed and dynamic object features of the target object in the video.

[0121] In one possible implementation, such as Figure 3 As shown, the training method for the first encoder may include the following steps:

[0122] S301. Input the sampled video embedding vector into the first encoder to obtain the image representation vector corresponding to the sampled video.

[0123] S302. Use the first decoder corresponding to the first encoder to decode the image representation vector to obtain the reconstructed video corresponding to the sampled video.

[0124] S303. Based on the difference between the reconstructed video and the sampled video, adjust the parameters of the first encoder and the first decoder to obtain the trained first encoder and the first decoder.

[0125] Specifically, the training architecture of the first encoder is as follows: Figure 4As shown in the diagram. The first encoder (also called encoder 1, or video encoder 1) can be built based on the reconstruction task, aiming to learn image representations. First, the video x is divided into blocks to obtain a sequence of pixel blocks, and then linear projection is used to convert the pixel block sequence into a multi-dimensional vector. This vector is input into encoder 1 to obtain the latent space vector z1, and z1 is input into the corresponding decoder to obtain the decoded vector. Then, through back projection, the reconstructed video x' is obtained. The distance between the reconstructed video and the input video is calculated as the reconstruction loss to optimize encoder 1 and decoder. To enhance model performance, some pixel blocks of the input video can be occluded. Encoder 1 and decoder use a transformer network. Pre-trained models of encoder 1 and decoder were obtained through the reconstruction task.

[0126] Optionally, the weight parameters of the first decoder corresponding to the first encoder can be retained as the initial weight parameters of the decoder in the overall model, and the decoder can be trained.

[0127] Correspondingly, in one possible implementation, the training method for the second encoder may include:

[0128] The sampled video embedding vector is input into the second encoder to obtain the temporal feature vector corresponding to the sampled video.

[0129] The temporal feature vector is decoded using a sequence prediction network to obtain the predicted sequence code of the video frames corresponding to the sampled video.

[0130] Based on the difference between the video frame sequence code and the video frame predicted sequence code of the sampled video, the parameters of the second encoder and the sequence prediction network are adjusted to obtain the trained second encoder and sequence prediction network.

[0131] Specifically, the training architecture of the second encoder is as follows: Figure 5 As shown, the second encoder (also called encoder 2, or video encoder 2) can be constructed based on the video frame order prediction task, aiming to learn the temporal features of the video. First, the video x is divided into blocks to obtain a sequence of pixel blocks, and then linear projection is used to convert the pixel blocks into multi-dimensional vectors. These vectors are input into encoder 2 to obtain the latent space vector z2, and z2 is input into the order prediction network to obtain the video frame prediction sequence code, which uses one-hot encoding. The video frame sequence code corresponding to the input video is compared with the predicted sequence code, and the distance loss is calculated to optimize encoder 2 and the order prediction network. To enhance network performance, the order of the input video frames can be randomly shuffled during training. Both encoder 2 and the order prediction network use transformer networks. The pre-trained model of encoder 2 is obtained through the video frame order prediction task.

[0132] In one possible implementation, the training method for the third encoder may include the following steps:

[0133] The embedded vector of the sampled video is input into the third encoder to obtain the dynamic feature vector corresponding to the sampled video; the dynamic feature vector is used to characterize the motion speed features and dynamic object features of the sampled video.

[0134] The dynamic feature vector and the target frame velocity are input into the image difference prediction network to obtain the corresponding predicted image difference.

[0135] Based on the difference between the predicted image difference and the ground truth image difference of the sampled video, the parameters of the third encoder and the image difference prediction network are adjusted to obtain the trained third encoder and image difference prediction network.

[0136] Specifically, the training architecture of the third encoder is as follows: Figure 6 As shown, the third encoder (also called encoder 3 or video encoder 3) can be constructed based on the image difference prediction task, aiming to learn motion speed features and dynamic object features. The image difference is defined as the difference between the previous and subsequent frames. In addition to the video x, the input to this encoder training also includes a specified fps, used to change the video frame rate. The network should predict the image difference of the video frame after the frame rate change based on the input video and frame rate. First, the video x is divided into blocks to obtain a sequence of pixel blocks, and then linear projection is used to convert the pixel blocks into multi-dimensional vectors. The vectors are input to encoder 3 to obtain the latent space vector z3, and the target frame rate fps and z3 are input to the image difference prediction network to obtain the image difference. The predicted image difference is compared with the ground truth image difference, and the distance loss is calculated to optimize encoder 3 and the image difference prediction network. To enhance network performance, some pixel blocks of the input video can be occluded. Encoder 3 uses a transformer network, and the image difference prediction network uses ResNet. The pre-trained model of encoder 3 is obtained through the image difference prediction task.

[0137] Based on the pre-trained decoder, the three pre-trained encoders and decoders can be embedded into the overall network for training. The training process and loss function are consistent with the diffusion model. The diffusion model uses the DiT architecture. In a specific application scenario, the generation condition can be only text, and the text encoder uses T5.

[0138] Based on the video generation model trained using the above model training method, this application also provides a video generation method, such as... Figure 7 As shown, the following steps may be included:

[0139] S701. Obtain a condition description for generating a video, wherein the condition description includes at least one of the following: text description, image description, and video description;

[0140] S702. Encode the condition description to obtain the condition code;

[0141] S703. Using conditional coding as a guiding condition, and employing the diffusion model of the first aspect and / or various possible implementations of the first aspect as described above, the random noise is back-diffused to obtain the corresponding third latent space vector.

[0142] S704. The third latent space vector is decoded and video converted using the decoder described in the first aspect and / or various possible implementations of the first aspect to obtain the video corresponding to the condition description.

[0143] Specifically, for the trained overall model, only the back-diffusion network and decoder of the diffusion model are needed in video generation applications. For example, this model can be used as the backend algorithm for a text-to-video system. This system supports generating videos corresponding to the input text description, such as inputting phrases like "A young rider is riding a horse on a vast grassland" or "The setting sun slowly sinks below the horizon and disappears." The system can consist of a front-end web page and a back-end algorithm. Users input text descriptions through the web page and click the "Generate" button to transmit the data to a cloud server. The server deploys the text-to-video algorithm, calculates the generated video, and transmits it back to the web page for display. Users can click the "Play" button to preview the video or click the "Download" button to download a satisfactory video.

[0144] Figure 8 A schematic diagram of the structure of the model training device provided in this application is shown below. Figure 8 As shown, the model training device provided in this embodiment includes:

[0145] The acquisition module 801 is used to acquire sampled videos and pre-train multiple encoders using the sampled videos; each encoder is trained using a self-supervised learning method based on different preset tasks; each trained encoder is used to extract different preset features from the sampled videos.

[0146] The pre-training module 802 is used to extract each preset feature of the sampled video using each trained encoder, and to sum the preset features by weight to obtain the first latent space vector corresponding to the sampled video.

[0147] The diffusion module 803 is used to add and remove noise to the first latent space vector using a diffusion model to obtain the second latent space vector.

[0148] The decoding module 804 is used to decode the second latent space vector using the decoder to obtain the corresponding prediction embedding vector; and to perform video conversion processing on the prediction embedding vector to obtain the corresponding prediction video.

[0149] The adjustment module 805 is used to adjust the parameters of the diffusion model and the decoder based on the sampled video and the predicted video until a trained diffusion model and decoder are obtained.

[0150] In one possible implementation, the diffusion model includes a forward diffusion network and a backward diffusion network; the diffusion module is further used for:

[0151] The first latent space vector is input into the forward diffusion network so that the forward diffusion network adds noise to the first latent space vector;

[0152] After a preset number of noise addition processes, the noise vector corresponding to the first latent space vector is obtained;

[0153] The noise vector is input into the backdiffusion network so that the backdiffusion network subtracts the predicted noise from the noise vector;

[0154] After a preset number of denoising processes, the second latent space vector is obtained.

[0155] In one possible implementation, the predicted noise is obtained based on guiding conditions in the backdiffusion network; the diffusion module is also used for:

[0156] Obtain the generation conditions and encode them to obtain the generation condition code;

[0157] Generative conditional encoding is added to the backdiffusion network in the form of cross-attention as a guiding condition for the backdiffusion model.

[0158] In one possible implementation, the acquisition module is further configured to:

[0159] Each video frame of the sampled video is divided into blocks to obtain multiple pixel blocks, and these multiple pixel blocks are sorted in a preset order to obtain the first set of pixel blocks corresponding to the sampled video.

[0160] The first set of pixel blocks is processed by vector embedding to obtain the corresponding sampled video embedding vector;

[0161] Each encoder is trained using the sampled video embedding vectors to obtain trained encoders; each trained encoder is then used to extract different preset features from the sampled video based on the sampled video embedding vectors.

[0162] In one possible implementation, the decoding module is also used for:

[0163] The predicted embedding vector is reverse-embedded to obtain the set of second pixel blocks corresponding to the predicted embedding vector.

[0164] Based on a preset sorting method, the second pixel block set is arranged and stitched together to obtain the corresponding predicted video.

[0165] In one possible implementation, the encoder in the model includes a first encoder, a second encoder, and a third encoder;

[0166] The first encoder is used to extract the image representation vector of the sampled video;

[0167] The second encoder is used to extract the temporal feature vector of the sampled video;

[0168] The third encoder is used to extract the dynamic feature vector of the sampled video.

[0169] In one possible implementation, the training method for the first encoder includes:

[0170] The sampled video embedding vector is input into the first encoder to obtain the image representation vector corresponding to the sampled video.

[0171] The image representation vector is decoded using the first decoder corresponding to the first encoder to obtain the reconstructed video corresponding to the sampled video;

[0172] Based on the differences between the reconstructed video and the sampled video, the parameters of the first encoder and the first decoder are adjusted to obtain the trained first encoder and the first decoder.

[0173] In one possible implementation, the training method for the second encoder includes:

[0174] The sampled video embedding vector is input into the second encoder to obtain the temporal feature vector corresponding to the sampled video.

[0175] The temporal feature vector is decoded using a sequence prediction network to obtain the predicted sequence code of the video frames corresponding to the sampled video.

[0176] Based on the difference between the video frame sequence code and the video frame predicted sequence code of the sampled video, the parameters of the second encoder and the sequence prediction network are adjusted to obtain the trained second encoder and sequence prediction network.

[0177] In one possible implementation, the training method for the third encoder includes:

[0178] The embedded vector of the sampled video is input into the third encoder to obtain the dynamic feature vector corresponding to the sampled video; the dynamic feature vector is used to characterize the motion speed features and dynamic object features of the sampled video.

[0179] The dynamic feature vector and the target frame velocity are input into the image difference prediction network to obtain the corresponding predicted image difference.

[0180] Based on the difference between the predicted image difference and the ground truth image difference of the sampled video, the parameters of the third encoder and the image difference prediction network are adjusted to obtain the trained third encoder and image difference prediction network.

[0181] The model training device provided in this embodiment can execute the method provided in the above method embodiment. Its implementation principle and technical effect are similar, and will not be described in detail here.

[0182] Corresponding to the aforementioned video generation method, this application also provides a video generation apparatus, comprising:

[0183] The condition acquisition module is used to acquire the condition description for generating the video. The condition description includes at least one of the following: text description, image description, and video description.

[0184] The condition encoding module is used to encode the condition description to obtain the condition code;

[0185] The diffusion processing module is used to perform backdiffusion processing on random noise using conditional coding as a guiding condition and a diffusion model as described in the first aspect and / or various possible implementations of the first aspect, to obtain the corresponding third latent space vector.

[0186] The video conversion module is used to decode and convert the third latent space vector using the decoder described in the first aspect and / or various possible implementations of the first aspect, to obtain the video corresponding to the condition description.

[0187] The video generation device provided in this embodiment can execute the method provided in the above method embodiment. Its implementation principle and technical effect are similar, and will not be described in detail here.

[0188] Figure 9 A schematic diagram of the structure of the electronic device provided in this application. Figure 9 As shown, the electronic device 90 provided in this embodiment includes at least one processor 901 and a memory 902. Optionally, the device 90 further includes a communication component 903. The processor 901, memory 902, and communication component 903 are connected via a bus.

[0189] In a specific implementation, at least one processor 901 executes computer execution instructions stored in memory 902, causing at least one processor 901 to perform the above-described method.

[0190] The specific implementation process of processor 901 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.

[0191] In the above embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.

[0192] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device.

[0193] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.

[0194] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method.

[0195] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the above-described method.

[0196] The aforementioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The readable storage medium can be any available medium accessible to a general-purpose or special-purpose computer.

[0197] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and the readable storage medium can exist as discrete components in the device.

[0198] The division of units is merely a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.

[0199] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0200] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0201] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0202] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.

[0203] Finally, it should be noted that other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein, and is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of the invention is limited only by the appended claims.

Claims

1. A model training method, characterized in that, The model includes multiple encoders, a diffusion model, and a decoder, and the method includes: A sampled video is acquired, and the sampled video is used to pre-train multiple encoders; wherein each encoder is trained using a self-supervised learning method based on a different preset task; each trained encoder is used to extract different preset features from the sampled video. The trained encoders are used to extract the preset features of the sampled video, and the preset features are weighted and summed to obtain the first latent space vector corresponding to the sampled video. The diffusion model is used to add and remove noise from the first latent space vector to obtain the second latent space vector. The second latent space vector is decoded using the decoder to obtain the corresponding predicted embedding vector; and the predicted embedding vector is then subjected to video conversion processing to obtain the corresponding predicted video. Based on the sampled video and the predicted video, the parameters of the diffusion model and the decoder are adjusted until the trained diffusion model and the decoder are obtained.

2. The method according to claim 1, characterized in that, The diffusion model includes a forward diffusion network and a backward diffusion network; The step of using the diffusion model to add and denoise the first latent space vector to obtain the second latent space vector includes: The first latent space vector is input into the forward diffusion network so that the forward diffusion network adds noise to the first latent space vector; After a preset number of noise addition processes, the noise vector corresponding to the first latent space vector is obtained; The noise vector is input into the backdiffusion network so that the backdiffusion network subtracts the predicted noise from the noise vector; After a preset number of denoising processes, the second latent space vector is obtained.

3. The method according to claim 2, characterized in that, The predicted noise is obtained based on the guiding conditions in the backdiffusion network; The method further includes: Obtain the generation conditions and encode the generation conditions to obtain the generation condition code; The generation condition encoding is added to the backdiffusion network in a cross-attention manner as a guiding condition for the backdiffusion network.

4. The method according to any one of claims 1-3, characterized in that, The step of performing video conversion processing on the predicted embedding vector to obtain the corresponding predicted video includes: The predicted embedding vector is reverse-embedded to obtain the second pixel block set corresponding to the predicted embedding vector. Based on a preset sorting method, the second set of pixel blocks is arranged and stitched together to obtain the corresponding predicted video.

5. The method according to claim 1, characterized in that, The pre-training of multiple encoders using the sampled video includes: Each video frame of the sampled video is divided into blocks to obtain multiple pixel blocks, and the multiple pixel blocks are sorted in a preset order to obtain the first set of pixel blocks corresponding to the sampled video. The first set of pixel blocks is subjected to vector embedding processing to obtain the corresponding sampled video embedding vector; The encoders are trained using the sampled video embedding vectors to obtain trained encoders; each trained encoder is used to extract different preset features of the sampled video based on the sampled video embedding vectors.

6. The method according to claim 5, characterized in that, The encoders in the model include a first encoder, a second encoder, and a third encoder; The first encoder is used to extract the image representation vector of the sampled video; The second encoder is used to extract the temporal feature vector of the sampled video; The third encoder is used to extract the dynamic feature vector of the sampled video.

7. The method according to claim 6, characterized in that, The training method for the first encoder includes: The sampled video embedding vector is input into the first encoder to obtain the image representation vector corresponding to the sampled video; The image representation vector is decoded using the first decoder corresponding to the first encoder to obtain the reconstructed video corresponding to the sampled video; Based on the difference between the reconstructed video and the sampled video, the parameters of the first encoder and the first decoder are adjusted to obtain the trained first encoder and the first decoder.

8. The method according to claim 6, characterized in that, The training method for the second encoder includes: The sampled video embedding vector is input into the second encoder to obtain the temporal feature vector corresponding to the sampled video; The temporal feature vector is decoded using a sequence prediction network to obtain the video frame prediction sequence code corresponding to the sampled video; Based on the difference between the video frame sequence code and the video frame predicted sequence code of the sampled video, the parameters of the second encoder and the sequence prediction network are adjusted to obtain the trained second encoder and sequence prediction network.

9. The method according to claim 6, characterized in that, The training method for the third encoder includes: The sampling video embedding vector is input into the third encoder to obtain the dynamic feature vector corresponding to the sampling video; the dynamic feature vector is used to characterize the motion speed feature and dynamic object feature of the sampling video. The dynamic feature vector and the target frame velocity are input into the image difference prediction network to obtain the corresponding predicted image difference. Based on the difference between the predicted image difference and the ground truth image difference of the sampled video, the parameters of the third encoder and the image difference prediction network are adjusted to obtain the trained third encoder and image difference prediction network.

10. A model training device, characterized in that, The model includes multiple encoders, a diffusion model, and a decoder; the device includes: An acquisition module is used to acquire sampled videos and pre-train multiple encoders using the sampled videos; wherein each encoder is trained using a self-supervised learning method based on different preset tasks; and each trained encoder is used to extract different preset features from the sampled videos. The pre-training module is used to extract each preset feature of the sampled video using each of the trained encoders, and to perform a weighted summation of the preset features to obtain the first latent space vector corresponding to the sampled video; A diffusion module is used to add and remove noise to the first latent space vector using the diffusion model to obtain a second latent space vector. The decoding module is used to decode the second latent space vector using the decoder to obtain the corresponding prediction embedding vector; and to perform video conversion processing on the prediction embedding vector to obtain the corresponding prediction video. An adjustment module is used to adjust the parameters of the diffusion model and the decoder based on the sampled video and the predicted video until the trained diffusion model and the decoder are obtained.

11. A video generation method, characterized in that, include: Obtain a conditional description for generating the video, the conditional description including at least one of the following: text description, image description, and video description; The condition description is encoded to obtain the condition code; Using the conditional encoding as a guiding condition, the random noise is back-diffused using the diffusion model as described in any one of claims 1-9 to obtain the corresponding third latent space vector; The third latent space vector is decoded and video converted using the decoder as described in any one of claims 1-9 to obtain the video corresponding to the condition description.

12. A video generation apparatus, characterized in that, include: The condition acquisition module is used to acquire condition descriptions for generating the video, wherein the condition descriptions include at least one of the following: text description, image description, and video description; The condition encoding module is used to encode the condition description to obtain the condition code; A diffusion processing module is used to perform backward diffusion processing on random noise using the conditional encoding as a guiding condition and the diffusion model as described in any one of claims 1-9 to obtain the corresponding third latent space vector. The video conversion module is used to decode and convert the third latent space vector using the decoder as described in any one of claims 1-9 to obtain the video corresponding to the condition description.

13. An electronic device, characterized in that, Includes memory and processor; among which, The memory is used to store computer programs; The processor is configured to read a computer program stored in the memory and execute the method described in any one of claims 1-9 or 11 according to the computer program in the memory.

14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1-9 or 11.

15. A computer program product, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-9 or 11 above.

Citation Information

Patent Citations

  • Video reconstruction model training method, video reconstruction method, device and equipment

    CN116757970A

  • Video filling method and device based on diffusion model, equipment and storage medium

    CN117314733A