Construction method of training-free framework for controlling object movement based on video diffusion generation model

By introducing the initial noise prior module, spatial attention constraints and switching time attention mechanism into the video diffusion model, the problems of inaccurate object position control and time-consuming training in traditional methods are solved, and high performance under zero-sample setting is achieved. Quality video generation and precise motion control.

CN118609014APending Publication Date: 2024-09-06EAST CHINA NORMAL UNIV
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410644279.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-23
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

Existing video diffusion models lack accuracy in controlling object positions and require additional training and a lot of computing power. Traditional methods rely on fully supervised learning, which is time-consuming and inefficient.

Method used

A training-free framework is designed, including an initial noise prior module, spatial attention constraints and switching temporal attention mechanism, to control the object motion generated by the video diffusion model, which can achieve arbitrary motion control in a zero-sample setting.

Benefits of technology

It achieves precise control of the position of objects in the video and temporal coherence without additional training. It is suitable for any pre-trained video diffusion model and improves the quality and control accuracy of the generated video.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118609014A
    Figure CN118609014A
Patent Text Reader

Abstract

The invention discloses a method for constructing a training-free framework for controlling object movement based on a video diffusion generative model, and the constructed framework can achieve the effect of controlling the position of a generated main body without additional training. Specifically, according to the method, an initial noise priori module INPM, a space attention constraint SC and a switching time attention mechanism STAM are applied to a video diffusion generation model. The INPM firstly provides a submerged space noise vector with prior information; the SC and the STAM can provide control capability in the process of predicting noise by the Unet; the SC can perform gradient descent constraint on a position with a correspondingly high Attention value in the Unet CrossAttention, and the STAM can perform gradient descent constraint on a position with a correspondingly high Attention value in the Unet CrossAttention; the INPM can keep the consistency of object themes between different frames. According to the frame constructed by the method, training is not needed, the generation quality is not influenced, and meanwhile, the control flow of the video diffusion model for controlling the position of the generated object in the video is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer vision and generative artificial intelligence image and video synthesis, and in particular to a framework construction method for controlling the moving position of a generated subject based on a video diffusion generation model, which does not require any training. Background Art

[0002] Recent text-to-image diffusion models have demonstrated a surprising ability to generate high-quality images. Due to the large-scale image-text pairing data available on the web, text-conditioned autoregressive and diffusion models have proven to be one of the panaceas for generating images with high fidelity and diverse concept coverage. The outstanding ability of image synthesis increases the potential of these models in practical applications, such as artistic creation. However, most existing models can only be conditioned on category labels or textual cues. A few studies have tried to use other modalities as conditions, such as spatial conditions, to further control the synthesis of objects or contexts.

[0003] The layout-to-image literature has studied methods for synthesizing images based on spatially conditioned inputs. However, the settings of these studies are limited to a limited number of closed categories, which is not feasible for new categories in open-world situations. In addition, previous studies have adopted a fully supervised learning process, thus requiring a large amount of paired location box / skeleton / mask image data for high-quality training. Since pixel-level annotations are time-consuming and labor-intensive, label efficiency has gradually become a bottleneck for fully supervised layout-to-image methods.

[0004] In addition to the textual prompt c as a condition, Stable Diffusion and ControlNet also study other modalities as conditional inputs and provide qualitative results. Compared with closed-set layout-to-image synthesis methods, Stable Diffusion and ControlNet trained from large-scale image-text pairs have strong perception of different visual concepts, such as different types of objects and contexts. However, they still follow the general pipeline of layout-to-image literature in a fully supervised manner, where large-scale image-layout pairing data is indispensable for high-quality training. In addition, the training cycle of training from scratch or fine-tuning is time-consuming.

[0005] In fact, the basic text-to-video diffusion model is trained on extremely large training datasets. In theory, the pre-trained model itself should have learned extensive knowledge of the motion dynamics of various objects. However, the semantics of the latent space in different modules of the video diffusion model are not well defined, which makes it difficult to manually control the generated videos to obtain the desired motion dynamics. To some extent, the above methods try to calibrate and define the latent space by training the baseline model with additional annotated datasets, and successfully use the intrinsic knowledge of the pre-trained model to control the motion. In addition, it is observed that the initial noise plays an important heuristic role in video generation. The same initial noise tends to generate videos with similar content. Using these two properties, the trajectory of moving objects can be manipulated. Summary of the invention

