General zero sample image synthesis method based on pre-training diffusion model
Through a universal zero-shot image synthesis method based on a pre-trained diffusion model, the problems of high-cost training and data dependence in the existing technology are solved, high-quality image synthesis is achieved in a wide range of scenes, especially good results are achieved in light and shadow problems, and Supports multiple conditions for booting.
Patent Information
- Application Number
- CN202410856081.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-10-01
AI Technical Summary
Existing image synthesis technology requires high-cost training and data dependence, and is difficult to achieve high-quality harmonization results in a wide range of scenes. In particular, it performs poorly in light and shadow problems, and it is difficult to effectively synthesize objects outside the data set.
A general zero-shot image synthesis method based on a pre-trained diffusion model is adopted. Through the object removal pipeline, image harmonization pipeline and semantic image synthesis pipeline, the prior of the diffusion model is used to perform image harmonization and semantics without additional training. Image synthesis supports multiple conditions as guidance for target features, achieving wider data applicability and high-quality results.
It achieves high-quality image harmonization results in a wider range of scenes, reduces training costs, supports a variety of image synthesis tasks without additional training, and overcomes the limitations of traditional methods in light and shadow problems and data dependence.
Smart Images

Figure CN118736048A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer vision and pattern recognition, and in particular to a universal zero-sample image synthesis method based on a pre-trained diffusion model. Background Art
[0002] Image synthesis is a fundamental task in computer vision, which aims to fuse the foreground object of one image with the background of another image to generate a smooth natural image. It has a wide range of applications in many fields such as image reconstruction, art design, game development, and virtual reality.
[0003] Generally, image synthesis is done by image harmonization. We assume that a background image I b and a foreground image I f , and the area mask M of the foreground on the background b and foreground image I f The foreground mask M f , a collage result image I p It can be expressed as Among them, M o To mask the foreground f The target object position mask is obtained by scaling to the background mask area size and taking the intersection, I f ′ To transform the foreground image I f The purpose of image harmonization is to blend the foreground and background of the collage by some means to obtain an image that is better than the I p More natural images.
[0004] Traditional image harmonization relies on handcrafted color and gradient priors, which requires high time and manpower costs. In recent years, with the development of deep learning technology, image harmonization methods based on neural networks have made significant progress. This type of method automatically determines the harmonization information by inputting the collage result image and the corresponding foreground mask, producing a smooth natural image, which improves the robustness and efficiency of harmonization.
[0005] In order to obtain accurate image harmonization results, the paper (Tsai, YH, Shen, X., Lin, Z., et al.: Deep Image Harmonization. 2017. DOI: 10.48550 / arXiv.1703.00069) first used convolutional neural networks for image harmonization tasks through end-to-end training. The method consists of three parts: a unified encoder SharedEncoder, a decoder Harmonization Decoder for harmonization, and a decoder Scene Parsing Decoder for scene analysis. First, the encoder is used to convert the input image into a low-dimensional feature, and then two decoders are used to generate scene analysis results and image harmonization results respectively. In this process, the features of scene analysis are inserted into the image harmonization process as additional feature input. The paper (Tan, L., Li, J., Niu, L., Zhang, L.: Deep image harmonization in dual color spaces. 2023. DOI: 10.48550 / arXiv.2308.02813) proposed a new end-to-end network that uses the features of different channels of the image for feature injection, and uses convolutional layers and attention layers to achieve high-quality image harmonization results through downsampling and upsampling processes. However, these networks require specific data for training, are limited by the expression range of the data set, and require high training costs.
[0006] Another newer image synthesis task is semantic image synthesis, in which additional conditions pointing to the target features (cue words, masks, etc.) are provided to guide the foreground to change to the target features and keep the background unchanged. The paper (Yang, B., Gu, S., Zhang, B., et al.: Paint by Example: Exemplar-based Image Editing with Diffusion Models. 2022. DOI: 10.48550 / arXiv.2211.13227) proposes a method for semantic image synthesis by introducing reference image information through pre-trained CLIP and additionally trained MLP modules, and fine-tuning the diffusion model parameters. The literature (Chen, X., Huang, L., Liu, Y., Shen, Y., Zhao, D., Zhao, H.: Anydoor: Zero-shot object-level image customization. 2023. DOI: 10.48550 / arXiv.2307.09481) achieved higher quality semantic image synthesis by training an identity extraction module (ID Extractor) to extract role information and a feature extraction module (Detail Extractor) to extract detail information, and fine-tuning the U-net of the pre-trained diffusion model. However, these methods require high additional training costs, and it is difficult to obtain good semantic image synthesis results for objects outside the dataset. Summary of the invention
[0007] In order to overcome the high training cost, the present invention proposes a universal zero-shot image synthesis method based on a pre-trained diffusion model, which is a method that uses the prior of a pre-trained diffusion model for image harmonization. With the help of the prior of the diffusion model with high expressive power, the present invention can obtain high-quality harmonization results on a wider range of data, and can achieve better results in light and shadow problems that are difficult to handle with previous methods.
[0008] The present invention can achieve better results in common cases through a wider range of diffusion model priors, and supports multiple conditions as guides for target features.
[0009] The object of the present invention is to provide a zero-sample universal image synthesis method that is effective for a variety of image synthesis tasks without the need for additional training.
[0010] A general zero-shot image synthesis method based on a pre-trained diffusion model, comprising:
[0011] Step 1: Determine whether to use the object removal pipeline based on whether the mask area of the input background image contains the foreground;
[0012] If the corresponding area of the background image contains the foreground, the object removal pipeline is used to remove the foreground to obtain the background image without foreground and the regional mask. If there is no foreground, it is directly used as the background image without foreground and the regional mask;
[0013] Step 2: Scale the foreground image and the object mask to the area mask size of the background image without foreground, and perform collage of the new foreground object by taking the intersection of the two masks to obtain the collage image and the new object mask;
[0014] Step 3: If the user does not provide additional foreground object change conditions, the collage image and the new object mask are used to perform collage image harmonization through the image harmonization pipeline to obtain a high-quality natural image.
[0015] If the user provides additional foreground object change conditions, the additional foreground object change conditions provided by the user are used as the target conditions. Through the semantic image synthesis pipeline, the collage image, the new object mask and the additional foreground object change conditions are used to guide the collage image to change towards the specified target condition, and at the same time make the whole image more harmonious, and finally a high-quality image that meets the target conditions is obtained.
[0016] The specific operations of removing the foreground using the object removal pipeline in step 1 may include:
[0017] The background image is passed through the first pre-trained encoder to obtain its expression in the latent space, and the same latent space is initialized as the optimization object to generate a target background image with the foreground object removed;
[0018] Add random noise to the latent space representation of the background image with a random number of time steps, use "something in some place" as a simple prompt word, and obtain the background image prediction noise through the first pre-trained diffusion model;
[0019] The same noise is added to the latent space expression of the target background image in a single step with the same number of time steps. "some place" is used as a simple prompt word. Based on the self-attention module ignoring method, the mask of the area where the foreground object is located is used to obtain some features that the self-attention module needs to ignore. The target background image prediction noise is obtained through the second pre-trained diffusion model.
[0020] By calculating the Delta Denoising Score (DDS loss) of the predicted noise of the background image and the predicted noise of the target background image, as well as the perceptual loss of the background area of the background image and the target background image in the image space through the first pre-trained decoder, and back-propagating to optimize the latent space expression of the target background image;
[0021] The latent space expression of the target background image is passed through the first pre-trained decoder to obtain a background image without foreground and a region mask.
[0022] The self-attention module ignoring method obtains a selection vector consistent with the length size of the self-attention layer sequence through interpolation and flattening, and uses the selection vector to ignore some features of the key-value features in the query (Query), key (Key), and value (Value) of the self-attention layer for calculation.
[0023] The original variation denoising score loss is designed for image editing tasks and is guided only at the conditional level. Affected by the input image, it is difficult to form large changes such as spatial structure in denoising optimization. In the object removal task, the foreground needs to be removed to achieve the generation of a complete background, which requires a strong removal capability. The present invention introduces the editing of key-value features in the query (Query), key (Key), and value (Value) of the self-attention layer. By using a region mask, only specific key-value features related to the background area are selected for the calculation of the self-attention layer. By operating in a more detailed feature space and ignoring the structural information and semantic information related to the foreground area, a greater degree of editing possibility is achieved, thereby satisfying the substantial editing capability required for object removal.
[0024] In the object removal pipeline, a combined loss function is used in Indicates the change of denoising score loss function using the self-attention module ignoring method, L per represents the perceptual loss function, I s and I t are the background image and the target background image respectively, P o and P t are background image prompt words and target background image prompt words, respectively, M s and M s ′ They are the area mask and the opposite mask required to remove the foreground of the background image, respectively. s ′ =1-M s ,λ per It is a hyperparameter and can be set to 0.3.
[0025] In step 3, the specific operations of performing the collage image harmonization process using the collage image and the new object mask through the image harmonization pipeline may include:
[0026] Passing the collage image through the second pre-trained encoder to obtain its expression in the latent space, and initializing the same latent space as the optimization object to produce high-quality synthetic generated images;
[0027] Random noise is added to the latent space expression of the collage image in a single step with a random number of time steps, and an empty prompt word ("") is used to obtain the collage image prediction noise through the third pre-trained diffusion model;
[0028] The same noise is added to the latent space representation of the synthetically generated image in a single step with the same number of time steps, and a harmonious scene ("a harmonious scene") is used as a simple prompt word. The synthetically generated image prediction noise is obtained through the fourth pre-trained diffusion model;
[0029] By calculating the denoising score loss of the predicted noise of the collage image and the predicted noise of the synthetic generated image, and respectively calculating the perceptual loss of the foreground area and background area of the collage image and the synthetic generated image in the image space through the second pre-trained decoder, and back-propagating to optimize the latent space expression of the synthetic generated image;
[0030] The latent space representation of the synthetically generated image is passed through the second pre-trained decoder to obtain a high-quality natural image.
[0031] In the image harmonization pipeline, a combined loss function can be used Where L DDS represents the change denoising score loss function, I p represents the collage image, I t1 represents the synthetically generated image, P o1 Indicates an empty prompt word, P t1 represents the synthetically generated image prompt word, L per represents the perceptual loss function, M p and M p ′ Respectively represent the new foreground mask and the corresponding background mask in the collage image, λ bak and λ for are hyperparameters and can be set to 0.3 and 0.1 respectively.
[0032] In step 3, the semantic image synthesis pipeline uses the collage image, the new object mask and the additional foreground object change conditions to guide the collage image to change to the specified target condition, and at the same time make the whole image more harmonious, and finally obtain a high-quality image that meets the target conditions. The specific operations may include:
[0033] The collage image is passed through a third pre-trained encoder to obtain its expression in the latent space, and the same latent space is initialized as an optimization object to generate a high-quality semantically synthesized image that meets the target condition constraints;
[0034] Random noise is added to the latent space expression of the collage image in a single step with a random number of time steps, and the original conditions of the collage image are used as a guide to obtain the collage image prediction noise through the fifth pre-trained diffusion model;
[0035] The same noise is added to the latent space expression of high-quality semantic synthesis images in a single step with the same number of time steps, guided by the target condition, and the features of the self-attention layer in the collage image noise prediction are used for feature replacement. The high-quality semantic synthesis image prediction noise is obtained through the sixth pre-trained diffusion model;
[0036] By calculating the denoising score loss of the collage image prediction noise and the high-quality semantic synthesis image prediction noise variation, and back-propagating to optimize the latent space expression of the high-quality semantic synthesis image;
[0037] The latent space expression of the high-quality semantic synthetic image is passed through the third pre-trained decoder to obtain a high-quality image that meets the target conditions.
[0038] The original condition guidance of the collage image and the target condition guidance may include any one or more of the following combinations:
[0039] For text conditions: the original condition is used as the prompt word in the collage image noise prediction; the target condition is used as the prompt word in the high-quality semantic synthesis image noise prediction;
[0040] For other conditions besides text, such as sketches and canny, a pre-trained text-to-image adapter is used to introduce condition changes for guidance. At this time, the same text condition or different text conditions can also be used as prompt words for guidance.
[0041] The feature replacement using the features of the self-attention layer in the collage image noise prediction may specifically include:
[0042] Starting from a given number of optimization steps, the key-value features in the noise prediction of the collage image are used to replace the key-value features in the noise prediction of the high-quality semantic synthesis image in the self-attention layer calculation of the specified index.
[0043] In the original change denoising score loss, its editing ability acts on the entire image, and it is difficult to achieve change editing that only acts on a specific target subject. In the object removal pipeline and the image harmonization pipeline, the present invention uses a perceptual loss function for balance. However, in the semantic image synthesis pipeline, since the space occupied by the edited object may change, it is difficult to directly maintain the non-edited subject part through the region mask. Therefore, the present invention achieves a more flexible balance between subject change and background retention by operating the key-value pair. Specifically, the present invention uses a key-value pair replacement method to replace the key-value pair of the target image (high-quality semantic synthetic image) in the denoising process with the key-value pair generated by the collage image in the denoising process, thereby achieving consistency of semantic information. However, since complete replacement will lead to a decrease in editing ability, the present invention only performs the key-value pair replacement operation under certain self-attention layers (which can be set manually based on experience) and certain denoising steps (which can be set manually based on experience) in the diffusion model. In this way, the present invention realizes image synthesis with variable object regions, that is, semantic image synthesis.
[0044] In the semantic image synthesis pipeline, a single loss function is used in Indicates the use of key-value feature replacement and the change of arbitrary conditional input denoising score loss function, I c represents the collage image, I t2 represents a high-quality semantic synthesis image, C o and C t represent the original condition and the target condition respectively.
[0045] The universal zero-shot image synthesis method based on the pre-trained diffusion model described in the present invention can use the AdamW algorithm to optimize the parameters of the latent space during the process of back-propagation optimization of the image latent space expression.
[0046] In the general zero-sample image synthesis method based on the pre-trained diffusion model described in the present invention, the DDS loss function (Delta Denoising Score loss) proposed in the literature (Hertz, A., Aberman, K., Cohen-Or, D.: Delta denoising score.2023.DOI:10.48550 / arXiv.2304.07090) and the perceptual loss function (perceptual loss) proposed in the literature (Johnson, J., Alahi, A., Fei-Fei, L.: Perceptual losses for real-time style transfer and super-resolution.2016.DOI:10.48550 / arXiv.1603.08155) can be used.
[0047] Compared with the prior art, the present invention has the following beneficial effects:
[0048] By using a pre-trained diffusion model as a basis, the present invention avoids the training overhead of additionally training a new model or fine-tuning an existing model. The present invention proposes a universal image synthesis method that can be flexibly applied to a variety of given image synthesis tasks, breaking away from the limitations of the inherent model on a single task. By using the prior of a wide range of diffusion models, the scope of use is not limited to data, and better average results can be achieved in more general cases. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 The flowchart of a general zero-shot image synthesis method based on a pre-trained diffusion model in a specific implementation manner. DETAILED DESCRIPTION
[0050] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments. It should be understood that these embodiments are only used to illustrate the present invention and are not used to limit the scope of the present invention.
[0051] Combination Figure 1 A general zero-shot image synthesis method based on a pre-trained diffusion model comprises: according to the input, using the background area mask to remove the foreground of the background image to obtain a complete background image; according to the required image synthesis method, for the synthesis task whose features do not change, using the image harmonization pipeline to generate high-quality natural images; for the synthesis task whose features need to be changed, using the semantic image synthesis pipeline to guide the foreground to change to the target result according to the provided condition changes, and generating high-quality natural images guided by specific conditions.
[0052] Specifically, a general zero-shot image synthesis method based on a pre-trained diffusion model includes:
[0053] Step 1: Determine whether to use the object removal pipeline based on whether the mask area of the input background image contains the foreground;
[0054] If the corresponding area of the background image contains the foreground, the object removal pipeline is used to remove the foreground to obtain a background image without foreground and a regional mask. If there is no foreground, it is directly used as the background image without foreground and the regional mask.
[0055] Among them, the specific operations of removing the foreground using the object removal pipeline include:
[0056] The background image is passed through the first pre-trained encoder to obtain its expression in the latent space, and the same latent space is initialized as the optimization object to generate a target background image with the foreground object removed;
[0057] Add random noise to the latent space representation of the background image with a random number of time steps, use "something in some place" as a simple prompt word, and obtain the background image prediction noise through the first pre-trained diffusion model;
[0058] The same noise is added to the latent space expression of the target background image in a single step with the same number of time steps. "some place" is used as a simple prompt word. Based on the self-attention module ignoring method, the mask of the area where the foreground object is located is used to obtain some features that the self-attention module needs to ignore. The target background image prediction noise is obtained through the second pre-trained diffusion model.
[0059] By calculating the denoising score loss of the background image prediction noise and the target background image prediction noise variation, as well as the perceptual loss of the background area of the background image and the target background image in the image space through the first pre-trained decoder, and back-propagating to optimize the latent space expression of the target background image;
[0060] The latent space expression of the target background image is passed through the first pre-trained decoder to obtain a background image without foreground and a region mask.
[0061] Furthermore, the self-attention module ignoring method obtains a selection vector consistent with the length size of the self-attention layer sequence through interpolation and flattening, and uses the selection vector to ignore some features of the key-value features in the query (Query), key (Key), and value (Value) of the self-attention layer for calculation.
[0062] In the object removal pipeline, a combined loss function is used in Indicates the change of denoising score loss function using the self-attention module ignoring method, L per represents the perceptual loss function, Is and I t are the background image and the target background image respectively, P o and P t are background image prompt words and target background image prompt words, respectively, M s and M s ′ They are the area mask and the opposite mask required to remove the foreground of the background image, respectively. s ′ =1-M s ,λ per is a hyperparameter and is set to 0.3.
[0063] Step 2: Scale the foreground image and the object mask to the area mask size of the background image without foreground, and perform collage of the new foreground object by taking the intersection of the two masks to obtain the collage image and the new object mask.
[0064] Step 3: If the user does not provide additional foreground object change conditions, the collage image and the new object mask are used to perform collage image harmonization through the image harmonization pipeline to obtain a high-quality natural image.
[0065] If the user provides additional foreground object change conditions, the additional foreground object change conditions provided by the user are used as the target conditions. Through the semantic image synthesis pipeline, the collage image, the new object mask and the additional foreground object change conditions are used to guide the collage image to change towards the specified target condition, and at the same time make the whole image more harmonious, and finally a high-quality image that meets the target conditions is obtained.
[0066] in:
[0067] I) The specific operations of performing collage image harmonization processing using collage images and new object masks through the image harmonization pipeline include:
[0068] Passing the collage image through the second pre-trained encoder to obtain its expression in the latent space, and initializing the same latent space as the optimization object to produce high-quality synthetic generated images;
[0069] Add random noise to the latent space expression of the collage image in a single step with a random number of time steps, use an empty prompt word, and obtain the collage image prediction noise through the third pre-trained diffusion model;
[0070] The same noise is added to the latent space expression of the synthetic generated image in a single step with the same number of time steps, a harmonious scene is used as a simple prompt word, and the synthetic generated image prediction noise is obtained through the fourth pre-trained diffusion model;
[0071] By calculating the denoising score loss of the predicted noise of the collage image and the predicted noise of the synthetic generated image, and respectively calculating the perceptual loss of the foreground area and background area of the collage image and the synthetic generated image in the image space through the second pre-trained decoder, and back-propagating to optimize the latent space expression of the synthetic generated image;
[0072] The latent space representation of the synthetically generated image is passed through the second pre-trained decoder to obtain a high-quality natural image.
[0073] In the image harmonization pipeline, a combined loss function can be used Where L DDS represents the change denoising score loss function, I p represents the collage image, I t1 represents the synthetically generated image, P o1 Indicates an empty prompt word, P t1 represents the synthetically generated image prompt word, L per represents the perceptual loss function, M p and M p ′ Respectively represent the new foreground mask and the corresponding background mask in the collage image, λ bak and λ for are hyperparameters and are set to 0.3 and 0.1 respectively.
[0074] II) Through the semantic image synthesis pipeline, the collage image, the new object mask and the additional foreground object change conditions are used to guide the collage image to change to the specified target condition and make the whole image more harmonious. Finally, the specific operations of obtaining a high-quality image that meets the target conditions include:
[0075] The collage image is passed through a third pre-trained encoder to obtain its expression in the latent space, and the same latent space is initialized as an optimization object to generate a high-quality semantically synthesized image that meets the target condition constraints;
[0076] Random noise is added to the latent space expression of the collage image in a single step with a random number of time steps, and the original conditions of the collage image are used as a guide to obtain the collage image prediction noise through the fifth pre-trained diffusion model;
[0077] The same noise is added to the latent space expression of high-quality semantic synthesis images in a single step with the same number of time steps, guided by the target condition, and the features of the self-attention layer in the collage image noise prediction are used for feature replacement. The high-quality semantic synthesis image prediction noise is obtained through the sixth pre-trained diffusion model;
[0078] By calculating the denoising score loss of the collage image prediction noise and the high-quality semantic synthesis image prediction noise variation, and back-propagating to optimize the latent space expression of the high-quality semantic synthesis image;
[0079] The latent space expression of the high-quality semantic synthetic image is passed through the third pre-trained decoder to obtain a high-quality image that meets the target conditions.
[0080] Furthermore, the original condition guidance of the collage image and the target condition guidance specifically include any one or more combinations of the following:
[0081] For text conditions: the original condition is used as the prompt word in the collage image noise prediction; the target condition is used as the prompt word in the high-quality semantic synthesis image noise prediction;
[0082] For other conditions besides text, such as sketch and canny, a pre-trained text-to-image adapter (T2I-Adapter) is used to introduce condition changes for guidance. At this time, the same text condition or different text conditions can also be used as prompt words for guidance.
[0083] The feature replacement using the features of the self-attention layer in the collage image noise prediction specifically includes:
[0084] Starting from a given number of optimization steps, the key-value features in the noise prediction of the collage image are used to replace the key-value features in the noise prediction of the high-quality semantic synthesis image in the self-attention layer calculation of the specified index.
[0085] In the semantic image synthesis pipeline, a single loss function is used in Indicates the use of key-value feature replacement and the change of arbitrary conditional input denoising score loss function, I c represents the collage image, I t2 represents a high-quality semantic synthesis image, C o and C t represent the original condition and the target condition respectively.
[0086] The above-mentioned general zero-shot image synthesis method based on the pre-trained diffusion model uses the AdamW algorithm to optimize the parameters of the latent space during the process of back-propagation optimization of the image latent space expression.
[0087] In the universal zero-shot image synthesis method based on a pre-trained diffusion model described in the present invention, the pre-trained encoder, pre-trained decoder and pre-trained diffusion model in each pipeline can adopt the same parameter setting.
[0088] The present invention proposes a universal image synthesis method by pre-training the diffusion model, which effectively utilizes the image prior of the diffusion model. It can be widely used in various case scenarios without the need for additional training, and provides a fast and effective solution to related needs and downstream tasks.
[0089] In addition, it should be understood that after reading the above description of the present invention, those skilled in the art may make various changes or modifications to the present invention, and these equivalent forms also fall within the scope defined by the claims attached to this application.
Claims
1. A universal zero-shot image synthesis method based on a pre-trained diffusion model, characterized in that: include: Step 1: Determine whether to use the object removal pipeline based on whether the mask area of the input background image contains the foreground; If the corresponding area of the background image contains the foreground, the object removal pipeline is used to remove the foreground to obtain the background image without foreground and the regional mask. If there is no foreground, it is directly used as the background image without foreground and the regional mask; Step 2: Scale the foreground image and the object mask to the area mask size of the background image without foreground, and perform collage of the new foreground object by taking the intersection of the two masks to obtain the collage image and the new object mask; Step 3: If the user does not provide additional foreground object change conditions, the collage image and the new object mask are used to perform collage image harmonization through the image harmonization pipeline to obtain a high-quality natural image. If the user provides additional foreground object change conditions, the additional foreground object change conditions provided by the user are used as the target conditions. Through the semantic image synthesis pipeline, the collage image, the new object mask and the additional foreground object change conditions are used to guide the collage image to change towards the specified target condition, and at the same time make the whole image more harmonious, and finally a high-quality image that meets the target conditions is obtained.
2. The universal zero-shot image synthesis method based on a pre-trained diffusion model according to claim 1, characterized in that: The specific operations of removing the foreground using the object removal pipeline in step 1 include: The background image is passed through the first pre-trained encoder to obtain its expression in the latent space, and the same latent space is initialized as the optimization object to generate a target background image with the foreground object removed; Random noise is added to the latent space expression of the background image in a single step with a random number of time steps, and a simple prompt word "something in a certain place" is used to obtain the background image prediction noise through the first pre-trained diffusion model; The same noise is added to the latent space expression of the target background image in a single step with the same number of time steps. A certain place is used as a simple prompt word. Based on the self-attention module ignoring method, the mask of the area where the foreground object is located is used to obtain some features that the self-attention module needs to ignore. The target background image prediction noise is obtained through the second pre-trained diffusion model. By calculating the denoising score loss of the background image prediction noise and the target background image prediction noise variation, as well as the perceptual loss of the background area of the background image and the target background image in the image space through the first pre-trained decoder, and back-propagating to optimize the latent space expression of the target background image; The latent space expression of the target background image is passed through the first pre-trained decoder to obtain a background image without foreground and a region mask.
3. The universal zero-shot image synthesis method based on a pre-trained diffusion model according to claim 2, characterized in that: The self-attention module ignoring method obtains a selection vector consistent with the length size of the self-attention layer sequence by interpolation and flattening, and ignores some features of the key-value features in the query, key, and value of the self-attention layer using the selection vector for calculation; In the object removal pipeline, a combined loss function is used in Indicates the change of denoising score loss function using the self-attention module ignoring method, L per represents the perceptual loss function, I s and I t are the background image and the target background image respectively, P o and P t are background image prompt words and target background image prompt words, respectively, M s and M s ′ They are the area mask and the opposite mask required to remove the foreground of the background image, respectively. s ′ =1-M s ,λ per is a hyperparameter.
4. The universal zero-shot image synthesis method based on a pre-trained diffusion model according to claim 1, characterized in that: In step 3, the specific operations of performing the collage image harmonization process using the collage image and the new object mask through the image harmonization pipeline include: Passing the collage image through the second pre-trained encoder to obtain its expression in the latent space, and initializing the same latent space as the optimization object to produce high-quality synthetic generated images; Add random noise to the latent space expression of the collage image in a single step with a random number of time steps, use an empty prompt word, and obtain the collage image prediction noise through the third pre-trained diffusion model; The same noise is added to the latent space expression of the synthetic generated image in a single step with the same number of time steps, a harmonious scene is used as a simple prompt word, and the synthetic generated image prediction noise is obtained through the fourth pre-trained diffusion model; By calculating the denoising score loss of the predicted noise of the collage image and the predicted noise of the synthetic generated image, and respectively calculating the perceptual loss of the foreground area and background area of the collage image and the synthetic generated image in the image space through the second pre-trained decoder, and back-propagating to optimize the latent space expression of the synthetic generated image; The latent space representation of the synthetically generated image is passed through the second pre-trained decoder to obtain a high-quality natural image.
5. The universal zero-shot image synthesis method based on a pre-trained diffusion model according to claim 4, characterized in that: In the image harmonization pipeline, a combined loss function is used Medium DDS represents the change denoising score loss function, I p represents the collage image, I t1 represents the synthetically generated image, P o1 Indicates an empty prompt word, P t1 represents the synthetically generated image prompt word, L per represents the perceptual loss function, M p and M p ′ Respectively represent the new foreground mask and the corresponding background mask in the collage image, λ bak and λ for is a hyperparameter.
6. The universal zero-shot image synthesis method based on a pre-trained diffusion model according to claim 1, characterized in that: In step 3, the semantic image synthesis pipeline uses the collage image, the new object mask and the additional foreground object change conditions to guide the collage image to change to the specified target condition and make the whole image more harmonious. The specific operations to finally obtain a high-quality image that meets the target conditions include: The collage image is passed through a third pre-trained encoder to obtain its expression in the latent space, and the same latent space is initialized as an optimization object to generate a high-quality semantically synthesized image that meets the target condition constraints; Random noise is added to the latent space expression of the collage image in a single step with a random number of time steps, and the original conditions of the collage image are used as a guide to obtain the collage image prediction noise through the fifth pre-trained diffusion model; The same noise is added to the latent space expression of high-quality semantic synthesis images in a single step with the same number of time steps, guided by the target condition, and the features of the self-attention layer in the collage image noise prediction are used for feature replacement. The high-quality semantic synthesis image prediction noise is obtained through the sixth pre-trained diffusion model; By calculating the denoising score loss of the collage image prediction noise and the high-quality semantic synthesis image prediction noise variation, and back-propagating to optimize the latent space expression of the high-quality semantic synthesis image; The latent space expression of the high-quality semantic synthetic image is passed through the third pre-trained decoder to obtain a high-quality image that meets the target conditions.
7. The universal zero-shot image synthesis method based on a pre-trained diffusion model according to claim 6, characterized in that: The original condition guidance of the collage image and the target condition guidance specifically include any one or more combinations of the following: For text conditions: the original condition is used as the prompt word in the collage image noise prediction; the target condition is used as the prompt word in the high-quality semantic synthesis image noise prediction; For conditions other than text, a pre-trained text-to-image adapter is used to introduce conditional variations for guidance.
8. The universal zero-shot image synthesis method based on a pre-trained diffusion model according to claim 6 or 7, characterized in that: The feature replacement using the features of the self-attention layer in the collage image noise prediction specifically includes: Starting from a given number of optimization steps, the key-value features in the noise prediction of the collage image are used to replace the key-value features in the noise prediction of the high-quality semantic synthesis image in the self-attention layer calculation of the specified index.
9. The universal zero-shot image synthesis method based on a pre-trained diffusion model according to claim 8, characterized in that: In the semantic image synthesis pipeline, a single loss function is used in Indicates the use of key-value feature replacement and the change of arbitrary conditional input denoising score loss function, I c represents the collage image, I t2 represents a high-quality semantic synthesis image, C o and C t represent the original condition and the target condition respectively.
10. The universal zero-shot image synthesis method based on a pre-trained diffusion model according to claim 2, 4 or 6, characterized in that: In the process of back-propagation optimization of image latent space expression, the AdamW algorithm is used to optimize the parameters of the latent space.
Citation Information
Cited By
Maskless image synthesis method and system based on diffusion model
CN120747303A
AI data set generation method and system based on image generation
CN121686137A
