Image processing method, training method of image generation model, and information processing method based on image generation model
The reference area is determined in the reference image through the image generation model, and the image is repaired based on the semantic feature information, which solves the problem in the existing technology that image repair is difficult to transfer features with high fidelity, and achieves a more natural fusion effect and a simplified operation process.
Patent Information
- Application Number
- CN202410737834.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-06
- Publication Date
- 2024-09-13
AI Technical Summary
Existing image inpainting technology is difficult to transfer the features in the reference image to the original image with high fidelity, especially when processing local areas, and the user operation is cumbersome and it is difficult to accurately convey the editing intention.
Through the image generation model, the semantic feature information of the redrawn area in the image to be processed is used to determine the reference area in the reference image, and the redrawn area is transferred after adding noise to generate the target image without the need to cut out or specify in the reference image. Reference area.
It simplifies user operations and improves the convenience and applicability of image synthesis. The generated target image has a more natural fusion effect and avoids the incompatibility between local features and the background.
Smart Images

Figure CN118644575A
Abstract
Description
Technical Field
[0001] The embodiments of this specification relate to the field of computer technology, and in particular to an image processing method, a training method for an image generation model, and an information processing method based on an image generation model. Background Art
[0002] Diffusion models are an emerging generative model technology that has received widespread attention in the field of deep learning, especially in the field of image generation. The core principle of the diffusion model is to train a UNet model by adding noise to a given target image at different steps during the training process. Given the number of steps and the image after adding noise, the current noise is predicted. During the test process, the trained UNet model can denoise the Gaussian noise step by step to generate an image. Based on the principle of the diffusion model, industry research uses various conditions to guide the diffusion model to perform image repair with controllable content.
[0003] Image inpainting technology generally uses language description to redraw a given area, but due to the limitations of language description, when the user has a clear expectation of the redrawing target, it is difficult to describe the redrawing target (especially texture, pattern details, etc.) similarly by relying solely on language. Image synthesis technology can insert specified objects in a reference image into a specified area of the original image, but this method requires specifying the replacement area in the reference image and is not applicable to the local replacement of some objects. Therefore, how to improve the convenience and applicability of image synthesis technology has become an urgent problem for technicians to solve. Summary of the invention
[0004] In view of this, the embodiments of this specification provide an image processing method, a training method for an image generation model, and an information processing method based on an image generation model. One or more embodiments of this specification also relate to a computing device, a computer-readable storage medium, and a computer program product to solve the technical defects existing in the prior art.
[0005] According to a first aspect of an embodiment of this specification, there is provided an image processing method, including:
[0006] Acquire an image to be processed and a reference image corresponding to the image to be processed, wherein the image to be processed includes a redrawing area;
[0007] The image to be processed and the reference image are input into an image generation model to obtain a target image generated by the image generation model, wherein the image generation model determines a reference area in the reference image based on semantic feature information of the redrawn area, and redraws the redrawn area of the noisy image to be processed based on the reference area to generate a target image.
[0008] According to a second aspect of an embodiment of this specification, a training method for an image generation model is provided, which is applied to a cloud-side device, and includes:
[0009] A sample video segment sent by a receiving end-side device is obtained, and based on the sample video segment, a sample initial image and a sample reference image corresponding to the sample initial image are obtained;
[0010] Marking a sample mask area in the sample initial image to obtain a sample to-be-processed image corresponding to the sample initial image;
[0011] Inputting the sample to-be-processed image and the sample reference image into an image generation model to obtain a predicted image output by the image generation model, wherein the image generation model determines a sample reference area in the sample reference image based on semantic feature information of the sample mask area, and redraws the noisy sample to-be-processed image based on the sample reference area to generate a predicted image;
[0012] Calculate a model loss value according to the predicted image and the sample initial image;
[0013] The model parameters of the image generation model are adjusted according to the model loss value, and the image generation model is continuously trained until the model training stop condition is reached, the model parameters of the image generation model are obtained, and the model parameters are sent to the end-side device.
[0014] According to a third aspect of an embodiment of this specification, there is provided an image processing method, which is applied to a cloud-side device, including:
[0015] An image generation task sent by a receiving end-side device, wherein the image generation task includes an image to be processed and a reference image corresponding to the image to be processed, and the image to be processed includes a redrawing area;
[0016] Inputting the image to be processed and the reference image into an image generation model to obtain a target image generated by the image generation model, wherein the image generation model determines a reference area in the reference image based on semantic feature information of the redrawn area, and redraws the redrawn area of the noisy image to be processed based on the reference area to generate a target image;
[0017] The target image is sent to the terminal device.
[0018] According to a fourth aspect of the embodiments of this specification, there is provided an information processing method based on an image generation model, which is applied to a task platform and includes:
[0019] Receiving a task generation request sent by a terminal device, wherein the task generation request includes request information;
[0020] Based on the request information, an image generation model is acquired, wherein the image generation model determines a reference area in a reference image based on semantic feature information of the redrawn area in the image to be processed, and redraws the redrawn area of the noisy image to be processed based on the reference area to generate a target image;
[0021] Based on the image generation model, task information is generated, wherein the task information is used for the terminal device to perform the image generation task.
[0022] According to a fifth aspect of the embodiments of this specification, there is provided a task platform, including a request interface and a response unit;
[0023] The request interface is used to receive a task generation request sent by a terminal device, wherein the task generation request includes request information;
[0024] The response unit is used to obtain an image generation model based on the request information, and generate task information based on the image generation model, wherein the image generation model determines a reference area in a reference image based on semantic feature information of the redrawn area in the image to be processed, and redraws the redrawn area of the noisy image to be processed based on the reference area to generate a target image, and the task information is used for the terminal side device to perform the image generation task.
[0025] According to a sixth aspect of an embodiment of this specification, a computing device is provided, including:
[0026] Memory and processor;
[0027] The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions. When the computer programs / instructions are executed by the processor, the steps of the above method are implemented.
[0028] According to a seventh aspect of the embodiments of this specification, a computer-readable storage medium is provided, which stores a computer program / instruction, and the steps of the above method are implemented when the computer program / instruction is executed by a processor.
[0029] According to an eighth aspect of the embodiments of this specification, a computer program product is provided, comprising a computer program / instruction, which implements the steps of the above method when executed by a processor.
[0030] An image processing method provided by an embodiment of the present specification includes obtaining an image to be processed and a reference image corresponding to the image to be processed, wherein the image to be processed includes a redrawn area; inputting the image to be processed and the reference image into an image generation model to obtain a target image generated by the image generation model, wherein the image generation model determines a reference area in the reference image based on semantic feature information of the redrawn area, and redraws the redrawn area of the noisy image to be processed based on the reference area to generate a target image.
[0031] Through the image processing method provided in the embodiments of this specification, the user only needs to provide the image to be processed including the redrawn area and its corresponding reference image. The image to be processed and the reference image are input into the image generation model, and the image generation model can determine the corresponding reference area in the reference image according to the semantic feature information of the redrawn area, without marking the reference area in the reference image, which simplifies the user's operation steps and improves the user's experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 is a flow chart of an image processing method provided by an embodiment of this specification;
[0033] Figure 2 is a schematic diagram of an image to be processed and a reference image provided by an embodiment of this specification;
[0034] Figure 3 is a schematic diagram of determining a sample to-be-processed image and a sample reference image from a sample video clip provided by an embodiment of the present specification;
[0035] Figure 4 is a data processing schematic diagram of an image generation model provided by an embodiment of this specification;
[0036] Figure 5 is a schematic diagram of an image processing method provided by an embodiment of this specification;
[0037] Figure 6 It is a schematic diagram of the effect of an image processing method provided by an embodiment of this specification;
[0038] Figure 7 It is a flowchart of a training method for an image generation model provided by an embodiment of this specification;
[0039] Figure 8 is an architecture diagram of an image processing system provided by an embodiment of this specification;
[0040] Fig. 9 It is a flowchart of an image processing method applied to a cloud-side device provided by an embodiment of this specification;
[0041] Fig.10 is a flowchart of an information processing method based on an image generation model provided by an embodiment of this specification;
[0042] Fig.11 is a schematic diagram of a task platform provided by an embodiment of this specification;
[0043] Fig.12 is a structural schematic diagram of an image processing device provided by an embodiment of this specification;
[0044] Fig.13 It is a structural block diagram of a computing device provided by an embodiment of this specification. DETAILED DESCRIPTION
[0045] Many specific details are described in the following description to facilitate a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of this specification, so this specification is not limited to the specific implementation disclosed below.
[0046] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.
[0047] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0048] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this manual are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards in the relevant regions, and corresponding operation entrances shall be provided for users to choose to authorize or refuse.
[0049] First, the terms involved in one or more embodiments of this specification are explained.
[0050] Diffusion model: The diffusion model is inspired by non-equilibrium thermodynamics and generates images from Gaussian noise in the form of iterative denoising. It is a technical route in the current deep generative model.
[0051] Customized Generation: Users provide a single or a few reference images of a specified concept and generate images of the concept in different scenes, actions, and forms.
[0052] Image Editing: Given an image to be edited, modify the content of the image to be edited according to the statement or reference image.
[0053] Diffusion Models is a branch of current image generation technology. Its core principle is to add noise to a given target image at different steps during the training process, train a UNet model, and predict the current noise given the number of steps and the image after adding noise. The trained UNet model can denoise the Gaussian noise step by step to generate an image.
[0054] Based on the principle of diffusion model, the industry studies use various conditions to guide diffusion model to modify images with controllable content. For example, given an original image, edit a certain local area. Considering the diversity of user needs, researchers have explored image repair and synthesis techniques under various conditions.
[0055] In the field of image processing, image inpainting technology generally uses language description to describe a given area. However, due to the limitations of language description, when the user has a clear expectation of the redrawn target, it is difficult to describe the redrawn target (especially details such as texture and pattern) in detail by language alone. Image synthesis technology can insert a specified object in a reference image into a specified area of the original image, but the current approach is only for complete reference objects. It is necessary to specify a mask or detection frame of the reference area in a given reference image, segment the specific reference target, extract and obtain accurate representation, but this solution is not applicable to the local part of the object, because the local area and the surrounding background are often strongly coupled and are not suitable for segmentation and understanding. Secondly, the redrawn original area also needs to be naturally integrated and interacted with the background objects. The current method often finds it difficult to maintain local details and will generate a rigid fusion effect.
[0056] Both of the above techniques can be understood as local feature combination techniques in image editing. Given an original image and a reference image, the features of a certain area in the original image are redrawn according to the area of the reference image. For example, the hairstyle of the model in the reference image is transferred to the model in the original image; the sole design in the reference image is transferred to the sole design of the shoe in the original image, etc. The difficulty of this image processing is:
[0057] 1. How to transfer the features in the reference image to the original image in a high-fidelity form.
[0058] 2. How to seamlessly integrate the migrated local features with the original image to avoid any sense of disharmony.
[0059] Traditional methods often require users to provide detailed text descriptions or make manual adjustments, which is not only time-consuming and labor-intensive, but also difficult to accurately convey the user's editing intentions.
[0060] Based on this, in this specification, an image processing method is provided. This specification also involves a training method of an image generation model, an information processing method based on the image generation model, a computing device, a computer-readable storage medium and a computer program product, which are described in detail one by one in the following embodiments.
[0061] See also Figure 1 , Figure 1 A flowchart of an image processing method provided according to an embodiment of the present specification is shown, which specifically includes the following steps.
[0062] Step 102: Acquire an image to be processed and a reference image corresponding to the image to be processed, wherein the image to be processed includes a redrawing area.
[0063] The image to be processed can be understood as an image that needs to be re-edited in a local area, and the image to be processed includes a redrawing area that needs to be redrawn. The reference image can be understood as an image that provides a reference for the image to be processed. Figure 2 , Figure 2 A schematic diagram of an image to be processed and a reference image provided in an embodiment of the present specification is shown.
[0064] like Figure 2 As shown, the image to be processed includes a beaver, and its ear and neck regions are marked, indicating that it is desired to redraw its ear and neck regions. The reference image is an image of a kitten, which includes pointed ears and a necklace decoration on its neck.
[0065] In the method provided in the embodiments of this specification, preferably, the image to be processed and the reference image have corresponding information, for example, both images include an animal's head, both images include shoes, both images include a quilt, etc. In practical applications, there may be no corresponding relationship between the image to be processed and the reference image, for example, the image to be processed is a photo of a sofa, and the reference image is a photo of a cake, etc.
[0066] It should be noted that in the method provided in this specification, the image to be processed includes a redrawn area, and its purpose is to edit the image for the redrawn area in the image to be processed based on the information in the reference image. The method provided in this specification only has a redrawn area in the image to be processed, and no marking is required in the reference image.
[0067] In a specific implementation provided in this specification, the user can mark the part that he wants to adjust in the original image. On the basis of the original image, the marked redrawn area is added to generate the image to be processed.
[0068] Step 104: Input the image to be processed and the reference image into an image generation model to obtain a target image generated by the image generation model, wherein the image generation model determines a reference area in the reference image based on semantic feature information of the redrawn area, and redraws the redrawn area of the noisy image to be processed based on the reference area to generate a target image.
[0069] After obtaining the image to be processed and the reference image, the image to be processed and the reference image are input into the image generation model for processing to obtain a target image generated by the image generation model based on the image to be processed and the reference image. The target image can be understood as an image generated after redrawing the redrawn area in the image to be processed based on the reference image.
[0070] In the method provided in this specification, the image generation model is a diffusion model, which is based on the semantic feature information of the redrawn area. A reference area corresponding to the redrawn area is located in the reference image, and after the image to be processed is denoised, the redrawn area in the noisy image to be processed is redrawn based on the reference area according to the characteristics of the diffusion model, thereby obtaining a target image.
[0071] In this method, the user does not need to cut out or specify the reference area in the reference image. The image generation model can find the corresponding reference area in the reference image and imitate it according to the semantic correspondence of the redrawn area. This method eliminates the time-consuming and labor-intensive reference image cutout process. At the same time, the scheme understands the reference area in the global context of the entire reference image, and can better learn the interaction between the local area and the surrounding objects, thereby generating a more natural fusion effect.
[0072] In the method provided in an embodiment of the present specification, the image generation model includes a first image processing branch and a second image processing branch;
[0073] Inputting the image to be processed and the reference image into an image generation model to obtain a target image generated by the image generation model, including S1042-S1044:
[0074] S1042. Input the reference image into the first image processing branch, and obtain reference attention key value information generated by the first image processing branch in the process of processing the reference image, wherein the reference attention key value information represents semantic feature information in the reference image.
[0075] In the method provided in the embodiment of this specification, two image processing branches composed of the same network structure are provided, namely, a first image processing branch and a second image processing branch, wherein the first image processing branch is used to process a reference image. The first image processing branch and the second image processing branch are both created based on the UNet network structure.
[0076] UNet is a semantic segmentation model. Its main execution process is similar to other semantic segmentation models. In the image processing process, it is a pixel-level classification, and the output is the category of each pixel in the image. The UNet network is divided into a backbone feature extraction network (encoder), an enhanced feature extraction network (decoder) and a classifier.
[0077] The backbone feature extraction network is used to extract features from the image and fuse the extracted features. The enhanced feature extraction network is used to upsample the extracted effective feature layer and fuse the features to obtain a final effective feature layer that fuses all features. The classifier is used to classify each pixel according to the final features obtained.
[0078] In the first image processing branch, an attention mechanism is included. The UNet network combined with the attention mechanism can effectively improve the performance of image segmentation tasks. The attention module is integrated into the UNet architecture to dynamically redistribute the intersections of the network so that it can focus more on the key parts of the image for the segmentation task. In this way, UNet can more effectively utilize its jump-continuous characteristics to improve segmentation accuracy with fine localized information.
[0079] In the method provided in the embodiment of the present specification, in the process of classifying each pixel in the reference image through the first image processing branch, the attention module in the first image processing branch generates reference attention key information for the reference image, and the reference attention key information represents the semantic feature information in the reference image. The reference attention key information of the attention module in the first image processing branch is obtained.
[0080] Specifically, the first image processing branch includes a first image encoder and a first image decoder;
[0081] Inputting the reference image into the first image processing branch to obtain reference attention key value information in the first image processing branch includes:
[0082] Inputting the reference image into the first image encoder to obtain a reference image encoding feature corresponding to the reference image;
[0083] The reference image encoding features are input into the first image decoder to obtain the reference image decoding features and reference attention key value information.
[0084] In practical applications, the first image processing branch includes a first image encoder and a first image decoder. The reference image is input into the first image encoder for feature extraction, and the reference image is downsampled to obtain reference image coding features corresponding to the reference image. When the first image encoder has five coding layers, five preliminary effective feature layers can be obtained in the first image encoder.
[0085] The reference image encoding features are input into the first image decoder for enhanced feature extraction, and the multiple preliminary effective feature layers obtained in the previous step are feature fused, and the feature layers are upsampled and stacked. In this process, the reference attention key value information of the attention module in the first image decoder is obtained.
[0086] The image generation model provided in the embodiments of this specification adopts an implicit diffusion model. Before the reference image is input into the first image processing branch, it is first compressed and mapped to a smaller spatial dimension of implicit representation by VAE (Variational Auto-Encoder), and then mapped to the original image. By diffusing on the implicit representation, less memory can be used, the number of UNet layers can be reduced, and the generation of images can be accelerated. The results can also be input into the VAE decoder to obtain high-resolution images.
[0087] Therefore, before the reference image is input into the first image encoder, the reference image is first input into the VAE network for processing to obtain implicit expression information of the reference image, and then the implicit expression information of the reference image is input into the first image encoder for subsequent processing.
[0088] The first image processing branch provided in the embodiment of this specification is used to determine the reference attention key value information generated during the reference image processing process, so as to facilitate the input of the reference attention key value information into the second image processing branch for processing in the subsequent processing process, and assist the second image processing branch in generating the target image.
[0089] S1044. Input the image to be processed and the reference attention key value information into the second image processing branch to obtain the target image output by the second image processing branch.
[0090] After obtaining the reference attention key value information in the first image processing branch, the image to be processed and the reference attention key value information are input into the second image processing branch for processing to obtain the target image output by the second image processing branch.
[0091] Specifically, inputting the image to be processed and the reference attention key information into the second image processing branch to obtain the target image output by the second image processing branch includes:
[0092] Constructing features of the image to be processed according to the image to be processed;
[0093] The features of the image to be processed and the reference attention key information are input into the second image processing branch to obtain a target image output by the second image processing branch.
[0094] In the method provided in the embodiment of this specification, a diffusion model is used to generate a target image. In this process, an implicit noise image is used as a representation of the image to be processed, and features of the image to be processed are constructed according to the image to be processed. The process of constructing features of the image to be processed according to the image to be processed is carried out in an image generation model, and the image generation model includes a preprocessing module for the image to be processed, in which the image to be processed is preprocessed to construct features of the image to be processed.
[0095] The features of the image to be processed and the reference attention key information are input into the second image processing branch for processing to obtain the target image output by the second image processing branch.
[0096] The feature of the image to be processed can be understood as an image feature constructed based on the image to be processed and used to participate in the iterative denoising process, which includes implicit image noise, depth information of the image to be processed, redrawing area information of the image to be processed and implicit expression information of the image to be processed. Specifically, constructing the feature of the image to be processed based on the image to be processed includes:
[0097] Creating noise information of the image to be processed according to the image to be processed;
[0098] Generate mask information of the image to be processed according to the redrawn area in the image to be processed;
[0099] Generating depth information of the image to be processed corresponding to the image to be processed;
[0100] Acquire implicit expression information of the image to be processed corresponding to the image to be processed;
[0101] The noise information of the image to be processed, the mask information of the image to be processed, the depth information of the image to be processed and the implicit expression information of the image to be processed are spliced to construct features of the image to be processed.
[0102] In practical applications, the 4-channel noise information of the image to be processed is used as a representation of the image to be processed to participate in the iterative denoising process.
[0103] According to the redrawn area in the image to be processed, the corresponding mask information of the image to be processed (mask information corresponding to the image to be processed) is generated to represent the redrawn area information in the image to be processed. The mask information of the image to be processed is 1 channel.
[0104] In addition, the original image corresponding to the image to be processed can be processed according to the depth estimation model to extract the depth information of the image to be processed corresponding to the original image of the image to be processed. The depth map is mapped to a 4-channel implicit expression through the mapping layer of the science department. The user can choose whether to keep the shape information before editing, edit only the texture, or design the shape as an editable attribute.
[0105] In addition, the image to be processed can also be processed through the VAE network to obtain the implicit expression information of the image to be processed corresponding to the image to be processed. In practical applications, the implicit expression information of the image to be processed is 4 channels.
[0106] After obtaining the image noise information (4 channels), image mask information (1 channel), image depth information (4 channels) and image implicit expression information (4 channels) corresponding to the image to be processed, the above 4 information can be spliced in the channel dimension to construct a 13-channel image feature to be processed.
[0107] In a specific implementation provided in this specification, the second image processing branch includes a second image encoder, a second image decoder and an output layer;
[0108] Inputting the to-be-processed image features and the reference attention key information into the second image processing branch to obtain a target image output by the second image processing branch, including:
[0109] Inputting the reference attention key information into the second image decoder to update the attention key information in the second image decoder;
[0110] Inputting the to-be-processed image feature into the second image encoder to obtain the to-be-processed image coding feature corresponding to the to-be-processed image feature;
[0111] Inputting the encoding features of the image to be processed into the second image decoder to obtain decoding features of the image to be processed;
[0112] The decoded features of the image to be processed are input into the output layer to obtain a target image.
[0113] After the features of the image to be processed are obtained, the features of the image to be processed are input into the second image encoder of the second image processing branch for feature extraction to obtain encoding features of the image to be processed corresponding to the features of the image to be processed.
[0114] The coding features of the image to be processed and the reference attention key information are input into the second image decoder for processing. In the second image decoder, the reference attention key information and the attention key information in the second image encoder are spliced to complete the feature sharing of the attention key information. The coding features of the image to be processed are then processed to obtain the decoded features of the image to be processed. It should be noted that when the coding features of the image to be processed are input into the second image decoder for processing, the attention key information in the second image decoder has been updated with the reference attention key information. Finally, the decoded features of the image to be processed are input into the output layer of the second image processing branch for processing. After multiple iterative denoising operations of the second image processing branch, the final target image is generated.
[0115] In practical applications, the reference attention key value information is added to the second image encoder, the attention key value information in the second image encoder is updated, and an updated second image encoder is obtained.
[0116] The updated second image encoder and the second image decoder are used together to perform multiple iterations of denoising on the features of the image to be processed, thereby generating a final target image.
[0117] Specifically, the second image decoder includes an attention layer;
[0118] Inputting the reference attention key information into the second image decoder, and updating the attention key information in the second image decoder, comprising:
[0119] Inputting the reference attention key value information into the attention layer, wherein the attention layer includes the target attention key value information;
[0120] Generate spliced attention key information according to the reference attention key information and the target attention key information, and use the spliced attention key information as the attention key information of the attention layer.
[0121] In practical applications, the second image decoder includes an image decoding layer and an attention layer, and the attention layer includes target attention key information. Furthermore, the number of image decoding layers is multiple, and each image decoder corresponds to an attention layer. The network structure in the first image processing branch is the same as the network structure in the second image processing branch. The reference attention key information of the multiple attention layers in the first image processing branch is spliced with the corresponding target attention key information respectively.
[0122] For example, the first image decoder of the first image processing branch includes 5 attention layers, and the second image decoder of the second image processing branch also includes 5 attention layers. The first reference attention key information in the first image decoder is spliced with the first target attention key information in the second image decoder to obtain the first spliced attention key information. Similarly, after the second reference attention key information is spliced with the second target attention key information, the second spliced attention key information is obtained, and so on. The second image decoder includes 5 image decoding layers and 5 attention layers, and the attention key information in each attention layer is spliced by the reference attention key information and the target attention key information. The spliced attention key information is used as the attention key information of the attention layer.
[0123] In the process of iterative denoising operation of the image feature to be processed by the second image processing branch, the attention layer in the second image decoder includes the reference attention key information in the first image processing branch. The reference attention key information represents the semantic feature information in the reference image. In the process of processing the image feature to be processed by the second image processing branch, the image feature to be processed includes the information of the mask area. The semantic feature information of the mask area in the image to be processed can be obtained according to the information of the mask area. By comparing the semantic feature information of the mask area with the semantic feature information of the reference image, the reference area corresponding to the mask area can be found in the reference image. In the process of iterative processing of the image feature to be processed, the second image processing branch refers to the relevant information in the reference image. The image feature to be processed also includes the mask information, depth information and implicit expression information of the image to be processed. The semantic feature information in the image to be processed can be better obtained and combined according to the reference attention key information in the reference image processing process. Thus, the image to be processed is edited by imitating the information in the reference image to obtain the final target image.
[0124] In a specific implementation manner provided in this specification, the image generation model is a trained machine learning model. Further, the image generation model is a model that has been trained in a progressive manner. Specifically, the image generation model is obtained through the following S1060-S1068 training:
[0125] S1060: Acquire a sample initial image and a sample reference image corresponding to the sample initial image based on the sample video clip.
[0126] The model training method of the image generation model provided in the embodiments of this specification adopts supervised training, which includes a sample initial image for training and a sample reference image corresponding to the sample initial image. It should be noted that the training method provided in the embodiments of this specification is based on the sample initial image and the sample reference image obtained based on the sample video clip.
[0127] Specifically, obtaining a sample initial image and a sample reference image corresponding to the sample initial image based on the sample video clip includes:
[0128] Acquire the sample video clip, wherein the sample video clip is a sample split-shot video;
[0129] A sample initial image and a sample reference image are selected from multiple frames of images of the sample video clip.
[0130] In the method provided in the embodiment of this specification, the sample video clip can be understood as a sample split-shot video clip, and the split-shot video clip can be understood as a video clip without cut shots in a video. For example, in a video, there are 5 split-shot clips, and these 5 split-shot clips can all be used as sample video clips.
[0131] The sample storyboard video is usually the same scene, and the content in the video will not change much. The sample initial image and the sample reference image are selected to facilitate better matching of corresponding feature points in the two images during subsequent training.
[0132] The method of obtaining sample initial images and sample reference images through sample video clips simplifies the process of determining training sample pairs and improves the convenience of determining training sample pairs in the model training stage.
[0133] S1062: Mark a sample mask area in the sample initial image to obtain a sample to-be-processed image corresponding to the sample initial image.
[0134] The sample mask area can be understood as the area that needs to be redrawn in the sample initial image. In the method provided in the embodiment of this specification, after the sample initial image is obtained, the local area in the sample initial image is masked with a mask to simulate the redrawn area in the image. The marking of the sample mask area in the sample initial image can be determined manually by a technician, randomly, or by a preset comparison rule.
[0135] In another specific implementation manner provided in this specification, marking a sample mask area in the sample initial image includes:
[0136] Dividing the sample initial image into a plurality of sample grids according to a preset rule;
[0137] Randomly mark sample mask areas in each sample grid.
[0138] In this embodiment, the sample initial image may be divided into a plurality of sample grids according to a preset rule, for example, the sample initial image may be divided into N*M sample grids, wherein N may be the same as M or different from M. After the plurality of sample grids are determined, the sample mask area may be randomly marked in each sample grid, thereby enabling the sample mask area to be determined quickly and conveniently from the sample initial image.
[0139] In another specific implementation manner provided in this specification, the method further comprises:
[0140] Determine at least one reference control point in the sample initial image and the sample reference image, wherein the reference control point is a feature point in the sample initial image and the sample reference image;
[0141] Accordingly, the sample mask area is randomly marked in each sample grid, including:
[0142] Marking a sample mask region in a reference control point grid based on a first mask probability, wherein the reference control point grid includes a sample grid where reference control points exist;
[0143] A sample mask region is marked in a non-reference control point grid based on a second mask probability, wherein the non-reference control point grid includes a sample grid without reference control points.
[0144] In practical applications, the sample initial image and the sample reference image are randomly selected images from the same video clip, and there are many common contents in the sample initial image and the sample reference image. For example, if the sample video clip is a video clip of a sailing ship, the sample initial image and the sample reference image will most likely include the image of the sailing ship. Therefore, at least one reference control point can be determined in the sample initial image and the sample reference image. The reference control point can be understood as a feature point in the sample initial image and the sample reference image.
[0145] In the image processing scenario, a feature point refers to a point where the grayscale value of an image changes dramatically, or a point with a large curvature on the edge of an image (i.e., the intersection of two edges). Image feature points play a very important role in image matching algorithms based on feature points. Image feature points can reflect the essential features of an image, can identify target objects in an image, and can match images by matching feature points. In the method provided in the embodiments of this specification, the SIFT feature matching method can be used to obtain at least one feature point in the sample initial image and the sample reference image. Each feature point is used as a reference control point in the sample initial image and the sample reference image.
[0146] By randomly marking the sample mask area in each sample grid, it can be determined whether there is a reference control point in each sample grid. If there is a reference control point in the sample grid, the sample grid is called a reference control point grid; if there is no reference control point in the sample grid, the sample grid is called a non-reference control point grid.
[0147] After determining the reference control point grid and the non-reference control point grid, the sample mask area can be marked with different mask probabilities, for example, the sample mask area is marked in the reference control point grid with a first mask probability, and the reference control area is determined in the non-reference control point grid with a second mask probability. The first mask probability and the second mask probability are probabilities for determining that a certain sample grid is a sample mask area. Furthermore, in the method provided in the embodiment of the present specification, it is hoped to train an image generation model that can perform semantic region matching. If the sample mask area has corresponding feature points in the sample reference image, the image generation model can be better trained. Therefore, in another specific implementation provided in the present specification, the first mask probability can be greater than the second mask probability. For example, the first mask probability is 0.75 and the second mask probability is 0.5. For the reference control point grid, the sample mask area is marked with a probability of 0.75, and for the non-reference control point grid, the sample mask area is marked with a probability of 0.5. The sample initial image is masked according to the sample mask area to obtain a sample to be processed image.
[0148] Depending on whether the reference control point exists in the sample grid, different mask probabilities are used to select the sample mask area, which can make the sample mask area more biased towards the sample grid with matching feature points, so that the subsequent image generation model can better perform semantic comparison during the training process.
[0149] See also Figure 3 , Figure 3 FIG. 1 shows a schematic diagram of determining a sample to-be-processed image and a sample reference image from a sample video clip according to an embodiment of the present specification. Figure 3As shown, a sample video clip is first selected, and two video frames are randomly selected therefrom as a sample initial image and a sample reference image, respectively. The sample initial image is then divided into multiple sample grids, and sample mask areas are marked in the multiple sample grids according to a preset masking probability. The sample initial image is masked based on the sample mask area to obtain a sample image to be processed.
[0150] S1064. Input the sample image to be processed and the sample reference image into an image generation model to obtain a predicted image output by the image generation model, wherein the image generation model determines a sample reference area in the sample reference image based on semantic feature information of the sample mask area, and redraws the noisy sample image to be processed based on the sample reference area to generate a predicted image.
[0151] After obtaining the sample to-be-processed image and the sample reference image in the above steps, both are input into the image generation model, which is an image generation model that has not been trained yet. In the image generation model, the feature information of the sample reference image is first extracted, and the sample reference area is determined in the feature information of the sample reference image through the semantic feature information of the sample mask area, and the noisy sample to-be-processed image is iteratively denoised based on the feature information of the sample reference area to achieve redrawing of the sample mask area, thereby generating a predicted image.
[0152] See also Figure 4 , Figure 4 FIG. 2 shows a data processing diagram of an image generation model provided in an embodiment of the present specification. Figure 4 As shown in Figure 1, the image generation model includes a first image processing branch and a second image processing branch. The first image processing branch and the second image processing branch are symmetrical structures. They have the same network structure but process different data. The first image processing branch processes the sample reference image, and the second image processing branch processes the sample image to be processed. It should be noted that in the model inference stage, the model architecture of the image generation model is also as shown in Figure 1. Figure 4 The model architecture of the image generation model is the same as that of
[0153] In the first image processing branch, the reference sample image is first processed through the VAE Encoder module to obtain the implicit expression information corresponding to the sample reference image, and the implicit expression information of the sample reference image is input into the first image processing branch for processing, and the attention key value information in the first image processing branch is extracted.
[0154] In the second image processing branch, the corresponding sample image features are generated according to the sample image to be processed. Specifically, the 4-channel noise information of the image to be processed is first used as the representation of the denoised image to participate in the subsequent iterative denoising process; the depth estimation model is used to extract the depth map of the sample initial image before masking, and the depth map is mapped into a 4-channel implicit expression using a learnable mapping layer to obtain the depth information of the image to be processed; at the same time, the mask information of the image to be processed corresponding to the sample image to be processed is obtained, and the mask information of the image to be processed is a 1-channel expression; finally, the sample image to be processed is processed using the VAE Encoder to obtain the implicit expression information of the image to be processed corresponding to the 4-channel representation of the sample image to be processed.
[0155] The noise information of the image to be processed, the depth information of the image to be processed, the mask information of the image to be processed and the implicit expression information of the image to be processed are spliced on the channel blockage to generate 13-channel sample image features to be processed.
[0156] The features of the sample image to be processed are input into the second image processing branch for processing. During the processing of the second image processing branch, the attention features extracted from the first image processing branch (Key and Value in the attention layer of the decoder in the first image processing branch) are spliced with the attention key information in the attention layer of the decoder of the second image processing branch to obtain the spliced attention key information, and the spliced attention key information is used to update the attention key information of the attention layer in the decoder of the second image processing branch. The updated second image processing branch is used to perform an iterative denoising step on the features of the sample image to be processed, so as to complete the information of the sample mask area and generate a predicted image.
[0157] In a specific implementation manner provided in this specification, before the sample to-be-processed image and the sample reference image are input into the image generation model, the method further includes:
[0158] Data enhancement is performed on the sample to-be-processed image and the sample reference image respectively to obtain enhanced sample to-be-processed image and sample reference image.
[0159] In practical applications, before the sample to-be-processed image and the sample reference image are input into the image generation model, data enhancement processing can be performed on the sample to-be-processed image and the sample reference image respectively. Specifically, brightness adjustment, contrast adjustment, saturation perturbation, random perspective change, size scaling and other processing can be performed on the sample to-be-processed image and the sample reference image respectively. By performing data enhancement on the sample to-be-processed image and the sample reference image respectively, the difference between the two images can be enlarged, the specificity of the image generation model can be enhanced, and the image generation model has better generalization. After data enhancement is performed on the sample to-be-processed image and the sample reference image respectively, the enhanced sample to-be-processed image and the sample reference image are input into the image generation model for processing.
[0160] S1066. Calculate a model loss value according to the predicted image and the sample initial image.
[0161] After obtaining the predicted image of the image generation model, the model loss value can be calculated based on the predicted image and the sample initial image. In the method provided in this specification, there are many methods for calculating the model loss value, such as cross entropy loss function, maximum loss function, average loss function, etc. In this specification, the specific method of the loss function is not limited, and it is subject to actual application.
[0162] S1068. Adjust the model parameters of the image generation model according to the model loss value, and continue to train the image generation model until the model training stop condition is reached.
[0163] After obtaining the model loss value, the model parameters of the image generation model can be adjusted according to the model loss value. Specifically, the model loss value can be back-propagated to update the model parameters of the image generation model in sequence.
[0164] After adjusting the model parameters, the above steps can be repeated to continue training the image processing model until the training stop condition is reached. In practical applications, the training stop condition of the image processing model includes:
[0165] The model loss value is less than a preset threshold; and / or
[0166] The training rounds reach the preset training rounds.
[0167] Specifically, in the process of training the image processing model, the training stop condition of the model can be set to a model loss value less than a preset threshold, or the training stop condition can be set to a preset number of training rounds, such as 10 rounds of training. In this specification, there is no specific limitation on the preset threshold of the loss value and / or the preset number of training rounds, which shall be subject to actual application.
[0168] The model training method of the image generation model provided in the embodiments of the present specification uses a data construction paradigm based on video clips, selects two video frames in a video clip to simulate the sample initial image and the sample reference image in the model training stage, simplifies the process of determining the training sample pairs, and improves the convenience of determining the training sample pairs in the model training stage.
[0169] In the process of partially masking the sample initial image and generating the sample to-be-processed image, a feature point comparison method is used to determine the feature points in the sample original image and the sample reference image, and the sample grid is randomly masked with a certain probability according to whether the sample grid contains feature points, so as to ensure that the masked area has a corresponding reference area in the reference image as much as possible, so as to facilitate the subsequent image generation model to better perform semantic comparison during the training process. The model training method provided in the embodiment of this specification uses a depth map to control the shape of the sample mask area, and supports the user to choose whether to retain the shape information before editing, edit the texture, or design the shape as an editable attribute.
[0170] The following combination Figure 5 , taking the application of the image processing method provided in this specification in the image reconstruction scene as an example, the image processing method is further described. Figure 5 A schematic diagram of an image processing method provided by an embodiment of the present specification is shown.
[0171] like Figure 5 As shown, a reference image and an image to be processed are obtained, and the image to be processed includes a redrawing area that needs to be redrawn.
[0172] The reference image and the image to be processed are input into the image generation model. Specifically, the reference image is first processed by VAEEncoder to obtain an implicit expression of the reference image, and the implicit expression of the reference image is input into the first image processing branch for processing to obtain the reference attention key value information in the decoder of the first image processing branch. The reference attention key value information is input into the decoder of the second image processing branch, and is spliced and fused with the attention key value information in the decoder of the second image processing branch to obtain the spliced attention key value information.
[0173] According to the image to be processed, the corresponding image noise information to be processed, image mask information to be processed, image depth information to be processed and image implicit expression information to be processed are obtained, and the above information is spliced according to the channel dimension to obtain the image features to be processed, and the image features to be processed are input into the second image processing branch for processing.
[0174] At this time, the attention key information in the second image processing branch is a parameter updated by the reference attention key information in the first image processing branch. The second image processing branch performs iterative denoising on the features of the image to be processed, and finally generates a target image.
[0175] It should be noted that, through the image generation model provided in the embodiments of this specification, if there are identical or similar objects in the image to be processed and the reference image, image synthesis can be performed through semantic feature information. If there are no identical or similar objects in the image to be processed and the reference image, the target object can be identified from the reference image, and the redrawn area in the image to be processed can be regenerated based on the target object to obtain the target image.
[0176] See also Figure 6 , Figure 6 1 is a schematic diagram of the effect of an image processing method provided by an embodiment of the present specification. The redrawn area in the image to be processed is a sofa, and the reference image is a cake. The image to be processed and the reference image are input into the image generation model, and the image generation model can recognize that the target object in the reference image is a cake, and redraw the sofa in the image to be processed according to the characteristics of the cake, and finally generate the target image.
[0177] See also Figure 7 , Figure 7 A flow chart of a method for training an image generation model provided in an embodiment of the present specification is shown. The model training method is applied to a cloud-side device and includes:
[0178] Step 702: Receive a sample video segment sent by a terminal-side device, and acquire a sample initial image and a sample reference image corresponding to the sample initial image based on the sample video segment.
[0179] Step 704: Mark a sample mask area in the sample initial image to obtain a sample to-be-processed image corresponding to the sample initial image.
[0180] Step 706: Input the sample image to be processed and the sample reference image into an image generation model to obtain a predicted image output by the image generation model, wherein the image generation model determines a sample reference area in the sample reference image based on semantic feature information of the sample mask area, and redraws the noisy sample image to be processed based on the sample reference area to generate a predicted image.
[0181] Step 708: Calculate a model loss value based on the predicted image and the sample initial image.
[0182] Step 710: Adjust the model parameters of the image generation model according to the model loss value, and continue to train the image generation model until the model training stop condition is reached, obtain the model parameters of the image generation model, and send the model parameters to the end-side device.
[0183] In practical applications, since model training requires a large amount of data and good computing resources, the end-side device may not have the corresponding processing capabilities. Therefore, the model training process can be implemented on the cloud-side device. After obtaining the model parameters of the image generation model, the cloud-side device can also send the model parameters to the end-side device. The end-side device can build an image generation model locally based on the model parameters of the image generation model, and further use the image generation model to perform image processing tasks.
[0184] The model training method of the image generation model provided in the embodiments of the present specification uses a data construction paradigm based on video clips, selects two video frames in a video clip to simulate the sample initial image and the sample reference image in the model training stage, simplifies the process of determining the training sample pairs, and improves the convenience of determining the training sample pairs in the model training stage.
[0185] In the process of partially masking the sample initial image and generating the sample to-be-processed image, a feature point comparison method is used to determine the feature points in the sample original image and the sample reference image, and the sample grid is randomly masked with a certain probability according to whether the sample grid contains feature points, so as to ensure that the masked area has a corresponding reference area in the reference image as much as possible, so as to facilitate the subsequent image generation model to better perform semantic comparison during the training process. The model training method provided in the embodiment of this specification uses a depth map to control the shape of the sample mask area, and supports the user to choose whether to retain the shape information before editing, edit the texture, or design the shape as an editable attribute.
[0186] See also Figure 8 , Figure 8 An architecture diagram of an image processing system provided by an embodiment of the present specification is shown, and the image processing system may include a client 100 and a server 200;
[0187] The client 100 is used to send an image generation task to the server 200, wherein the image generation task includes an image to be processed and a reference image corresponding to the image to be processed, and the image to be processed includes a redrawing area;
[0188] The server 200 is used to receive an image generation task sent by a terminal device, wherein the image generation task includes an image to be processed and a reference image corresponding to the image to be processed, and the image to be processed includes a redrawing area; the image to be processed and the reference image are input into an image generation model to obtain a target image generated by the image generation model, wherein the image generation model determines a reference area in the reference image based on semantic feature information of the redrawing area, and redraws the redrawing area of the noisy image to be processed based on the reference area to generate a target image; and the target image is sent to the client 100;
[0189] The client 100 is also used to receive the target image sent by the server 200.
[0190] The image processing system may include multiple clients 100 and a server 200, wherein the client 100 may be referred to as a client-side device and the server 200 may be referred to as a cloud-side device. Multiple clients 100 may establish a communication connection through the server 200. In the image processing scenario, the server 200 is used to provide image generation services between multiple clients 100. Multiple clients 100 may serve as a sender or a receiver, respectively, and realize communication through the server 200.
[0191] The user can interact with the server 200 through the client 100 to receive data sent by other clients 100, or send data to other clients 100, etc. In the image processing scenario, the user can publish a data stream to the server 200 through the client 100, and the server 200 generates a target image according to the data stream and pushes the target image to other clients that have established communication.
[0192] The client 100 and the server 200 are connected via a network. The network provides a medium for a communication link between the client 100 and the server 200. The network may include various connection types, such as wired or wireless communication links or optical fiber cables, etc. The data transmitted by the client 100 may need to be encoded, transcoded, compressed, etc. before being released to the server 200.
[0193] The client 100 can be a browser, an APP (Application), or a web application such as an H5 (HyperText Markup Language 5, Hypertext Markup Language Version 5) application, or a light application (also known as a mini-program, a lightweight application) or a cloud application, etc. The client 100 can be based on the software development kit (SDK, Software Development Kit) of the corresponding service provided by the server 200, such as based on the real-time communication (RTC, Real Time Communication) SDK development and acquisition. The client 100 can be deployed in an electronic device, and needs to rely on the device to run or some APPs in the device to run. For example, the electronic device can have a display screen and support information browsing, such as a personal mobile terminal such as a mobile phone, a tablet computer, a personal computer, etc. Various other types of applications can also be configured in the electronic device, such as human-computer dialogue applications, model training applications, text processing applications, web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0194] The server 200 may include servers that provide various services, such as servers that provide communication services to multiple clients, servers for background training that provide support for models used on clients, and servers that process data sent by clients. It should be noted that the server 200 can be implemented as a distributed server cluster consisting of multiple servers, or as a single server. The server can also be a server of a distributed system, or a server combined with a blockchain. The server can also be a cloud server for basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution networks (CDN, Content Delivery Network), and big data and artificial intelligence platforms, or an intelligent cloud computing server or intelligent cloud host with artificial intelligence technology.
[0195] It is worth noting that the image processing method provided in the embodiments of this specification is generally executed by the server, but in other embodiments of this specification, the client may also have similar functions to the server, thereby executing the image processing method provided in the embodiments of this specification. In other embodiments, the image processing method provided in the embodiments of this specification may also be jointly executed by the client and the server.
[0196] Fig. 9 A schematic diagram of a process flow of an image processing method applied to a cloud-side device provided in an embodiment of this specification is shown. Fig. 9 Said method comprises:
[0197] Step 902: receiving an image generation task sent by a terminal-side device, wherein the image generation task includes an image to be processed and a reference image corresponding to the image to be processed, and the image to be processed includes a redrawing area.
[0198] Step 904: Input the image to be processed and the reference image into an image generation model to obtain a target image generated by the image generation model, wherein the image generation model determines a reference area in the reference image based on semantic feature information of the redrawn area, and redraws the redrawn area of the noisy image to be processed based on the reference area to generate a target image.
[0199] Step 906: Send the target image to the terminal device.
[0200] In another specific implementation provided in the embodiments of this specification, the method further includes:
[0201] The image adjustment information sent by the receiving end side device for the target image;
[0202] Adjust the target image based on the image adjustment information to obtain an adjusted target image;
[0203] The adjustment target image is sent to the terminal side device.
[0204] Through the image processing method provided by the embodiments of this specification, the user only needs to provide the image to be processed including the redrawn area, and its corresponding reference image. The image to be processed and the reference image are input into the image generation model. The image generation model can determine the corresponding reference area in the reference image according to the semantic feature information of the redrawn area. There is no need to mark the reference area in the reference image, which simplifies the user's operation steps and improves the user's experience. The image processing method runs on the cloud-side device, and the end-side device used by the user only needs to communicate with the cloud-side device. There is no requirement for the performance of the end-side device, which expands the application scenarios of the image processing method.
[0205] Fig.10 A flow chart of an information processing method based on an image generation model provided in an embodiment of the present specification is shown, and the method is applied to a task platform, including:
[0206] Step 1002: Receive a task generation request sent by a terminal device, wherein the task generation request includes request information.
[0207] Step 1004: Based on the request information, an image generation model is obtained, wherein the image generation model determines a reference area in the reference image based on semantic feature information of the redrawn area in the image to be processed, and redraws the redrawn area of the noisy image to be processed based on the reference area to generate a target image.
[0208] Step 1006: Generate task information based on the image generation model, wherein the task information is used for the terminal device to perform the image generation task.
[0209] The task platform is an online platform that provides services or functions, allowing developers, enterprises or individual users to submit tasks, obtain resources or implement specific functions through API calls, web interfaces or other interactive methods. In the embodiments of this specification, the task platform is a cloud service platform that can provide image processing services, allowing external applications (such as content recommendations, social media, digital twin systems, etc.) to access and use its image processing capabilities to generate new target images. The task platform ensures efficient and accurate response to requests from terminal devices by managing model training, updating, optimization and load balancing.
[0210] A task generation request is a specific operation request initiated by a terminal device to the task platform, which is intended to trigger the platform to perform an image processing task. The task generation request usually contains necessary parameters and request information, such as the image to be processed, the reference image, etc.
[0211] The task platform can obtain the corresponding image generation model according to the request information. For the relevant information of the image generation model, please refer to the relevant description in the above embodiment, which will not be repeated here.
[0212] After the task platform processes the task generation request, it generates task information based on the output of the scene localization model as a response to the terminal device. The task information can guide the terminal device to operate the image generation model to perform the corresponding image generation task.
[0213] In another specific implementation manner provided in this specification, the request information includes a task scenario identifier of the image processing task, or a task model identifier;
[0214] Based on the request information, an image generation model is obtained, including:
[0215] Based on the task scene identifier, determine a target scene template from a plurality of preset scene templates, and based on the target scene template, search for an image generation model from a model library, wherein the model library stores a plurality of image processing models;
[0216] or,
[0217] Based on the task model identifier, an image generation model is searched from the model library.
[0218] The task scenario identifier of an image processing task is a label or code that uniquely identifies or classifies an image processing task, which helps the task platform understand which specific task category the image processing task belongs to.
[0219] The task scenario of the image processing task is identified as a tag used to distinguish and identify different image processing task models. Each model may be designed for different data features, processing logic or optimization goals. For example, some models are used to generate new images, some models are used for image segmentation, some models are used for image classification, and so on.
[0220] In practical applications, the target scene template corresponding to the task scene identifier can be found from multiple preset scene templates according to the task scene identifier, and the corresponding image generation model can be found from the model library based on the target scene template. Alternatively, the corresponding image generation model can be found directly from the model library according to the task model identifier.
[0221] In another specific implementation manner provided in this specification, the request information includes sample data of the image generation task;
[0222] Based on the request information, an image generation model is obtained, including:
[0223] Based on the sample data, an initial image generation model corresponding to the image generation task is trained to obtain a trained image generation model.
[0224] Fig.11 A schematic diagram of a task platform provided in an embodiment of the present specification is shown, the task platform includes a request interface 1102 and a response unit 1104, wherein:
[0225] The request interface 1102 is used to receive a task generation request sent by a terminal device, wherein the task generation request includes request information.
[0226] The response unit 1104 is used to obtain an image generation model based on the request information, and generate task information based on the image generation model, wherein the image generation model determines a reference area in a reference image based on semantic feature information of the redrawn area in the image to be processed, and redraws the redrawn area of the noisy image to be processed based on the reference area to generate a target image, and the task information is used by the terminal side device to perform the image generation task.
[0227] Corresponding to the above method embodiment, this specification also provides an image processing device embodiment, Fig.12 FIG. 2 shows a schematic diagram of the structure of an image processing device provided by an embodiment of the present specification. Fig.12 As shown, the device comprises:
[0228] The acquisition module 1202 is configured to acquire an image to be processed and a reference image corresponding to the image to be processed, wherein the image to be processed includes a redrawing area.
[0229] The processing module 1204 is configured to input the image to be processed and the reference image into an image generation model to obtain a target image generated by the image generation model, wherein the image generation model determines a reference area in the reference image based on semantic feature information of the redrawn area, and redraws the redrawn area of the noisy image to be processed based on the reference area to generate a target image.
[0230] Optionally, the image generation model includes a first image processing branch and a second image processing branch;
[0231] The processing module 1204 is further configured to:
[0232] Inputting the reference image into the first image processing branch to obtain reference attention key value information in the first image processing branch;
[0233] The image to be processed and the reference attention key value information are input into the second image processing branch to obtain the target image output by the second image processing branch.
[0234] Optionally, the first image processing branch includes a first image encoder and a first image decoder;
[0235] The processing module 1204 is further configured to:
[0236] Inputting the reference image into the first image encoder to obtain a reference image encoding feature corresponding to the reference image;
[0237] The reference image encoding features are input into the first image decoder to obtain the reference image decoding features and reference attention key value information.
[0238] Optionally, the processing module 1204 is further configured to:
[0239] Constructing features of the image to be processed according to the image to be processed;
[0240] The features of the image to be processed and the reference attention key information are input into the second image processing branch to obtain a target image output by the second image processing branch.
[0241] Optionally, the processing module 1204 is further configured to:
[0242] Creating noise information of the image to be processed according to the image to be processed;
[0243] Generate mask information of the image to be processed according to the redrawn area in the image to be processed;
[0244] Generating depth information of the image to be processed corresponding to the image to be processed;
[0245] Acquire implicit expression information of the image to be processed corresponding to the image to be processed;
[0246] The features of the image to be processed are constructed according to the noise information of the image to be processed, the mask information of the image to be processed, the depth information of the image to be processed and the implicit expression information of the image to be processed.
[0247] Optionally, the second image processing branch includes a second image encoder, a second image decoder and an output layer;
[0248] The processing module 1204 is further configured to:
[0249] Inputting the reference attention key information into the second image decoder to update the attention key information in the second image decoder;
[0250] Inputting the to-be-processed image feature into the second image encoder to obtain the to-be-processed image coding feature corresponding to the to-be-processed image feature;
[0251] Inputting the encoding features of the image to be processed into the second image decoder to obtain decoding features of the image to be processed;
[0252] The decoded features of the image to be processed are input into the output layer to obtain a target image.
[0253] Optionally, the second image decoder includes an image decoding layer and an attention layer, and the attention layer includes target attention key value information;
[0254] The processing module 1204 is further configured to:
[0255] The reference attention key value information is input into the attention layer, and spliced attention key value information is generated according to the reference attention key value information and the target attention key value information.
[0256] Optionally, the device further includes a model training module configured to:
[0257] Acquire a sample initial image and a sample reference image corresponding to the sample initial image based on the sample video clip;
[0258] Marking a sample mask area in the sample initial image to obtain a sample to-be-processed image corresponding to the sample initial image;
[0259] Inputting the sample to-be-processed image and the sample reference image into an image generation model to obtain a predicted image output by the image generation model, wherein the image generation model determines a sample reference area in the sample reference image based on semantic feature information of the sample mask area, and redraws the noisy sample to-be-processed image based on the sample reference area to generate a predicted image;
[0260] Calculate a model loss value according to the predicted image and the sample initial image;
[0261] The model parameters of the image generation model are adjusted according to the model loss value, and the image generation model is continued to be trained until the model training stop condition is reached.
[0262] Optionally, the model training module is further configured as follows:
[0263] Obtaining a sample video clip, wherein the sample video clip is a sample split-shot video;
[0264] A sample initial image and a sample reference image are selected from the sample video clip.
[0265] Optionally, the model training module is further configured as follows:
[0266] Dividing the sample initial image into a plurality of sample grids according to a preset rule;
[0267] Randomly mark sample mask areas in each sample grid.
[0268] Optionally, the model training module is further configured as follows:
[0269] Determine at least one reference control point in the sample initial image and the sample reference image, wherein the reference control point is a feature point in the sample initial image and the sample reference image;
[0270] Marking a sample mask region in a reference control point grid based on a first mask probability, wherein the reference control point grid includes a sample grid where reference control points exist;
[0271] A sample mask region is marked in a non-reference control point grid based on a second mask probability, wherein the non-reference control point grid includes a sample grid without reference control points.
[0272] Optionally, the model training module is further configured as follows:
[0273] Data enhancement is performed on the sample to-be-processed image and the sample reference image respectively to obtain enhanced sample to-be-processed image and sample reference image.
[0274] Through the image processing device provided by the embodiment of this specification, the user only needs to provide the image to be processed including the redrawing area and its corresponding reference image. The image to be processed and the reference image are input into the image generation model, and the image generation model can determine the corresponding reference area in the reference image according to the semantic feature information of the redrawing area, without marking the reference area in the reference image, which simplifies the user's operation steps and improves the user's experience.
[0275] The device also includes a model training module, which uses a data construction paradigm based on video clips to select two video frames in a video clip to simulate a sample initial image and a sample reference image in the model training stage, thereby simplifying the process of determining training sample pairs and improving the convenience of determining training sample pairs in the model training stage.
[0276] In the process of partially masking the sample initial image and generating the sample to-be-processed image, a feature point comparison method is used to determine the feature points in the sample original image and the sample reference image, and the sample grid is randomly masked with a certain probability according to whether the sample grid contains feature points, so as to ensure that the masked area has a corresponding reference area in the reference image as much as possible, so as to facilitate the subsequent image generation model to better perform semantic comparison during the training process. The model training module provided in the embodiment of this specification uses a depth map to control the shape of the sample mask area, and supports the user to choose whether to retain the shape information before editing, edit the texture, or design the shape as an editable attribute.
[0277] The above is a schematic scheme of an image processing device of this embodiment. It should be noted that the technical scheme of the image processing device and the technical scheme of the above-mentioned image processing method belong to the same concept, and the details not described in detail in the technical scheme of the image processing device can be referred to the description of the technical scheme of the above-mentioned image processing method.
[0278] Fig.13 The block diagram of a computing device 1300 according to one embodiment of the present specification is shown. The components of the computing device 1300 include but are not limited to a memory 1310 and a processor 1320. The processor 1320 is connected to the memory 1310 via a bus 1330, and the database 1350 is used to store data.
[0279] The computing device 1300 also includes an access device 1340 that enables the computing device 1300 to communicate via one or more networks 1360. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 1340 may include one or more of any type of network interface (e.g., a network interface card (NIC)) of wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a world-wide interoperability for microwave access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, and a near field communication (NFC).
[0280] In one embodiment of the present specification, the above components of the computing device 1300 and Fig.13 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Fig.13 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.
[0281] The computing device 1300 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or a personal computer (PC). The computing device 1300 may also be a mobile or stationary server.
[0282] The processor 1320 is used to execute the following computer program / instruction, which implements the steps of the above-mentioned image processing method when executed by the processor.
[0283] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the computing device embodiment, since it is basically similar to the image processing method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the image processing method embodiment.
[0284] An embodiment of the present specification further provides a computer-readable storage medium storing a computer program / instruction, which implements the steps of the above-mentioned image processing method when executed by a processor.
[0285] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the computer-readable storage medium embodiment, since it is basically similar to the image processing method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the image processing method embodiment.
[0286] An embodiment of the present specification further provides a computer program product, including a computer program / instruction, which implements the steps of the above-mentioned image processing method when executed by a processor.
[0287] The above is a schematic solution of a computer program product of this embodiment. It should be noted that the technical solution of the computer program product and the technical solution of the above-mentioned image processing method belong to the same concept, and the details not described in detail in the technical solution of the computer program product can be referred to the description of the technical solution of the above-mentioned image processing method.
[0288] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0289] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0290] It should be noted that the above is a description of a specific embodiment of the present specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of the present specification.
[0291] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0292] The preferred embodiments of this specification disclosed above are only used to help explain this specification. The optional embodiments do not describe all the details in detail, nor do they limit the invention to only the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the embodiments of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of this specification, so that technicians in the relevant technical field can well understand and use this specification. This specification is only limited by the claims and their full scope and equivalents.
Claims
1. An image processing method, comprising: Acquire an image to be processed and a reference image corresponding to the image to be processed, wherein the image to be processed includes a redrawing area; The image to be processed and the reference image are input into an image generation model to obtain a target image generated by the image generation model, wherein the image generation model determines a reference area in the reference image based on semantic feature information of the redrawn area, and redraws the redrawn area of the noisy image to be processed based on the reference area to generate a target image.
2. The method of claim 1, wherein the image generation model comprises a first image processing branch and a second image processing branch; Inputting the image to be processed and the reference image into an image generation model to obtain a target image generated by the image generation model includes: Inputting the reference image into the first image processing branch, obtaining reference attention key information generated by the first image processing branch in the process of processing the reference image, wherein the reference attention key information represents semantic feature information in the reference image; The image to be processed and the reference attention key value information are input into the second image processing branch to obtain the target image output by the second image processing branch.
3. The method of claim 2, wherein the first image processing branch comprises a first image encoder and a first image decoder; Inputting the reference image into the first image processing branch to obtain reference attention key value information in the first image processing branch includes: Inputting the reference image into the first image encoder to obtain a reference image encoding feature corresponding to the reference image; The reference image encoding features are input into the first image decoder to obtain the reference image decoding features and reference attention key value information.
4. The method according to claim 2, inputting the image to be processed and the reference attention key information into the second image processing branch to obtain the target image output by the second image processing branch, comprising: Constructing features of the image to be processed according to the image to be processed; The features of the image to be processed and the reference attention key information are input into the second image processing branch to obtain a target image output by the second image processing branch.
5. The method according to claim 4, constructing features of the image to be processed according to the image to be processed, comprising: Creating noise information of the image to be processed according to the image to be processed; Generate mask information of the image to be processed according to the redrawn area in the image to be processed; Generating depth information of the image to be processed corresponding to the image to be processed; Acquire implicit expression information of the image to be processed corresponding to the image to be processed; The noise information of the image to be processed, the mask information of the image to be processed, the depth information of the image to be processed and the implicit expression information of the image to be processed are spliced to construct features of the image to be processed.
6. The method of claim 4, wherein the second image processing branch comprises a second image encoder, a second image decoder, and an output layer; Inputting the to-be-processed image features and the reference attention key information into the second image processing branch to obtain a target image output by the second image processing branch, including: Inputting the reference attention key information into the second image decoder to update the attention key information in the second image decoder; Inputting the to-be-processed image feature into the second image encoder to obtain the to-be-processed image coding feature corresponding to the to-be-processed image feature; Inputting the encoding features of the image to be processed into the second image decoder to obtain decoding features of the image to be processed; The decoded features of the image to be processed are input into the output layer to obtain a target image.
7. The method of claim 6, wherein the second image decoder comprises an attention layer; Inputting the reference attention key information into the second image decoder, and updating the attention key information in the second image decoder, comprising: Inputting the reference attention key value information into the attention layer, wherein the attention layer includes the target attention key value information; Generate spliced attention key information according to the reference attention key information and the target attention key information, and use the spliced attention key information as the attention key information of the attention layer.
8. The method according to claim 1, wherein the image generation model is trained by the following steps: Acquire a sample initial image and a sample reference image corresponding to the sample initial image based on the sample video clip; Marking a sample mask area in the sample initial image to obtain a sample to-be-processed image corresponding to the sample initial image; The sample to-be-processed image and the sample reference image are input into an image generation model to obtain a predicted image output by the image generation model, wherein: The image generation model determines a sample reference area in the sample reference image based on the semantic feature information of the sample mask area, and redraws the noisy sample to-be-processed image based on the sample reference area to generate a predicted image; Calculate a model loss value according to the predicted image and the sample initial image; The model parameters of the image generation model are adjusted according to the model loss value, and the image generation model is continued to be trained until the model training stop condition is reached.
9. The method according to claim 8, obtaining a sample initial image and a sample reference image corresponding to the sample initial image based on the sample video clip, comprising: Acquire the sample video clip, wherein the sample video clip is a sample split-shot video; A sample initial image and a sample reference image are selected from multiple frames of images of the sample video clip.
10. The method according to claim 8, marking a sample mask area in the sample initial image, comprising: Dividing the sample initial image into a plurality of sample grids according to a preset rule; Randomly mark sample mask areas in each sample grid.
11. The method of claim 9, further comprising: Determine at least one reference control point in the sample initial image and the sample reference image, wherein the reference control point is a feature point in the sample initial image and the sample reference image; Accordingly, the sample mask area is randomly marked in each sample grid, including: Marking a sample mask area in a reference control point grid based on a first mask probability, wherein the reference control point grid is a sample grid where reference control points exist; A sample mask area is marked in a non-reference control point grid based on the second mask probability, wherein the non-reference control point grid is a sample grid without any reference control points.
12. The method according to claim 8, before inputting the sample to-be-processed image and the sample reference image into an image generation model, further comprising: Data enhancement is performed on the sample to-be-processed image and the sample reference image respectively to obtain enhanced sample to-be-processed image and sample reference image.
13. A training method for an image generation model, applied to a cloud-side device, comprising: A sample video segment sent by a receiving end-side device is obtained, and based on the sample video segment, a sample initial image and a sample reference image corresponding to the sample initial image are obtained; Marking a sample mask area in the sample initial image to obtain a sample to-be-processed image corresponding to the sample initial image; Inputting the sample to-be-processed image and the sample reference image into an image generation model to obtain a predicted image output by the image generation model, wherein the image generation model determines a sample reference area in the sample reference image based on semantic feature information of the sample mask area, and redraws the noisy sample to-be-processed image based on the sample reference area to generate a predicted image; Calculate a model loss value according to the predicted image and the sample initial image; The model parameters of the image generation model are adjusted according to the model loss value, and the image generation model is continuously trained until the model training stop condition is reached, the model parameters of the image generation model are obtained, and the model parameters are sent to the end-side device.
14. An image processing method, applied to a cloud-side device, comprising: An image generation task sent by a receiving end-side device, wherein the image generation task includes an image to be processed and a reference image corresponding to the image to be processed, and the image to be processed includes a redrawing area; Inputting the image to be processed and the reference image into an image generation model to obtain a target image generated by the image generation model, wherein the image generation model determines a reference area in the reference image based on semantic feature information of the redrawn area, and redraws the redrawn area of the noisy image to be processed based on the reference area to generate a target image; The target image is sent to the terminal device.
15. The method of claim 14, further comprising: The image adjustment information sent by the receiving end side device for the target image; Adjust the target image based on the image adjustment information to obtain an adjusted target image; The adjustment target image is sent to the terminal side device.
16. An information processing method based on an image generation model, applied to a task platform, comprising: Receiving a task generation request sent by a terminal device, wherein the task generation request includes request information; Based on the request information, an image generation model is acquired, wherein the image generation model determines a reference area in a reference image based on semantic feature information of the redrawn area in the image to be processed, and redraws the redrawn area of the noisy image to be processed based on the reference area to generate a target image; Based on the image generation model, task information is generated, wherein the task information is used for the terminal device to perform the image generation task.
17. The method according to claim 16, wherein the request information includes a task scenario identifier of the image processing task, or a task model identifier; Based on the request information, an image generation model is obtained, including: Based on the task scene identifier, determine a target scene template from a plurality of preset scene templates, and based on the target scene template, search for an image generation model from a model library, wherein the model library stores a plurality of image processing models; or, Based on the task model identifier, an image generation model is searched from the model library.
18. The method of claim 16, wherein the request information includes sample data of an image generation task; Based on the request information, an image generation model is obtained, including: Based on the sample data, an initial image generation model corresponding to the image generation task is trained to obtain a trained image generation model.
19. A task platform, comprising a request interface and a response unit; The request interface is used to receive a task generation request sent by a terminal device, wherein the task generation request includes request information; The response unit is used to obtain an image generation model based on the request information, and generate task information based on the image generation model, wherein the image generation model determines a reference area in a reference image based on semantic feature information of the redrawn area in the image to be processed, and redraws the redrawn area of the noisy image to be processed based on the reference area to generate a target image, and the task information is used for the terminal side device to perform the image generation task.
20. A computing device comprising: Memory and processor; The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions. When the computer program / instructions are executed by the processor, the steps of the method described in any one of claims 1 to 18 are implemented.
21. A computer-readable storage medium storing a computer program / instruction, wherein the computer program / instruction, when executed by a processor, implements the steps of the method according to any one of claims 1 to 18.
22. A computer program product, comprising a computer program / instruction, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 18.
Citation Information
Cited By
Image processing method and image processing model training method
WO2026170879A1