[0006] The purpose of the present invention is to address the following issues: a) traditional diffusion model video generation does not have the ability to accurately control the position of an object; b) in order to achieve the precise control described in a) further training is required, and this training requires additional computing power and may take a lot of time. A method for constructing a training-free framework for controlling the movement of an object based on a video-generated diffusion model is proposed. The constructed framework is used to control the movement of an object and can be applied to any video diffusion model. Unlike previous methods that require a lot of training, the framework constructed by the present invention can achieve arbitrary motion control in a zero-sample setting.

[0007] Initial noise plays an important role in the motion of an object. Therefore, the present invention introduces an initial noise prior module to achieve a stable control effect.

[0008] The values ​​in the cross-attention map significantly affect the position and appearance of the object corresponding to the cue, so a spatial constraint is designed to optimize the position of the moving object and ensure spatial consistency. In addition, to ensure the consistency of object motion, a shifted temporal attention mechanism is developed to maintain the temporal coherence of the moving object.

[0009] The specific technical solution for achieving the purpose of the present invention is:

[0010] A method for constructing a training-free framework for controlling object movement based on a video diffusion generation model, wherein the framework is used to control the position of a main content generated by the video diffusion generation model, and the construction method is characterized in that the construction method comprises the following specific steps:

[0011] Step 1: Set up the initial noise prior module INMP

[0012] Before the user input stream enters the Unet of the video diffusion model to predict the noise, it enters the initial noise prior module INPM to provide prior information for the position of the moving object and obtain a latent space vector with prior information; finally, a noise sequence in the latent space with low-frequency prior information is output; the setting module INPM is to obtain a noise sequence in the latent space with prior information, and the noise sequence will be used as the input of the subsequent Unet for iterative denoising; the noise sequence carries prior information, which provides a rough coordinate position prior in the denoising iteration;

[0013] Step 2: Set the spatial attention constraint SC

[0014] A spatial attention constraint SC is set inside the Unet of the video diffusion model to predict noise, which is used to derive the latent space variables based on several pre-designed loss functions; the several loss functions make the noise prediction process more consistent with the coordinate position, so that each time the Unet is passed through the iterative denoising process, it has:

[0015] 1) Predict the noise sequence in the current latent space and subtract the predicted noise to achieve the effect of noise reduction;

[0016] 2) Before the noise is reduced by Unet, the noise is derivatized by gradient descent following the designed loss function. The subsequent output is still a noise sequence in the latent space, which is used for the next noise reduction.

[0017] The spatial attention constraint SC acts on the CrossAttention layer in Unet to ensure that the position of each generated frame subject meets the expected position input by the user;

[0018] Step 3: Set up the Switching Temporal Attention Mechanism STAM

[0019] A switching temporal attention mechanism STAM is set in the TemporalAttention layer of Unet to transform the position of each vector in the time dimension of the latent space to achieve the consistency of the motion of the moving object; the switching temporal attention mechanism STAM acts on the TemporalAttention layer in the video diffusion model Unet to keep the main features of each frame consistent.

[0020] The initial noise prior module INMP, in which the user first inputs a string c and a set of positions B of rectangular boxes corresponding to each frame, B f Represents the position of the box in the fth frame; the user's input string c and the position B of the first frame 0As a guiding condition, Unet will continuously reduce the noise of a Gaussian noise vector z*~N(0,I) in a latent space that follows a Gaussian distribution. The noise vector z* does not carry prior information and is automatically generated by the model, not the input of Unet. During the denoising process, the noise vector z* is subjected to a gradient descent with the loss function designed in the SC module as the target according to the value of the CrossAttention layer in Unet. Finally, the video V with the target position fixed, i.e., the position of the first frame, is obtained. meta ; Then, the video V meta Encode it through encoder E to get the generated video potential vector z meta ; For the video potential vector z meta Perform DDIMInversion to obtain the corresponding noise potential representation z I ; For each frame in the bounding box B 0 The variables in the inner latent space are pruned to obtain a pruned sequence z in the latent space I *; Then, use the local blending operation to adjust z frame by frame I * In the given box position B f The clipped sequence z obtained before mixing within the range I and initial noise z*; when cropping, crop B for each frame 0 Position noise; the position of the local blend is the position blend indicated by the bounding box corresponding to each frame; this enables setting a coherent prior corresponding to the object position in the initial noise; it also ensures that the appearance and motion of the animated object in the video frame remain consistent without adding additional computational cost in the generation process;

