Video editing method, device, equipment and storage medium
By using the self-attention mechanism of the preset diffusion model in video editing to capture image frame features in portrait videos, it solves the problem of insufficient feature tracking stability in video editing, improves the stability and flexibility of video editing, and achieves Improves the stability of video timing.
Patent Information
- Application Number
- CN202410634874.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-22
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2044-05-22
AI Technical Summary
In existing video editing technology, the stability and accuracy of video feature tracking methods are insufficient, which affects the stability of video editing. Moreover, methods based on generative adversarial networks have stability and generalization problems, while methods based on diffusion models have problems with video editing. Issues such as timing instability and frame skipping.
By receiving the portrait video input by the user, the set of image frames to be edited is determined, and based on the self-attention mechanism in the preset diffusion model, the correspondence between the portrait key point features of the image frame and the reference image is captured to generate the edited image frame set. , improve the stability and flexibility of video editing.
Significantly improves the stability of video editing, avoids the problems of unstable key point features of portraits and unstable video timing, improves the accuracy and flexibility of video editing, and allows the image generation diffusion model to be quickly combined, making it suitable for video editing .
Smart Images

Figure CN118233699B
Abstract
Description
Technical Field
[0001] The present application relates to the field of virtual reality and computer vision technology, and in particular to a video editing method, device, equipment and storage medium. Background Art
[0002] Video editing can migrate the existing content of the source video to the specified subject to generate a new video. Currently, existing video editing generally uses video feature tracking to perform video editing. However, when using the video feature tracking method, it is necessary to track the key points of the portrait in the image frame to locate the position of the editing area in the image frame, and then locate the required editing position of other image frames in the video through feature matching. This is limited by the stability and accuracy of feature tracking, affecting the stability of video editing.
[0003] Therefore the prior art still needs to be improved and enhanced. Summary of the invention
[0004] The technical problem to be solved by the present application is to provide a video editing method, device, equipment and storage medium in view of the deficiencies in the prior art.
[0005] In order to solve the above technical problems, the first aspect of the present application provides a video editing method, wherein the video editing method specifically includes:
[0006] Receiving a portrait video input by a user, and determining a set of image frames to be edited based on the portrait video;
[0007] In response to an editing operation on the image frame set to be edited, editing a first image frame and a second image frame in the image frame set to be edited to obtain a first reference image and a second reference image;
[0008] Acquire a conditional image set of the image frame set to be edited;
[0009] Based on the acquired conditional image set, the first reference image and the second reference image, an edited image frame set of the image frame set to be edited is determined by a preset diffusion model, wherein the conditional image in the conditional image set contains portrait key point features of the image frame.
[0010] In the video editing method, the step of receiving a portrait video input by a user and determining a set of image frames to be edited based on the portrait video specifically comprises:
[0011] Receiving a portrait video input by a user, and receiving an editing range corresponding to the portrait video, wherein the editing range includes a start frame position and an end frame position;
[0012] A video segment to be edited is selected from the portrait video based on the editing range, and the video segment to be edited is decomposed into a set of image frames to be edited.
[0013] The video editing method, wherein the step of obtaining the conditional image set of the image frame set to be edited specifically includes:
[0014] Performing key point detection on each image frame in the image frame set to be edited to obtain portrait key point features corresponding to each image frame;
[0015] Based on the portrait key point features corresponding to each image frame, generating a conditional image of each image frame;
[0016] According to the conditional image of each image frame, a conditional image set of the image frame set to be edited is obtained.
[0017] The video editing method, wherein the step of determining the edited image frame set of the image frame set to be edited by using a preset diffusion model based on the acquired conditional image set, the first reference image, and the second reference image, specifically comprises:
[0018] Acquire a first reference feature map of the first reference image, a second reference feature map of the second reference image, and a conditional feature map set of the conditional image set;
[0019] Based on the first reference feature map, the second reference feature map and the conditional feature map set, determining fusion features corresponding to each intermediate image frame in the image frame set to be edited, wherein the intermediate image frame is an image frame other than the first image frame and the second image frame in the image frame set to be edited;
[0020] Based on the fusion features corresponding to the intermediate image frames, the edited image frames corresponding to the intermediate image frames are determined by a preset diffusion model;
[0021] The edited image frame set of the image frame set to be edited is obtained according to the first reference image, the second reference image and the edited image frames corresponding to the intermediate frames.
[0022] The video editing method, wherein determining the fusion features corresponding to each intermediate image frame in the image frame set to be edited based on the first reference feature map, the second reference feature map and the conditional feature map set, specifically includes:
[0023] determining a reference image representation based on the first reference feature map and the second reference feature map;
[0024] Grouping the intermediate image frames in the to-be-edited image frame set to obtain a plurality of image frame groups, wherein each image frame group includes a first intermediate image frame and a second intermediate image frame;
[0025] Acquire a noise image representation of each intermediate image frame of each image frame group, and obtain a conditional image representation of each intermediate image frame of each image frame group according to the conditional feature set;
[0026] Based on the reference image representation, the conditional image representation and the noise image representation, the fusion features of each intermediate image frame of each image frame group are determined to obtain the fusion features corresponding to each intermediate image frame in the image frame set to be edited.
[0027] The video editing method, wherein determining the reference image representation based on the first reference feature map and the second reference feature map specifically includes:
[0028] Constructing a first reference feature map and a second reference feature map;
[0029] The first reference feature map, the second reference feature map, the first reference feature map and the second reference feature map are spliced in a four-square grid to obtain a reference image representation, wherein the first reference feature map and the second reference feature map are located on a diagonal line of the reference image representation.
[0030] The video editing method, wherein obtaining the noise image representation of each intermediate image frame of each image frame group specifically includes:
[0031] Respectively acquiring noise images of the first image frame, the second image frame, and each intermediate image frame of each image frame group to obtain a noise image of the first image frame, a noise image of the second image frame, a noise image of the first intermediate image frame, and a noise image of the second intermediate image frame;
[0032] The noise image of the first image frame, the noise image of the second image frame, the noise image of the first intermediate image frame and the noise image of the second intermediate image frame are spliced in a four-square grid to obtain a noise image representation corresponding to each image frame group.
[0033] The video editing method, wherein obtaining the conditional image representation of each intermediate image frame of each image frame group according to the conditional feature set specifically includes:
[0034] Acquire conditional feature graphs of each intermediate image frame of each image frame group according to the conditional feature graph set, and obtain conditional feature graphs of a first intermediate image frame and a second intermediate image frame in each image frame group;
[0035] The conditional feature map of the first image frame, the conditional feature map of the second image frame, the conditional feature map of the first intermediate image frame and the conditional feature map of the second intermediate image frame are spliced in a four-square grid to obtain the conditional image representation corresponding to each image frame group.
[0036] In the video editing method, the first image frame is the first image frame in the set of image frames to be edited, and the second image frame is the last image frame in the set of image frames to be edited.
[0037] The video editing method, wherein, for each image frame group, the image frame distance between the first intermediate image frame and the first image frame in the image frame group is the same as the image frame distance between the second intermediate image frame and the second image frame in the image frame group, wherein the image frame distance is used to indicate the number of image frames spaced between two image frames in the playback order.
[0038] The video editing method, wherein the step of determining the edited image frames corresponding to the intermediate image frames based on the fusion features corresponding to the intermediate image frames by using a preset diffusion model, specifically includes:
[0039] Inputting the fused features corresponding to each intermediate image frame into a preset diffusion model, and performing denoising processing on the fused features through the preset diffusion model to obtain a denoised feature map of each intermediate frame;
[0040] Based on the denoising feature maps of the intermediate frames, the edited image frames corresponding to the intermediate image frames are determined.
[0041] The video editing method, wherein the step of determining the edited image frames corresponding to the intermediate image frames based on the denoising feature maps of the intermediate frames specifically includes:
[0042] Performing feature extraction on the denoised feature graphs of the intermediate frames to obtain feature coding graphs;
[0043] The feature coding map is decoded to obtain edited image frames corresponding to each intermediate image frame.
[0044] The video editing method, wherein obtaining the edited image frame set of the image frame set to be edited according to the first reference image, the second reference image and the edited image frames corresponding to each of the intermediate frames, specifically comprises:
[0045] The first reference image, the edited image frames corresponding to the intermediate frames, and the second reference image are sorted according to the playback order of the portrait video to obtain an edited image frame set of the image frame set to be edited.
[0046] A second aspect of the present application provides a video editing device, wherein the video editing device specifically includes:
[0047] a preprocessing module, configured to receive a portrait video input by a user, determine a to-be-edited image frame set based on the portrait video, and edit a first image frame and a second image frame in the to-be-edited image frame set in response to an editing operation on the to-be-edited image frame set to obtain a first reference image and a second reference image;
[0048] An execution module is used to obtain a conditional image set of the image frame set to be edited, and based on the obtained conditional image set, the first reference image and the second reference image, determine an edited image frame set of the image frame set to be edited through a preset diffusion model, and obtain an edited portrait video according to the edited image frame set, wherein the conditional image in the conditional image set contains portrait key point features of the image frame.
[0049] A third aspect of the present application provides a computer-readable storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement the steps in any of the video editing methods described above.
[0050] A fourth aspect of the present application provides a terminal device, comprising: a processor and a memory;
[0051] The memory stores a computer-readable program executable by the processor;
[0052] When the processor executes the computer-readable program, the steps in any of the above-mentioned video editing methods are implemented.
[0053] Beneficial effects: Compared with the prior art, the present application provides a method for receiving a portrait video input by a user, determining an image frame set to be edited based on the portrait video; in response to an editing operation on the image frame set to be edited, editing the first image frame and the second image frame in the image frame set to be edited to obtain a first reference image and a second reference image; obtaining a conditional image set of the image frame set to be edited, and determining the edited image frame set of the image frame set to be edited through a preset diffusion model based on the acquired conditional image set, the first reference image and the second reference image, and obtaining an edited portrait video according to the edited image frame set. The present application selects the image frame to be edited in the portrait video input by the user, determines the first reference image and the second reference image through an editing operation on the image frame set to be edited, and then uses the self-attention mechanism in the preset diffusion model to accurately capture the correspondence between the portrait key point features of the image frame and the reference image, thereby significantly improving the stability of video editing. At the same time, the present application can migrate the portrait edited by the user to the specified image frame set in the portrait video, and can form a quick combination with the image generation diffusion model, so that the image generation diffusion model can be easily embedded in the present application for video editing, thereby improving the flexibility of the use of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0055] Figure 1 A flowchart of a video editing method provided in an embodiment of the present application.
[0056] Figure 2 A flow chart of the principles of the video editing method provided in an embodiment of the present application.
[0057] Figure 3 A flowchart of an implementation method of the video editing method provided in an embodiment of the present application.
[0058] Figure 4 A schematic diagram of the structure of the video editing provided in the embodiment of the present application.
[0059] Figure 5 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0060] The embodiments of the present application provide a video editing method, device, equipment and storage medium. To make the purpose, technical solution and effect of the present application clearer and more specific, the present application is further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0061] It will be understood by those skilled in the art that, unless expressly stated, the singular forms "one", "said", and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present application refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be an intermediate element. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein includes all or any unit and all combinations of one or more associated listed items.
[0062] It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as those generally understood by those skilled in the art to which this application belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with those in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless specifically defined as here.
[0063] It should be understood that the sequence numbers and sizes of the steps in this embodiment do not mean the order of execution. The execution order of each process is determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application.
[0064] After research, it was found that video editing can migrate the existing content of the source video to the specified subject to generate a new video. Currently, existing video editing generally uses video feature tracking to perform video editing. However, when using the video feature tracking method, it is necessary to track the key points of the portrait in the image frame to locate the position of the editing area in the image frame, and then locate the required editing position of other image frames in the video through feature matching. This is limited by the stability and accuracy of feature tracking, affecting the stability of video editing.
[0065] In order to solve the above problems, some studies have adopted a video editing method based on generative adversarial networks to learn the mapping method of driving images to portrait images and a video editing method based on diffusion models. Among them, the method based on generative adversarial networks will affect the stability and generalization of the adversarial network, which will make it difficult to deploy in actual complex scenes, and there will be loss of details, more facial artifacts, and a heavy 2D stretching feeling that is not realistic enough. The method based on the diffusion model will cause unstable video timing and frame skipping, which will affect the stability of video editing.
[0066] In an embodiment of the present application, a set of image frames to be edited is determined based on a portrait video; in response to an editing operation on the set of image frames to be edited, a first image frame and a second image frame in the set of image frames to be edited are edited to obtain a first reference image and a second reference image; a conditional image set of the set of image frames to be edited is obtained, and based on the obtained conditional image set, the first reference image and the second reference image, the edited set of image frames of the set of image frames to be edited is determined by a preset diffusion model. The present application selects image frames to be edited from a portrait video input by a user, and determines a first reference image and a second reference image by an editing operation on the set of image frames to be edited, and then uses the first reference image and the second reference image as reference images, and uses the fusion features determined by the reference image and the conditional image as input items of a preset diffusion model, and uses the self-attention mechanism in the preset diffusion model to accurately capture the correspondence between the key point features of the image frame and the reference image. On the one hand, the problem of affecting the stability of video editing due to the instability of the key point features of the portrait can be avoided, and on the other hand, the problem of unstable video timing can be avoided by selecting two frames of images as reference images, thereby improving the stability of video editing.
[0067] The application content is further explained below through the description of embodiments in conjunction with the accompanying drawings.
[0068] This embodiment provides a video editing method, which can be applied to the fields of portrait re-enactment, video frame skipping and smoothing, video special effects, and style migration. Figure 1 and Figure 2 As shown, the method includes:
[0069] S10: receiving a portrait video input by a user, and determining a set of image frames to be edited based on the portrait video.
[0070] Specifically, the portrait video is a video to be edited input by the user, and the image frame set to be edited includes several image frames in the portrait video, and the several image frames may be part of the image frames in the source video, wherein the source video may be a shot video or a downloaded video, etc. In addition, the image frame set to be edited may include several continuous image frames in the source video, and may also include some discontinuous image frames in the source video. For example, a video segment is selected in the source video, and then the image frames of the video segment are disassembled to obtain the image frame set to be edited, or, several image frames are selected in the source video according to preset conditions to obtain the image frame set to be edited, wherein the preset conditions may be pre-set, for example, selecting image frames containing target objects, or selecting image frames according to preset intervals, etc.
[0071] In one implementation, the receiving of a portrait video input by a user and determining a set of image frames to be edited based on the portrait video specifically includes:
[0072] Receiving a portrait video input by a user, and receiving an editing range corresponding to the portrait video;
[0073] A video segment to be edited is selected from the portrait video based on the editing range, and the video segment to be edited is decomposed into a set of image frames to be edited.
[0074] Specifically, the editing range is used to reflect the selection range of image frames to be edited in the portrait video, wherein the editing range can be an image frame sequence number set, and the image frames corresponding to the image frame sequences in the image frame sequence number set are the image frames to be edited; or, the editing range includes a starting frame position and an ending frame position, and the starting frame corresponding to the starting frame position, the ending frame corresponding to the ending frame position, and all intermediate image frames between the starting frame and the ending frame are combined into the image frames to be edited, that is, a video segment with the starting frame as the first frame and the ending frame as the last frame is the video segment to be edited.
[0075] In the embodiment of the present application, the editing range includes a start frame position and an end frame position. Selecting a video segment to be edited in the portrait video based on the editing range refers to selecting a video segment in the portrait video consisting of a start frame corresponding to the start frame position, an end frame corresponding to the end frame position, and all intermediate image frames between the start frame and the end frame. The video segment is the video segment to be edited. Among them, all intermediate image frames between the start frame and the end frame refer to image frames located between the start frame and the end frame in chronological order. For example, the time corresponding to the start frame position is , the time corresponding to the end frame position is , and the intermediate image frame is The image frames corresponding to the time, that is, the image frame set to be edited is the portrait video and In the embodiment of the present application, the image frame set to be edited can be selected in the portrait video by the editing range, so that the user can select the image frame set to be edited by marking the editing range, so as to edit any image frame in the portrait video, and can edit a video segment of any length.
[0076] S20 , in response to an editing operation on the image frame set to be edited, editing a first image frame and a second image frame in the image frame set to be edited to obtain a first reference image and a second reference image.
[0077] Specifically, the first image frame and the second image frame may be any two image frames in the set of image frames to be edited, or may be the starting frame and the ending frame in the set of image frames to be edited. In an embodiment of the present application, the first image frame is the starting frame in the set of image frames to be edited, and the second image frame is the ending frame in the set of image frames to be edited. By using the starting frame and the ending frame as reference images, the timing relationship of the generated image frames can be effectively established, thereby avoiding the problem of unstable video timing and improving the stability of video editing. The first reference image is obtained by performing an editing operation on the first image frame, and the second reference image is obtained by performing an editing operation on the second image frame, wherein the first reference image and the second reference image are used as reference images for other image frames in the set of image frames to be edited, so as to migrate the image content (for example, portrait) in the first reference image and the second reference image after responding to the editing operation to other image frames in the set of image frames to be edited.
[0078] The editing operation may be input by the user, triggered based on a preset condition, or sent by an external device, and is used to edit the image frame set to be edited, wherein the editing operation includes one or more of an operation of adding content, an operation of deleting content, and an operation of changing style; the editing operation may be input through text description, may be input through voice, or may be implemented through other means. For example, the editing operation is an operation of modifying a portrait to a portrait with black hair, or deleting a specified target, or adding a red earring, etc.
[0079] Furthermore, in response to the editing operation, the editing operation will be performed on the first image frame and the second image frame. The first image frame and the second image frame may be edited directly, or the editing operation, the first image frame and the second image frame may be input into the preset diffusion model through a preset diffusion model, and the first image frame and the second image frame are diffused with the editing operation as a condition. In other words, the editing operation is a condition for the preset diffusion model to diffuse the first image frame and the second image frame, so that the diffused first reference image and the second reference image meet the requirements of the editing operation. Of course, in practical applications, other methods may also be used to respond to the editing operation of the first image frame and the second image frame.
[0080] S30, obtaining a conditional image set of the image frame set to be edited, and determining portrait key point features of an edited image frame set of the image frame set to be edited through a preset diffusion model based on the obtained conditional image set, the first reference image, and the second reference image, and obtaining an edited portrait video according to the edited image frame set.
[0081] Specifically, the conditional image set includes a conditional image of each image frame to be edited in the image frame set to be edited, and the conditional image is used as a condition of a preset diffusion model, wherein the conditional image is obtained by visualizing key point features of a portrait.
[0082] In one implementation, the step of obtaining the conditional image set of the image frame set to be edited specifically includes:
[0083] Performing key point detection on each image frame in the image frame set to be edited to obtain portrait key point features corresponding to each image frame;
[0084] Based on the portrait key point features corresponding to each image frame, generating a conditional image of each image frame;
[0085] According to the conditional image of each image frame, a conditional image set of the image frame set to be edited is obtained.
[0086] Specifically, the portrait key point features may include facial key points, body key points, facial key points and body key points, etc. Among them, the portrait key point features can be identified by opencv model, dlib model, mediapipe model, DwPose model, etc., or can be identified by existing face detection algorithms, body detection algorithms, etc., and there is no specific limitation here. In addition, after obtaining the portrait key points, the portrait key point features can be mapped to a blank image to obtain a conditional image, wherein the image dimension of the blank image is equal to the image dimension of the image frame to be edited; or, the portrait key point features can be visualized using visualization technology to obtain a conditional image, etc.
[0087] In one implementation, based on the acquired conditional image set, the first reference image, and the second reference image, determining the edited image frame set of the to-be-edited image frame set by using a preset diffusion model specifically includes:
[0088] Acquire a first reference feature map of the first reference image, a second reference feature map of the second reference image, and a conditional feature map set of the conditional image set;
[0089] Based on the first reference feature map, the second reference feature map and the conditional feature map set, determining fusion features corresponding to each intermediate image frame in the image frame set to be edited, wherein the intermediate image frame is an image frame other than the first image frame and the second image frame in the image frame set to be edited;
[0090] Based on the fusion features corresponding to the intermediate image frames, the edited image frames corresponding to the intermediate image frames are determined by a preset diffusion model;
[0091] The edited image frame set of the image frame set to be edited is obtained according to the first reference image, the second reference image and the edited image frames corresponding to the intermediate frames.
[0092] Specifically, the first reference feature map, the second reference feature map, and each conditional feature map are obtained by feature encoding, that is, the first reference image, the second reference image, and the conditional image of each image frame are feature encoded to obtain the first reference feature map, the second reference feature map, and each conditional feature map. When performing feature encoding, a trained feature encoding model can be used, such as a variational autoencoder (VAE).
[0093] For example, the VAE encoder is used to encode the first reference image, the second reference image, and the conditional image of each image frame. Then the encoding process of the first reference feature map, the second reference feature map, and each conditional feature map can be expressed as:
[0094] ,
[0095] in, represents the first reference feature map, represents the first reference image, represents the second reference feature map, represents the second reference image, represents the conditional feature atlas, Represents the set of conditional images.
[0096] It should be noted that, in practical applications, the first reference feature map, the second reference feature map and each conditional feature map can also be extracted by a trained feature extraction model, and no specific limitation is made here.
[0097] In a specific implementation, determining the fusion features corresponding to each intermediate image frame in the image frame set to be edited based on the first reference feature map, the second reference feature map, and the conditional feature map of each image frame in the image frame set to be edited specifically includes:
[0098] H11. Determine a reference image representation based on the first reference feature map and the second reference feature map;
[0099] H12, grouping the intermediate image frames in the to-be-edited image frame set to obtain a plurality of image frame groups, wherein each image frame group includes a first intermediate image frame and a second intermediate image frame;
[0100] H13, obtaining a noise image representation of each intermediate image frame of each image frame group, and obtaining a conditional image representation of each intermediate image frame of each image frame group according to the conditional feature set;
[0101] H14. Based on the reference image representation, the conditional image representation and the noise image representation, determine the fusion features of each intermediate image frame of each image frame group to obtain the fusion features corresponding to each intermediate image frame in the image frame set to be edited.
[0102] Specifically, in step H11, the reference image representation is used as a reference feature to facilitate editing content migration based on the reference image representation, wherein the reference image representation can be obtained by fusing the first reference feature map and the second reference feature map, for example, by splicing the first reference feature map and the second reference feature map according to channels, or by splicing the first reference feature map and the second reference feature map using a four-square splicing technique, etc.
[0103] In a specific implementation, determining the reference image representation based on the first reference feature map and the second reference feature map specifically includes:
[0104] Constructing a first reference feature map and a second reference feature map;
[0105] The first reference feature map, the second reference feature map, the first reference feature map and the second reference feature map are spliced in a four-square grid to obtain a reference image representation.
[0106] Specifically, the feature dimensions of the first reference feature map, the second reference feature map, the first reference feature map, and the second reference feature map are the same, and the feature dimensions of the first reference feature map and the second reference feature map are equal to the feature dimensions of the first reference image. For example, if the feature dimensions of the first reference feature map and the second reference feature map are both 64x64x4, then the feature dimensions of the first reference feature map and the second reference feature map are both 64x64x4. Therefore, when constructing the first reference feature map and the second reference feature map, the feature dimensions of the first reference feature map or the second reference feature map can be read first, and then two reference feature maps can be constructed according to the feature dimensions to obtain the first reference feature map and the second reference feature map, wherein each element value in the first reference feature map and the second reference feature map can be 0, that is, the first reference feature map and the second reference feature map are both all 0 feature maps. Of course, in actual applications, pixel values can also be assigned to the pixels in the first reference feature map and the second reference feature map according to actual needs, for example, the pixel values of each pixel in the first reference feature map and the second reference feature map are set to 0.5, 1, etc.
[0107] Further, after obtaining the first reference feature map and the second reference feature map, the first reference feature map, the second reference feature map, the first reference feature map and the second reference feature map are respectively used as one of the four grids, and then the first reference feature map, the second reference feature map, the first reference feature map and the second reference feature map are spliced together through the four-grid splicing technology. Among them, the positions of the first reference feature map, the second reference feature map, the first reference feature map and the second reference feature map in the four grids can be pre-set or randomly generated. For example, when the first reference feature map, the second reference feature map, the first reference feature map and the second reference feature map are spliced together in the four grids, a splicing position can be randomly generated for the first reference feature map, the second reference feature map, the first reference feature map and the second reference feature map, and then the first reference feature map, the second reference feature map, the first reference feature map and the second reference feature map are spliced together according to their corresponding splicing positions.
[0108] In an embodiment of the present application, when the first reference feature map, the second reference feature map, the first reference feature map and the second reference feature map are spliced in four grids, the first reference feature map and the second reference feature map are located in two grids on the diagonal, and the first reference feature map and the second reference feature map are located in the remaining two grids. For example, the reference image representation can be expressed as:
[0109] ,
[0110] Where R represents the reference image representation, represents the first reference feature map, Represents the second reference feature map, the upper right corner Represents the first reference feature map, which is a matrix of all 0s, with Represents the second reference feature map, which is also a matrix of all zeros.
[0111] Further, in step H12, each image frame group includes two intermediate image frames in the image frame set to be edited, which are respectively recorded as the first intermediate image frame and the second intermediate image frame. When the intermediate image frames in the image frame set to be edited are grouped, the number of image frames included in the image frame set to be edited can be read first. When the number of image frames is an even number, the intermediate image frames in the image frame set to be edited can be directly grouped in pairs to obtain a number of image frame groups. When the number of frames is an odd number, an intermediate image frame can be selected in the image frame set to be edited first, and an image frame group can be constructed based on the intermediate image frame. The image frame group includes two intermediate image frames, and then the selected image frame set to be edited is grouped, and each image frame group includes two intermediate image frames in the image frame set to be edited. Among them, when the image frame set to be edited is grouped, it can be grouped directly according to the playback order, or it can be grouped according to the positional relationship between each intermediate image frame in the image frame set to be edited and the first image frame and the second image frame.
[0112] In an embodiment of the present application, the first image frame is the image frame to be edited that is arranged at the front frame in the playback order (starting frame), and the second image frame is the image frame to be edited that is arranged at the last frame in the image frame set to be edited in the playback order (ending frame). In other words, the first image frame is the first image frame in the image frame set to be edited, and the second image frame is the last image frame in the image frame set to be edited. Therefore, when grouping the image frame set to be edited, the grouping can be based on the positional relationship between the image frame and the first image frame and the second image frame, so that the image frame distance between the first intermediate image frame and the first image frame in the image frame group is the same as the image frame distance between the second intermediate image frame and the second image frame in the image frame group, wherein the image frame distance is used to indicate the number of image frames spaced between two image frames in the playback order.
[0113] Further, in step H13, the noise image representation is generated based on the noise images of the first image frame, the second image frame and each intermediate image frame, and is used to determine the edited image of each intermediate image frame together with the reference feature representation and the conditional feature representation. In other words, the noise image representation is used as the image to be denoised.
[0114] In one implementation, obtaining the noise image representation of each intermediate image frame of each image frame group specifically includes:
[0115] Respectively acquiring noise images of the first image frame, the second image frame, and each intermediate image frame of each image frame group to obtain a noise image of the first image frame, a noise image of the second image frame, a noise image of the first intermediate image frame, and a noise image of the second intermediate image frame;
[0116] The noise image of the first image frame, the noise image of the second image frame, the noise image of the first intermediate image frame and the noise image of the second intermediate image frame are spliced in a four-square grid to obtain a noise image representation corresponding to each image frame group.
[0117] Specifically, the noise image can be formed by performing forward diffusion processing on the image frame, which is an intermediate process result of the preset diffusion model. That is, the noise image of the first image frame, the noise image of the second image frame, the noise image of the first intermediate image frame, and the noise image of the second intermediate image frame are all determined by the preset diffusion model, that is, the first image frame, the second image frame, the first intermediate image frame, and the second intermediate image frame are respectively forward diffused by the preset diffusion model to obtain the corresponding noise images.
[0118] Further, after obtaining the noise image of the first image frame, the noise image of the second image frame, the noise image of the first intermediate image frame, and the noise image of the second intermediate image frame, the above noise images are spliced in four grids to obtain a noise image representation. That is, the noise image representation is a four-grid feature map composed of the above noise images, each noise image occupies a grid in the noise image representation, wherein the noise image of the first image frame and the noise image of the second image frame are located on the diagonal of the noise image representation. Of course, in practical applications, the above noise images can also be represented in other ways, for example, the noise image of the first intermediate image frame and the noise image of the second intermediate image frame are located on the diagonal of the noise image representation, etc.
[0119] In a specific embodiment of the present application, the noise image of the first image frame and the noise image of the second image frame are located on a diagonal line of the noise image representation. For example, the noise image representation can be expressed as:
[0120] ,
[0121] in, represents the noisy image representation, represents the noise image of the first image frame at diffusion time step t, represents the noise image formed by the first intermediate image frame at the diffusion time step t, represents the noise image formed by the second intermediate image frame at the diffusion time step t, represents the noise image formed by the second image frame at the diffusion time step t.
[0122] It should be noted that, in practical applications, each noise image may also be represented by other methods, for example, by splicing each noise image in a channel direction.
[0123] Further, in step H13, the conditional image representation is used to act on the description information, which can be obtained by fusing the conditional feature map of the first image frame, the conditional feature map of the second image frame, the conditional feature map of the first intermediate image frame, and the conditional feature map of the second intermediate image frame in the image frame group.
[0124] In a typical implementation of the embodiment of the present application, the fusion method adopts a four-grid splicing technology. Accordingly, the conditional image representation of each intermediate image frame of each image frame group is obtained according to the conditional feature set, specifically including:
[0125] Acquire conditional feature graphs of each intermediate image frame of each image frame group according to the conditional feature graph set, and obtain conditional feature graphs of a first intermediate image frame and a second intermediate image frame in each image frame group;
[0126] The conditional feature map of the first image frame, the conditional feature map of the second image frame, the conditional feature map of the first intermediate image frame and the conditional feature map of the second intermediate image frame are spliced in a four-square grid to obtain the conditional image representation corresponding to each image frame group.
[0127] Specifically, the four conditional feature maps can use the method described in the above-mentioned reference image representation generation process to determine various corresponding splicing positions. This is not described in detail here, and only a specific embodiment is given. In this specific embodiment, the conditional feature map of the first image frame and the conditional feature map of the second image frame are located on the diagonal line of the conditional image representation. For example, the conditional image representation It can be expressed as:
[0128] ,
[0129] in, represents the conditional feature map of the first image frame, represents the conditional feature map of the second image frame, represents the conditional feature map of the first intermediate image frame, Represents the conditional feature map of the second intermediate image frame.
[0130] Further, in step H14, after obtaining the conditional image representation, the noise image representation and the reference image representation, the conditional image representation, the noise image representation and the reference image representation can be fused, wherein the fusion method can be splicing in the channel direction, adding in pixels, or multiplying in pixels, etc. In the embodiment of the present application, the fusion method adopts splicing in the channel direction, that is, the conditional image representation, the noise image representation and the reference image representation are spliced in the channel direction to obtain the fusion feature, and accordingly, the fusion feature can be:
[0131] ,
[0132] in, represents the fusion feature, Indicates splicing in the channel direction.
[0133] Example: Reference image representation R, conditional image representation and noisy image representation All are four-dimensional tensors (Tensor), and their feature dimensions are [B, C, H, W], where B represents the batch dimension, C represents the channel dimension, H represents the height dimension, and W represents the width dimension. Then, the fusion feature The feature dimension of is [B,3*C,H,W], that is, the reference feature representation R and the conditional feature representation are represented on the channel dimension C. and noisy image representation For splicing, it is 3*C.
[0134] Exemplarily, the preset diffusion model is pre-set and used to determine the edited image frame corresponding to the image frame based on the fusion feature corresponding to the image frame, wherein the edited image frame migrates the edited content formed based on the editing operation. The preset diffusion model can be a stable diffusion model or a latent diffusion model (LDM). The following description takes the preset diffusion model as LDM as an example.
[0135] The preset diffusion model LDM includes a trained autoencoder model, which includes an encoder E and a decoder D. In the specific implementation, the encoder E is used to compress each image frame to be encoded in the pixel space to obtain the feature map of each image frame to be encoded in the latent space, and then diffusion processing is performed on the latent space to obtain a noise image. The fusion feature determined based on the noise image, the conditional feature map, the first reference feature map and the second reference feature map is used as the noisy hidden code corresponding to the denoising U-net network (U-Net). The fusion feature is denoised for T time steps through the denoising U-net to obtain a denoised feature map. Finally, the encoder D is used to restore the denoised feature map to the original pixel space to obtain the edited image corresponding to each frame to be edited. This process of encoding first and then decoding of LDM can also be called perceptual compression. Among them, the process of obtaining a noisy image by diffusion processing the image frame to be encoded can be called a diffusion processing process, and the corresponding processing module can be a diffusion module; the process of obtaining a denoised feature map by denoising the fused features can be called a reverse diffusion processing process, and the corresponding processing module can be a denoising module, wherein the denoising module can include a denoising U-type network, and denoising processing for T time steps is performed through a denoising U-type network, that is, the denoising U-type network is denoised for T cycles; the denoising module can also include T denoising U-type networks, and denoising processing is performed in sequence through T cascaded denoising U-type networks to achieve denoising processing for T time steps, wherein, when there are T cascaded denoising U-type networks, the network structures of the T cascaded denoising U-type networks can be the same.
[0136] In an embodiment of the present application, the denoising U-net in the preset diffusion model includes a self-attention mechanism, and a conditional temporal denoising autoencoder is constructed through the self-attention mechanism to control the generation process of the edited image frame through conditions. That is to say, the embodiment of the present application uses the reference image representation and the conditional image representation as conditions, and controls the generation process of the edited image frame through the self-attention mechanism in the denoising U-net in the preset diffusion model to complete the appearance migration of the reference image. Specifically, the objective function of the preset diffusion model can be expressed as:
[0137] ,
[0138] in, represents the target loss, represents Gaussian noise with mean 0 and variance 1. represents the noise predicted by the preset diffusion model, represents the denoising network in the diffusion model, represents the noise at time 0, represents the diffusion time step, represents the mathematical expectation, , The coefficient representing the intensity correlation when noise is added.
[0139] In one implementation, the determining, based on the fusion features corresponding to the intermediate image frames, the edited image frames corresponding to the intermediate image frames by using a preset diffusion model specifically includes:
[0140] Inputting the fused features corresponding to each intermediate image frame into a preset diffusion model, and performing denoising processing on the fused features through the preset diffusion model to obtain a denoised feature map;
[0141] Based on the denoising feature map, the edited image frames corresponding to the intermediate image frames are determined.
[0142] Specifically, the preset diffusion model uses the self-attention mechanism to fusion features Denoising, get the denoised feature map, where the denoised image The determination process can be expressed as:
[0143] ,
[0144] in, represents the denoising network in the preset diffusion model, Denoised image features, represents the fusion feature, Represents the denoised features at each diffusion time step during the backdiffusion process.
[0145] Furthermore, when determining the denoising feature map, the fused image can be denoised by the denoising network to obtain the denoised image feature map. Then, the denoised image features are extracted to obtain the denoised feature map Accordingly, determining the edited image frames corresponding to the intermediate image frames based on the denoising feature maps of the intermediate frames specifically includes:
[0146] Performing feature extraction on the denoised feature graphs of the intermediate frames to obtain feature coding graphs;
[0147] The feature coding map is decoded to obtain edited image frames corresponding to each intermediate image frame.
[0148] Specifically, after obtaining the denoised image After that, the denoised image Perform feature extraction to obtain a denoised feature map, where the denoised feature map It can be expressed as:
[0149] ,
[0150] in, Represents the denoising feature map, B represents the Batch dimension, C represents the channel dimension, and H and W are the width and height of the feature.
[0151] Further, after obtaining the denoising feature map After that, the denoising feature map can be decoded by a decoder (such as a VAE decoder) to obtain an edited image frame corresponding to the image frame. Specifically, the edited image frame It can be expressed as:
[0152] ,
[0153] in, represents the VAE decoder, Indicates the edited image frame.
[0154] In one implementation, after the edited image frames of each intermediate image frame are acquired, the edited image frame set formed by each edited image frame can be used to replace the image frame set to be edited in the portrait video to obtain the edited portrait video. Based on this, after the edited image frame set of the image frame set to be edited is determined by the preset diffusion model, the method further includes: sorting the first reference image, the edited image frames corresponding to each intermediate frame, and the second reference image according to the playback order of the portrait video to obtain the edited image frame set of the image frame set to be edited. In addition, the edited image frame set can also be used to replace the image frame set to be edited in the portrait video to obtain the edited portrait video. Of course, in actual applications, some edited image frames can also be selected to replace the corresponding image frames in the portrait video as needed.
[0155] In summary, the present embodiment provides a video editing method, the method comprising obtaining an image frame set to be edited, and obtaining a conditional image set of the image frame set to be edited; in response to an editing operation on the image frame set to be edited, editing the first image frame and the second image frame in the image frame set to be edited to obtain a first reference image and a second reference image; obtaining a first reference feature map of the first reference image, a second reference feature map of the second reference image, and a conditional feature map set of the conditional image set; determining fusion features corresponding to each intermediate image frame in the image frame set to be edited based on the first reference feature map, the second reference feature map, and the conditional feature map set; determining edited image frames corresponding to each intermediate image frame through a preset diffusion model based on the fusion features corresponding to each intermediate frame, and forming an edited video based on all the determined edited image frames. The present application uses the first reference image and the second reference image determined based on the editing operation as reference images, and uses the fusion features determined by the reference image and the conditional image as input items of the preset diffusion model, and uses the self-attention mechanism in the preset diffusion model to accurately capture the correspondence between the portrait key point features of the image frame and the reference image, thereby improving the stability of video editing.
[0156] In addition, it should be noted that when executing the video editing method provided in the embodiment of the present application, after acquiring the first reference image, the second reference image, and the conditional image of each image frame to be edited, the fusion features of each image frame can be acquired respectively, and then the edited image frame of each image frame can be acquired respectively. The specific process is as described in the above embodiment. Of course, in actual applications, it is also possible to acquire the edited image frame of an image frame to be edited after acquiring the fusion features of the image frame to be edited. The above embodiment is described by taking the example of first acquiring the fusion features of each image frame respectively, and then acquiring the edited image frame of each image frame respectively. For example, after determining a set of image frames to be edited ( K frames in total , ,… …, , , ), select the first frame of the image frame set to be edited (starting frame / ) is the first image frame, the last image frame (end frame / ) is the second image frame, and after obtaining the first reference feature map corresponding to the first frame image, the second reference feature map corresponding to the second frame image, and the conditional feature map of each frame of the image frame to be edited, the intermediate image frames ( , ,… …, , ) are grouped in pairs, and the second image frame is selected from the image frame set to be edited according to the playback time sequence ( ) and the second to last image frame ( ) is the first intermediate image frame group, and the third image frame ( ) and the third to last image frame ( ) is the second intermediate image frame group, ..., and so on, to obtain a grouping of all the intermediate image frames; then, for each intermediate image frame group, the above-mentioned step of determining the edited image based on the acquired conditional image set, the first reference image and the second reference image is repeated in sequence according to the first intermediate image frame group, the second intermediate image frame group, ..., until all the intermediate image frame groups, to obtain edited image frames of two intermediate image frames of each intermediate image frame group; the first reference image, the edited image frame of the acquired intermediate image frame, and the second reference image are arranged in the playback order of each image frame in the image frame set to be edited, to obtain an edited image frame set.
[0157] Based on this, in one implementation, Figure 3 As shown, the implementation process of the video editing method may be:
[0158] Receive a portrait video input by a user, and select a set of image frames to be edited from the portrait video ( , ,… …, , , );
[0159] In response to an editing operation on the image frame set to be edited, the first image frame in the image frame set to be edited is edited. and the last image frame Performing editing to obtain a first reference image and a second reference image respectively;
[0160] Acquire a conditional image of each image frame in the image frames to be edited, and acquire a conditional feature map of the conditional image of each image frame to be edited, a first reference feature map of the first reference image, and a second reference feature map of the second reference image;
[0161] The first Frame by frame and Frame by frame A set of intermediate image frame groups is formed to obtain a sequence of all intermediate image frame groups, where: ;
[0162] The steps of obtaining the fusion features of each intermediate image frame and determining the edited image frame corresponding to each intermediate image frame based on the fusion features by using a preset diffusion model are sequentially performed on each intermediate image frame group in the intermediate image frame group sequence. When all the edited image frames corresponding to the intermediate image frames are determined, the edited image frames corresponding to the intermediate image frames are obtained. ;
[0163] Sorting the first reference image, each edited image frame, and the second reference image according to the order of their corresponding image frames in the portrait video to obtain an edited image frame set;
[0164] The edited image frame set replaces the image frame set to be edited in the input portrait video to obtain the edited portrait video.
[0165] The user inputs a video and specifies the starting and ending positions in the video to be modified. The image frames in the specified modification range are modified through the above implementation steps, so that the portrait edited and modified by the user can be migrated to the input portrait video.
[0166] Based on the above video editing method, this embodiment provides a video editing device, such as Figure 4 As shown, the video editing device specifically includes:
[0167] The preprocessing module 100 is used to receive a portrait video input by a user, determine an image frame set to be edited based on the portrait video, and edit a first image frame and a second image frame in the image frame set to be edited in response to an editing operation on the image frame set to be edited, so as to obtain a first reference image and a second reference image;
[0168] The execution module 200 is used to obtain a conditional image set of the image frame set to be edited, and based on the obtained conditional image set, the first reference image and the second reference image, determine an edited image frame set of the image frame set to be edited through a preset diffusion model, and obtain an edited portrait video according to the edited image frame set, wherein the conditional image in the conditional image set contains portrait key point features of the image frame.
[0169] Based on the above video editing method, this embodiment provides a computer-readable storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement the steps in the video editing method described in the above embodiment.
[0170] Based on the above video editing method, the present application also provides a terminal device, such as Figure 5As shown, it includes at least one processor 20; a display screen 21; and a memory 22, and may also include a communications interface 23 and a bus 24. The processor 20, the display screen 21, the memory 22, and the communications interface 23 may communicate with each other through the bus 24. The display screen 21 is configured to display a preset user guide interface in the initial setting mode. The communications interface 23 may transmit information. The processor 20 may call the logic instructions in the memory 22 to execute the method in the above embodiment.
[0171] In addition, the logic instructions in the memory 22 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product.
[0172] The memory 22 is a computer-readable storage medium that can be configured to store software programs, computer executable programs, such as program instructions or modules corresponding to the methods in the embodiments of the present disclosure. The processor 20 executes functional applications and data processing by running the software programs, instructions or modules stored in the memory 22, that is, implementing the methods in the above embodiments.
[0173] The memory 22 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the terminal device, etc. In addition, the memory 22 may include a high-speed random access memory and may also include a non-volatile memory. For example, a variety of media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, may also be a transient storage medium.
[0174] In addition, the specific process of loading and executing the multiple instruction processors in the above-mentioned storage medium and the terminal device has been described in detail in the above-mentioned method, and will not be described one by one here.
[0175] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A video editing method, characterized in that: The video editing method specifically includes: Receiving a portrait video input by a user, and determining a set of image frames to be edited based on the portrait video; In response to an editing operation on the image frame set to be edited, editing a first image frame and a second image frame in the image frame set to be edited to obtain a first reference image and a second reference image; Acquire a conditional image set of the image frame set to be edited; Based on the acquired conditional image set, the first reference image and the second reference image, determining the edited image frame set of the image frame set to be edited by a preset diffusion model, wherein the conditional image in the conditional image set includes the portrait key point features of the image frame; An edited portrait video is obtained according to the edited image frame set.
2. The video editing method according to claim 1, characterized in that: The receiving of a portrait video input by a user and determining a set of image frames to be edited based on the portrait video specifically includes: Receiving a portrait video input by a user, and receiving an editing range corresponding to the portrait video, wherein the editing range includes a start frame position and an end frame position; A video segment to be edited is selected from the portrait video based on the editing range, and the video segment to be edited is decomposed into a set of image frames to be edited.
3. The video editing method according to claim 1, characterized in that: The step of obtaining the conditional image set of the image frame set to be edited specifically includes: Performing key point detection on each image frame in the image frame set to be edited to obtain portrait key point features corresponding to each image frame; Based on the portrait key point features corresponding to each image frame, generating a conditional image of each image frame; According to the conditional image of each image frame, a conditional image set of the image frame set to be edited is obtained.
4. The video editing method according to claim 1, characterized in that: The step of determining the edited image frame set of the image frame set to be edited by using a preset diffusion model based on the acquired conditional image set, the first reference image, and the second reference image specifically includes: Acquire a first reference feature map of the first reference image, a second reference feature map of the second reference image, and a conditional feature map set of the conditional image set; Based on the first reference feature map, the second reference feature map and the conditional feature map set, determining fusion features corresponding to each intermediate image frame in the image frame set to be edited, wherein the intermediate image frame is an image frame other than the first image frame and the second image frame in the image frame set to be edited; Based on the fusion features corresponding to the intermediate image frames, the edited image frames corresponding to the intermediate image frames are determined by a preset diffusion model; The edited image frame set of the image frame set to be edited is obtained according to the first reference image, the second reference image and the edited image frames corresponding to the intermediate frames.
5. The video editing method according to claim 4, characterized in that: The determining, based on the first reference feature map, the second reference feature map and the conditional feature map set, the fusion feature corresponding to each intermediate image frame in the to-be-edited image frame set specifically includes: determining a reference image representation based on the first reference feature map and the second reference feature map; Grouping the intermediate image frames in the to-be-edited image frame set to obtain a plurality of image frame groups, wherein each image frame group includes a first intermediate image frame and a second intermediate image frame; Acquire a noise image representation of each intermediate image frame of each image frame group, and obtain a conditional image representation of each intermediate image frame of each image frame group according to the conditional feature set; Based on the reference image representation, the conditional image representation and the noise image representation, the fusion features of each intermediate image frame of each image frame group are determined to obtain the fusion features corresponding to each intermediate image frame in the image frame set to be edited.
6. The video editing method according to claim 5, characterized in that: The determining of the reference image representation based on the first reference feature map and the second reference feature map specifically includes: Constructing a first reference feature map and a second reference feature map; The first reference feature map, the second reference feature map, the first reference feature map and the second reference feature map are spliced in a four-square grid to obtain a reference image representation.
7. The video editing method according to claim 5, characterized in that: Acquiring the noise image representation of each intermediate image frame of each image frame group specifically includes: Respectively acquiring noise images of the first image frame, the second image frame, and each intermediate image frame of each image frame group to obtain a noise image of the first image frame, a noise image of the second image frame, a noise image of the first intermediate image frame, and a noise image of the second intermediate image frame; The noise image of the first image frame, the noise image of the second image frame, the noise image of the first intermediate image frame and the noise image of the second intermediate image frame are spliced in a four-square grid to obtain a noise image representation corresponding to each image frame group.
8. The video editing method according to claim 5, characterized in that: The step of obtaining the conditional image representation of each intermediate image frame of each image frame group according to the conditional feature set specifically includes: Acquire conditional feature graphs of each intermediate image frame of each image frame group according to the conditional feature graph set, and obtain conditional feature graphs of a first intermediate image frame and a second intermediate image frame in each image frame group; The conditional feature map of the first image frame, the conditional feature map of the second image frame, the conditional feature map of the first intermediate image frame and the conditional feature map of the second intermediate image frame are spliced in a four-square grid to obtain the conditional image representation corresponding to each image frame group.
9. The video editing method according to any one of claims 1 to 8, characterized in that: The first image frame is the first image frame in the set of image frames to be edited, and the second image frame is the last image frame in the set of image frames to be edited.
10. The video editing method according to claim 9, characterized in that: For each image frame group, the image frame distance between the first intermediate image frame and the first image frame in the image frame group is the same as the image frame distance between the second intermediate image frame and the second image frame in the image frame group, wherein the image frame distance is used to indicate the number of image frames spaced between two image frames in the playback order.
11. The video editing method according to any one of claims 5 to 8, characterized in that: The step of determining the edited image frames corresponding to the intermediate image frames based on the fusion features corresponding to the intermediate image frames by using a preset diffusion model specifically includes: Inputting the fused features corresponding to each intermediate image frame into a preset diffusion model, and performing denoising processing on the fused features through the preset diffusion model to obtain a denoised feature map of each intermediate frame; Based on the denoising feature maps of the intermediate frames, the edited image frames corresponding to the intermediate image frames are determined.
12. The video editing method according to claim 11, characterized in that: The determining, based on the denoising feature graphs of the intermediate frames, the edited image frames corresponding to the intermediate image frames specifically includes: Performing feature extraction on the denoised feature graphs of the intermediate frames to obtain feature coding graphs; The feature coding map is decoded to obtain edited image frames corresponding to each intermediate image frame.
13. The video editing method according to any one of claims 5 to 8, characterized in that: Obtaining the edited image frame set of the image frame set to be edited according to the first reference image, the second reference image and the edited image frames corresponding to the intermediate frames, specifically includes: The first reference image, the edited image frames corresponding to the intermediate frames, and the second reference image are sorted according to the playback order of the portrait video to obtain an edited image frame set of the image frame set to be edited.
14. A video editing device, characterized in that: The video editing device specifically comprises: a preprocessing module, configured to receive a portrait video input by a user, determine a to-be-edited image frame set based on the portrait video, and edit a first image frame and a second image frame in the to-be-edited image frame set in response to an editing operation on the to-be-edited image frame set to obtain a first reference image and a second reference image; An execution module is used to obtain a conditional image set of the image frame set to be edited, and based on the obtained conditional image set, the first reference image and the second reference image, determine an edited image frame set of the image frame set to be edited through a preset diffusion model, and obtain an edited portrait video according to the edited image frame set, wherein the conditional image in the conditional image set contains portrait key point features of the image frame.
15. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps in the video editing method according to any one of claims 1-13.
16. A terminal device, characterized in that: include: Processor and memory; The memory stores a computer-readable program executable by the processor; When the processor executes the computer-readable program, the steps in the video editing method according to any one of claims 1 to 13 are implemented.
