Graphics video model generation method, video generation method and device
By introducing the temporal self-attention module and motion adapter into the Wensheng video model, combined with spatial feature extraction, the problem of high resource consumption during the training process of the Wensheng video model is solved, and the adaptability and generation of image spatial arrangement control are achieved. Improvement of efficiency.
Patent Information
- Application Number
- CN202410833892.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2024-10-08
AI Technical Summary
In the existing technology, when extending the Wensheng video model to the Tusheng video model, the training process consumes a lot of resources, and the model is not suitable for the existing image space arrangement control and stylization components after retraining.
By obtaining sample video data and sample text description information, the spatial module and temporal self-attention module in the preset Wensheng video model are used for feature extraction and motion information control to generate predicted video data, and based on the difference between the video data and the preset video data The model parameters are updated differentially until the preset conditions are met, and the Tusheng video model is obtained.
It reduces the consumption of system resources in the Tusheng video generation process, and can reuse existing image space arrangement control and stylization components, improving the adaptability and generation efficiency of the model.
Smart Images

Figure CN118747862A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computers, and in particular to a method for generating an image-based video model, a method for generating a video, and a device for generating the video. Background Art
[0002] With the rapid development of generative artificial intelligence, video generation technology has received extensive attention and research. The Vincent video model (AnimateDiff) inserts a temporal module of modeling video frames on the Vincent image model (Stable Diffusion) to generate video clips that conform to the input text. However, due to the complexity of video data compared to image data, generating high-quality videos from text is still challenging. Image-generated video technology can accept both text and images as input to generate videos, where the input image provides rich visual reference information and the input text can supplement certain motion information. Therefore, it is a more promising and practical video generation solution.
[0003] In the related art, the existing text-generated video model is expanded into an image-generated video model (e.g., Stable Video Diffusion). The specific approach is to expand the input layer dimension of the text-generated video model and input the reference image in the expanded dimension to inject image information. However, the related art requires retraining the entire model, resulting in a large resource consumption in the training process. In addition, since the spatial module including the control of the spatial arrangement of the image is retrained, the trained model is no longer adapted to the existing image spatial arrangement control and stylization components. Summary of the invention
[0004] The present disclosure provides a method for generating an image-generated video model, a method for generating a video, and a device, to at least solve the problem that the training process in the related art consumes a lot of resources, and the training process retrains the spatial module including the control of the spatial arrangement of the image, resulting in the trained model no longer being adapted to the existing image spatial arrangement control and stylization components. The technical solution of the present disclosure is as follows:
[0005] According to a first aspect of an embodiment of the present disclosure, a method for generating an image-based video model is provided, comprising:
[0006] Acquire sample video data, sample text description information for the sample video data, and a preset Vincent video model; the preset Vincent video model includes a spatial module and a temporal module, the temporal module includes a temporal self-attention module and a motion adapter module, the motion adapter module is used to control motion information of an image frame, and the sample video data includes a sample image;
[0007] Inputting the sample image and the sample text description information into the preset Wensheng video model;
[0008] Performing spatial feature extraction processing on the sample image and the sample text description information based on the spatial module to obtain a first sample feature processing result;
[0009] Based on the temporal self-attention module, the first sample feature processing result is subjected to feature relationship modeling processing between image frames, so that the image frames are continuous in time sequence, and a second sample feature processing result is obtained; and based on the motion adapter module, the first sample feature processing result is subjected to motion information control processing of the image frame, and a third sample feature processing result is obtained;
[0010] Generate predicted video data according to the second sample feature processing result and the third sample feature processing result;
[0011] According to the difference between the preset video data and the sample video data, the parameters of the space module and the motion adapter module are updated until the difference meets the preset conditions, thereby obtaining an image-generated video model; the image-generated video model is used to perform video generation processing on the processed image to obtain the target video data.
[0012] In an optional embodiment, the step of performing motion information control processing of an image frame on the first sample feature processing result based on the motion adapter module to obtain a third sample feature processing result includes:
[0013] Acquire sample timing sampling information of the sample video data; the sample timing sampling information is used to characterize the number of frames per second and the frame extraction step length of the sample video data;
[0014] Determine, based on the motion adapter module, the product of the first sample feature processing result and the corresponding query weight matrix to obtain a sample query, determine the product of the sample timing sampling information and the corresponding key weight matrix to obtain a first sample key, and determine the product of the sample timing sampling information and the corresponding value weight matrix to obtain a first sample value;
[0015] Determine the similarity between the sample query and the first sample key based on the motion adapter module, and obtain first sample attention data; the first sample attention data represents the importance of the first sample value;
[0016] Based on the motion adapter module, the first sample value is weightedly processed through the first sample attention data to obtain the third sample feature processing result.
[0017] In an optional embodiment, the step of performing feature relationship modeling processing between image frames on the first sample feature processing result based on the temporal self-attention module so as to make the image frames continuous in time sequence, and obtaining a second sample feature processing result, includes:
[0018] Determine, based on the temporal self-attention module, the product of the first sample feature processing result and the corresponding query weight matrix to obtain a sample query, determine the product of the first sample feature processing result and the corresponding key weight matrix to obtain a second sample key, and determine the product of the first sample feature processing result and the corresponding value weight matrix to obtain a second sample value;
[0019] Determine the similarity between the sample query and the second sample key based on the temporal self-attention module, and obtain second sample attention data; the second sample attention data represents the importance of the second sample value;
[0020] Based on the temporal self-attention module, the second sample value is weightedly processed through the second sample attention data to obtain the second sample feature processing result.
[0021] In an optional embodiment, generating predicted video data according to the second sample feature processing result and the third sample feature processing result includes:
[0022] Adding the second sample feature processing result and the third sample feature processing result to obtain a sample time series feature;
[0023] The sample time series features are subjected to video conversion processing to obtain the predicted video data.
[0024] In an optional embodiment, the spatial module includes a self-attention module, a cross-attention module, a first adapter module corresponding to the self-attention module, and a second adapter module corresponding to the cross-attention module, wherein the first adapter module is used to extract local image features of the image frame, and the second adapter module is used to extract global image features of the image frame; and updating the parameters of the spatial module and the motion adapter module according to the difference between the preset video data and the sample video data includes:
[0025] Calculating loss data according to the difference between the preset video data and the sample video data;
[0026] Freeze the parameters of the self-attention module, the parameters of the cross-attention module, the parameters of the second adapter module, and the parameters of the temporal self-attention module, and update the parameters of the first adapter module and the parameters of the motion adapter module based on the loss data.
[0027] In an optional embodiment, the parameters of the first adapter module include a key weight matrix and a value weight matrix, the parameters of the motion adapter module include a key weight matrix and a value weight matrix, the key weight matrix included in the parameters of the first adapter module and the key weight matrix included in the parameters of the motion adapter module are randomly initialized, and the value weight matrix included in the parameters of the first adapter module and the value weight matrix included in the parameters of the motion adapter module are initialized to all zeros;
[0028] The updating of the parameters of the first adapter module and the model parameters of the motion adapter module based on the loss data comprises:
[0029] A key weight matrix and a value weight matrix included in the parameters of the first adapter module are updated based on the loss data, and a key weight matrix and a value weight matrix included in the parameters of the motion adapter module are updated.
[0030] In an optional embodiment, the sample image includes a first frame sample image and a sample noise image, the spatial module includes a self-attention module, a cross-attention module, a first adapter module corresponding to the self-attention module, and a second adapter module corresponding to the cross-attention module, the first adapter module is used to extract local image features of the image frame, and the second adapter module is used to extract global image features of the image frame;
[0031] The performing spatial feature extraction processing on the sample image and the sample text description information based on the spatial module to obtain a first sample feature processing result includes:
[0032] Based on the self-attention module, the sample image is subjected to dependency modeling processing between features to obtain a first sample subspace feature; and based on the first adapter module, the first frame sample image and the sample noise image are subjected to local image feature extraction processing to obtain a second sample subspace feature;
[0033] Generate a sample output feature of the self-attention module according to the first sample subspace feature and the second sample subspace feature;
[0034] Based on the cross attention module, the sample output feature and the sample text encoding feature are subjected to feature and text dependency modeling processing to obtain a third sample subspace feature; and based on the second adapter module, the sample output feature and the sample image encoding feature are subjected to global image feature extraction processing to obtain a fourth sample subspace feature; the sample image encoding feature is obtained by encoding the sample image, and the sample text encoding feature is obtained by encoding the sample text description information;
[0035] The first sample feature processing result is generated according to the third sample subspace feature and the fourth sample subspace feature.
[0036] In an optional embodiment, generating the sample output feature of the self-attention module according to the first sample subspace feature and the second sample subspace feature includes:
[0037] The first sample subspace feature and the second sample subspace feature are added to obtain the sample output feature.
[0038] According to a second aspect of an embodiment of the present disclosure, a video generation method is provided, the method comprising:
[0039] Acquire an image to be processed, a preset number of frames of noisy images, text description information and an image-generated video model; the text description information is used to describe the target video data to be generated; the image-generated video model includes a spatial module and a temporal module, the temporal module includes a temporal self-attention module and a motion adapter module, and the motion adapter module is used to control the motion information of the video frame;
[0040] Inputting the image to be processed, text description information and the noise image into the image-generated video model;
[0041] Based on the spatial module, spatial feature extraction processing is performed on the image to be processed, the text description information and the noise image to obtain a first feature processing result;
[0042] Based on the temporal self-attention module, the first feature processing result is subjected to feature relationship modeling processing between image frames, so that the image frames are temporally coherent, thereby obtaining a second feature processing result; and based on the motion adapter module, the first feature processing result is subjected to motion information control processing of the image frames, thereby obtaining a third feature processing result;
[0043] Generate target video data according to the second feature processing result and the third feature processing result.
[0044] In an optional embodiment, the step of performing motion information control processing of the image frame on the first feature processing result based on the motion adapter module to obtain a third feature processing result includes:
[0045] Acquire preset timing sampling information; the sample timing sampling information is used to characterize the number of frames per second and the frame extraction step of the target data to be generated;
[0046] Determine the product of the first feature extraction result and the corresponding query weight matrix based on the motion adapter module to obtain a query; and determine the product of the preset timing sampling information and the corresponding key weight matrix to obtain a first key; and determine the product of the preset timing sampling information and the corresponding value weight matrix to obtain a first value;
[0047] Determine the similarity between the query and the first key based on the motion adapter module, and obtain first attention data; the first attention data represents the importance of the first value;
[0048] The motion adapter module performs weighted sum processing on the first value through the first attention data to obtain the third feature processing result.
[0049] In an optional embodiment, the step of performing feature relationship modeling processing between image frames on the first feature processing result based on the temporal self-attention module to make the image frames temporally coherent to obtain a second feature processing result includes:
[0050] Determine the product of the first feature processing result and the corresponding query weight matrix based on the temporal self-attention module to obtain a query; determine the product of the first feature processing result and the corresponding key weight matrix to obtain a second key; and determine the product of the first feature processing result and the corresponding value weight matrix to obtain a second value;
[0051] Determine the similarity between the query and the second key based on the temporal self-attention module to obtain second attention data; the second attention data represents the importance of the second value;
[0052] Based on the temporal self-attention module, the second value is weightedly summed up through the second attention data to obtain the second feature processing result.
[0053] In an optional embodiment, generating target video data according to the second feature processing result and the third feature processing result includes:
[0054] Adding the second feature processing result and the third feature processing result to obtain a time series feature;
[0055] The target video data is obtained by performing video conversion processing on the timing features.
[0056] In an optional embodiment, the spatial module includes a self-attention module, a cross-attention module, a first adapter module corresponding to the self-attention module, and a second adapter module corresponding to the cross-attention module, wherein the first adapter module is used to model local image features of the image frame, and the second adapter module is used to model global image features of the image frame;
[0057] The performing spatial feature extraction processing on the image to be processed, the text description information and the noise image based on the spatial module to obtain a first feature processing result includes:
[0058] Based on the self-attention module, the dependency relationship between features of the image to be processed is modeled to obtain a first subspace feature; and based on the first adapter module, local image feature extraction is performed on the image to be processed, the noise image and the text description information to obtain a second subspace feature;
[0059] Generate an output feature of the self-attention module according to the first subspace feature and the second subspace feature;
[0060] Based on the cross attention module, the output feature and the text encoding feature are subjected to feature and text dependency modeling processing to obtain a third subspace feature; and based on the second adapter module, the output feature and the image encoding feature are subjected to global feature extraction processing to obtain a fourth subspace feature; the image encoding feature is a feature obtained by encoding the image to be processed, and the text encoding feature is obtained by encoding the text description information;
[0061] The first feature processing result is generated according to the third subspace feature and the fourth subspace feature.
[0062] In an optional embodiment, generating the output feature of the self-attention module according to the first subspace feature and the second subspace feature includes:
[0063] The first subspace feature and the second subspace feature are added to obtain the output feature.
[0064] According to a third aspect of an embodiment of the present disclosure, a device for generating an image-based video model is provided, including:
[0065] A sample data model acquisition module is configured to execute acquisition of sample video data, sample text description information for the sample video data, and a preset Vincent video model; the preset Vincent video model includes a spatial module and a temporal module, the temporal module includes a temporal self-attention module and a motion adapter module, the motion adapter module is used to control motion information of an image frame, and the sample video data includes a sample image;
[0066] A sample data input module, configured to input the sample image and the sample text description information into the preset Wensheng video model;
[0067] A spatial feature processing module, configured to perform spatial feature extraction processing on the sample image and the sample text description information based on the spatial module to obtain a first sample feature processing result;
[0068] a temporal feature processing module configured to perform feature relationship modeling processing between image frames on the first sample feature processing result based on the temporal self-attention module, so that the image frames are continuous in time sequence, and obtain a second sample feature processing result; and perform motion information control processing of the image frame on the first sample feature processing result based on the motion adapter module, and obtain a third sample feature processing result;
[0069] A predicted video data generating module, configured to generate predicted video data according to the second sample feature processing result and the third sample feature processing result;
[0070] The updating module is configured to update the parameters of the spatial module and the motion adapter module according to the difference between the preset video data and the sample video data until the difference meets the preset conditions to obtain the image-generated video model; the image-generated video model is used to perform video generation processing on the processed image to obtain the target video data.
[0071] In an optional embodiment, the above-mentioned time series feature processing module includes:
[0072] A sample timing sampling information acquisition unit is configured to acquire sample timing sampling information of the sample video data; the sample timing sampling information is used to characterize the number of frames per second and the frame extraction step of the sample video data;
[0073] a first product determination unit, configured to perform, based on the motion adapter module, determining the product of the first sample feature processing result and the corresponding query weight matrix to obtain a sample query, and determining the product of the sample timing sampling information and the corresponding key weight matrix to obtain a first sample key, and determining the product of the sample timing sampling information and the corresponding value weight matrix to obtain a first sample value;
[0074] A first sample attention data determining unit is configured to determine the similarity between the sample query and the first sample key based on the motion adapter module to obtain first sample attention data; the first sample attention data represents the importance of the first sample value;
[0075] The third sample feature processing result generating unit is configured to perform weighted processing on the first sample value based on the motion adapter module through the first sample attention data to obtain the third sample feature processing result.
[0076] In an optional embodiment, the above-mentioned time series feature processing module includes:
[0077] A second product determination unit is configured to determine the product of the first sample feature processing result and the corresponding query weight matrix based on the temporal self-attention module to obtain a sample query, determine the product of the first sample feature processing result and the corresponding key weight matrix to obtain a second sample key, and determine the product of the first sample feature processing result and the corresponding value weight matrix to obtain a second sample value;
[0078] A second sample attention data determination unit is configured to determine the similarity between the sample query and the second sample key based on the temporal self-attention module to obtain second sample attention data; the second sample attention data represents the importance of the second sample value;
[0079] The second sample feature processing result generating unit is configured to perform weighted processing on the second sample value through the second sample attention data based on the temporal self-attention module to obtain the second sample feature processing result.
[0080] In an optional embodiment, the above-mentioned predicted video data generation module includes:
[0081] a sample time series feature generating unit, configured to add the second sample feature processing result and the third sample feature processing result to obtain a sample time series feature;
[0082] The conversion unit is configured to perform video conversion processing on the sample timing features to obtain the predicted video data.
[0083] In an optional embodiment, the spatial module includes a self-attention module, a cross-attention module, a first adapter module corresponding to the self-attention module, and a second adapter module corresponding to the cross-attention module, wherein the first adapter module is used to extract local image features of the image frame, and the second adapter module is used to extract global image features of the image frame; the above-mentioned update module includes:
[0084] a loss data calculation unit, configured to calculate loss data according to a difference between the preset video data and the sample video data;
[0085] A freeze update unit is configured to freeze the parameters of the self-attention module, the parameters of the cross-attention module, the parameters of the second adapter module, and the parameters of the temporal self-attention module, and update the parameters of the first adapter module and the parameters of the motion adapter module based on the loss data.
[0086] In an optional embodiment, the parameters of the first adapter module include a key weight matrix and a value weight matrix, the parameters of the motion adapter module include a key weight matrix and a value weight matrix, the key weight matrix included in the parameters of the first adapter module and the key weight matrix included in the parameters of the motion adapter module are randomly initialized, and the value weight matrix included in the parameters of the first adapter module and the value weight matrix included in the parameters of the motion adapter module are initialized to all zeros;
[0087] The freezing and updating unit comprises:
[0088] The key-value updating subunit is configured to update the key weight matrix and the value weight matrix included in the parameters of the first adapter module based on the loss data, and to update the key weight matrix and the value weight matrix included in the parameters of the motion adapter module.
[0089] In an optional embodiment, the sample image includes a first frame sample image and a sample noise image, the spatial module includes a self-attention module, a cross-attention module, a first adapter module corresponding to the self-attention module, and a second adapter module corresponding to the cross-attention module, the first adapter module is used to extract local image features of the image frame, and the second adapter module is used to extract global image features of the image frame;
[0090] The spatial feature processing module comprises:
[0091] The first and second sample subspace feature acquisition units are configured to perform dependency relationship modeling processing on the sample image based on the self-attention module to obtain the first sample subspace feature; and perform local image feature extraction processing on the first frame sample image and the sample noise image based on the first adapter module to obtain the second sample subspace feature;
[0092] A sample output feature generating unit, configured to generate a sample output feature of the self-attention module according to the first sample subspace feature and the second sample subspace feature;
[0093] The third sample subspace feature acquisition unit is configured to perform a dependency modeling process on the sample output feature and the sample text encoding feature based on the cross attention module, and obtain a third sample subspace feature; and perform a global image feature extraction process on the sample output feature and the sample image encoding feature based on the second adapter module, and obtain a fourth sample subspace feature; the sample image encoding feature is obtained by encoding the sample image, and the sample text encoding feature is obtained by encoding the sample text description information;
[0094] The feature processing result generating unit is configured to generate the first sample feature processing result according to the third sample subspace feature and the fourth sample subspace feature.
[0095] In an optional embodiment, the sample output feature generation unit is further configured to execute:
[0096] The first sample subspace feature and the second sample subspace feature are added to obtain the sample output feature.
[0097] According to a fourth aspect of an embodiment of the present disclosure, there is provided a video generating device, including:
[0098] A data model acquisition module is configured to acquire an image to be processed, a preset number of frames of noise images, text description information, and an image-generated video model; the text description information is used to describe the target video data to be generated; the image-generated video model includes a spatial module and a temporal module, the temporal module includes a temporal self-attention module and a motion adapter module, and the motion adapter module is used to control the motion information of the video frame;
[0099] A data input module is configured to input the image to be processed, the text description information and the noise image into the image-generated video model;
[0100] A first feature processing result generating module is configured to perform spatial feature extraction processing on the image to be processed, the text description information and the noise image based on the spatial module to obtain a first feature processing result;
[0101] The second feature processing result generating module is configured to perform feature relationship modeling processing between image frames on the first feature processing result based on the temporal self-attention module to make the image frames coherent in time sequence, thereby obtaining a second feature processing result; and perform motion information control processing of the image frames on the first feature processing result based on the motion adapter module to obtain a third feature processing result;
[0102] The target video data generating module is configured to generate target video data according to the second feature processing result and the third feature processing result.
[0103] In an optional embodiment, the sample time series feature processing module includes:
[0104] A preset timing sampling information acquisition unit is configured to acquire preset timing sampling information; the sample timing sampling information is used to characterize the number of frames per second and the frame extraction step of the target data to be generated;
[0105] A first query key value generating unit is configured to perform a query based on the motion adapter module by determining the product of the first feature extraction result and the corresponding query weight matrix; and determining the product of the preset timing sampling information and the corresponding key weight matrix to obtain a first key; and determining the product of the preset timing sampling information and the corresponding value weight matrix to obtain a first value;
[0106] A first attention data generating unit is configured to determine the similarity between the query and the first key based on the motion adapter module to obtain first attention data; the first attention data represents the importance of the first value;
[0107] The third feature processing result generating unit is configured to perform weighted summation processing on the first value through the first attention data based on the motion adapter module to obtain the third feature processing result.
[0108] In an optional embodiment, the sample time series feature processing module includes:
[0109] A second query key value generating unit is configured to perform the steps of determining the product of the first feature processing result and the corresponding query weight matrix based on the temporal self-attention module to obtain a query; determining the product of the first feature processing result and the corresponding key weight matrix to obtain a second key; and determining the product of the first feature processing result and the corresponding value weight matrix to obtain a second value;
[0110] A second attention data generating unit is configured to determine the similarity between the query and the second key based on the temporal self-attention module to obtain second attention data; the second attention data represents the importance of the second value;
[0111] The second feature processing result generating unit is configured to perform weighted summation processing on the second value through the second attention data based on the temporal self-attention module to obtain the second feature processing result.
[0112] In an optional embodiment, the target video data generating module includes:
[0113] a time series feature generating unit, configured to add the second feature processing result and the third feature processing result to obtain a time series feature;
[0114] The video data conversion unit is configured to perform video conversion processing on the timing feature to obtain the target video data.
[0115] In an optional embodiment, the spatial module includes a self-attention module, a cross-attention module, a first adapter module corresponding to the self-attention module, and a second adapter module corresponding to the cross-attention module, wherein the first adapter module is used to model local image features of the image frame, and the second adapter module is used to model global image features of the image frame;
[0116] The sample space feature processing module includes:
[0117] The first and second subspace feature generation units are configured to perform dependency modeling processing on the image to be processed based on the self-attention module to obtain a first subspace feature; and perform local image feature extraction processing on the image to be processed, the noise image and the text description information based on the first adapter module to obtain a second subspace feature;
[0118] an output feature generating unit, configured to generate an output feature of the self-attention module according to the first subspace feature and the second subspace feature;
[0119] The third and fourth subspace feature generation units are configured to perform a dependency modeling process on the output features, the text encoding features and the texts based on the cross attention module to obtain a third subspace feature; and perform a global feature extraction process on the output features and the image encoding features based on the second adapter module to obtain a fourth subspace feature; the image encoding feature is a feature obtained by encoding the image to be processed, and the text encoding feature is obtained by encoding the text description information;
[0120] The first feature processing result generating unit is configured to generate the first feature processing result according to the third subspace feature and the fourth subspace feature.
[0121] In an optional embodiment, the output feature generating unit is further configured to execute:
[0122] The first subspace feature and the second subspace feature are added to obtain the output feature.
[0123] According to a fifth aspect of an embodiment of the present disclosure, there is provided an electronic device, including:
[0124] processor;
[0125] a memory for storing instructions executable by the processor;
[0126] The processor is configured to execute the instructions to implement the image-generated video model generation method or video generation method as described in any of the above embodiments.
[0127] According to the sixth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device executes the image-generated video model generation method or the video generation method as described in any of the above embodiments.
[0128] According to a seventh aspect of an embodiment of the present disclosure, a computer program product is provided, comprising a computer program, wherein when the computer program is executed by a processor, the image-generated video model generation method or the video generation method described in any of the above-mentioned embodiments is implemented.
[0129] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:
[0130] The disclosed embodiments provide a method for generating an image-derived video model, a method for generating a video, and a device. The preset image-derived video model obtained by the image-derived video model generation method includes a spatial module and a temporal module. The temporal module includes a temporal self-attention module and a motion adapter module. The motion adapter module is used to control the motion information of the image frame. The sample image in the sample video data and the sample text description information for the sample video data are input into the preset image-derived video model. The spatial module is used to perform spatial feature extraction processing on the sample image and the sample text description information to obtain a first sample feature processing result. The temporal self-attention module is used to perform feature relationship modeling processing between image frames on the first sample feature processing result to make the image frames continuous in time sequence to obtain a second sample feature processing result. The motion adapter module is used to perform motion information control processing on the first sample feature processing result to obtain a third sample feature processing result. The predicted video is generated according to the second sample feature processing result and the third sample feature processing result. data; according to the difference between the preset video data and the sample video data, the parameters of the spatial module and the motion adapter module are updated until the difference meets the preset conditions, and the image-generated video model is obtained. On the one hand, the motion information of the generated video is controlled by the motion adapter, and on the other hand, the parameters of the spatial module and the motion adapter module are changed during the training process. The parameters of the basic preset image-generated video model are not updated, but the parameters of the basic preset image-generated video model are reused, that is, the spatial module of the existing preset image-generated video model for controlling the spatial arrangement of the image can be reused, so as to adapt the existing image spatial arrangement control and stylization group at a lower cost, thereby reducing the consumption of system resources by the image-generated video generation process.
[0131] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0132] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.
[0133] Figure 1 The present invention is an application environment diagram of a method for generating a graph-based video model according to an exemplary embodiment.
[0134] Figure 2 The following is a flow chart of a method for generating a graph-generated video model according to an exemplary embodiment. Figure 1 .
[0135] Figure 3 It is a schematic diagram of a flow chart of obtaining a first sample feature processing result according to an exemplary embodiment.
[0136] Figure 4 It is a schematic diagram of a flow chart of obtaining a second sample feature processing result according to an exemplary embodiment.
[0137] Figure 5 It is a schematic diagram of a flow chart of obtaining a third sample feature processing result according to an exemplary embodiment.
[0138] Figure 6 The following is a flow chart of a method for generating a graph-generated video model according to an exemplary embodiment. Figure 2 .
[0139] Figure 7 The following is a flow chart of a method for generating a graph-generated video model according to an exemplary embodiment. Figure 3 .
[0140] Figure 8 It is a flowchart of a video generating method according to an exemplary embodiment.
[0141] Fig. 9 The figure is a schematic diagram showing a different FPS and framestride control to generate a motion amplitude and speed of a video according to an exemplary embodiment.
[0142] Fig.10 The present invention is a block diagram of a device for generating a graph-based video model according to an exemplary embodiment.
[0143] Fig.11 The figure is a block diagram of a video generating device according to an exemplary embodiment.
[0144] Fig.12 The invention is a block diagram of an electronic device for image-based video model generation or video generation according to an exemplary embodiment. DETAILED DESCRIPTION
[0145] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.
[0146] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0147] See also Figure 1 , Figure 1 1 is an application environment diagram of a method for generating a graph-generated video model according to an exemplary embodiment. The application environment may include a client 01 and a server 02. The server 02 may communicate with the client 01 in a wired or wireless manner, which is not limited in the present disclosure.
[0148] The server 02 is used to train the image-generated video model and to process the image to be processed by the trained image-generated video model to obtain target video data. Optionally, the server 02 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0149] The client 01 may be used to send a target video data generation request to the server 02 and display the obtained target video data. Optionally, the client may include a smart phone, a desktop computer, a tablet computer, a laptop computer, etc.
[0150] It should be noted that Figure 1 This is only one application environment of the image-generated video model generation method provided in the present disclosure. In practical applications, other application environments may also be included.
[0151] Figure 2 The following is a flow chart of a method for generating a graph-generated video model according to an exemplary embodiment. Figure 1 ,like Figure 2 As shown, this method can be used to Figure 1 In the server in, the method comprises at least the following steps:
[0152] In step S11, sample video data, sample text description information for the sample video data, and a preset Vincent video model are obtained; the preset Vincent video model includes a spatial module and a temporal module, the temporal module includes a temporal self-attention module and a motion adapter module, the motion adapter module is used to control the motion information of the image frame, and the sample video data includes a sample image.
[0153] Optionally, the sample video data may be various types of video data, including a number of frames of sample images, and the present disclosure does not specifically limit the type of the sample video data.
[0154] Optionally, the sample text description information provides semantic information and guidance of the video to be generated, and describes the content or style that is expected to be seen in the generated video data.
[0155] Optionally, the preset Vincent video model (AnimateDiff) is extended from the Vincent image model (StableDiffusion), and the preset Vincent video model includes multiple modules (blocks), and the multiple blocks can be considered to be connected in series, and the output of the previous block can be considered to be the output of the next block. Each block can be divided into a spatial module (spatial block) and a temporal module (temporal block), and the spatial module and the temporal module can be considered to be connected in series, and the output of the spatial module can be considered to be the input of the temporal module. Among them, the spatial module is used to extract spatial features, which comes from the pre-trained graph model (StableDiffusion), which includes a self-attention module and a cross-attention module. Each temporal module includes a preset number of temporal self-attention modules (temp-attention), and the temporal self-attention module is pre-trained from AnimateDiff. The temporal self-attention mechanism can model the feature relationship between different frames, and is mainly used to improve the temporal coherence of the generated video during the video generation process.
[0156] In order to be able to control the motion information of the generated video, and further, to enable the model to model and control the video motion amplitude and speed (for example, the speed of motion, etc.), the present invention injects a lightweight adapter module, namely, the motion adapter module (Motion-Adapter), into the temporal self-attention module, so that the model can model and control the video motion amplitude and speed.
[0157] Exemplarily, a corresponding motion adapter module can be injected into each temporal self-attention module, and the motion adapter module can be considered as a bypass branch of the corresponding temporal self-attention module, that is, the motion adapter module and the corresponding temporal self-attention module can be considered to be in parallel. For example, if the number of temporal self-attention modules is two, a corresponding motion adapter module is set for each temporal self-attention module.
[0158] In step S12, sample images and sample text description information are input into a preset text-generated video model.
[0159] In step S13, spatial feature extraction processing is performed on the sample image and sample text description information based on the spatial module to obtain a first sample feature processing result.
[0160] Optionally, the spatial module is used to extract spatial features, and the sample image and sample text description information can be put into a preset Wensheng video model, and the spatial module is used to perform spatial feature extraction processing on the sample image and sample text description information to obtain a first sample feature processing result. Exemplarily, the first sample feature processing result may include but is not limited to: color, texture, shape and spatial relationship in the image.
[0161] In step S14, the feature relationship between image frames is modeled based on the temporal self-attention module for the first sample feature processing result, so that the image frames are continuous in time, thereby obtaining the second sample feature processing result; and the motion information of the image frames is controlled based on the motion adapter module for the first sample feature processing result, so as to obtain the third sample feature processing result.
[0162] Optionally, after the spatial module processing is completed, the first sample feature processing result output by the spatial module can be used as the input of the temporal self-attention module. The temporal self-attention module performs feature relationship modeling processing between image frames on the first sample feature processing result to make the image frames continuous in time, thereby improving the temporal coherence of the generated video and obtaining the second sample feature processing result.
[0163] At the same time, the first sample feature processing result output by the spatial module can also be used as the input of the motion adapter module, and the motion information of the image frame is controlled and processed by the motion adapter module to control the motion information of the generated video, so as to control the motion amplitude and motion speed (for example, the speed of motion, etc.) of the generated video to obtain the third sample feature processing result.
[0164] It should be noted that, when there are two temporal self-attention modules, the two temporal self-attention modules are connected in series, and each temporal self-attention module is provided with a corresponding motion adapter module, the first sample feature processing result can be processed based on the first temporal self-attention module and the corresponding motion adapter module, respectively, and the processing results of the two are added to obtain the final output of the first temporal self-attention module. Then, the final output of the first temporal self-attention module is processed based on the second temporal self-attention module and the corresponding motion adapter module, and the respective outputs of the second temporal self-attention module and the corresponding motion adapter module are obtained. The respective outputs of the two are added to obtain the final output of the temporal self-attention module, that is, the third sample feature processing result is obtained.
[0165] In step S15, predicted video data is generated according to the second sample feature processing result and the third sample feature processing result.
[0166] In step S16, according to the difference between the preset video data and the sample video data, the parameters of the spatial module and the motion adapter module are updated until the difference meets the preset conditions, thereby obtaining an image-generated video model; the image-generated video model is used to perform video generation processing on the processed image to obtain the target video data.
[0167] Optionally, after obtaining the second sample feature processing result and the third sample feature processing result, the two can be subjected to video conversion processing to obtain predicted video data, and the difference between the preset video data and the sample video data can be calculated, and the parameters of the difference space module and the motion adapter module are adjusted according to the difference until the difference meets the preset conditions, and a graph-generated video model for performing video generation processing on the processed image to obtain the target video data is obtained. That is, during the training process, the parameters of the space module and the motion adapter module are changed, and the parameters of the basic preset Vincent video model are not updated, but the parameters of the basic preset Vincent video model are reused, that is, the space module for controlling the spatial arrangement of the image of the existing preset Vincent video model can be reused.
[0168] Therefore, on the one hand, the present invention realizes the motion information of the generated video through the motion adapter control, and on the other hand, changes the parameters of the spatial module and the motion adapter module during the training process. Instead of updating the parameters of the basic preset Vincent video model, the parameters of the basic preset Vincent video model are reused, that is, the spatial module for controlling the spatial arrangement of the image of the existing preset Vincent video model can be reused, so as to adapt the existing image spatial arrangement control and stylization group at a lower cost, thereby reducing the consumption of system resources by the image-generated video generation process.
[0169] In an optional embodiment, the sample image includes a first-frame sample image and a sample noise image, and the spatial module includes a self-attention module, a cross-attention module, a first adapter module corresponding to the self-attention module, and a second adapter module corresponding to the cross-attention module, the first adapter module is used to extract local image features of the image frame, and the second adapter module is used to extract global image features of the image frame. Figure 3 is a schematic diagram of a process for obtaining a first sample feature processing result according to an exemplary embodiment. Figure 3 As shown, in the above step S13, the above-mentioned spatial module performs spatial feature extraction processing on the sample image and the sample text description information to obtain a first sample feature processing result, including:
[0170] In step S131, the dependency relationship between features of the sample image is modeled based on the self-attention module to obtain the first sample subspace feature; and the local image feature extraction is performed on the first frame sample image and the sample noise image based on the first adapter module to obtain the second sample subspace feature.
[0171] In step S132, a sample output feature of the self-attention module is generated according to the first sample subspace feature and the second sample subspace feature.
[0172] In step S133, based on the cross-attention module, the sample output features, the sample text encoding features and the dependency relationship between the features and the texts are modeled to obtain the third sample subspace features; and based on the second adapter module, the sample output features and the sample image encoding features are subjected to global image feature extraction to obtain the fourth sample subspace features; the sample image encoding features are obtained by encoding the sample images, and the sample text encoding features are obtained by encoding the sample text description information.
[0173] In step S134, a first sample feature processing result is generated according to the third sample subspace feature and the fourth sample subspace feature.
[0174] Optionally, the spatial module may include a self-attention module and a cross-attention module, and the self-attention module and the cross-attention module may be considered to be connected in series, that is, the output of the self-attention module may be considered to be the input of the cross-attention module, and the output of the cross-attention module may be considered to be the output of the spatial module. Among them, the self-attention module may model the dependencies between model features, and is mainly used to determine the spatial arrangement of the generated image / video in the image / video generation model. The cross-attention module may model the dependencies between model features and text features, and may help generate images / videos that conform to the semantics of the input text.
[0175] In addition to the motion adapter, the present disclosure also introduces a lightweight adapter module for the self-attention module, namely the first adapter module (I2V-Adapter), which can be considered as a bypass branch of the self-attention module, which can be considered to be connected in parallel with the self-attention module, that is, the output of the self-attention module and the output of the first adapter module are connected together, which can be considered as the input of the cross-attention module. The first adapter module enables the model to model the fine-grained local information of the input image, that is, the first adapter module is used to extract local image features of the image frame.
[0176] The present disclosure also introduces a lightweight adapter module for the cross-attention module, namely the second adapter module (Content-Adapter), which can be considered as a bypass branch of the cross-attention module, which can be considered to be connected in parallel with the cross-attention module, and the second adapter module enables the model to model the coarse-grained global information of the input image, that is, the second adapter module is used to extract the global image features of the image frame. The Content-Adapter can be pre-trained from the IP-Adapter.
[0177] Optionally, the sample image includes a first frame sample image and a non-first frame sample image, and the non-first frame sample image is subjected to noise processing to obtain a sample noise image corresponding to the non-first frame sample image. For example, the sample video data includes T frames of image frames, the first frame is the first frame sample image, and other image frames (i.e., T-1 frames) except the first frame are non-first frame sample images, then the non-first frame sample image is subjected to noise processing to obtain a T-1 frame random noise image. Wherein, T is a positive integer greater than 1.
[0178] Optionally, in the above step S131, after the sample image and the sample text description information are input into the preset Wensheng video model, the sample image may first be subjected to dependency modeling processing between features based on the self-attention module to obtain a first sample subspace feature, and the calculation formula may be as follows:
[0179]
[0180] Where Q = XW Q , K = XW K , V = XW V , Q represents the query of the self-attention mechanism, K represents the key of the self-attention mechanism, V represents the value of the self-attention mechanism, d is the dimension, X represents the overall characteristics of the sample video data, and the overall characteristics of the sample video data can be reflected by the image characteristics of the sample images included in the sample video data, and W Q , W K , W V They represent the query weight matrix, key weight matrix, and value weight matrix respectively.
[0181] Referring to the above formula, we can first calculate the sample images and W based on the self-attention module. Q , W K , W V The query represents the "interest" of each position in the sample image in other positions. The key is used to match the query in the attention mechanism, and the value contains the specific information of each position in the feature map. Then, the similarity between the query and the key is calculated based on the self-attention module. For example, the product between the query and the key is calculated to obtain QK T . Calculate the quotient of the similarity and the square root of dimension d, and get Attention data is calculated based on the quotient, the softmax function and V, and the attention data is used to characterize the importance of V. V is weighted and summed according to the importance to extract local image features of the image frame and obtain the first sample subspace features.
[0182] At the same time, based on the first adapter module (I2V-Adapter), local image feature extraction processing can be performed on the first frame sample image, sample noise image and sample text description information to obtain the second sample subspace feature. It should be noted that the calculation logic of I2V-Adapter is consistent with the original self-attention. The difference is that I2V-Adapter is a cross-frame attention (Cross-FrameAttention), that is, each frame (sample noise image) performs an attention operation with the first frame without noise (first frame sample image) to extract the fine-grained information of the input image, which is used to maintain the consistency between the subsequent frames of the generated video and the input image. The specific calculation formula can be as follows:
[0183]
[0184] Where Q = XW Q , K 1 =X 1 W′ K , V 1 =X 1 W′ V , Q represents query, K 1 Indicates key, V 1 represents value, X represents the overall characteristics of the sample video data, X 1 Represents the features of the first frame sample image, d is the dimension, W Q , W′ K , W′ V They represent the query weight matrix, key weight matrix and value weight matrix respectively, and d is the dimension.
[0185] Referring to the above formula, the sample image and W can be first calculated based on the first adapter module. Q The product between them is obtained by querying, and the first frame sample image is calculated and W′ K , W′ V Then, the similarity between the query and the key is calculated based on the self-attention module. For example, the product between the query and the key is calculated to obtain Calculate the quotient of the similarity and the square root of dimension d to get Based on the quotient, softmax function and V 1 , calculate the attention data, which is used to represent V 1 According to the importance of V 1 A weighted sum is performed to extract local image features of the image frame to obtain second sample subspace features.
[0186] Optionally, in the above step S132, since the first adapter module is a bypass branch of the self-attention module, the two can be considered to be arranged in parallel. After obtaining the first sample subspace feature and the second sample subspace feature, the sample output feature of the self-attention module can be generated based on the two.
[0187] In one embodiment, the above step S132 may include: adding the first sample subspace feature and the second sample subspace feature to obtain the sample output feature. That is, adding the final output of the I2V-Adapter and the final output of the Self-Attention together as the final output of the self-attention module in one block. The calculation formula may be as follows:
[0188] Attention(Q,K,V)+Attention(Q,K 1 , V 1 );
[0189] Among them, Attention(Q, K, V) refers to the first sample subspace feature, Attention(Q, K 1 , V 1 ) refers to the second sample subspace feature.
[0190] Since the parameters updated in the model training process are the parameters of K and V, rather than updating the output parameter matrix (W o ), so we can directly use Attention(Q, K, V), Attention(Q, K 1 , V 1 ) is added as the final output of the self-attention module without going through a linear layer (i.e. multiplying by W o ) and then added together, which can improve the overall performance of the model.
[0191] Optionally, in the above step S133, since the self-attention module and the spatial attention module are connected in series, the sample output features output by the self-attention module can be used as the input of the cross-attention module. In addition to the sample output features in this input, the input of the cross-attention module can also include sample text encoding features, which are obtained by encoding the sample text description information in advance through a text encoder.
[0192] When the sample output features and sample text encoding features flow to the cross attention module, the cross attention module can model the dependency relationship between the sample output features and sample text encoding features and the text, that is, the dependency relationship between the model features and the text features, which can help generate images / videos that conform to the semantics of the input text and obtain the third sample subspace features. The calculation formula can be as follows:
[0193]
[0194] in, Q, K text 、V text The query, key, and value of the cross-attention mechanism are shown in Figure 2. d represents the dimension, X represents the overall characteristics of the sample video data, and Y represents the sample text encoding characteristics. They represent the query weight matrix, key weight matrix, and value weight matrix respectively.
[0195] Referring to the above formula, we can first calculate the sample image and The product between them is the query, and the sample text encoding features are calculated and W′ K , W′ V Then the cross attention module calculates the similarity between the query and the key, for example, by calculating the product between the query and the key to obtain QK text T . Calculate the quotient of the similarity and the square root of dimension d, and get Based on the quotient, softmax function and V text , calculate the attention data, which is used to represent V text According to the importance of V text Perform weighted summation to obtain the third sample subspace feature.
[0196] At the same time, the sample output features and image coding features can be processed for global image feature extraction based on the second adapter module to obtain the fourth sample subspace feature. The image coding feature is a feature obtained by pre-encoding the sample image using an image encoder. The Content-Adapter is used to inject the input image features encoded by the image encoder into the image-generated video model, which enhances the model's understanding of the semantic information of the input image and improves the global stability of the generated video. The specific calculation formula can be as follows:
[0197]
[0198] in, Q, K image 、V image They represent the query, key, and value of the cross attention mechanism, X represents the overall characteristics of the feature sample video data, and V image represents the image encoding features, They represent the query weight matrix, key weight matrix, and value weight matrix respectively.
[0199] Referring to the above formula, we can first calculate the sample image and The product between them is the query, and the image encoding features are calculated respectively with Then, based on the Content-Adapter, we calculate the similarity between the query and the key. For example, we calculate the product between the query and the key to get QK image T . Calculate the quotient of the similarity and the square root of dimension d, and get Based on the quotient, softmax function and V image , calculate the attention data, which is used to represent V image According to the importance of V text A weighted sum is performed to extract the global image features of the image frame and obtain the fourth sample subspace features.
[0200] Optionally, in the above step S134, the third sample subspace feature and the fourth sample subspace feature may be added to obtain a first sample feature processing result, and the first sample feature processing result may be considered as the final output of a space module in a block, and the final output of the space module in a block will be used as the input of the timing module in the block. The calculation formula may be as follows:
[0201] Attention(Q,K text , V text )+Attention(Q,K image , V image );
[0202] Among them, Attention(Q, K text , V text ) refers to the third sample subspace feature, Attention(Q, K image , V image ) refers to the fourth sample subspace feature.
[0203] Therefore, the present invention injects a lightweight Adapter module (I2V-Adapter) into the self-attention layer (Self-Attention) so that the model can model the fine-grained local information of the input image, and injects a lightweight Adapter module (Content-Adapter) into the cross-attention layer (Cross-Attention) so that the model can model the coarse-grained global information of the input image. On the one hand, the accuracy of feature extraction by the model is improved, thereby improving the generation accuracy of image-generated videos. On the other hand, due to the addition of the lightweight Adapter module, it is only necessary to adjust the newly added parameters during the parameter adjustment process without retraining the entire model, thereby reducing the consumption of system resources during the model training process.
[0204] Figure 4 is a schematic diagram of a process for obtaining a second sample feature processing result according to an exemplary embodiment. Figure 4 As shown, in an optional embodiment, in the above step S14, the above temporal self-attention module performs feature relationship modeling processing between image frames on the first sample feature processing result to make the image frames continuous in time sequence, and obtains the second sample feature processing result, which may include:
[0205] In step S141-1, based on the temporal self-attention module, the product of the first sample feature processing result and the corresponding query weight matrix is determined to obtain a sample query, the product of the first sample feature processing result and the corresponding key weight matrix is determined to obtain a second sample key, and the product of the first sample feature processing result and the corresponding value weight matrix is determined to obtain a second sample value.
[0206] In step S141-2, the similarity between the sample query and the second sample key is determined based on the temporal self-attention module to obtain second sample attention data; the second sample attention data represents the importance of the second sample value.
[0207] In step S141-3, the second sample value is weightedly processed through the second sample attention data based on the temporal self-attention module to obtain the second sample feature processing result.
[0208] In this embodiment, the final output of the spatial module in the block can be used as the input of the temporal self-attention module in the block, and the temporal self-attention module calculates the second sample feature processing result based on the following formula:
[0209]
[0210] in, Q temp , K temp 、Vtemp They refer to the query, key, and value of the cross-attention mechanism respectively. X represents the result of the first sample feature processing. They represent the query weight matrix, key weight matrix and value weight matrix respectively, and d represents the dimension.
[0211] Referring to the above formula, the temporal self-attention module can first calculate the product of the first sample feature processing result and the query weight matrix, the key weight matrix, and the value weight matrix to obtain the sample query, the second sample key, and the second sample value. Then the temporal self-attention module calculates the similarity between the sample query and the second sample key. For example, the product between the sample query and the second sample key is calculated to obtain Then calculate the quotient of the similarity and the square root of dimension d, and get Based on the quotient, softmax function and V temp , calculate the first sample attention data, which is used to characterize the importance of the second sample value. According to the importance, the second sample value is weighted and summed to obtain the second sample feature processing result. In this way, the feature relationship between different frames can be modeled, which is mainly used to improve the temporal coherence of the generated video during the video generation process.
[0212] It should be noted that Q temp , K temp , V temp The shape of is (BHW)×F×C, which means that they perform attention calculations on the temporal frame dimension, while the shapes of Q, K, V of spatial self-attention are (BF)×(HW)×C (they perform attention calculations on the height and width dimensions in space). Among them, B is the number of samples (batchsize), H is the height (height), W is the width (width), F is the number of frames (frames), C is the number of channels (channel), and frame is the time dimension / inter-frame dimension.
[0213] Figure 5 is a schematic diagram of a process for obtaining a third sample feature processing result according to an exemplary embodiment. Figure 5 As shown, in an optional embodiment, in the above step S14, the above motion adapter module performs motion information control processing of the first sample feature processing result on the image frame to obtain the third sample feature processing result, which may include:
[0214] In step S143 - 1 , sample timing sampling information of the sample video data is obtained; the sample timing sampling information is used to characterize the number of frames per second and the frame extraction step of the sample video data.
[0215] In step S143-2, based on the motion adapter module, the product of the first sample feature processing result and the corresponding query weight matrix is determined to obtain the sample query, and the product of the sample timing sampling information and the corresponding key weight matrix is determined to obtain the first sample key, and the product of the sample timing sampling information and the corresponding value weight matrix is determined to obtain the first sample value.
[0216] In step S143 - 3 , the similarity between the sample query and the first sample key is determined based on the motion adapter module to obtain first sample attention data; the first sample attention data represents the importance of the first sample value.
[0217] In step S143-4, the first sample value is weightedly processed based on the first sample attention data by the motion adapter module to obtain a third sample feature processing result.
[0218] Since the motion adapter module is a bypass branch module of the temporal self-attention module, it is connected in series with the temporal self-attention module. Therefore, the final output of the spatial module in a block can be used as the input of the motion adapter module in the block. The function of the motion adapter module is to inject the original sample timing sampling information of the sample video data. The sample timing sampling information may include the number of frames per second (FPS) and the frame step (framestride) of the sample video data. Among them, the frame step may refer to how many frames are sampled for one frame. Different FPS and framestrides indicate the speed and amplitude of the movement of the image frames actually used for training. Generally speaking, the smaller the FPS and the larger the framestride, the greater the motion speed and amplitude of the captured image frames, and vice versa.
[0219] Exemplarily, the motion adapter module calculates the third sample feature processing result based on the following formula:
[0220]
[0221] in, Q temp And Q in the temporal self-attention module temp Similarly, F represents the sample timing sampling information. Respectively represent the key weight matrix and value weight matrix, K motion , V motion They represent the key and value extracted from the sample timing sampling information (indicating the features of FPS and framestride).
[0222] Referring to the above formula, the motion adapter module can first calculate the product of the first sample feature processing result and the query weight matrix to obtain the sample query Q temp, calculate the product of the sample timing sampling information and the corresponding key weight matrix to obtain the first sample key weight matrix K motion , calculate the product of the sample timing sampling information and the corresponding value weight matrix to obtain the first sample value V motion Next, the motion adapter module calculates the similarity between the sample query and the first sample key, for example, by calculating the product between the sample query and the first sample key to obtain Then calculate the quotient of the similarity and the square root of dimension d, and get Based on the quotient, softmax function and V motion , calculate the first sample attention data, the first sample attention data is used to characterize the importance of the first sample value. The first sample value is weighted and summed according to the importance to control the motion information of the image frame to obtain the second sample feature processing result. In this way, the motion information of the generated video can be controlled by the motion adapter, for example, the motion amplitude and motion speed of the generated video can be controlled by the motion adapter.
[0223] In an optional embodiment, in the above step S15, generating predicted video data according to the second sample feature processing result and the third sample feature processing result may include:
[0224] The second sample feature processing result and the third sample feature processing result are added to obtain the sample time series feature.
[0225] Perform video conversion processing on the sample time series features to obtain predicted video data.
[0226] In this embodiment, since the motion adapter module is a bypass branch module of the temporal self-attention module, the motion adapter module and the temporal self-attention module can be connected in parallel, and the inputs of the motion adapter module and the temporal self-attention module can be added as the final output of the temporal self-attention module to obtain the final output of a block. The final output of a block is used as the final input of the next block, and the next block obtains the final output of the next block in the above manner, and so on, until the final output of the last block is obtained. Then, an additional mathematical transformation is performed on the final output of the last block to obtain the predicted video data. Due to the introduction of the motion adapter module, the motion amplitude and motion speed of the generated predicted video data can be controlled.
[0227] Figure 6 The following is a flow chart of a method for generating a graph-generated video model according to an exemplary embodiment. Figure 2 ,like Figure 6As shown, in an optional embodiment, in the above step S16, the above updating the parameters of the space module and the motion adapter module according to the difference between the preset video data and the sample video data includes:
[0228] In step S161, loss data is calculated according to the difference between the preset video data and the sample video data.
[0229] In step S163, the parameters of the self-attention module, the parameters of the cross-attention module, the parameters of the second adapter module, and the parameters of the temporal self-attention module are frozen, and the parameters of the first adapter module and the parameters of the motion adapter module are updated based on the loss data.
[0230] In this embodiment, after the predicted video data is predicted, the loss data can be calculated according to the difference between the preset video data and the sample video data. Exemplarily, the training loss function of the diffusion model can be used. For any sample video data v and its sample text description information c and sample time series sampling information F (FPS and framestride), the loss function is defined as:
[0231]
[0232] in, are two hyperparameters in the diffusion model. v1 represents the first frame sample image of the sample video data v, ∈ is random Gaussian noise, which can be considered as taking sample video data, ∈ θ is the entire graph-generated video model, all of whose parameters are represented by θ. This disclosure only updates some of the parameters θ′ (i.e., the matrix ),∈ θ (α t v+σ t ∈, c, t, v1, f) can be considered as the predicted video data, t can refer to the noise addition time of the diffusion model, and c can refer to the text.
[0233] After calculating the loss data, the parameters of the self-attention module, the cross-attention module, the second adapter module, and the temporal self-attention module can be frozen, and the parameters of the first adapter module and the motion adapter module can be updated based on the loss data, that is, only the parameters of the I2V-Adapter module and the Motion-Adapter module are trained, and the parameter weights of the IP-Adatper and the basic Vincent video model are not updated, so as to reuse the weights of the basic Vincent video model, that is, the spatial module for controlling the spatial arrangement of the image of the existing preset Vincent video model can be reused, so as to adapt the existing image spatial arrangement control and stylization group at a lower cost, thereby reducing the consumption of system resources by the image-generated video generation process.
[0234] In an optional embodiment, in the above step S163, the above updating the parameters of the first adapter module and the parameters of the motion adapter module based on the loss data may include:
[0235] The key weight matrix and the value weight matrix included in the parameters of the first adapter module are updated based on the loss data, and the key weight matrix and the value weight matrix included in the parameters of the motion adapter module are updated.
[0236] The disclosed embodiment only trains the I2V-Adapter module and the Motion-Adapter module. The parameters of the first adapter module include the query weight matrix, the key weight matrix and the value weight matrix, and the parameters of the motion adapter module include the query weight matrix, the key weight matrix and the value weight matrix. The disclosed embodiment specifically only trains the key weight matrix W′ included in the parameters of the parameter matrix first adapter module K The sum value weight matrix W′V, and the key weight matrix included in the parameters of the updated motion adapter module Sum weight matrix And only train the parameter matrix W′ K , W′ V as well as The advantage is that the difference between I2V-Adapter and Self-Attention is that the sources of K and V are different, so W is fixed. Q , updating K and V can reuse the features of Q as much as possible, and the mathematical formula is consistent with Content-Adapter and Motion-Adapter. The parameter weight matrix W′ of I2V-Adapter and Motion-Adapter modules K and is randomly initialized, the parameter weight matrix W′ V and is initialized to all zeros, in particular, the parameter weight matrices W′V and All-zero initialization makes I2V-Adapter ineffective at the beginning of training, and the pre-trained model is used as much as possible. Through training, it can gradually take effect. Therefore, it can smoothly migrate from the text-generated video model to the image-generated video model, accelerate the training convergence process, and improve the model training efficiency.
[0237] The following is an overall description of the above-mentioned image-generated video model generation method:
[0238] Figure 7 The following is a flow chart of a method for generating a graph-generated video model according to an exemplary embodiment. Figure 3 ,like Figure 7 As shown, the above-mentioned image-generated video model generation method includes:
[0239] Step 1: Obtain sample video data, sample text description information for the sample video data, and a preset Vincent video model; the preset Vincent video model includes M blocks connected in series, where M is a positive integer greater than 1. Each block includes a spatial module and a temporal module. The spatial module includes a self-attention module, a cross-attention module, a first adapter module corresponding to the self-attention module, and a second adapter module corresponding to the cross-attention module. The first adapter module is used to extract local image features of the image frame, and the second adapter module is used to extract global image features of the image frame. The temporal module includes two temporal self-attention modules and a motion adapter module corresponding to each temporal self-attention module. The motion adapter module is used to control the motion information of the image frame. The sample video data includes a sample image.
[0240] Step 2: Input the sample image and sample text description information into the preset Wensheng video model, perform spatial feature extraction processing on the sample image and sample text description information based on the spatial module in the first block, and obtain the first sample feature processing result. For details, please refer to the above steps S131-S134.
[0241] Step 3: Based on the temporal self-attention module in the temporal module in the first block, the first sample feature processing result is modeled with the feature relationship between the image frames to make the image frames continuous in time sequence, and the second sample feature processing result is obtained; and based on the motion adapter module, the first sample feature processing result is processed with motion information control of the image frame to obtain the third sample feature processing result. For details, please refer to the above steps S141-1 to S141-3, and the above steps S143-1 to S143-4.
[0242] Step 4: Add the second sample feature processing result and the third sample feature processing result to obtain the sample timing feature, which can be considered as the final output of the first block.
[0243] Step 5: Input the final output of the first block into the second block, and generate the final output of the first block according to the above steps 2 to 4, and so on, to obtain the final output of the Mth block.
[0244] Step 6: Perform video conversion processing on the final output of the Mth block to obtain predicted video data.
[0245] Step 7: Calculate loss data based on the difference between the preset video data and the sample video data; freeze the parameters of the self-attention module, the parameters of the cross-attention module, the parameters of the second adapter module, and the parameters of the temporal self-attention module, and update the key weight matrix and value weight matrix included in the parameters of the first adapter module based on the loss data, as well as update the key weight matrix and value weight matrix included in the parameters of the motion adapter module, until the difference meets the preset conditions to obtain the image-generated video model.
[0246] Figure 8 is a flow chart of a video generation method according to an exemplary embodiment. Figure 8 As shown, the video generation method includes:
[0247] In step S21, the image to be processed, a preset number of frames of noisy images, text description information and an image-generated video model are obtained; the text description information is used to describe the target video data to be generated; the image-generated video model includes a spatial module and a temporal module, the temporal module includes a temporal self-attention module and a motion adapter module, and the motion adapter module is used to control the motion information of the video frame.
[0248] Optionally, the image to be processed may be an image of various types, and the present disclosure does not specifically limit the type of the image to be processed.
[0249] Optionally, the preset number of noise image frames may be randomly generated noise images, and the preset number is determined according to the number of target video data to be generated. For example, if the generated target video data includes N image frames, the preset number of noise image frames may be randomly generated N-1 noise images, where N is a positive integer greater than 1.
[0250] Optionally, the graph-generated video model includes multiple modules (blocks), and the multiple blocks can be considered to be connected in series, and the output of the previous block can be considered to be the output of the next block. Each block can be divided into a spatial module (spatial block) and a temporal module (temporal block), and the temporal module includes a temporal self-attention module and a motion adapter module, and the motion adapter module is used to control the motion information of the video frame. It should be noted that the structure of the spatial module (spatial block) and the temporal module (temporal block) here is the same as the structure of the spatial module (spatial block) and the temporal module (temporal block) summarized in the training process, and no specific limitation is made to this.
[0251] In step S22, the image to be processed, text description information and the noise image are input into the image-generated video model.
[0252] In step S23, spatial feature extraction processing is performed on the image to be processed, the text description information and the noise image based on the spatial module to obtain a first feature processing result.
[0253] Optionally, the spatial module is used to extract spatial features, and the image to be processed, the text description information, and the noisy image can be input into a trained image-generated video model, and the image to be processed, the text description information, and the noisy image can be processed by the spatial module to extract spatial features to obtain a first feature processing result. Exemplarily, the first feature processing result may include, but is not limited to: color, texture, shape, and spatial relationship in the image.
[0254] In step S24, based on the temporal self-attention module, the feature relationship between image frames is modeled on the first feature processing result to make the image frames temporally coherent, thereby obtaining the second feature processing result; and based on the motion adapter module, the motion information of the image frames is controlled on the first feature processing result to obtain the third feature processing result.
[0255] Optionally, after the spatial module processing is completed, the first feature processing result output by the spatial module can be used as the input of the temporal self-attention module. The temporal self-attention module performs feature relationship modeling processing between image frames on the first feature processing result to make the image frames continuous in time, thereby improving the temporal coherence of the generated video and obtaining the second feature processing result.
[0256] At the same time, the first feature processing result output by the spatial module can also be used as the input of the motion adapter module, and the motion information of the image frame can be controlled and processed by the motion adapter module to control the motion information of the generated video, and further control the motion amplitude and motion speed (for example, the speed of motion, etc.) of the generated video to obtain the third feature processing result.
[0257] In step S25, target video data is generated according to the second feature processing result and the third feature processing result.
[0258] Optionally, after obtaining the second feature processing result and the third feature processing result, video conversion processing may be performed on the two to obtain target video data.
[0259] As a result, the motion information of the generated video is controlled by the motion adapter, and the existing image space arrangement control and stylization group can be adapted at a lower cost, thereby reducing the consumption of system resources in the image-generated video generation process.
[0260] In an optional embodiment, in the above step S23, the above-mentioned spatial module-based spatial feature extraction processing is performed on the image to be processed, the text description information and the noise image to obtain the first feature processing result, which may include:
[0261] Based on the self-attention module, the dependency relationship between features of the processed image is modeled to obtain the first subspace feature; and based on the first adapter module, local image feature extraction is performed on the processed image and the noise image to obtain the second subspace feature.
[0262] Generate output features of the self-attention module according to the first subspace features and the second subspace features.
[0263] Based on the cross-attention module, the output features, text encoding features and the dependency relationship between the texts are modeled to obtain the third subspace features; and based on the second adapter module, the output features and image encoding features are globally extracted to obtain the fourth subspace features; the image encoding features are the features obtained by encoding the image to be processed, and the text encoding features are obtained by encoding the text description information.
[0264] A first feature processing result is generated according to the third subspace feature and the fourth subspace feature.
[0265] It should be noted that the process of generating the first feature processing result is the same as the process of generating the first sample feature processing result in the above steps S131 to S134, and will not be repeated here.
[0266] Therefore, the present invention injects a lightweight Adapter module (I2V-Adapter) into the self-attention layer (Self-Attention) so that the model can model the fine-grained local information of the input image, and injects a lightweight Adapter module (Content-Adapter) into the cross-attention layer (Cross-Attention) so that the model can model the coarse-grained global information of the input image. On the one hand, the accuracy of feature extraction by the model is improved, thereby improving the generation accuracy of image-generated videos.
[0267] In an optional embodiment, the generating of the first feature processing result according to the third subspace feature and the fourth subspace feature may include:
[0268] The first subspace feature and the second subspace feature are added to obtain the output feature. Thus, there is no need to go through a linear layer (i.e., multiply by W O ) and then added together, which can improve the overall performance of the model.
[0269] In an optional embodiment, in the above step S24, the above temporal self-attention module performs feature relationship modeling processing between image frames on the first feature processing result to make the image frames temporally coherent, and obtains the second feature processing result, which may include:
[0270] Based on the temporal self-attention module, the product of the first feature processing result and the corresponding query weight matrix is determined to obtain the query; and the product of the first feature processing result and the corresponding key weight matrix is determined to obtain the second key; and the product of the first feature processing result and the corresponding value weight matrix is determined to obtain the second value.
[0271] Based on the temporal self-attention module, the similarity between the query and the second key is determined to obtain second attention data; the second attention data represents the importance of the second value.
[0272] Based on the temporal self-attention module, a weighted summation process is performed on the second value through the second attention data to obtain a second feature processing result.
[0273] It should be noted that the above process of generating the second feature processing result is the same as the process of generating the second sample feature processing result in the above steps S141 - 1 to S141 - 3, and will not be repeated here.
[0274] This makes it possible to model the feature relationship between different frames and improve the temporal coherence of the generated video during the video generation process.
[0275] In an optional embodiment, in the above step S24, the motion adapter module performs motion information control processing on the first feature processing result to obtain a third feature processing result, which may include:
[0276] Acquire preset timing sampling information; the sample timing sampling information is used to characterize the number of frames per second and the frame extraction step of the target data to be generated.
[0277] Based on the motion adapter module, the product of the first feature extraction result and the corresponding query weight matrix is determined to obtain the query; and the product of the preset timing sampling information and the corresponding key weight matrix is determined to obtain the first key; and the product of the preset timing sampling information and the corresponding value weight matrix is determined to obtain the first value.
[0278] The similarity between the query and the first key is determined based on the motion adapter module to obtain first attention data; the first attention data represents the importance of the first value.
[0279] Based on the motion adapter module, a weighted summation process is performed on the first value through the first attention data to obtain a third feature processing result.
[0280] Optionally, the preset timing sampling information is pre-set and is used to characterize the number of frames per second and the frame extraction step length of the target data to be generated.
[0281] It should be noted that the process of generating the third feature processing result is the same as the process of generating the third sample feature processing result in the above steps S143-1 to S143-4, and will not be repeated here.
[0282] Therefore, the motion information of the generated video can be controlled by the motion adapter, for example, the motion amplitude and motion speed of the generated video can be controlled by the motion adapter.
[0283] In an optional embodiment, in the above step S25, generating the target video data according to the second feature processing result and the third feature processing result may include:
[0284] The second feature processing result and the third feature processing result are added together to obtain the time series feature.
[0285] The target video data is obtained by performing video conversion processing on the time series features.
[0286] In this embodiment, since the motion adapter module is a bypass branch module of the temporal self-attention module, the motion adapter module and the temporal self-attention module can be connected in parallel, and the inputs of the motion adapter module and the temporal self-attention module can be added as the final output of the temporal self-attention module to obtain the final output of a block. The final output of a block is used as the final input of the next block, and the next block obtains the final output of the next block in the above manner, and so on, until the final output of the last block is obtained. Then, an additional mathematical transformation is performed on the final output of the last block to obtain the predicted video data. Due to the introduction of the motion adapter module, the motion amplitude and motion speed of the generated predicted video data can be controlled.
[0287] The video generated by the image-generated video model provided by the embodiment of the present disclosure has the following beneficial effects:
[0288] 1) Table 1 is a comparison of the effects of the video generated by the image-generated video model of the present invention and the video generated by the image-generated video model in the prior art. As shown in Table 1, the aesthetic score (DoverVQA), first frame consistency (CLIPTemp), and motion amplitude (FlowScore) of the video generated by the image-generated video model of the present invention are better than those of the video generated by the image-generated video model in the prior art, and the WarpingError of the video generated by the image-generated video model of the present invention is smaller than that of the video generated by the image-generated video model in the prior art, wherein the WarpingError is mainly used to measure the topological shape effect of the segmentation target.
[0289] Table 1 Comparison of the effects of videos generated by the image-generated video model disclosed in the present invention and those generated by the image-generated video model in the prior art
[0290] DoverVQA CLIPTemp FlowScore WarpingError Prior art 0.0847 0.9365 0.6883 20.8362 The Disclosure 0.0891 0.9382 0.7134 12.2647
[0291] 2) The video generated by the image-generated video model provided by the embodiment of the present disclosure can control the motion amplitude and speed of the generated video:
[0292] Fig. 9 is a schematic diagram showing a different FPS and framestride control for generating a motion amplitude and speed of a video according to an exemplary embodiment. Fig. 9 The FPS and framestride from top to bottom are: FPS=30; frameStride=1, FPS=30; frameStride=3, FPS=30; frameStride=10.
[0293] like Fig. 9 As shown, when the FPS is the same, the larger the frameStride is, the greater the image frame motion speed and motion amplitude are.
[0294] 3) The number of training parameters is reduced to 20% of the Stable Video Diffusion model.
[0295] 4) The number of training iterations is reduced to 5.7% of the Stable Video Diffusion model.
[0296] 5) The amount of training data is reduced to 18% of the Stable Video Diffusion model.
[0297] Fig.10 FIG. 1 is a block diagram of a device for generating a video model based on an image according to an exemplary embodiment. Fig.10 , the device comprises:
[0298] The sample data model acquisition module 31 is configured to execute acquisition of sample video data, sample text description information for the sample video data, and a preset Vincent video model; the preset Vincent video model includes a spatial module and a temporal module, the temporal module includes a temporal self-attention module and a motion adapter module, the motion adapter module is used to control motion information of an image frame, and the sample video data includes a sample image;
[0299] The sample data input module 32 is configured to input the sample image and the sample text description information into the preset Wensheng video model;
[0300] A spatial feature processing module 33 is configured to perform spatial feature extraction processing on the sample image and the sample text description information based on the spatial module to obtain a first sample feature processing result;
[0301] The temporal feature processing module 34 is configured to perform feature relationship modeling processing between image frames based on the temporal self-attention module on the first sample feature processing result, so that the image frames are continuous in time sequence, to obtain a second sample feature processing result; and perform motion information control processing of the image frame based on the motion adapter module on the first sample feature processing result, to obtain a third sample feature processing result;
[0302] A predicted video data generating module 35 is configured to generate predicted video data according to the second sample feature processing result and the third sample feature processing result;
[0303] The updating module 36 is configured to update the parameters of the spatial module and the motion adapter module according to the difference between the preset video data and the sample video data until the difference meets the preset conditions, thereby obtaining a graph-generated video model; the graph-generated video model is used to perform video generation processing on the processed image to obtain the target video data.
[0304] In an optional embodiment, the above-mentioned time series feature processing module includes:
[0305] A sample timing sampling information acquisition unit is configured to acquire sample timing sampling information of the sample video data; the sample timing sampling information is used to characterize the number of frames per second and the frame extraction step of the sample video data;
[0306] a first product determination unit, configured to perform, based on the motion adapter module, determining the product of the first sample feature processing result and the corresponding query weight matrix to obtain a sample query, and determining the product of the sample timing sampling information and the corresponding key weight matrix to obtain a first sample key, and determining the product of the sample timing sampling information and the corresponding value weight matrix to obtain a first sample value;
[0307] A first sample attention data determining unit is configured to determine the similarity between the sample query and the first sample key based on the motion adapter module to obtain first sample attention data; the first sample attention data represents the importance of the first sample value;
[0308] The third sample feature processing result generating unit is configured to perform weighted processing on the first sample value based on the motion adapter module through the first sample attention data to obtain the third sample feature processing result.
[0309] In an optional embodiment, the above-mentioned time series feature processing module includes:
[0310] A second product determination unit is configured to determine the product of the first sample feature processing result and the corresponding query weight matrix based on the temporal self-attention module to obtain a sample query, determine the product of the first sample feature processing result and the corresponding key weight matrix to obtain a second sample key, and determine the product of the first sample feature processing result and the corresponding value weight matrix to obtain a second sample value;
[0311] A second sample attention data determination unit is configured to determine the similarity between the sample query and the second sample key based on the temporal self-attention module to obtain second sample attention data; the second sample attention data represents the importance of the second sample value;
[0312] The second sample feature processing result generating unit is configured to perform weighted processing on the second sample value through the second sample attention data based on the temporal self-attention module to obtain the second sample feature processing result.
[0313] In an optional embodiment, the above-mentioned predicted video data generation module includes:
[0314] a sample time series feature generating unit, configured to add the second sample feature processing result and the third sample feature processing result to obtain a sample time series feature;
[0315] The conversion unit is configured to perform video conversion processing on the sample timing features to obtain the predicted video data.
[0316] In an optional embodiment, the spatial module includes a self-attention module, a cross-attention module, a first adapter module corresponding to the self-attention module, and a second adapter module corresponding to the cross-attention module, wherein the first adapter module is used to extract local image features of the image frame, and the second adapter module is used to extract global image features of the image frame; the above-mentioned update module includes:
[0317] a loss data calculation unit, configured to calculate loss data according to a difference between the preset video data and the sample video data;
[0318] A freeze update unit is configured to freeze the parameters of the self-attention module, the parameters of the cross-attention module, the parameters of the second adapter module, and the parameters of the temporal self-attention module, and update the parameters of the first adapter module and the parameters of the motion adapter module based on the loss data.
[0319] In an optional embodiment, the parameters of the first adapter module include a key weight matrix and a value weight matrix, the parameters of the motion adapter module include a key weight matrix and a value weight matrix, the key weight matrix included in the parameters of the first adapter module and the key weight matrix included in the parameters of the motion adapter module are randomly initialized, and the value weight matrix included in the parameters of the first adapter module and the value weight matrix included in the parameters of the motion adapter module are initialized to all zeros;
[0320] The freezing and updating unit comprises:
[0321] The key-value updating subunit is configured to update the key weight matrix and the value weight matrix included in the parameters of the first adapter module based on the loss data, and to update the key weight matrix and the value weight matrix included in the parameters of the motion adapter module.
[0322] In an optional embodiment, the sample image includes a first frame sample image and a sample noise image, the spatial module includes a self-attention module, a cross-attention module, a first adapter module corresponding to the self-attention module, and a second adapter module corresponding to the cross-attention module, the first adapter module is used to extract local image features of the image frame, and the second adapter module is used to extract global image features of the image frame;
[0323] The spatial feature processing module comprises:
[0324] The first and second sample subspace feature acquisition units are configured to perform dependency relationship modeling processing on the sample image based on the self-attention module to obtain the first sample subspace feature; and perform local image feature extraction processing on the first frame sample image and the sample noise image based on the first adapter module to obtain the second sample subspace feature;
[0325] A sample output feature generating unit, configured to generate a sample output feature of the self-attention module according to the first sample subspace feature and the second sample subspace feature;
[0326] The third sample subspace feature acquisition unit is configured to perform a dependency modeling process on the sample output feature and the sample text encoding feature based on the cross attention module, and obtain a third sample subspace feature; and perform a global image feature extraction process on the sample output feature and the sample image encoding feature based on the second adapter module, and obtain a fourth sample subspace feature; the sample image encoding feature is obtained by encoding the sample image, and the sample text encoding feature is obtained by encoding the sample text description information;
[0327] The feature processing result generating unit is configured to generate the first sample feature processing result according to the third sample subspace feature and the fourth sample subspace feature.
[0328] In an optional embodiment, the sample output feature generation unit is further configured to execute:
[0329] The first sample subspace feature and the second sample subspace feature are added to obtain the sample output feature.
[0330] Fig.11 is a block diagram of a video generation device according to an exemplary embodiment. Fig.11 , the device comprises:
[0331] The data model acquisition module 41 is configured to acquire an image to be processed, a preset number of frames of noise images, text description information, and an image-generated video model; the text description information is used to describe the target video data to be generated; the image-generated video model includes a spatial module and a temporal module, the temporal module includes a temporal self-attention module and a motion adapter module, and the motion adapter module is used to control the motion information of the video frame;
[0332] A data input module 42 is configured to input the image to be processed, the text description information and the noise image into the image-generated video model;
[0333] A first feature processing result generating module 43 is configured to perform spatial feature extraction processing on the image to be processed, the text description information and the noise image based on the spatial module to obtain a first feature processing result;
[0334] The second feature processing result generating module 44 is configured to perform feature relationship modeling processing between image frames on the first feature processing result based on the temporal self-attention module to make the image frames coherent in time sequence, thereby obtaining a second feature processing result; and perform motion information control processing of the image frames on the first feature processing result based on the motion adapter module to obtain a third feature processing result;
[0335] The target video data generating module 45 is configured to generate target video data according to the second feature processing result and the third feature processing result.
[0336] In an optional embodiment, the sample time series feature processing module includes:
[0337] A preset timing sampling information acquisition unit is configured to acquire preset timing sampling information; the sample timing sampling information is used to characterize the number of frames per second and the frame extraction step of the target data to be generated;
[0338] A first query key value generating unit is configured to perform a query based on the motion adapter module by determining the product of the first feature extraction result and the corresponding query weight matrix; and determining the product of the preset timing sampling information and the corresponding key weight matrix to obtain a first key; and determining the product of the preset timing sampling information and the corresponding value weight matrix to obtain a first value;
[0339] A first attention data generating unit is configured to determine the similarity between the query and the first key based on the motion adapter module to obtain first attention data; the first attention data represents the importance of the first value;
[0340] The third feature processing result generating unit is configured to perform weighted summation processing on the first value through the first attention data based on the motion adapter module to obtain the third feature processing result.
[0341] In an optional embodiment, the sample time series feature processing module includes:
[0342] A second query key value generating unit is configured to perform the steps of determining the product of the first feature processing result and the corresponding query weight matrix based on the temporal self-attention module to obtain a query; determining the product of the first feature processing result and the corresponding key weight matrix to obtain a second key; and determining the product of the first feature processing result and the corresponding value weight matrix to obtain a second value;
[0343] A second attention data generating unit is configured to determine the similarity between the query and the second key based on the temporal self-attention module to obtain second attention data; the second attention data represents the importance of the second value;
[0344] The second feature processing result generating unit is configured to perform weighted summation processing on the second value through the second attention data based on the temporal self-attention module to obtain the second feature processing result.
[0345] In an optional embodiment, the target video data generating module includes:
[0346] a time series feature generating unit, configured to add the second feature processing result and the third feature processing result to obtain a time series feature;
[0347] The video data conversion unit is configured to perform video conversion processing on the timing feature to obtain the target video data.
[0348] In an optional embodiment, the spatial module includes a self-attention module, a cross-attention module, a first adapter module corresponding to the self-attention module, and a second adapter module corresponding to the cross-attention module, wherein the first adapter module is used to model local image features of the image frame, and the second adapter module is used to model global image features of the image frame;
[0349] The sample space feature processing module includes:
[0350] The first and second subspace feature generation units are configured to perform dependency modeling processing on the image to be processed based on the self-attention module to obtain a first subspace feature; and perform local image feature extraction processing on the image to be processed, the noise image and the text description information based on the first adapter module to obtain a second subspace feature;
[0351] an output feature generating unit, configured to generate an output feature of the self-attention module according to the first subspace feature and the second subspace feature;
[0352] The third and fourth subspace feature generation units are configured to perform a dependency modeling process on the output features, the text encoding features and the texts based on the cross attention module to obtain a third subspace feature; and perform a global feature extraction process on the output features and the image encoding features based on the second adapter module to obtain a fourth subspace feature; the image encoding feature is a feature obtained by encoding the image to be processed, and the text encoding feature is obtained by encoding the text description information;
[0353] The first feature processing result generating unit is configured to generate the first feature processing result according to the third subspace feature and the fourth subspace feature.
[0354] In an optional embodiment, the output feature generating unit is further configured to execute:
[0355] The first subspace feature and the second subspace feature are added to obtain the output feature.
[0356] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0357] In an exemplary embodiment, an electronic device for image processing is also provided, comprising a processor; a memory for storing instructions executable by the processor; wherein when the processor is configured to execute the instructions stored in the memory, it implements the steps of any image-generated video model generation method or video generation method in the above-mentioned embodiments.
[0358] The electronic device may be a terminal, a server or a similar computing device. For example, the electronic device is a server. Fig.12It is a block diagram of an electronic device for image-generated video model generation or video generation according to an exemplary embodiment. The electronic device 50 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 51 (the central processing unit 51 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 53 for storing data, and one or more storage media 52 (such as one or more mass storage devices) for storing application programs 523 or data 522. Among them, the memory 53 and the storage medium 52 can be short-term storage or permanent storage. The program stored in the storage medium 52 may include one or more modules, each of which may include a series of instruction operations in the electronic device. Furthermore, the central processing unit 51 can be configured to communicate with the storage medium 52 to execute a series of instruction operations in the storage medium 52 on the electronic device 50. The electronic device 50 may also include one or more power supplies 56, one or more wired or wireless network interfaces 55, one or more input and output interfaces 54, and / or one or more operating systems 521, such as Windows Server TM, Mac OS X TM, Unix TM, Linux TM, FreeBSD TM, etc.
[0359] The input / output interface 54 may be used to receive or send data via a network. The specific example of the network may include a wireless network provided by a communication provider of the electronic device 50. In one example, the input / output interface 54 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In an exemplary embodiment, the input / output interface 54 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0360] It can be understood by those skilled in the art that Fig.12 The structure shown is only for illustration and does not limit the structure of the above electronic device. Fig.12 More or fewer components as shown, or with Fig.12 Different configurations are shown.
[0361] In an exemplary embodiment, a computer-readable storage medium is also provided. When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device can perform the steps of any image-generated video model generation method or video generation method in the above-mentioned embodiments.
[0362] In an exemplary embodiment, a computer program product is also provided, including a computer program, which, when executed by a processor, implements the image-generated video model generation method or video generation method provided in any of the above-mentioned embodiments.
[0363] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present disclosure can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0364] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0365] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A method for generating a graph-based video model, characterized in that: The method comprises: Acquire sample video data, sample text description information for the sample video data, and a preset Vincent video model; the preset Vincent video model includes a spatial module and a temporal module, the temporal module includes a temporal self-attention module and a motion adapter module, the motion adapter module is used to control motion information of an image frame, and the sample video data includes a sample image; Inputting the sample image and the sample text description information into the preset Wensheng video model; Performing spatial feature extraction processing on the sample image and the sample text description information based on the spatial module to obtain a first sample feature processing result; Based on the temporal self-attention module, the first sample feature processing result is subjected to feature relationship modeling processing between image frames, so that the image frames are continuous in time sequence, and a second sample feature processing result is obtained; and based on the motion adapter module, the first sample feature processing result is subjected to motion information control processing of the image frame, and a third sample feature processing result is obtained; Generate predicted video data according to the second sample feature processing result and the third sample feature processing result; According to the difference between the preset video data and the sample video data, the parameters of the space module and the motion adapter module are updated until the difference meets the preset conditions, thereby obtaining an image-generated video model; the image-generated video model is used to perform video generation processing on the processed image to obtain the target video data.
2. The method for generating a graph-based video model according to claim 1, characterized in that: The step of performing motion information control processing of the image frame on the first sample feature processing result based on the motion adapter module to obtain a third sample feature processing result includes: Acquire sample timing sampling information of the sample video data; the sample timing sampling information is used to characterize the number of frames per second and the frame extraction step length of the sample video data; Determine, based on the motion adapter module, the product of the first sample feature processing result and the corresponding query weight matrix to obtain a sample query, determine the product of the sample timing sampling information and the corresponding key weight matrix to obtain a first sample key, and determine the product of the sample timing sampling information and the corresponding value weight matrix to obtain a first sample value; Determine the similarity between the sample query and the first sample key based on the motion adapter module, and obtain first sample attention data; the first sample attention data represents the importance of the first sample value; Based on the motion adapter module, the first sample value is weightedly processed through the first sample attention data to obtain the third sample feature processing result.
3. The method for generating a graph-based video model according to claim 1, characterized in that: The step of performing feature relationship modeling processing between image frames on the first sample feature processing result based on the temporal self-attention module so as to make the image frames continuous in time sequence, and obtaining a second sample feature processing result, comprises: Determine, based on the temporal self-attention module, the product of the first sample feature processing result and the corresponding query weight matrix to obtain a sample query, determine the product of the first sample feature processing result and the corresponding key weight matrix to obtain a second sample key, and determine the product of the first sample feature processing result and the corresponding value weight matrix to obtain a second sample value; Determine the similarity between the sample query and the second sample key based on the temporal self-attention module, and obtain second sample attention data; the second sample attention data represents the importance of the second sample value; Based on the temporal self-attention module, the second sample value is weightedly processed through the second sample attention data to obtain the second sample feature processing result.
4. The method for generating a graph-based video model according to claim 1, characterized in that: The generating predicted video data according to the second sample feature processing result and the third sample feature processing result comprises: Adding the second sample feature processing result and the third sample feature processing result to obtain a sample time series feature; The sample time series features are subjected to video conversion processing to obtain the predicted video data.
5. The method for generating a graph-based video model according to claim 1, characterized in that: The spatial module includes a self-attention module, a cross-attention module, a first adapter module corresponding to the self-attention module, and a second adapter module corresponding to the cross-attention module, wherein the first adapter module is used to extract local image features of an image frame, and the second adapter module is used to extract global image features of an image frame; The updating of the parameters of the spatial module and the motion adapter module according to the difference between the preset video data and the sample video data comprises: Calculating loss data according to the difference between the preset video data and the sample video data; Freeze the parameters of the self-attention module, the parameters of the cross-attention module, the parameters of the second adapter module, and the parameters of the temporal self-attention module, and update the parameters of the first adapter module and the parameters of the motion adapter module based on the loss data.
6. The method for generating a graph-based video model according to claim 5, characterized in that: The parameters of the first adapter module include a key weight matrix and a value weight matrix, the parameters of the motion adapter module include a key weight matrix and a value weight matrix, the key weight matrix included in the parameters of the first adapter module and the key weight matrix included in the parameters of the motion adapter module are randomly initialized, and the value weight matrix included in the parameters of the first adapter module and the value weight matrix included in the parameters of the motion adapter module are initialized to all zeros; The updating of the parameters of the first adapter module and the model parameters of the motion adapter module based on the loss data comprises: A key weight matrix and a value weight matrix included in the parameters of the first adapter module are updated based on the loss data, and a key weight matrix and a value weight matrix included in the parameters of the motion adapter module are updated.
7. The method for generating a graph-based video model according to any one of claims 1 to 6, characterized in that: The sample image includes a first frame sample image and a sample noise image, the spatial module includes a self-attention module, a cross-attention module, a first adapter module corresponding to the self-attention module, and a second adapter module corresponding to the cross-attention module, the first adapter module is used to extract local image features of the image frame, and the second adapter module is used to extract global image features of the image frame; The performing spatial feature extraction processing on the sample image and the sample text description information based on the spatial module to obtain a first sample feature processing result includes: Based on the self-attention module, the sample image is subjected to dependency modeling processing between features to obtain a first sample subspace feature; and based on the first adapter module, the first frame sample image and the sample noise image are subjected to local image feature extraction processing to obtain a second sample subspace feature; Generate a sample output feature of the self-attention module according to the first sample subspace feature and the second sample subspace feature; Based on the cross attention module, the sample output feature and the sample text encoding feature are subjected to feature and text dependency modeling processing to obtain a third sample subspace feature; and based on the second adapter module, the sample output feature and the sample image encoding feature are subjected to global image feature extraction processing to obtain a fourth sample subspace feature; the sample image encoding feature is obtained by encoding the sample image, and the sample text encoding feature is obtained by encoding the sample text description information; The first sample feature processing result is generated according to the third sample subspace feature and the fourth sample subspace feature.
8. The method for generating a graph-based video model according to claim 7, characterized in that: The generating the sample output feature of the self-attention module according to the first sample subspace feature and the second sample subspace feature comprises: The first sample subspace feature and the second sample subspace feature are added to obtain the sample output feature.
9. A video generation method, characterized in that: The video generation method comprises: Acquire an image to be processed, a preset number of frames of noisy images, text description information and an image-generated video model; the text description information is used to describe the target video data to be generated; the image-generated video model includes a spatial module and a temporal module, the temporal module includes a temporal self-attention module and a motion adapter module, and the motion adapter module is used to control the motion information of the video frame; Inputting the image to be processed, text description information and the noise image into the image-generated video model; Based on the spatial module, spatial feature extraction processing is performed on the image to be processed, the text description information and the noise image to obtain a first feature processing result; Based on the temporal self-attention module, the first feature processing result is subjected to feature relationship modeling processing between image frames, so that the image frames are temporally coherent, thereby obtaining a second feature processing result; and based on the motion adapter module, the first feature processing result is subjected to motion information control processing of the image frames, thereby obtaining a third feature processing result; Generate target video data according to the second feature processing result and the third feature processing result.
10. The video generation method according to claim 9, characterized in that: The step of performing motion information control processing of the image frame on the first feature processing result based on the motion adapter module to obtain a third feature processing result includes: Acquire preset timing sampling information; the sample timing sampling information is used to characterize the number of frames per second and the frame extraction step of the target data to be generated; Determine the product of the first feature extraction result and the corresponding query weight matrix based on the motion adapter module to obtain a query; and determine the product of the preset timing sampling information and the corresponding key weight matrix to obtain a first key; and determine the product of the preset timing sampling information and the corresponding value weight matrix to obtain a first value; Determine the similarity between the query and the first key based on the motion adapter module, and obtain first attention data; the first attention data represents the importance of the first value; The motion adapter module performs weighted sum processing on the first value through the first attention data to obtain the third feature processing result.
11. The video generation method according to claim 9, characterized in that: The step of performing feature relationship modeling processing between image frames on the first feature processing result based on the temporal self-attention module to make the image frames temporally coherent to obtain a second feature processing result includes: Determine the product of the first feature processing result and the corresponding query weight matrix based on the temporal self-attention module to obtain a query; determine the product of the first feature processing result and the corresponding key weight matrix to obtain a second key; and determine the product of the first feature processing result and the corresponding value weight matrix to obtain a second value; Determine the similarity between the query and the second key based on the temporal self-attention module to obtain second attention data; the second attention data represents the importance of the second value; Based on the temporal self-attention module, the second value is weightedly summed up through the second attention data to obtain the second feature processing result.
12. The video generation method according to claim 9, characterized in that: The generating target video data according to the second feature processing result and the third feature processing result includes: Adding the second feature processing result and the third feature processing result to obtain a time series feature; The target video data is obtained by performing video conversion processing on the timing features.
13. The video generation method according to any one of claims 10 to 12, characterized in that: The spatial module includes a self-attention module, a cross-attention module, a first adapter module corresponding to the self-attention module, and a second adapter module corresponding to the cross-attention module, wherein the first adapter module is used to model local image features of an image frame, and the second adapter module is used to model global image features of an image frame; The performing spatial feature extraction processing on the image to be processed, the text description information and the noise image based on the spatial module to obtain a first feature processing result includes: Based on the self-attention module, the dependency relationship between features of the image to be processed is modeled to obtain a first subspace feature; and based on the first adapter module, local image feature extraction is performed on the image to be processed, the noise image and the text description information to obtain a second subspace feature; Generate an output feature of the self-attention module according to the first subspace feature and the second subspace feature; Based on the cross attention module, the output feature and the text encoding feature are subjected to feature and text dependency modeling processing to obtain a third subspace feature; and based on the second adapter module, the output feature and the image encoding feature are subjected to global feature extraction processing to obtain a fourth subspace feature; the image encoding feature is a feature obtained by encoding the image to be processed, and the text encoding feature is obtained by encoding the text description information; The first feature processing result is generated according to the third subspace feature and the fourth subspace feature.
14. The video generation method according to claim 13, characterized in that: Generating the output feature of the self-attention module according to the first subspace feature and the second subspace feature includes: The first subspace feature and the second subspace feature are added to obtain the output feature.
15. A device for generating a graph-based video model, characterized in that: The device comprises: A sample data model acquisition module is configured to execute acquisition of sample video data, sample text description information for the sample video data, and a preset Vincent video model; the preset Vincent video model includes a spatial module and a temporal module, the temporal module includes a temporal self-attention module and a motion adapter module, the motion adapter module is used to control motion information of an image frame, and the sample video data includes a sample image; A sample data input module, configured to input the sample image and the sample text description information into the preset Wensheng video model; A spatial feature processing module, configured to perform spatial feature extraction processing on the sample image and the sample text description information based on the spatial module to obtain a first sample feature processing result; a temporal feature processing module configured to perform feature relationship modeling processing between image frames on the first sample feature processing result based on the temporal self-attention module, so that the image frames are continuous in time sequence, and obtain a second sample feature processing result; and perform motion information control processing of the image frame on the first sample feature processing result based on the motion adapter module, and obtain a third sample feature processing result; A predicted video data generating module, configured to generate predicted video data according to the second sample feature processing result and the third sample feature processing result; The updating module is configured to update the parameters of the spatial module and the motion adapter module according to the difference between the preset video data and the sample video data until the difference meets the preset conditions to obtain the image-generated video model; the image-generated video model is used to perform video generation processing on the processed image to obtain the target video data.
16. A video generating device, characterized in that: include: A data model acquisition module is configured to acquire an image to be processed, a preset number of frames of noisy images, text description information, and an image-generated video model; The text description information is used to describe the target video data to be generated; the image-generated video model includes a spatial module and a temporal module, the temporal module includes a temporal self-attention module and a motion adapter module, and the motion adapter module is used to control the motion information of the video frame; A data input module is configured to input the image to be processed, the text description information and the noise image into the image-generated video model; A sample space feature processing module is configured to perform space feature extraction processing on the image to be processed, the text description information and the noise image based on the space module to obtain a first feature processing result; a sample time series feature processing module, configured to perform feature relationship modeling processing between image frames on the first feature processing result based on the time series self-attention module, so as to make the image frames coherent in time series, and obtain a second feature processing result; and performing motion information control processing of the image frame on the first feature processing result based on the motion adapter module to obtain a third feature processing result; The target video data generating module is configured to generate target video data according to the second feature processing result and the third feature processing result.
17. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the image-generated video model generation according to any one of claims 1 to 8 or the video generation method according to any one of claims 9 to 14.
18. A computer-readable storage medium, when the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device executes the image-generated video model generation method as described in any one of claims 1 to 8 or the video generation method as described in any one of claims 9 to 14.
Citation Information
Cited By
Video generation method and device, electronic equipment and computer readable storage medium
CN119364146A
Video generation method, device, electronic device and computer-readable storage medium
CN119364146B
Graphics video model training method and device, equipment and storage medium
CN119629426A
Graphics video generation method based on non-training strategy and multi-subject attention alignment
CN120050481A
Video generation method, system and model
CN122073636A