[0021] The final output of the initial noise prior module INMP is a noise sequence in the latent space with low-frequency prior information, which serves as the starting input for subsequent Unet denoising.

[0022] The spatial attention constraint SC is specifically: optimize the intermediate potential representation vector z in each denoising step t t ; Based on the string c and the potential representation vector z t , the corresponding cross attention map A is obtained by the following formula:

[0023]

[0024] Q=W Q z t ,K=W K c

[0025] Among them, A is the output attention map; Q and K are z t and c's query and key; W Q , W Kare two learnable matrices, d is W Q The dimensions of the matrix are kept fixed in the setting. When the user specifies a box B for controlling the object trajectory, a box loss is used to ensure that the model controls the object to appear within the input box in each frame. Specifically, the box loss is implemented by maximizing the value of A corresponding to the prompt inside the box while minimizing the value outside the box through an optimization method. Frame by frame, the user-specified coordinate box is scaled to the corresponding coordinates in the latent space and a mask M is constructed. f ;

[0026] The optimization method is implemented by creating four loss functions:

[0027]

[0028]

[0029]

[0030]

[0031] Among them, L i f and L o f The CrossAttention value used to control the pixels in the latent space of each frame can be the highest inside the box B given by the user and the lowest outside; g(A k f , M f , P) represents the attention map A for the kth prompt word in the fth frame of the attention map k f , enter M f The average value of the first P percent largest elements in the range; P is an integer value used to specify the first P maximum values;

[0032] L c f Used to focus the attention in each box on the center of the box, where x 1 f and x 2 f Indicates the center coordinates of the box in the fth frame; W Akf and H Akf and represents the center weight of the CrossAttention value of the f-th frame;

[0033] Ls is used to ensure that the objects in each frame have a certain degree of similarity. The similarity used is cosine similarity, i.e. Sim(·,·) represents the calculation of the cosine similarity of two inputs. Pixel(A,B) represents the elements in the range from A to B.

[0034] The weighted sum of several losses gives the overall loss:

[0035]

[0036] For L s p The value of the pixel in can represent the latent space z t Perform gradient descent to update z t ; Among them, the prefix coefficient λ i ,λ o ,λ c ,λ s are all pre-set hyperparameter coefficients, and their settings will be demonstrated through multiple experiments; the formula for gradient descent is as follows; where β t It is also a hyperparameter, and the most suitable value will be obtained based on the results of multiple tests;

[0037]

[0038] In each step of the denoising process, each time Unet is passed through, not only the noise sequence in the current latent space is predicted and the predicted noise is subtracted to achieve the denoising effect, but also the noise z is denoised before passing through Unet denoising. t Perform a gradient descent following the above formula to obtain z t '; The output after that is still a noise sequence in the latent space, which is used for the next denoising iteration.

[0039] The switching temporal attention mechanism STAM is used to improve the dynamic characteristics of moving objects in different frames; specifically, frame B f z in range f Elements and B 0 The elements within the range are shifted, and the subsequent frames within the frame range can be aligned with the frame range of the first frame; the specific steps are as follows:

[0040]

[0041] z w ′-TemporalAttention(z w ),

[0042]

[0043] Shift(z f ,B f ,B 0 ) is a shift operation, z f represents the latent space representation vector of frame f, B f With B 0The Shift operation indicates the expected position of the object in the fth frame and the first frame respectively; 0 Swap the elements in position to B f Positionally;

[0044] As shown in the formula, before passing through the TemporalAttention layer, the box alignment operation is performed on the elements of each frame except the first frame and the first frame, so that the mathematical calculation logic of the corresponding position in the subsequent Temporal Attention layer has semantics; after passing through the TemporalAttention layer, the corresponding inverse operation is performed to restore the elements that were moved in each frame except the first frame for subsequent denoising iterations.

[0045] The framework constructed by the present invention can be easily applied to any pre-trained video diffusion model and achieve universality and plug-and-play control capabilities.

