Video generation method and device, medium and computer equipment
By retrieving matching videos from the video database and inputting the target text into the video generation model, the problem of poor quality of Chinese text videos in the prior art is solved, more coherent and high-quality video generation is achieved, and the need for high-quality text-video pairs is reduced. rely.
Patent Information
- Application Number
- CN202311078346.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-24
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2043-08-24
AI Technical Summary
Existing text video generation technology requires a large number of text video pairs for model training, and high-quality text video pairs are scarce, resulting in poor video generation quality, especially jitter and incoherence problems.
By retrieving matching videos that semantically match the target text from the video database, and inputting the target text and matching videos into the video generation model, semantic and temporal information are used to improve video generation quality, reduce jitter, and improve video coherence.
Improves the video quality output by the video generation model, reduces jitter, reduces the need for high-quality text-video pairs, and enhances the versatility and user experience of video generation.
Smart Images

Figure CN117095085B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of video processing technology, and in particular to a video generation method and apparatus, a medium and a computer device. Background Art
[0002] AI-generated content (AIGC) refers to content generated by generative AI technology. Text-to-video is a specific application scenario of AIGC, that is, by inputting text into a video generation model and generating video through the video generation model. The current text-to-video method requires a large number of text-video pairs to train the video generation model. Since the video files are relatively large, the training of the video generation model requires high computing power. In addition, high-quality text-video pairs are very scarce, so it is difficult to train a high-quality video generation model, resulting in poor quality of videos generated by the video generation model. Summary of the invention
[0003] In a first aspect, an embodiment of the present disclosure provides a video generation method, the method comprising: obtaining a target text; retrieving a matching video that semantically matches the target text from a video database; inputting the target text and the matching video into a target video generation model; and obtaining a target video output by the target video generation model.
[0004] In some embodiments, retrieving a matching video that semantically matches the target text from a video database includes: obtaining semantic features corresponding to the target text; obtaining video features corresponding to a plurality of candidate videos in the video database, the video features being used to characterize semantic information of the corresponding candidate videos; and determining a matching video that semantically matches the target text from the plurality of candidate videos based on the semantic features corresponding to the target text and the video features corresponding to the plurality of candidate videos.
[0005] In some embodiments, determining a matching video that semantically matches the target text from the multiple candidate videos based on the semantic features corresponding to the target text and the video features corresponding to the multiple candidate videos respectively includes: determining the similarity between the semantic features corresponding to the target text and the video features corresponding to each candidate video in the multiple candidate videos; and determining the candidate video corresponding to at least one video feature having a descending similarity with the semantic features corresponding to the target text as the matching video.
[0006] In some embodiments, obtaining video features corresponding to multiple candidate videos in the video database includes: determining at least one key frame from the candidate video; performing feature extraction on each key frame of the at least one key frame to obtain features of each key frame; and obtaining video features corresponding to the candidate video frame based on the features of each key frame.
[0007] In some embodiments, retrieving a matching video that semantically matches the target text from a video database includes: obtaining keyword tags corresponding to multiple candidate videos in the video database, the keyword tags being used to characterize the semantic categories to which the corresponding candidate videos belong; determining a degree of match between the target text and the keyword tags corresponding to each of the multiple candidate videos; and determining the candidate video corresponding to at least one keyword tag with the highest degree of match with the target text from highest to lowest as the matching video.
[0008] In some embodiments, the target video generation model is trained based on the following method: based on the first sample text and the sample image that semantically matches the first sample text, the image generation model is pre-trained to obtain a pre-trained model; based on the second sample text and the sample matching video that semantically matches the second sample text, the pre-trained model after adding the attention module is fine-tuned to obtain the target video generation model; the attention module is used to extract the temporal features in the sample matching video.
[0009] In some embodiments, the target text includes multiple text blocks, the matching videos that semantically match the target text include matching videos that semantically match each of the multiple text blocks, and the target video includes the target video corresponding to each text block; the method also includes: fusing the target videos corresponding to each text block to obtain a fused video.
[0010] In some embodiments, the target video corresponding to the i+1th text block among the multiple text blocks is generated by the target video generation model based on the i+1th text block, a matching video that semantically matches the i+1th text block, and video features corresponding to the target video corresponding to the i-th text block among the multiple text blocks, where i is a positive integer.
[0011] In some embodiments, the target video generation model is trained based on the following method: pre-training an initial video generation model based on at least one sample data to obtain the target video generation model; wherein each sample data in the at least one sample data includes: a sample text block; a sample matching video that semantically matches the sample text block; and a sample video feature corresponding to a sample matching video that semantically matches a previous sample text block in the sample text to which the sample text block belongs.
[0012] In some embodiments, the target video generation model is trained based on the following method: multiple sample data are input into an initial video generation model; each of the multiple sample data includes a sample text block among multiple sample text blocks included in the sample text and a sample matching video that semantically matches the sample text block; a sample output video corresponding to each sample text block output by the initial video generation model is obtained; the initial video generation model is trained based on the video features corresponding to the sample output video corresponding to each sample text block and preset conditions to obtain the target video generation model; the preset conditions include: a first similarity between a video feature corresponding to a first sample output video and a video feature corresponding to a second sample output video is less than a second similarity between a video feature corresponding to the first sample output video and a video feature corresponding to a reference video, and the first similarity is less than a third similarity between a video feature corresponding to the second sample output video and a video feature corresponding to the reference video; the first sample output video and the second sample output video are sample output videos corresponding to adjacent sample text blocks, respectively, and the reference video is a video obtained from a video database.
[0013] In some embodiments, each of the multiple pieces of sample data further includes a sample video feature corresponding to a sample matching video that semantically matches a previous sample text block in the sample text to which the sample text block belongs.
[0014] In some embodiments, retrieving a matching video that semantically matches the target text from a video database includes: extracting key information from the target text, where the key information is related to the visual features of the target text; and retrieving a matching video that semantically matches the target text from a video database based on the key information.
[0015] In some embodiments, the method further includes: performing smoothing processing on adjacent target videos in the fused video.
[0016] In a second aspect, an embodiment of the present disclosure provides a video generation device, which includes: a text acquisition module for acquiring a target text; a retrieval module for retrieving a matching video that semantically matches the target text from a video database; an input module for inputting the target text and the matching video into a target video generation model; and a video acquisition module for acquiring a target video output by the target video generation model.
[0017] In a third aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in any embodiment of the present disclosure.
[0018] In a fourth aspect, an embodiment of the present disclosure provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in any embodiment of the present disclosure when executing the program.
[0019] In the disclosed embodiment, after obtaining the target text, a matching video that semantically matches the target text can be retrieved from a video database, and then the target text and the matching video are used together as inputs to a target video generation model. In this way, in the process of generating the target video, the target video generation model can not only obtain the semantic information in the target text, but also the semantic information and timing information in the matching video, thereby making the target video output by the target video generation model more coherent, reducing the jitter of the target video, and improving the quality of the target video output by the target video generation model.
[0020] It is to be understood that both 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
[0021] The drawings herein are incorporated into the specification and constitute a part of the present disclosure. These drawings illustrate embodiments consistent with the present disclosure and are used to illustrate the technical solutions of the present disclosure together with the specification.
[0022] Figure 1 It is a schematic diagram of an application scenario of an embodiment of the present disclosure.
[0023] Figure 2 It is a flowchart of the video generation method of an embodiment of the present disclosure.
[0024] Figure 3A and Figure 3B They are respectively schematic diagrams of the video matching process of the embodiments of the present disclosure.
[0025] Figure 4 It is a schematic diagram of the training process of the target video generation model of an embodiment of the present disclosure.
[0026] Figure 5 It is a block diagram of a video generating device according to an embodiment of the present disclosure.
[0027] Figure 6 is a schematic diagram of a computer device according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0028] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. 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.
[0029] The terms used in this disclosure are only for the purpose of describing specific embodiments and are not intended to limit the disclosure. The singular forms of "a", "said" and "the" used in this disclosure and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items. In addition, the term "at least one" herein means any combination of at least two of any one or more of a plurality of.
[0030] It should be understood that although the terms first, second, third, etc. may be used in the present disclosure to describe various information, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present disclosure, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0031] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present disclosure and to make the above-mentioned purposes, features and advantages of the embodiments of the present disclosure more obvious and understandable, the technical solutions in the embodiments of the present disclosure are further described in detail below in conjunction with the accompanying drawings.
[0032] Text-to-video refers to the way in which a video generation model generates a video based on the input text. Figure 1 In some embodiments, the text includes the content "a boy is playing football". The text is input into the video generation model, and the video generation model can generate a video that is semantically related to the text, and the content presented in the video is also "a boy is playing football".
[0033] In the related art, a large number of text-video pairs are needed to train the video generation model. Each text-video pair needs to include a text and a video that is semantically related to the text. However, since the video files are relatively large, the training of the video generation model requires high computing power. In addition, high-quality text-video pairs are very scarce. Therefore, it is difficult to train a high-quality video generation model, resulting in poor quality of the video generated by the video generation model, for example, there are a lot of jitters and incoherence.
[0034] Based on this, the present disclosure provides a video generation method, see Figure 2 , the method comprising:
[0035] Step S1: Obtain target text;
[0036] Step S2: Retrieving a matching video that semantically matches the target text from a video database;
[0037] Step S3: inputting the target text and the matching video into a target video generation model;
[0038] Step S4: Obtain the target video output by the target video generation model.
[0039] The disclosed embodiment combines video retrieval with target video generation. After obtaining the target text, it is possible to retrieve a matching video that semantically matches the target text from a video database, and then use the target text and the matching video together as the input of the target video generation model. In this way, in the process of generating the target video, the target video generation model can not only obtain the semantic information in the target text, but also obtain the semantic information and timing information in the matching video, so that the target video output by the target video generation model is more coherent, the jitter of the target video is reduced, and the quality of the target video output by the target video generation model is improved. In addition, the disclosed embodiment adopts a retrieval method to obtain a matching video that semantically matches the target text from a video database. The user only needs to input the target text into the target video generation model without inputting the matching video, which improves the versatility of the target video generation. In addition, the user does not need to pay attention to which video needs to be input as the matching video into the target video generation model, and the whole process is user-friendly. The specific implementation details of the disclosed embodiment are illustrated below.
[0040] In step S1, the target text can be edited and input by the user, determined by recognizing the user's voice information, or obtained from other methods such as a web page. The content of the target text can be news, novels, narration descriptions (such as narrating a complete story), dialogue content (such as dialogue subtitles in a movie), etc., and the present disclosure does not limit this. The target text may include at least one sentence. In some embodiments, the target text may be divided into blocks to obtain multiple text blocks. Among them, each text block may include a semantically complete content in the target text. Optionally, the target text may be split according to punctuation marks. For example, the target text may be split according to punctuation marks (referred to as terminators) such as periods, question marks, and exclamation marks that indicate the end of a sentence. The text between two terminators may be regarded as a text block. Alternatively, the target text may be divided into text blocks according to paragraphs. For example, each paragraph in the target text may be regarded as a text block. The target text may also be divided into line text blocks based on semantic understanding. In addition to the above-listed methods, other methods may be used to divide text blocks, which are not listed here one by one.
[0041] In step S2, the video database may be a pre-established offline database or an online database, and the video database may include multiple videos. Some or all of the videos in the video database may be used as candidate videos, and matching videos that semantically match the target text may be retrieved from the candidate videos. The number of matching videos may be greater than or equal to 1. When the number is greater than 1, each matching video may be used as an input to the target video generation model, so that the diversity of the generated target video can be improved. The following is an example of a method for retrieving matching videos.
[0042] See also Figure 3A In one approach, a matching video may be determined by feature matching. Specifically, a semantic feature corresponding to the target text and video features corresponding to a plurality of candidate videos may be obtained, and a matching video that semantically matches the target text may be determined from the plurality of candidate videos based on the semantic feature corresponding to the target text and the video features corresponding to the plurality of candidate videos.
[0043] For the target text, the target text can be encoded (for example, the target text can be encoded using a CLIP text encoder), and a feature vector g of the target text is obtained after encoding, and the feature vector g is used as a semantic feature corresponding to the target text.
[0044] For each candidate video, a feature vector can be extracted from the candidate video. Assuming that the number of candidate videos is N, the feature vectors extracted from each candidate video can be recorded as f_1, f_2, ..., f_N, where f_i (1≤i≤N) is the feature vector extracted from the i-th candidate video, and the feature vector f_i is the video feature corresponding to the i-th candidate video, which can be used to characterize the semantic information of the i-th candidate video.
[0045] In some embodiments, at least one key frame can be determined from the candidate video. For example, a key frame can be determined every M video frames, or an I frame in the video can be determined as a key frame, or a certain frame in the video can be extracted as a key frame, or all video frames in the video can be determined as key frames. After determining the key frame, feature extraction can be performed on each key frame to obtain the features of the key frame. For example, each key frame can be input into a pre-trained image feature extraction model (VIT, CLIP model, etc.) to obtain the features of the key frame. Then, based on the features of each key frame, the video features corresponding to the candidate video frame are obtained. For example, the features of each key frame can be pooled (for example, average pooling or maximum pooling) to obtain the video features corresponding to the candidate video frame.
[0046] See also Figure 3B In other embodiments, the candidate video may be directly input into a video feature extraction model (such as TimeSformer, I3D, SlowFast, etc.) to obtain the features of the candidate video. Extracting the video features of the candidate video through the video feature extraction model is conducive to extracting the temporal features in the candidate video.
[0047] After obtaining the feature vector g and the feature vectors f_1, f_2, ..., f_N, the feature vector g can be used to perform similarity matching on the feature vectors f_1, f_2, ..., f_N of the N candidate videos, that is, the similarity between the feature vector g and each of the feature vectors f_1, f_2, ..., f_N is calculated respectively, and at least one video feature with a high to low similarity to the feature vector g is obtained, denoted as f_x1, f_x2, ..., f_xk, and the candidate videos corresponding to the video features f_x1, f_x2, ..., f_xk are determined as matching videos.
[0048] The feature vectors f_1, f_2, ..., f_N corresponding to the candidate videos in the above embodiment can be extracted in advance and stored in the video database in association with each candidate video. In this way, when determining the matching video, the pre-stored feature vector can be directly obtained from the video database without extracting features from the candidate video, thereby improving the efficiency of determining the matching video. Alternatively, the video database can also only store the candidate video without storing the feature vectors corresponding to the candidate video. In the case where it is necessary to determine the matching video from the candidate videos, the candidate video can be obtained from the video database, and the feature extraction of the candidate video can be performed to obtain the feature vectors corresponding to each candidate video.
[0049] In another way, matching videos can be determined by keyword matching. Specifically, keyword tags corresponding to multiple candidate videos in a video database can be obtained; the matching degree between the target text and the keyword tag corresponding to each candidate video in the multiple candidate videos can be determined; and the candidate video corresponding to at least one keyword tag with the highest to lowest matching degree with the target text can be determined as a matching video.
[0050] The keyword tag is used to characterize the semantic category to which the corresponding candidate video belongs. The semantic category may include but is not limited to at least one of the following:
[0051] The categories of actions performed by the target object in the candidate video, including the categories of body movements (e.g., running, kicking a ball, climbing a mountain, squatting) and / or the categories of facial expressions (e.g., smiling, crying, opening the mouth, blinking, etc.);
[0052] Attribute categories of the target object in the candidate video, including but not limited to the gender, age, etc. of the target object;
[0053] The scene category presented in the candidate video, for example, forest, grassland, city, indoor, outdoor, etc.;
[0054] The climate category presented in the candidate video, for example, windy, snowy, sunny, rainy, etc.
[0055] Semantic categories can also be divided according to other conditions, which are not listed here. Each semantic category has its corresponding semantic features. For example, when the semantic category includes the category of the action performed by the target object in the candidate video, the semantic feature corresponding to the candidate video is used to characterize the action performed by the target object in the candidate video; when the semantic category includes the attribute category of the target object in the candidate video, the semantic feature corresponding to the candidate video is used to characterize the attribute of the target object in the candidate video.
[0056] The keyword tags corresponding to the candidate videos can be pre-generated and stored in the video database in association with the candidate videos. In this way, when determining the matching video, the pre-stored keyword tags can be directly obtained from the video database without executing the keyword tag generation process, thereby improving the efficiency of determining the matching video. Alternatively, the video database can also only store the candidate videos without storing the keyword tags corresponding to the candidate videos. In the case where it is necessary to determine the matching video from the candidate videos, the candidate videos can be obtained from the video database and the keyword tags corresponding to the candidate videos can be generated. The keyword tags can be generated by a neural network for generating keyword tags, or generated by other methods.
[0057] In this way, it is possible to obtain matching videos that semantically match the target text. For example, if the target text is "a boy is dancing", the matching videos searched are also videos of a boy dancing.
[0058] In some embodiments, if the target text is relatively long, or the target text includes more descriptive information about the facial features of visual features, for example, descriptive information about people's psychological activities or personality characteristics, key information can be extracted from the target text, and a matching video that matches the semantics of the target text can be retrieved from the video database based on the key information. Among them, the key information is related to the visual features in the target text, including but not limited to the appearance, action and / or object of the target object described in the target text. Usually, the key information includes at least part of the subject, predicate and object of the target text. For example, the target text is as follows: "After a psychological struggle, the timid and cowardly little girl finally made up her mind and handed the competition registration form to the teacher". In the above target text, the descriptive information such as "timid and cowardly", "after a psychological struggle", "made up her mind" is difficult to present visually, but the above content occupies a considerable amount of space in the target text, so these contents may affect the feature matching and keyword matching of the target text. In order to solve the above problem, the following key information can be extracted from the target text: "The little girl handed the competition registration form to the teacher". Among them, "little girl" is the target object described by the target text, "handed over to" is the action of the target object, and "competition registration form" and "teacher" are the objects targeted by the target object's action.
[0059] After extracting the key information, feature matching can be performed based on the semantic features corresponding to the key information and the video features corresponding to the candidate videos in the video database, or keyword matching can be performed based on the key information and the key frame tags corresponding to the candidate videos in the video database, so as to determine the matching video corresponding to the target text.
[0060] When the target text includes multiple text blocks, each text block can be determined as a segment of target text, and a matching video can be determined for each text block using any of the above methods, thereby obtaining one or more matching videos corresponding to each text block.
[0061] In step S3 and step S4, the target text and the matching video can be input into the target video generation model together, and the target video that matches the semantics of the target text can be output through the target video generation model. When the target text includes multiple text blocks, each text block and the matching video that matches the semantics of each text block can be input into the target video generation model, so that the target video that matches the semantics of each text block can be output through the target video generation model. For example, the matching video that matches the semantics of the i-th text block (i is a positive integer) can be input into the target video generation model, so that the target video that matches the semantics of the i-th text block can be output through the target video generation model. Assuming that the target text includes X (X is a positive integer) text blocks, X segments of target video can be generated in the end.
[0062] Furthermore, the video features corresponding to the i+1th text block, the matching video semantically matched to the i+1th text block, and the target video corresponding to the i-th text block can be input into the target video generation model, so as to output the target video semantically matched to the i+1th text block through the target video generation model. In this way, when generating the target video corresponding to each text block, the target video generation module can refer to the video features of the target video corresponding to the previous text block, thereby improving the feature consistency between the target videos corresponding to different text blocks.
[0063] After obtaining the target videos corresponding to each text block, the target videos corresponding to each text block can also be fused to obtain a fused video. For example, the target videos corresponding to each text block can be spliced to obtain a fused video. Through the above method, the embodiment of the present disclosure can generate a fused video with a longer duration (hereinafter referred to as a long video). Among them, a long video can refer to a video with a duration greater than 10s. In order to further improve the consistency of each target video in the fused video, each target video in the fused video can also be smoothed. For example, optical flow estimation and depth map estimation algorithm (Depth-Aware Video Frame Interpolation, DAIN), real-time intermediate optical flow estimation algorithm (Real-TimeIntermediate Flow Estimation, RIFE) and other interpolation methods are used for smoothing, so that the transition between the beginning and the end of adjacent target videos in the fused video is more natural.
[0064] In the related art, if a long video (for example, a video with a duration greater than 10 seconds) needs to be generated, a text-video pair including a long video and text is required to train the target video generation model. This further increases the difficulty of obtaining sample data and the computing power requirements. The disclosed embodiment divides the target text into blocks, generates a shorter target video for each text block, and then merges the generated target videos to obtain a longer long video. In this way, there is no need to use a text-video pair including a long video and text to train the target video generation model, which reduces the difficulty of obtaining sample data and the computing power requirements during training.
[0065] The target video generation model used in the above embodiment can be obtained by pre-training. The specific method of training the target video generation model is described below by way of example.
[0066] In some embodiments, the image generation model can be pre-trained based on the first sample text and the sample image semantically matching the first sample text to obtain a pre-trained model. Then, the pre-trained model with the attention module added can be fine-tuned based on the second sample text and the sample matching video semantically matching the second sample text to obtain a target video generation model. The attention module is used to extract temporal features in the sample matching video.
[0067] In this embodiment, the image generation model is first trained through text-image pairs (i.e., the first sample text and the sample image). Since the data volume of the text-image pairs is large and the quality is usually high, a large number of text-image pairs can be obtained to train a high-quality image generation model. Then, an attention module is added to the pre-trained model obtained through training, and the pre-trained model with the attention module added is fine-tuned using text-video pairs (i.e., the second sample text and the sample matching video). On the one hand, the data volume of the text-video pairs required for the fine-tuning process is small, which reduces the model training cost; on the other hand, the fine-tuned model can extract temporal features, so that the video generated by the trained target video generation model has higher quality.
[0068] It is understandable that the above training method is only an exemplary description. The disclosed embodiment can also directly use the second sample text and the sample matching video that semantically matches the second sample text to pre-train the initial video generation model, thereby obtaining the target video generation model. Among them, the sample matching video can be obtained by the feature matching or keyword matching method in the aforementioned embodiment, which will not be repeated here.
[0069] In some embodiments, the second sample text may include multiple sample text blocks. On this basis, each sample text block and a sample matching video semantically matching the sample text block may be used as a sample data to train a target video generation model. Furthermore, each sample data used to train the target video generation model may include, in addition to the sample text block and a sample matching video semantically matching the sample text block, a sample video feature corresponding to a sample matching video semantically matching the previous sample text block in the sample text where the sample text block is located.
[0070] For example, assuming that the sample text includes sample text block A, sample text block B and sample text block C in sequence, three pieces of sample data may be generated, namely:
[0071] Sample data 1, including a sample text block A and a sample matching video semantically matching the sample text block A;
[0072] Sample data 2, including sample text block B, a sample matching video semantically matching the sample text block B, and sample video features corresponding to the sample matching video semantically matching the sample text block A;
[0073] Sample data 3 includes sample text block C, a sample matching video semantically matching sample text block C, and sample video features corresponding to the sample matching video semantically matching sample text block B.
[0074] The initial video generation model can be pre-trained based on the sample data to obtain a target video generation model, wherein the initial video generation model can be a pre-trained model obtained by training text-image pairs, or can be the untrained initial video generation model.
[0075] It is worth noting that in the embodiment where the sample text and the target text are divided into multiple text blocks, the initial video generation model has three inputs (respectively, the sample text block, the sample matching video semantically matched with the sample text block, and the sample video features corresponding to the sample matching video semantically matched with the previous sample text block in the sample text where the sample text block is located, referred to as the previous sample video features), and the trained target video generation model also has three inputs. Among them, the previous sample video features can be used as the initial input and input into the backbone network of the initial video generation model and the target video generation model. The main network can be, for example, a stable diffusion UNet. Alternatively, the previous sample video features can be used as a conditional input and input into the initial video generation model and the target video generation model as a priori information through a cross-attention mechanism. In the embodiment where the sample text and the target text are not divided into text blocks, that is, the sample text is used as a text block to train the initial video generation model, the initial video generation model only includes two inputs (respectively, the sample text block and the sample matching video semantically matched with the sample text block), and the trained target video generation model also has two inputs. In this way, the target video generation model used in different situations is different. In order to solve the above problem, when the sample text and the target text are not divided into text blocks, the initial video generation model and the target video generation model including three inputs can still be used, and one of the inputs of the model is empty. In this way, the versatility of the model can be improved.
[0076] In an embodiment where the sample text includes multiple sample text blocks, a sample output video output by the initial video generation model based on each sample data may be obtained, wherein each sample data includes a sample text block and a sample matching video semantically matching the sample text block, or each sample data includes a sample text block, a sample matching video semantically matching the sample text block, and sample video features corresponding to a sample matching video semantically matching the previous sample text block in the sample text where the sample text block is located. The initial video generation model may be trained based on the video features corresponding to the sample output video corresponding to each sample text block and preset conditions to obtain a target video generation model.
[0077] The similarity between the video features corresponding to the sample output videos output by the initial video generation model based on adjacent text blocks can be obtained, and the preset condition can be determined based on the similarity. Ideally, the similarity between the video features corresponding to the sample output videos output by adjacent text blocks should be greater than the similarity between the video features corresponding to the sample output videos output by any text block in the adjacent text blocks and the video features corresponding to other videos.
[0078] Based on this, the following preset conditions can be determined: the first similarity between the video features corresponding to the first sample output video and the video features corresponding to the second sample output video is less than the second similarity between the video features corresponding to the first sample output video and the video features corresponding to the reference video, and the first similarity is less than the third similarity between the video features corresponding to the second sample output video and the video features corresponding to the reference video.
[0079] Among them, the reference video can be any video in the video database. The video features in this embodiment can be obtained based on the method of obtaining video features in any of the aforementioned embodiments, which will not be repeated here. A loss function can be generated based on preset conditions for model training, for example, a triplet loss function or a contrastive loss function, or the loss function generated based on preset conditions can be weighted with other loss functions, and the weighted loss function can be used for model training. By adjusting the model parameters of the initial video generation model, the loss function used for model training is minimized, and finally the target video generation model is trained. The model training process of some embodiments is as follows Figure 4 As shown, in a training process, the i+1th sample text block, the sample matching video semantically matching the i+1th sample text block, and the sample video features of the sample matching video semantically matching the i-th sample text block can be input into the initial video generation model, and the target video corresponding to the i+1th sample text block output by the initial video generation model is obtained. Then, the loss function is calculated based on the target video corresponding to the i+1th sample text block, the target video corresponding to the i-th sample text block, and the reference video in the video database, and the initial video generation model is trained based on the loss function to obtain the target video generation model.
[0080] The target video generation model trained in the above manner generates target videos for adjacent text blocks with more similar features, that is, each target video has better feature consistency. In this way, by fusing each target video, a long video (i.e., a fused video) with better feature consistency can be obtained.
[0081] like Figure 5 As shown, the embodiment of the present disclosure further provides a video generating device, the device comprising:
[0082] A text acquisition module 11 is used to acquire a target text;
[0083] A retrieval module 12 is used to retrieve a matching video that semantically matches the target text from a video database;
[0084] An input module 13, used for inputting the target text and the matching video into a target video generation model;
[0085] The video acquisition module 14 is used to acquire the target video output by the target video generation model.
[0086] In some embodiments, the retrieval module 12 is specifically used to: obtain semantic features corresponding to the target text; obtain video features corresponding to multiple candidate videos in the video database, wherein the video features are used to characterize semantic information of the corresponding candidate videos; based on the semantic features corresponding to the target text and the video features corresponding to the multiple candidate videos, determine a matching video that semantically matches the target text from the multiple candidate videos.
[0087] In some embodiments, the retrieval module 12 is specifically used to: determine the similarity between the semantic features corresponding to the target text and the video features corresponding to each candidate video in the multiple candidate videos; and determine the candidate video corresponding to at least one video feature whose similarity with the semantic features corresponding to the target text is from high to low as the matching video.
[0088] In some embodiments, the retrieval module 12 is specifically used to: determine at least one key frame from the candidate video; perform feature extraction on each key frame in the at least one key frame to obtain features of each key frame; and obtain video features corresponding to the candidate video frame based on the features of each key frame.
[0089] In some embodiments, the retrieval module 12 is specifically used to: obtain keyword tags corresponding to multiple candidate videos in the video database, wherein the keyword tags are used to characterize the semantic category to which the corresponding candidate video belongs; determine the matching degree between the target text and the keyword tags corresponding to each candidate video in the multiple candidate videos; and determine the candidate video corresponding to at least one keyword tag whose matching degree with the target text is from high to low as the matching video.
[0090] In some embodiments, the target video generation model is trained based on the following modules: a first pre-training module, used to pre-train an image generation model based on a first sample text and a sample image that semantically matches the first sample text, to obtain a pre-trained model; a fine-tuning module, used to fine-tune the pre-trained model after adding an attention module based on a second sample text and a sample matching video that semantically matches the second sample text, to obtain the target video generation model; the attention module is used to extract temporal features in the sample matching video.
[0091] In some embodiments, the target text includes multiple text blocks, the matching videos that semantically match the target text include matching videos that semantically match each of the multiple text blocks, and the target video includes the target video corresponding to each text block; the device also includes: a fusion module, which is used to fuse the target videos corresponding to each text block to obtain a fused video.
[0092] In some embodiments, the target video corresponding to the i+1th text block among the multiple text blocks is generated by the target video generation model based on the i+1th text block, a matching video that semantically matches the i+1th text block, and video features corresponding to the target video corresponding to the i-th text block among the multiple text blocks, where i is a positive integer.
[0093] In some embodiments, the target video generation model is trained based on the following modules: an initial video generation model is pre-trained based on at least one sample data to obtain the target video generation model; wherein each sample data in the at least one sample data includes: a sample text block; a sample matching video that semantically matches the sample text block; and sample video features corresponding to a sample matching video that semantically matches a previous sample text block in a sample text to which the sample text block belongs.
[0094] In some embodiments, the target video generation model is trained based on the following method: an input module, used to input multiple sample data into the initial video generation model; each of the multiple sample data includes a sample text block among multiple sample text blocks included in the sample text and a sample matching video semantically matched with the sample text block; a sample video acquisition module, used to acquire a sample output video corresponding to each sample text block output by the initial video generation model; a training module, used to train the initial video generation model based on the video features corresponding to the sample output video corresponding to each sample text block and preset conditions to obtain the target video generation model; the preset conditions include: a first similarity between the video features corresponding to the first sample output video and the video features corresponding to the second sample output video is less than a second similarity between the video features corresponding to the first sample output video and the video features corresponding to the reference video, and the first similarity is less than a third similarity between the video features corresponding to the second sample output video and the video features corresponding to the reference video; the first sample output video and the second sample output video are sample output videos corresponding to adjacent sample text blocks, respectively, and the reference video is a video acquired from a video database.
[0095] In some embodiments, each of the multiple pieces of sample data further includes a sample video feature corresponding to a sample matching video that semantically matches a previous sample text block in the sample text to which the sample text block belongs.
[0096] In some embodiments, the retrieval module 12 is specifically used to: extract key information from the target text, where the key information is related to the visual features of the target text; and retrieve matching videos that semantically match the target text from a video database based on the key information.
[0097] In some embodiments, the device further includes: a smoothing processing module, configured to perform smoothing on adjacent target videos in the fused video.
[0098] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.
[0099] An embodiment of the present disclosure further provides a computer device, which at least includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method described in any of the above embodiments is implemented.
[0100] Figure 6 A more specific hardware structure diagram of a computing device provided by an embodiment of the present disclosure is shown, and the device may include: a processor 21, a memory 22, an input / output interface 23, a communication interface 24, and a bus 25. The processor 21, the memory 22, the input / output interface 23, and the communication interface 24 are connected to each other in communication within the device through the bus 25.
[0101] The processor 21 can be implemented by a general central processing unit (CPU), a microprocessor, an application specific integrated circuit (ASIC), or one or more integrated circuits, etc., for executing relevant programs to implement the technical solutions provided by the embodiments of the present disclosure. The processor 21 can also include a graphics card, which can be a Nvidia titan X graphics card or a 10120Ti graphics card, etc.
[0102] The memory 22 can be implemented in the form of a read-only memory (ROM), a random access memory (RAM), a static storage device, a dynamic storage device, etc. The memory 22 can store an operating system and other application programs. When the technical solution provided by the embodiment of the present disclosure is implemented by software or firmware, the relevant program code is stored in the memory 22 and called and executed by the processor 21.
[0103] The input / output interface 23 is used to connect the input / output module to realize information input and output. The input / output module can be configured as a component in the device (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.
[0104] The communication interface 24 is used to connect a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).
[0105] The bus 25 includes a path that transmits information between the various components of the device (eg, the processor 21, the memory 22, the input / output interface 23, and the communication interface 24).
[0106] It should be noted that, although the above device only shows the processor 21, the memory 22, the input / output interface 23, the communication interface 24 and the bus 25, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include the components necessary for implementing the embodiments of the present disclosure, and does not necessarily include all the components shown in the figure.
[0107] The present disclosure also provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the method described in any of the above embodiments is implemented.
[0108] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0109] It can be known from the description of the above implementation methods that those skilled in the art can clearly understand that the embodiments of the present disclosure can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the embodiments of the present disclosure is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a disk, an optical disk, etc., including several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present disclosure or some parts of the embodiments.
[0110] The systems, devices, modules or units described in the above embodiments may be implemented by computer devices or entities, or by products with certain functions. A typical implementation device is a computer, which may be in the form of a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver, a game console, a tablet computer, a wearable device or a combination of any of these devices.
[0111] Each embodiment in the present disclosure is described in a progressive manner, and the same and similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. The device embodiment described above is merely schematic, wherein the modules described as separate components may or may not be physically separated, and the functions of each module can be implemented in the same one or more software and / or hardware when implementing the embodiment of the present disclosure. It is also possible to select some or all of the modules according to actual needs to achieve the purpose of the embodiment. A person of ordinary skill in the art can understand and implement it without paying creative labor.
[0112] The above is only a specific implementation of the embodiment of the present disclosure. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the embodiment of the present disclosure. These improvements and modifications should also be regarded as the protection scope of the embodiment of the present disclosure.
Claims
1. A video generation method, characterized in that: The method comprises: Get the target text; Retrieving a matching video that semantically matches the target text from a video database; Inputting the target text and the matching video into a target video generation model; Acquire a target video output by the target video generation model; wherein the target text includes a plurality of text blocks, the matching video semantically matching the target text includes a matching video semantically matching each text block in the plurality of text blocks, the target video includes a target video corresponding to each text block, and the target video corresponding to each text block is acquired based on the text block and the matching video semantically matching the text block; Fusing the target video corresponding to each text block to obtain a fused video; The target video corresponding to the i+1th text block among the multiple text blocks is generated by the target video generation model based on the i+1th text block, a matching video that semantically matches the i+1th text block, and video features corresponding to the target video corresponding to the i-th text block among the multiple text blocks, where i is a positive integer.
2. The method according to claim 1, characterized in that: The step of retrieving a matching video that semantically matches the target text from a video database includes: Acquire semantic features corresponding to the target text; Obtaining video features corresponding to a plurality of candidate videos in the video database, respectively, wherein the video features are used to represent semantic information of the corresponding candidate videos; Based on the semantic features corresponding to the target text and the video features respectively corresponding to the multiple candidate videos, a matching video that semantically matches the target text is determined from the multiple candidate videos.
3. The method according to claim 2, characterized in that The determining, from the multiple candidate videos, a matching video that semantically matches the target text based on the semantic features corresponding to the target text and the video features respectively corresponding to the multiple candidate videos, comprises: Determine the similarity between the semantic feature corresponding to the target text and the video feature corresponding to each of the multiple candidate videos; The candidate video corresponding to at least one video feature having a semantic feature similarity from high to low with the target text is determined as the matching video.
4. The method according to claim 2, characterized in that: The obtaining of video features respectively corresponding to a plurality of candidate videos in the video database includes: Determine at least one key frame from the candidate video; Extracting features of each key frame in the at least one key frame to obtain features of each key frame; Based on the features of each key frame, video features corresponding to the candidate video frames are obtained.
5. The method according to claim 1, characterized in that The step of retrieving a matching video that semantically matches the target text from a video database includes: Obtaining keyword tags corresponding to a plurality of candidate videos in the video database, wherein the keyword tags are used to represent the semantic category to which the corresponding candidate videos belong; Determining a degree of match between the target text and a keyword tag corresponding to each of the plurality of candidate videos; The candidate videos corresponding to at least one keyword tag with a decreasing degree of matching with the target text are determined as the matching videos.
6. The method according to claim 1, characterized in that The target video generation model is trained based on the following method: Pre-training an image generation model based on a first sample text and a sample image semantically matching the first sample text to obtain a pre-trained model; The pre-trained model after adding the attention module is fine-tuned based on the second sample text and the sample matching video that semantically matches the second sample text to obtain the target video generation model; the attention module is used to extract the temporal features in the sample matching video.
7. The method according to claim 1, characterized in that The target video generation model is trained based on the following method: The target video generation model is obtained by pre-training an initial video generation model based on at least one sample data; wherein the initial video generation model is a pre-trained model obtained by training based on text image pairs, or an untrained video generation model; each of the at least one sample data includes: Sample text block; A sample matching video that semantically matches the sample text block; The sample video features corresponding to the sample matching video that semantically matches the previous sample text block in the sample text to which the sample text block belongs.
8. The method according to claim 1, characterized in that: The target video generation model is trained based on the following method: Inputting a plurality of sample data into an initial video generation model; each of the plurality of sample data comprises a sample text block among a plurality of sample text blocks included in a sample text and a sample matching video semantically matching the sample text block; the initial video generation model is a pre-trained model obtained by training based on text-image pairs, or an untrained video generation model; Obtain a sample output video corresponding to each sample text block output by the initial video generation model; The initial video generation model is trained based on the video features corresponding to the sample output video corresponding to each sample text block and preset conditions to obtain the target video generation model; The preset conditions include: A first similarity between video features corresponding to a first sample output video and a video feature corresponding to a second sample output video is smaller than a second similarity between video features corresponding to the first sample output video and a video feature corresponding to a reference video, and the first similarity is smaller than a third similarity between video features corresponding to the second sample output video and a video feature corresponding to the reference video; the first sample output video and the second sample output video are sample output videos corresponding to adjacent sample text blocks, respectively, and the reference video is a video obtained from a video database.
9. The method according to claim 8, characterized in that Each of the multiple pieces of sample data further includes a sample video feature corresponding to a sample matching video that semantically matches a previous sample text block in the sample text to which the sample text block belongs.
10. The method according to claim 1, characterized in that The method further comprises: The adjacent target videos in the fused video are smoothed.
11. The method according to claim 1, characterized in that: The step of retrieving a matching video that semantically matches the target text from a video database includes: Extracting key information from the target text, wherein the key information is related to the visual features of the target text; A matching video that semantically matches the target text is retrieved from a video database based on the key information.
12. A video generating device, characterized in that: The device comprises: A text acquisition module is used to acquire the target text; A retrieval module, used to retrieve matching videos that semantically match the target text from a video database; An input module, used for inputting the target text and the matching video into a target video generation model; A video acquisition module, used to acquire a target video output by the target video generation model; wherein the target text includes a plurality of text blocks, the matching video semantically matching the target text includes a matching video semantically matching each text block in the plurality of text blocks, the target video includes a target video corresponding to each text block, and the target video corresponding to each text block is acquired based on the text block and the matching video semantically matching the text block; A fusion module, used for fusing the target video corresponding to each text block to obtain a fused video; The target video corresponding to the i+1th text block among the multiple text blocks is generated by the target video generation model based on the i+1th text block, a matching video that semantically matches the i+1th text block, and video features corresponding to the target video corresponding to the i-th text block among the multiple text blocks, where i is a positive integer.
13. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method described in any one of claims 1 to 11 is implemented.
14. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 11 is implemented.
Citation Information
Patent Citations
Video association method and device, server and readable storage medium
CN111767796A
Robot vision man-machine interaction method and system based on text generation video
CN113051420A
Video clip retrieval method and training method and device of video clip retrieval model
CN113590881A
Video synthesis method and device, computer equipment and storage medium
CN114390217A
Video generation method and device, computer equipment and storage medium
CN114390218A