[0046] To this end, an initial noise prior module (Init Prior Noise Module) is designed to provide a noise with potential low-frequency information according to the motion trajectory given by the user; it can provide potential position information.

[0047] At the same time, it is found that the value of the cross attention map in U-Net largely determines the generated position of the subject mentioned in the prompt. By applying spatial constraints (Spatial Constraints) of attention similarity loss to these attention maps, the pixel-level control effect is achieved to achieve precise operation of the object position in a single frame. In addition, multiple loss functions are set to help understand the semantics of coordinates, so that the prediction noise process can be more consistent with the coordinate position.

[0048] In addition, merely imposing spatial constraints on the position of objects may have a negative impact on the overall coherence and video quality. In order to maintain the continuity of the entire video sequence, a novel shift temporal attention mechanism is proposed to further enable the baseline model to focus on the same object in the time axis. The position of each vector in the latent space time dimension is transformed.

[0049] The constructed framework can effectively generate high-quality videos controlled by bounding box trajectories without any training process.

[0050] The framework of the present invention adds the above-mentioned three modules on the basis of the traditional video diffusion model, that is, it can achieve the control flow of the video diffusion model which does not require training, does not affect the generation quality, and can control the position of the generated object in the video.

[0051] Beneficial Effects

[0052] 1. The present invention constructs a control framework that does not require training, and can control the motion trajectory of any object in a pre-trained video generation diffusion model. The present invention is plug-and-play and does not require any additional training.

[0053] 2. By recognizing the impact of initial noise on video generation, we implement an initial noise conditioning module to establish favorable starting conditions for controllable video diffusion.

[0054] 3. In order to further precisely control the generated video, a spatial constraint and a novel shift temporal attention mechanism are proposed, which aim to ensure the position accuracy and temporal continuity and consistency of the target respectively. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Figure 1 This is a working diagram of the initial noise prior module INPM of the present invention;

[0056] Figure 2 This is a schematic diagram of the application of the switching time attention mechanism STAM of the present invention;

[0057] Figure 3 A flow chart of the present invention applied to the overall video diffusion generation model;

[0058] Figure 4 Schematic diagram of the effectiveness and versatility of the method of the present invention. DETAILED DESCRIPTION

[0059] The present invention is described in detail below with reference to the accompanying drawings and embodiments.

[0060] The framework constructed by the present invention is used to control the position of the content generated by the video diffusion model, which includes a pair of encoders and decoders and a Unet for predicting noise. Based on the video diffusion model, the present invention adds three modules to ensure the position or coordinate control of the generated content, specifically:

[0061] 1. Initial Noise Prior Module (INMP):

[0062] According to the theory of DDIM Inversion, the initial noise has an important influence on the final generated result. The Initial Noise Prior Module (INPM) aims to take advantage of this feature and provide strong prior information for the position of the moving object. In this module, the user input c is essentially a string of characters; the user input B is the x and y coordinates of the upper left corner and lower right corner of a series of rectangular boxes in each frame. Figure 1As shown in Fig. 2, integrating moving objects into a series of coherent frames involves several steps. First, a meta-video V is sampled using the original video diffusion method (SC) with spatial constraints (SC). meta , where the potential input is z*~N(0,I), conditioned on the given prompt string c and the bounding box B of the first frame 0 Note that the difference between this diffusion model and the common diffusion model is the addition of the SC module. At the same time, only the first frame coordinates of a series of coordinates are used for the user input. Then, based on V meta Generate video latent vector z from encoder E meta Once you are ready meta , perform DDIMInversion to obtain the corresponding noise potential representation z I For each frame in the bounding box B 0 The variables in the inner latent space are pruned to obtain a pruned sequence z in the latent space I . Then, a local blending operation is used frame by frame in B f The cropped sequence z obtained before blending within the range of frames I and initial noise z*. When cropping, B is cropped for each frame. 0 The position of the local blend is the position of the bounding box corresponding to each frame. This approach enables setting a coherent prior corresponding to the object position in the initial noise. It also ensures that the appearance and motion of animated objects remain consistent across video frames without adding additional computational cost to the generation process.

[0063] The final output of this module is a noise sequence in the latent space with low-frequency prior information, which is used in the subsequent denoising process.

[0064] 2. Spatial Attention Constraint (SC):

[0065] INPM alone is not sufficient to precisely manipulate the trajectory of an object. To further improve control, a spatial constraint (SC) is introduced to optimize the intermediate latent representation z in each denoising step t. This optimization is crucial to improve the accuracy of the moving object position and maintain spatial consistency. In the conditional denoising architecture, cross attention plays a key role in connecting the text prompt and the generated content. In the denoising step, the prompt string c and the intermediate feature z are used to generate the content. t , the corresponding cross attention map can be obtained by the following formula:

[0066]

[0067] Q=W Q zt,K=W K c

[0068] Where Q and K are z t and c's query and key. Q , W K are two learnable matrices that are kept fixed in the setting. When the user specifies a box B for controlling the trajectory of an object, a box loss can be used to ensure that the model controls the object to appear within the input box in each frame. Specifically, the box loss is implemented by maximizing the value of the attention map A corresponding to the prompt inside the box while minimizing the value outside the box through an optimization method. Frame by frame, the user-specified coordinate box is scaled to the corresponding coordinates in the latent space and a mask M is constructed. f .

[0069] The optimization method mentioned above is implemented by creating four losses:

[0070]

[0071]

[0072]

[0073]

[0074] Among them, L i f and L o f The CrossAttention value used to control the pixels in the latent space of each frame can be the highest inside the box B given by the user and the lowest outside. g(·, M, P) means getting the average value of the top P percent largest elements within the input mask M range.

[0075] L c f It is used to make the attention in each box focus on the center of the box, where x1f and x2f represent the center coordinates of the box in the fth frame; W Akf and H Akf and represents the center weight of the CrossAttention value of the fth frame. Ls is used to ensure a certain similarity between objects in each frame. The similarity used in the method is cosine similarity.

[0076] The weighted sum of several losses gives the overall loss:

[0077]

[0078] The value of the pixel in Lsp can be used to perform gradient descent on the representation of the latent space zt, which can update zt. Among them, each coefficient before loss is a hyperparameter, and its setting will be shown through multiple experiments. The formula for gradient descent is as follows. Among them, β is also a hyperparameter, and the most suitable value will be obtained based on the results of multiple experiments.

[0079]

[0080] In the denoising process of each step of the video diffusion model with the SC module, each time the Unet is passed through, not only the noise sequence in the current latent space is predicted, but also the predicted noise is subtracted to achieve the denoising effect. At the same time, the noise is subjected to a gradient descent following the above formula (before the Unet denoising). The subsequent output is still a noise sequence in the latent space, which is used for the next denoising.

[0081] 3. Switching Temporal Attention Mechanism (STAM):

[0082] After the spatial constraints of the attention map, the pre-trained video diffusion model still has difficulties in generating continuous action sequences. In the temporal module of the diffusion process, the latent representation is reshaped into the following configuration:

[0083] rearrange(z,bfchw→(bhw)fc)

[0084] Where b represents the batch size, f represents the number of frames, c represents the number of channels, and w and h represent the width and height. In the temporal transformer, attention is focused on the same pixels in different frames. This leads to a situation where if the range of motion is too large, the same position in different frames may undergo significant semantic changes, resulting in a lack of consistency in the generated dynamics.

[0085] To address this inconsistency, a switching temporal attention mechanism (STAM) is proposed to improve the dynamic characteristics of moving objects in different frames. f z in range f Elements and B 0 Shift the elements in the range, such as Figure 2 As shown. Therefore, the subsequent frames within the frame range can be aligned with the frame range of the first frame. The specific steps are as follows:

[0086]

[0087] z w ′-TemporalAttention(z w ),

[0088]

[0089] Shift(z f ,B f ,B 0 ) is a shift operation, z f represents the latent space representation vector of frame f, B f With B 0 The Shift operation indicates the expected position of the object in the fth frame and the first frame respectively; 0 Swap the elements in position to B f In terms of location.

[0090] As shown in the formula, before passing through the TemporalAttention layer, the box alignment operation is performed on the elements of each frame except the first frame and the first frame, so that the mathematical calculation logic of the corresponding position in the subsequent Temporal Attention layer has semantics. After passing through the TemporalAttention layer, the corresponding inverse operation is performed to restore the elements that were moved in each frame except the first frame for subsequent operations.

[0091] By applying STAM to the TemporalAttention layer, the consistency of the moving object motion can be achieved without additional training and without incurring additional computational cost during inference.

[0092] 4. See Figure 3 , the overall framework process is as follows:

[0093] First, the user needs to input a description statement for the control target (prompt, such as a cat walking in the yard) and the box coordinates B of the desired position of each frame. The user's input will first enter the INPM module to obtain a latent space vector with a priori; then the latent space vector will be predicted by Unet. In the step of predicting noise, Unet will be cycled several times (for example, 50 times). In the first T1 denoising step (for example, 20 times), according to the output of the CrossAttenion layer of Unet, the SC module is constructed to perform gradient descent on the latent space vector that is conducive to control; at the same time, in the Temporal Attention layer of each Unet, a STAM module is added before and after the Temporal Attention layer, which can make the objects in each frame of the video maintain better consistency. In the denoising step of the last T2 times (according to the above statement, there are 30 times left), the denoising process will no longer include the STAM module and the SC module, and only a Unet will be used for denoising (because the control process only plays a decisive role in the early stage of denoising). Finally, the latent space vector is decoded to obtain a video consisting of continuous frames.

[0094] In the whole framework, the INPM module is always passed once, and the SC module and STAM module are used T1 times.

[0095] See also Figure 4 , ModelScope and ZeroScope are two video diffusion models; the framework constructed by the present invention is added on the basis of these two video diffusion models; "+ours" means the original method plus the present invention; "+prompt" means only the original method is used; the box in the picture indicates the desired position B input by the user. The video sequence is from left to right. It can be seen that the method of the present invention improves the control ability of the original method; and has stronger control accuracy.

Claims

1. A method for constructing a training-free framework for controlling object movement based on a video diffusion generation model, wherein the framework is used to control the position of a main content generated by the video diffusion generation model, characterized in that: The construction method comprises the following specific steps: Step 1: Set up the initial noise prior module INMP Before the user input stream enters the Unet of the video diffusion model to predict noise, it enters the initial noise prior module INPM to provide prior information for the position of the moving object and obtain a latent space vector with prior information; finally, it outputs a noise sequence in the latent space with low-frequency prior information; The purpose of setting the module INPM is to obtain a noise sequence in the latent space with prior information, and the noise sequence will be used as the input of Unet for iterative denoising. The noise sequence carries prior information, which provides a rough coordinate position prior in the denoising iteration. Step 2: Set the spatial attention constraint SC A spatial attention constraint SC is set inside the Unet of the video diffusion model to predict noise, which is used to derive the latent space variables based on several pre-designed loss functions; the several loss functions make the noise prediction process more consistent with the coordinate position, so that each time the Unet is passed through the iterative denoising process, it has: 1) Predict the noise sequence in the current latent space and subtract the predicted noise to achieve the effect of noise reduction; 2) Before the noise is reduced by Unet, the noise is derivatized by gradient descent following the designed loss function. The subsequent output is still a noise sequence in the latent space, which is used for the next noise reduction. The spatial attention constraint SC acts on the CrossAttention layer in Unet to ensure that the position of each generated frame subject meets the expected position input by the user; Step 3: Set up the Switching Temporal Attention Mechanism STAM A switching temporal attention mechanism STAM is set in the TemporalAttention layer of Unet to transform the position of each vector in the time dimension of the latent space to achieve the consistency of the motion of the moving object; the switching temporal attention mechanism STAM acts on the TemporalAttention layer in the video diffusion model Unet to keep the main features of each frame consistent.

2. The construction method according to claim 1, characterized in that: The initial noise prior module INMP, in which the user first inputs a string c and a set of positions B of rectangular boxes corresponding to each frame, B f The box position represents the f-th frame; the user's input string c and the box position B0 of the first frame are used as guidance conditions. Unet will continuously reduce the noise of a Gaussian noise vector z*~N(0,I) in a latent space that follows a Gaussian distribution. The noise vector z* does not carry prior information and is automatically generated by the model, not the input of Unet. During the denoising process, the noise vector z* is subjected to a gradient descent with the loss function designed in the SC module as the target according to the value of the CrossAttention layer in Unet. Finally, the video V with the target position fixed, i.e., the position of the first frame, is obtained. meta ; Then, the video V meta Encode it through encoder E to get the generated video potential vector z meta ; For the video potential vector z meta Perform DDIM Inversion to obtain the corresponding noise potential representation z I ; Crop the variables in the latent space within the bounding box B0 for each frame to obtain a cropping sequence z in the latent space I *; Then, use the local blending operation to adjust z frame by frame I * In the given box position B f The clipped sequence z obtained before mixing within the range I and initial noise z*; during cropping, the B0 position noise is cropped for each frame; and the position of the local blending is blended at the position indicated by the bounding box corresponding to each frame; this enables setting a coherent prior corresponding to the position of the object in the initial noise; and also ensures that the appearance and motion of the animated object in the video frame remain consistent without adding additional computational cost during the generation process; The final output of the initial noise prior module INMP is a noise sequence in the latent space with low-frequency prior information, which serves as the starting input for the subsequent Unet denoising.

3. The construction method according to claim 1, characterized in that: The spatial attention constraint SC is specifically: optimize the intermediate potential representation vector z in each denoising step t t ; Based on the string c and the potential representation vector z t , the corresponding cross attention map A is obtained by the following formula: Q=W Q z t ,K=W K c Among them, A is the output attention map; Q and K are z t and c's query and key; W Q , W K are two learnable matrices, d is W Q The dimensions of the matrix are kept fixed in the setting. When the user specifies a box B for controlling the object trajectory, a box loss is used to ensure that the model controls the object to appear within the input box in each frame. Specifically, the box loss is implemented by maximizing the value of A corresponding to the prompt inside the box while minimizing the value outside the box through an optimization method. Frame by frame, the user-specified coordinate box is scaled to the corresponding coordinates in the latent space and a mask M is constructed. f ; The optimization method is implemented by creating four loss functions: Among them, L i f and L o f The CrossAttention value used to control the pixels in the latent space of each frame can be the highest inside the box B given by the user and the lowest outside; g(A k f , M f , P) represents the attention map A for the kth prompt word in the fth frame of the attention map k f , enter M f The average value of the first P percent largest elements in the range; P is an integer value used to specify the first P maximum values; L c f Used to focus the attention in each box on the center of the box, where x1 f and x2 f Indicates the center coordinates of the box in the fth frame; W Akf and H Akf and represents the center weight of the CrossAttention value of the f-th frame; Ls is used to ensure that the objects in each frame have a certain degree of similarity. The similarity used is cosine similarity, i.e. Sim(·,·) represents the calculation of the cosine similarity of two inputs. Pixel(A,B) represents the elements in the range from A to B. The weighted sum of several losses gives the overall loss: For L s p The value of the pixel in can represent the latent space z t Perform gradient descent to update z t ; Among them, the prefix coefficient λ i ,λ o ,λ c ,λ s are all pre-set hyperparameter coefficients, and their settings will be demonstrated through multiple experiments; the formula for gradient descent is as follows; where β t It is also a hyperparameter, and the most suitable value will be obtained based on the results of multiple tests; In each step of the denoising process, each time Unet is passed through, not only the noise sequence in the current latent space is predicted and the predicted noise is subtracted to achieve the denoising effect, but also the noise z is denoised before passing through Unet denoising. t Perform a gradient descent following the above formula to obtain z t '; The output after that is still a noise sequence in the latent space, which is used for the next denoising iteration.

4. The method according to claim 1, characterized in that: The switching temporal attention mechanism STAM is used to improve the dynamic characteristics of moving objects in different frames; specifically, frame B f z in range f The elements are shifted with the elements in the range of B0, and the subsequent frames in the frame range can be aligned with the frame range of the first frame; the specific steps are as follows: With w ′=TemporalAttention(z w ), Shift(z f ,B f ,B 0 ) is a shift operation, z f represents the latent space representation vector of frame f, B f With B 0 The Shift operation indicates the expected position of the object in the fth frame and the first frame respectively; 0 Swap the elements in position to B f Positionally; As shown in the formula, before passing through the TemporalAttention layer, the box alignment operation is performed on the elements of each frame except the first frame and the first frame, so that the mathematical calculation logic of the corresponding position in the subsequent Temporal Attention layer has semantics; after passing through the TemporalAttention layer, the corresponding inverse operation is performed to restore the elements that were moved in each frame except the first frame for subsequent denoising iterations.

Citation Information

Cited By

  • Multi-video object synthesis method

    CN118870119A