Training method, related device and medium of image generation model

Through the training method of the image generation model, using multiple image and text sample pairs and denoising network control information, the accuracy problem when replacing background image objects is solved, and the accuracy and consistency of the target image generation are improved.

CN118570054BActive Publication Date: 2024-10-01TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411060639.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-05
Publication Date
2024-10-01
Estimated Expiration
2044-08-05

AI Technical Summary

Technical Problem

In business scenarios such as video production, it is difficult to effectively replace the objects in the background image through the neural network model with the existing technology, resulting in the generated target image not meeting expectations, especially due to the limitations of angle, lighting and other factors, and the lack of sufficient training data. , affecting the accuracy of model generation.

Method used

An image generation model training method is used to obtain multiple image and text sample pairs, including background template images, noise reference images and sample object images, to determine the sample splicing image characteristics and denoising network control information, and perform noise prediction and model training. , improve the accuracy of target image generation.

Benefits of technology

Through rich training data and various constraints, the accuracy of the image generation model in generating target images is improved, making the target image consistent with the background lighting and filters, and improving the generation effect of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118570054B_ABST
    Figure CN118570054B_ABST
Patent Text Reader

Abstract

The present disclosure provides a training method, related device and medium for an image generation model. The method includes: obtaining multiple image-text sample pairs, the image-text sample pairs include a background template image, a noise reference image, image description information of the noise reference image and a sample object image of a sample object; determining sample splicing image features based on the noise reference image, the background template image and the template mask image; determining denoising network control information based on the contour features, image description information and sample object image of the reference object in the background template image; performing noise prediction through an image generation model based on the sample splicing image features and the denoising network control information to obtain a noise prediction result of the noise reference image; and training an image generation model based on a comparison of the noise reference images of multiple image-text sample pairs with the noise prediction results. The present disclosure can improve the accuracy of generating a target image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of big data technology, and in particular to a training method, related device and medium for an image generation model. Background Art

[0002] At present, in various business scenarios such as video production and virtual display, it is often necessary to replace background images and object images to create personalized images. For example, when making an object image of object A, object B in a background image needs to be replaced with object A. In this regard, the related art often uses a neural network model to remove the first object in the background image in the specified background image, and to create a second object with the same orientation and shooting angle as the first object in the background image, and then embed the second object into the background image in the form of a map, so that the second object is displayed in the specified background image.

[0003] However, the above methods are often limited by factors such as the angle between the target object and the background image, the lighting filter, etc. In actual model training, it is often difficult to collect enough training data that meets the expectations, which will affect the model training effect and cause the target image generated by the model to not meet the requirements (for example, it is impossible to make the lighting, filter and background of the target object in the image match each other). Figure 1 As a result, the accuracy of the target image generated by the model is not high. Summary of the invention

[0004] The embodiments of the present disclosure provide a method for training an image generation model, a related device, and a medium, which can improve the accuracy of the image generation model in generating a target image.

[0005] According to one aspect of the present disclosure, a training method for an image generation model is provided, the training method comprising:

[0006] Acquire a plurality of image-text sample pairs, wherein each of the image-text sample pairs comprises a background template image, a noise reference image, image description information corresponding to the noise reference image, and a sample object image of a sample object, wherein the noise reference image is obtained by adding noise to an expected result of replacing a reference object in the background template image with a sample object;

[0007] Determining sample stitching image features based on the noise reference image, the background template image, and the template mask image, wherein the template mask image is obtained by masking the reference object in the background template image;

[0008] Determining denoising network control information of the image generation model based on the contour features of the reference object in the background template image, the image description information, and the sample object image;

[0009] Based on the sample splicing image features and the denoising network control information, noise prediction is performed through the image generation model to obtain a noise prediction result of the noise reference image;

[0010] The image generation model is trained based on the comparison between the noise reference image and the noise prediction results of the plurality of image-text sample pairs.

[0011] According to one aspect of the present disclosure, there is provided an image generation method, the image generation method comprising:

[0012] Acquire a target object image, a target background image, and target description information of a target object, wherein the target background image includes a reference object to be replaced by the target object in the target object image, and the target description information is used to describe the replacement from the reference object to the target object;

[0013] Determining target stitching image features based on the target background image, a preset noise image, and a target mask image, wherein the target mask image is obtained by masking a reference object in the target background image;

[0014] Determining denoising control information of an image generation model based on the contour features of the reference object in the target background image, the target description information, and the target object image, wherein the image generation model is generated according to the training method of the image generation model described above;

[0015] Based on the target stitching image features and the denoising control information, image generation is performed through the image generation model to obtain a target image, wherein the target image is used to indicate a result of replacing the reference object in the target background image with the target object of the target object image.

[0016] According to one aspect of the present disclosure, a training device for an image generation model is provided, the training device for an image generation model comprising:

[0017] A first acquisition unit is used to acquire a plurality of image-text sample pairs, wherein each of the image-text sample pairs includes a background template image, a noise reference image, image description information corresponding to the noise reference image, and a sample object image of a sample object, wherein the noise reference image is obtained by adding noise to an expected result of replacing a reference object in the background template image with a sample object;

[0018] A first determining unit, configured to determine a sample stitching image feature based on the noise reference image, the background template image, and a template mask image, wherein the template mask image is obtained by masking the reference object in the background template image;

[0019] A second determining unit, configured to determine denoising network control information of the image generation model based on the contour features of the reference object in the background template image, the image description information, and the sample object image;

[0020] A prediction unit, configured to perform noise prediction through the image generation model based on the sample splicing image features and the denoising network control information, to obtain a noise prediction result of the noise reference image;

[0021] A training unit is used to train the image generation model based on the comparison between the noise reference image and the noise prediction result of the plurality of image-text sample pairs.

[0022] Optionally, the training unit includes:

[0023] A calculation module, used for obtaining the reference noise in the noise reference image for each of the image-text sample pairs, and calculating a sub-loss function based on a comparison between the reference noise and the noise prediction result;

[0024] A determination module, configured to determine a total loss function based on the sub-loss function of each of the image-text sample pairs;

[0025] A training module is used to train the image generation model based on the total loss function.

[0026] Optionally, the noise prediction result is obtained by prediction of multiple prediction time steps;

[0027] The calculation module is used for:

[0028] Based on the noise prediction result, determining the prediction noise of the last prediction time step;

[0029] Performing regularization term calculation based on the reference noise and the predicted noise to obtain a regularization term calculation result;

[0030] Based on the calculation result of the regularization term, the sub-loss function is determined.

[0031] Optionally, the first determining unit is used to:

[0032] Performing a first encoding process on the noise reference image to obtain a reference image encoding feature;

[0033] Performing a second encoding process on the background template image to obtain a background image encoding feature;

[0034] Performing a third encoding process on the template mask image to obtain a mask image encoding feature;

[0035] The reference image coding feature, the background image coding feature, and the mask image coding feature are spliced ​​to obtain the sample spliced ​​image feature.

[0036] Optionally, the second determining unit includes:

[0037] An encoding module, used for encoding the image description information to obtain an image description embedding vector;

[0038] An extraction module, used for extracting features from the sample object image to obtain sample object feature data;

[0039] A generation module is used to generate control information through a preset control network based on the image description embedding vector, the sample object feature data, and the contour feature of the reference object to obtain the denoising network control information.

[0040] Optionally, the encoding module is used to:

[0041] Segmenting the image description information to obtain a plurality of description words;

[0042] Determine a target word from the plurality of description words, and search for a target word embedding feature corresponding to the target word based on a preset dictionary;

[0043] For other description words except the target word among the plurality of description words, perform word embedding processing on each of the other description words to obtain description word embedding features of the other description words;

[0044] The target word embedding feature and the description word embedding feature are integrated into the image description embedding vector.

[0045] Optionally, the control network includes a first control subnetwork and a second control subnetwork; the sample object feature data includes a first sample object feature, a second sample object feature, a third sample object feature, and a fourth sample object feature, wherein the first sample object feature, the second sample object feature, the third sample object feature, and the fourth sample object feature are obtained by respectively extracting features from the sample object image;

[0046] The generation module is used for:

[0047] Inputting the image description embedding vector, the first sample object feature, and the contour feature into the first control subnetwork to generate control information to obtain first control information;

[0048] Inputting the image description embedding vector and the second sample object feature into the second control subnetwork to generate control information, thereby obtaining second control information;

[0049] Determining upsampling network control information based on the third sample object feature and the fourth sample object feature;

[0050] Determine downsampling network control information based on the first control information, the second control information, the first sample object feature, and the second sample object feature;

[0051] The up-sampling network control information and the down-sampling network control information are integrated into the denoising network control information.

[0052] Optionally, the noise reference image is generated by:

[0053] Determining an expected result of replacing a reference object in the background template image with a sample object, wherein the expected result is image data;

[0054] Generate a random number that obeys a Gaussian distribution based on a predetermined random number generation model;

[0055] For each pixel point in the expected result, the random number is added to the pixel value of the pixel point to obtain the noise reference image.

[0056] Optionally, the image generation model includes a diffusion network and a denoising network;

[0057] The prediction unit comprises:

[0058] A compression module, used for compressing the sample spliced ​​image features to obtain sample compressed image features;

[0059] A diffusion module, used for performing diffusion processing on the sample compressed image features based on the diffusion network to obtain a sample latent space feature vector;

[0060] A denoising module is used to perform denoising processing on the sample latent space feature vector through the denoising network based on the denoising network control information to obtain the noise prediction result.

[0061] Optionally, the denoising network includes an upsampling attention network and a downsampling attention network; the denoising network control information includes upsampling network control information and downsampling network control information;

[0062] The denoising module is used to:

[0063] Fusion the downsampling network control information into a first attention matrix of the downsampling attention network to update the first attention matrix, and fusion the upsampling network control information into a second attention matrix of the upsampling attention network to update the second attention matrix;

[0064] The noise prediction result is obtained by denoising the sample latent space feature vector through the downsampling attention network after updating the first attention matrix and the upsampling attention network after updating the second attention matrix.

[0065] Optionally, the sample object image is generated by:

[0066] Acquire a sample image of the sample object;

[0067] Performing image segmentation on the sample image based on a preset object segmentation model to obtain a sample segmented image having the sample object;

[0068] Perform image enhancement on the sample segmented image to obtain the sample object image.

[0069] Optionally, the template mask image is generated by:

[0070] determining an object contour region of the reference object in the background template image;

[0071] In the background template image, the pixel value of each pixel point in the object contour area is replaced with a first value, and the pixel value of each pixel point outside the object contour area is replaced with a second value to obtain the template mask image.

[0072] Optionally, the contour feature of the reference object in the background template image is determined by:

[0073] Performing object detection on the background template image to obtain an object skeleton graph of the reference object;

[0074] Extracting posture features from the object skeleton graph to obtain a plurality of object posture key points;

[0075] The contour feature is determined based on the plurality of object posture key points.

[0076] According to one aspect of the present disclosure, there is provided an image generating device, the image generating device comprising:

[0077] a second acquisition unit, configured to acquire a target object image, a target background image, and target description information of a target object, wherein the target background image includes a reference object to be replaced by the target object in the target object image, and the target description information is used to describe the replacement from the reference object to the target object;

[0078] a third determining unit, configured to determine a target stitching image feature based on the target background image, a preset noise image, and a target mask image, wherein the target mask image is obtained by masking a reference object in the target background image;

[0079] a fourth determining unit, configured to determine denoising control information of an image generation model based on contour features of the reference object in the target background image, the target description information, and the target object image, wherein the image generation model is generated by the training method of the image generation model described above;

[0080] An image generation unit is used to generate an image through the image generation model based on the target spliced ​​image features and the denoising control information to obtain a target image, wherein the target image is used to indicate the result of replacing the reference object in the target background image with the target object of the target object image.

[0081] Optionally, the third determining unit is used to:

[0082] Performing a first encoding process on the preset noise image to obtain noise image features;

[0083] Performing a second encoding process on the target background image to obtain target background image features;

[0084] Performing a third encoding process on the target mask image to obtain target mask image features;

[0085] The noise image feature, the target background image feature, and the target mask image feature are spliced ​​to obtain the target spliced ​​image feature.

[0086] Optionally, the image generation model includes a diffusion network, a denoising network, and a decoding network;

[0087] The image generating unit is used for:

[0088] Performing compression processing on the target spliced ​​image features to obtain target compressed image features;

[0089] Performing diffusion processing on the target compressed image features based on the diffusion network to obtain a target latent space feature vector;

[0090] Based on the denoising control information, denoising the target latent space feature vector is performed through the denoising network to obtain a target denoising result;

[0091] The target denoising result is feature decoded based on the decoding network to obtain the target image.

[0092] According to one aspect of the present disclosure, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the above-mentioned image generation model training method or image generation method when executing the computer program.

[0093] According to one aspect of the present disclosure, a computer-readable storage medium is provided, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the training method of the image generation model or the image generation method as described above is implemented.

[0094] According to one aspect of the present disclosure, a computer program product is provided, which includes a computer program, and the computer program is read and executed by a processor of an electronic device, so that the electronic device executes the training method of the image generation model or the image generation method as described above.

[0095] In the embodiment of the present disclosure, when training the image generation model, a background template image, a noise reference image, image description information corresponding to the noise reference image, and a sample object image of a sample object are used to construct a text-image sample pair, wherein the noise reference image is obtained by adding noise to the expected result of replacing the reference object in the background template image with the sample object. This method can make the reference image used as a reference more in line with the actual situation. Then, the image features of the background template image, the object mask image of the background template, and the noise reference image are integrated into sample splicing image features, and the sample splicing image features are used as input for model training. Since the sample splicing image features have a variety of image feature information, using them as training data can enrich the information content of the training data. In addition, the embodiment of the present disclosure also introduces image description information (the image description information can indicate what the background and object in the noise reference image are like), contour features of the reference object in the background template image (contour features can reflect the action, posture, etc. of the reference object), and sample object images of the sample object (sample object images can reflect the contour, appearance, etc. of the sample object) to jointly generate denoising network control information, so that the denoising network control information has a variety of constraints. Furthermore, the denoising network control information and the sample splicing image features are input into the image generation model, so that when the image generation model performs noise prediction on the sample splicing image features, it is restricted by the denoising network control information, and the noise prediction process is corrected according to the denoising network control information, so that the noise prediction result of the noise reference image output by the image generation model is more accurate. Finally, the image generation model is trained by comparing the noise difference between the noise prediction result and the noise reference image, so as to obtain an image generation model that meets the training requirements. This method can improve the accuracy of the model generating the target image.

[0096] Other features and advantages of the present disclosure will be described in the following description, and partly become apparent from the description, or understood by practicing the present disclosure. The purpose and other advantages of the present disclosure can be realized and obtained by the structures particularly pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0097] The accompanying drawings are used to provide further understanding of the technical solution of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the technical solution of the present disclosure and do not constitute a limitation on the technical solution of the present disclosure.

[0098] Figure 1 is a system architecture diagram of a training method for an image generation model and a system for applying the image generation method according to an embodiment of the present disclosure;

[0099] Figure 2A-2CA schematic diagram showing an application of the image generation method according to an embodiment of the present disclosure in a video production scenario;

[0100] Figure 3 is a flowchart of a method for training an image generation model according to an embodiment of the present disclosure;

[0101] Figure 4 is a flowchart of determining a sample object image according to an embodiment of the present disclosure;

[0102] Figure 5 is a flow chart of determining a noise reference image according to an embodiment of the present disclosure;

[0103] Figure 6 is a schematic diagram of an implementation process of determining a noise reference image according to an embodiment of the present disclosure;

[0104] Figure 7 is a flow chart of generating sample spliced ​​image features according to an embodiment of the present disclosure;

[0105] Figure 8 is a flowchart of determining a template mask image according to an embodiment of the present disclosure;

[0106] Figure 9A-9B is a schematic diagram of an implementation process of determining a template mask image according to an embodiment of the present disclosure;

[0107] Fig.10 is a flow chart of generating denoising network control information according to an embodiment of the present disclosure;

[0108] Fig.11 is a flow chart of determining contour features of a reference object in a background template image according to an embodiment of the present disclosure;

[0109] Fig.12 is a schematic diagram of an implementation process of key point extraction when determining contour features according to an embodiment of the present disclosure;

[0110] Fig.13 is a flowchart of generating an image description embedding vector according to an embodiment of the present disclosure;

[0111] Fig.14 is a schematic diagram of an implementation process of generating an image description embedding vector according to an embodiment of the present disclosure;

[0112] Fig.15 is a flow chart of generating denoising network control information according to an embodiment of the present disclosure;

[0113] Fig.16 is a schematic diagram of an implementation process of generating denoising network control information according to an embodiment of the present disclosure;

[0114] Fig.17 is a flow chart of generating noise prediction results according to one embodiment of the present disclosure;

[0115] Fig.18 is a schematic diagram of an implementation process of generating a noise prediction result according to an embodiment of the present disclosure;

[0116] Fig.19 is a flowchart of a denoising process according to an embodiment of the present disclosure;

[0117] Fig. 20 is a schematic diagram of an implementation process of a downsampling process during denoising according to an embodiment of the present disclosure;

[0118] Fig.21 is a schematic diagram of an implementation process of an upsampling process during denoising according to an embodiment of the present disclosure;

[0119] Fig. 22 is a flowchart of a training image generation model according to one embodiment of the present disclosure;

[0120] Fig.23 is a flowchart of determining a sub-loss function according to an embodiment of the present disclosure;

[0121] Fig.24 is a schematic diagram of implementation details of a training image generation model according to an embodiment of the present disclosure;

[0122] Fig.25 is a flowchart of an image generating method according to an embodiment of the present disclosure;

[0123] Fig.26 is a flow chart for determining features of a target stitched image according to an embodiment of the present disclosure;

[0124] Fig. 27 is a flowchart of generating a target image according to one embodiment of the present disclosure;

[0125] Fig.28 is a simplified schematic diagram of an implementation of an image generation method according to an embodiment of the present disclosure;

[0126] Fig.29 is a schematic diagram of implementation details of an image generation method according to an embodiment of the present disclosure;

[0127] Fig.30 is a module diagram of a training device for an image generation model according to an embodiment of the present disclosure;

[0128] Fig.31 is a module diagram of an image generating device according to an embodiment of the present disclosure;

[0129] Fig.32 is a terminal structure diagram of a method for training an image generation model according to an embodiment of the present disclosure;

[0130] Fig.33 It is a server structure diagram of a method for training an image generation model according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0131] In order to make the purpose, technical solution and advantages of the present disclosure more clear, the present disclosure is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present disclosure and are not used to limit the present disclosure.

[0132] Before further describing the embodiments of the present disclosure in detail, the nouns and terms involved in the embodiments of the present disclosure are described. The nouns and terms involved in the embodiments of the present disclosure are subject to the following interpretations:

[0133] Cross Attention Control Module: A module used in deep learning to establish a cross-attention mechanism between multiple inputs. The Cross Attention Control Module can help the model automatically learn the correlation between inputs when processing multiple inputs, thereby improving the performance of the model.

[0134] The following describes the system architecture and scenarios for application of the embodiments of the present disclosure.

[0135] Figure 1 The system architecture diagram of the training method of the image generation model and the image generation method according to the embodiment of the present disclosure includes an object terminal 140, the Internet 130, a gateway 120, an image processing server 110, and an image database 150.

[0136] The object terminal 140 includes various forms such as desktop computers, laptop computers, PDAs (personal digital assistants), tablet computers, mobile phones, vehicle-mounted terminals, home theater terminals, smart TVs, and dedicated terminals. In addition, it can be a single device or a collection of multiple devices. The object terminal 140 can communicate with the Internet 130 in a wired or wireless manner to exchange data. The object terminal 140 includes an image processing system, which is used to receive the background image and the object image selected by the object, and submit the background image and the object image selected by the object to the image processing server, so that the image processing server generates a target image with the target object in the object image as the foreground and the background image as the background.

[0137] The image processing server 110 refers to a computer system that can provide certain services to the object terminal 140. Compared with the ordinary object terminal 140, the image processing server 110 has higher requirements in terms of stability, security, performance, etc. The image processing server 110 can be a high-performance computer in a network platform, a cluster of multiple high-performance computers, a part of a high-performance computer (such as a virtual machine), a combination of parts of multiple high-performance computers (such as virtual machines), or a cloud server. The image processing server 110 includes multiple types of services, wherein the implementation of each service of the image processing server 110 is often associated with some intermediate databases or storage media. The image processing server 110 is used to generate a target image with a target object in the object image as the foreground and a background image as the background using a trained image generation model, and the image database 150 is used to store various images such as target images, object images, and background images.

[0138] The gateway 120 is also called an internetwork connector or a protocol converter. The gateway realizes network interconnection at the transport layer and is a computer system or device that acts as a converter. The gateway is a translator between two systems that use different communication protocols, data formats or languages, or even have completely different architectures. At the same time, the gateway can also provide filtering and security functions. The message sent by the object terminal 140 to the image processing server 110 must be sent to the corresponding server through the gateway 120. The message sent by the image processing server 110 to the object terminal 140 must also be sent to the corresponding object terminal 140 through the gateway 120.

[0139] The embodiments of the present disclosure can be applied in various scenarios, such as Figure 2A-2C The video production scene shown, etc.

[0140] like Figure 2A As shown, when the object needs to use a scene with object A as the foreground and background image 5 as the background during the video production process, the object will log in to the image processing system on the object terminal and enter the image processing process. At this time, a prompt field "Please select the background image, upload the target object image, and enter the image description" will be displayed on the page, and an editing area for selecting the background image, an editing area for selecting the target object image, and an editing area for entering the image description will be provided. Based on this, the object selects "background image 5" in the editing area for selecting the background image; the object selects "D:\object image of object A\image 1+image 2" in the editing area for selecting the target object image; the object enters "Replace object B in background image 5 with object A" in the editing area for entering the image description, and clicks the "OK" button to confirm that the object B in background image 5 is replaced with object A through background image 5, image 1 and image 2 of object A.

[0141] like Figure 2B As shown, after the object clicks the "OK" button, a prompt window will be displayed on the page, wherein the prompt window has a prompt field "The mask map corresponding to the background image 5 and the object contour map of the object B are being generated, and the image generation model is called to perform image synthesis based on the mask map and the object contour map, etc. Please wait patiently..." to show the object the image synthesis process of the image generation model.

[0142] like Figure 2C As shown, when the image generation model is executed, the page will display a prompt field "Object B in background image 5 has been replaced with object A, see the figure below. In addition, the generated image has been saved to the path: D:\synthetic image folder\video production.", and a comparison diagram of background image 5 and the generated target image is displayed. Among them, there is bottle A (object B) in the background image 5, and there is bottle B (object A) in the target image. Through the image generation model in the image processing system, bottle A in background image 5 is replaced with bottle B while keeping the background unchanged.

[0143] It should be noted that, in addition to being applicable to the above-mentioned video production scenario, the image generation method of the embodiment of the present disclosure can also be applied to various application scenarios such as item display scenarios in e-commerce and personalized image production scenarios in social media.

[0144] The following is a general description of the training method of the image generation model of the embodiment of the present disclosure.

[0145] According to one embodiment of the present disclosure, a method for training an image generation model is provided.

[0146] The training method of this image generation model is generally used in business scenarios where reference objects (people, animals, objects, etc.) in a fixed background image need to be replaced with target objects (people, animals, objects, etc.), for example Figure 2A-2C The video production scene, item display scene, etc. The disclosed embodiment provides a solution for model training based on image description and object difference between the image to be generated and the background image, which can improve the accuracy of the image generation model in generating the target image.

[0147] like Figure 3 As shown, the training method of the image generation model according to an embodiment of the present disclosure can be performed by an electronic device, which can be Figure 1 The image processing server or object terminal shown, the training method of the image generation model may include:

[0148] Step 310: obtaining a plurality of image-text sample pairs;

[0149] Step 320: determining features of the sample spliced ​​image based on the noise reference image, the background template image, and the template mask image;

[0150] Step 330, determining denoising network control information of the image generation model based on the contour features of the reference object in the background template image, the image description information, and the sample object image;

[0151] Step 340: Based on the sample splicing image features and the denoising network control information, noise prediction is performed through the image generation model to obtain a noise prediction result of the noise reference image;

[0152] Step 350: training an image generation model based on the comparison between the noise reference images and the noise prediction results of the plurality of image-text sample pairs.

[0153] Steps 310 - 350 are described in detail below.

[0154] In step 310, a plurality of image-text sample pairs are obtained.

[0155] In the disclosed embodiment, a picture-text sample pair is used as training data, wherein each picture-text sample pair includes a background template image, a noise reference image, image description information corresponding to the noise reference image, and a sample object image of a sample object.

[0156] The background template image refers to a background image to which the sample object is to be added, wherein the background template image contains a reference object to be replaced by the sample object in the sample object image.

[0157] The sample object images of the sample objects refer to a series of images that can reflect the object characteristics (object posture, object motion, object appearance, etc.) of the sample objects.

[0158] The noise reference image is obtained by adding noise to the expected result of replacing the reference object in the background template image with the sample object.

[0159] The image description information corresponding to the noise reference image is used to indicate the conditional constraints on the denoising process. For example, the image description information may be generated by generating a person A in a background template image.

[0160] In step 320, sample stitching image features are determined based on the noise reference image, the background template image, and the template mask image.

[0161] The template mask image is obtained by masking the reference object in the background template image.

[0162] The sample stitching image feature is used to indicate the feature stitching result of the noise reference image, the background template image, and the template mask image.

[0163] In the specific implementation of this embodiment, first, the noise reference image, the background template image, and the template mask image are mapped from the pixel space to the latent vector space, respectively, to obtain the vector features corresponding to the noise reference image, the vector features corresponding to the background template image, and the vector features corresponding to the template mask image. Then, the vector features corresponding to the noise reference image, the vector features corresponding to the background template image, and the vector features corresponding to the template mask image are feature spliced ​​to obtain the sample spliced ​​image features.

[0164] In step 330, based on the contour features of the reference object in the background template image, the image description information, and the sample object image, the denoising network control information of the image generation model is determined.

[0165] The contour features of the reference object in the background template image are used to indicate the contour features of the action, posture, etc. of the reference object in the background template image.

[0166] The image generation model of the embodiment of the present disclosure is a neural network model constructed based on a stable diffusion (SD) model. The image generation model of the embodiment of the present disclosure often takes a background image, an object image, and information describing the object in the object image replacing the object in the background image as input, and outputs a composite image with the scene of the background image as the background and the object in the object image as the foreground. The image generation model can embed an object into a specific position of an image to meet the image generation requirements in various scenarios.

[0167] The denoising network control information is used as a conditional constraint to assist the image generation model in image denoising.

[0168] To save space, the specific process of determining the denoising network control information based on the contour features of the reference object in the background template image, image description information, and the sample object image in the embodiment of the present disclosure will be described in detail below and will not be repeated here.

[0169] In step 340, based on the sample splicing image features and the denoising network control information, noise prediction is performed through the image generation model to obtain a noise prediction result of the noise reference image.

[0170] The noise prediction result is used to indicate the noise level contained in the image features generated by the image generation model and consistent with the noise reference image.

[0171] To save space, the specific process of performing noise prediction through the image generation model based on sample splicing image features and denoising network control information in the embodiment of the present disclosure will be described in detail below and will not be repeated here.

[0172] In step 350, an image generation model is trained based on the comparison of noise reference images and noise prediction results of multiple image-text sample pairs.

[0173] In the specific implementation of this embodiment, the model parameters of the image generation model are adjusted according to the degree of noise difference between the noise reference image of the image-text sample pair and the noise prediction result, and the above steps 310-350 are repeated to continuously reduce the noise difference between the noise reference image of the image-text sample pair and the noise prediction result, until the noise difference between the noise reference image and the noise prediction result of multiple image-text sample pairs meets the model training requirements, the updating of the model parameters of the image generation model is stopped, the model parameters at this time are used as the final model parameters, and the image generation model with the final model parameters is used as the trained image generation model.

[0174] Through the above steps 310-350, the embodiment of the present disclosure, when training the image generation model, uses the background template image, the noise reference image, the image description information corresponding to the noise reference image, and the sample object image of the sample object to construct a picture-text sample pair, wherein the noise reference image is obtained by adding noise to the expected result of replacing the reference object in the background template image with the sample object. This method can make the reference image used as a reference more in line with the actual situation. Then, the background template image, the object mask image of the background template, and the image features of the noise reference image are integrated into the sample splicing image features, and the sample splicing image features are used as the input of the model training. Since the sample splicing image features have a variety of image feature information, using them as training data can enrich the information content of the training data. In addition, the embodiment of the present disclosure also introduces image description information (the image description information can indicate what the background and object in the noise reference image are like), the contour features of the reference object in the background template image (the contour features can reflect the action, posture, etc. of the reference object), and the sample object image of the sample object (the sample object image can reflect the contour, appearance, etc. of the sample object) to jointly generate the denoising network control information, so that the denoising network control information has a variety of constraints. Furthermore, the denoising network control information and the sample splicing image features are input into the image generation model, so that when the image generation model performs noise prediction on the sample splicing image features, it is restricted by the denoising network control information, and the noise prediction process is corrected according to the denoising network control information, so that the noise prediction result of the noise reference image output by the image generation model is more accurate. Finally, the image generation model is trained by comparing the noise difference between the noise prediction result and the noise reference image, so as to obtain an image generation model that meets the training requirements. This method can improve the accuracy of the model generating the target image.

[0175] The above is a general description of steps 310 to 350. The specific implementation of steps 310, 320, 330, 340 and 350 will be described in detail below.

[0176] Step 310 is described in detail below.

[0177] In step 310, a plurality of image-text sample pairs are obtained, wherein each image-text sample pair includes a background template image, a noise reference image, image description information corresponding to the noise reference image, and a sample object image of a sample object, wherein the noise reference image is obtained by adding noise to the expected result of replacing a reference object in the background template image with the sample object.

[0178] Please refer to Figure 4 In one embodiment, the sample object image of the sample object is determined by:

[0179] Step 410: Obtain a sample image of a sample object;

[0180] Step 420: performing image segmentation on the sample image based on a preset object segmentation model to obtain a sample segmented image having the sample object;

[0181] Step 430: Perform image enhancement on the sample segmentation image to obtain a sample object image.

[0182] Steps 410 - 430 are described in detail below.

[0183] In step 410, a sample image is an image containing a sample object.

[0184] In the specific implementation of this embodiment, with authorization, sample images of multiple sample images can be extracted from an existing image database, and video data with sample objects can be extracted from an existing video database, and the video data can be segmented into video frames, and each video frame with sample objects can be used as a sample image.

[0185] In step 420, the sample segmentation image refers to a local image having a sample object segmented from the sample image, and the sample segmentation image is a part of the sample image.

[0186] The object segmentation model can be a lightweight semantic segmentation model BiSeNet-v2 or PP_LiteSeg.

[0187] Taking the semantic segmentation model PP_LiteSeg as an example, the object segmentation model includes an encoding module, a pyramid pooling module, a decoding module and an attention fusion module. Specifically, first, the sample image is input into the encoding module of the object segmentation model, and the sample image is multi-scale encoded by the encoding module to obtain the first sample image feature whose image size is one-fourth of the sample image, the second sample image feature whose image size is one-eighth of the sample image, the third sample image feature whose image size is one-sixteenth of the sample image, and the fourth sample image feature whose image size is one-thirty-second of the sample image. Then, the fourth sample image feature is feature pooled by the pyramid pooling module to obtain the sample image pooling feature. Further, the sample image pooling feature and the third sample image feature are feature fused by the attention fusion module to obtain the first image fusion feature. Then, the first image fusion feature and the second sample image feature are feature fused by the attention fusion module to obtain the second image fusion feature. Further, the second image fusion feature is decoded by the decoding module to obtain a sample segmented image with a sample object.

[0188] In step 430, the image enhancement of the sample segmented image includes but is not limited to contrast enhancement, brightness enhancement, sharpening, and noise reduction of the sample segmented image. Specifically, first, when the sample segmented image is enhanced, a linear stretching or logarithmic transformation method is used to expand the pixel value distribution of the sample segmented image so that the light and dark areas of the sample image segmented image are more distinct, so as to achieve contrast enhancement of the sample segmented image. Then, after contrast enhancement, the brightness values ​​of all pixels of the sample segmented image are adjusted to improve the overall brightness of the sample segmented image. Further, after brightness adjustment, a Gaussian filter or a median filter is used to smooth the sample segmented image and reduce noise in the sample segmented image. Finally, after noise reduction, the sample segmented image is edge enhanced by a Laplace operator to achieve sharpening of the sample segmented image and obtain a sample object image.

[0189] The advantage of this embodiment is that the sample image of the sample object is segmented, and a local image with the sample object is segmented from the sample image, which can effectively eliminate the interference of irrelevant image information and improve the image quality of the sample segmented image used for training. Furthermore, multiple image enhancement processes such as contrast enhancement, brightness enhancement, sharpening, and noise reduction are adopted for the sample segmented image, which can further improve the image quality of the sample object image.

[0190] Please refer to Figure 5 In one embodiment, the noise reference image is determined by:

[0191] Step 510, determining the expected result of replacing the reference object in the background template image with the sample object;

[0192] Step 520: Generate a random number that obeys a Gaussian distribution based on a predetermined random number generation model;

[0193] Step 530: For each pixel point in the expected result, a random number is added to the pixel value of the pixel point to obtain a noise reference image.

[0194] Steps 510 - 530 are described in detail below.

[0195] In step 510, the expected result is image data.

[0196] In the specific implementation of this embodiment, the reference object of the background template image can be replaced with the sample object by using image editing software, so that the obtained replaced image is regarded as the expected result of replacing the reference object in the background template image with the sample object. The image editing software can be Adobe Photoshop or other software.

[0197] In step 520, the predetermined random number generation model refers to a random number generator, and a random number is a randomly generated number, wherein the random number generated by the embodiment of the present disclosure and obeying the Gaussian distribution may be repeated.

[0198] When this embodiment is specifically implemented, the predetermined random number generation model has a library function (numpy.random.normal() function). Specifically, through the library function of the predetermined random number generation model, a random number is generated according to the mean value of 0 and the standard deviation of 1 that the Gaussian distribution is to follow, and the random number obeys the Gaussian distribution. Among them, the random number obeying the Gaussian distribution can be expressed in the form of a random noise image, and the image size of the random noise image is the same as the image size of the expected result.

[0199] In step 530, for each pixel in the expected result, the pixel value of the pixel in the expected result is first determined, and the noise value of the pixel in the random noise image corresponding to the random number is determined. Then, the pixel value and the noise value of the pixel are added to obtain the noisy pixel value of the pixel. Finally, the noise reference image is obtained according to the noisy pixel value of each pixel.

[0200] like Figure 6As shown, it is a schematic diagram of the specific implementation process of superimposing random noise on the expected result. The expected result is an 8×8 image with 64 pixels. The random noise map corresponding to the random number obeying the Gaussian distribution is also an 8×8 image with 64 pixels. Specifically, for each pixel of the expected result, the pixel value of each pixel is first determined, wherein the pixel value of each pixel includes 1, 2, 3, 4, 5 or 6. Then, for each pixel, the noise value of each pixel in the random noise map is determined, wherein the noise value includes 0, 1, 2, 3, 4, 5 or 6. Further, for each pixel, the pixel value and the noise value are added to obtain the noisy pixel value of each pixel. For example, for each pixel in the first row of the expected result, the pixel value of the first pixel is 1, the noise value is 5, and the noisy pixel value is 1+5=6. The pixel value of the second pixel is 1, the noise value is 1, and the noisy pixel value is 1+1=2. The pixel value of the third pixel is 1, and the noise value is 4, so the noisy pixel value is 1+4=5; and so on, until the noisy pixel value of the last pixel in the last row is determined, generating a noise reference image.

[0201] The benefit of this embodiment is that random noise conforming to the Gaussian distribution is added to the expected result of replacing the reference object in the background template image with the sample object, and environmental noise is introduced into the idealized reference image, so that the final expected result is more in line with the actual situation, thereby improving the authenticity and accuracy of the noise reference image and making the noise reference image more referenceable.

[0202] Step 320 is described in detail below.

[0203] In step 320, the sample stitching image features are determined based on the noise reference image, the background template image, and the template mask image, wherein the template mask image is obtained by masking the reference object in the background template image.

[0204] Please refer to Figure 7 In one embodiment, step 320 specifically includes but is not limited to the following steps 710-740:

[0205] Step 710: Perform a first encoding process on the noise reference image to obtain a reference image encoding feature;

[0206] Step 720: Perform a second encoding process on the background template image to obtain a background image encoding feature;

[0207] Step 730: Perform a third encoding process on the template mask image to obtain a mask image encoding feature;

[0208] Step 740: splice the reference image coding features, the background image coding features, and the mask image coding features to obtain sample spliced ​​image features.

[0209] Steps 710-740 are described in detail below.

[0210] In step 710, the reference image encoding feature is used to indicate the result of converting the noisy reference image from the data space to the pixel space.

[0211] In the specific implementation of this embodiment, a preset image encoder can be used to perform a first encoding process on the noise reference image, converting the noise reference image from pixel space to latent vector space to capture the image key information of the noise reference image and obtain the reference image encoding features, wherein the image key information of the noise reference image includes but is not limited to texture information, edge information, and corner point information of the morning reference image.

[0212] In step 720, the background image encoding feature is used to indicate the result of converting the background template image from the data space to the pixel space.

[0213] When this embodiment is implemented, the specific process of step 720 is similar to the specific process of step 710. The difference is that the images to be encoded are different and the encoder parameters of the image encoders used are different. To save space, it will not be described in detail.

[0214] In step 730, the mask image encoding feature is used to indicate the result of converting the template mask image from the data space to the pixel space.

[0215] When this embodiment is implemented, the specific process of step 730 is similar to the specific process of the above step 730. The difference is that the images to be encoded are different and the encoder parameters of the image encoders used are different. To save space, it will not be repeated.

[0216] In step 740, feature splicing is performed on the reference image coding features, the background image coding features, and the mask image coding features, and the reference image coding features, the background image coding features, and the mask image coding features are spliced ​​into a vector feature with a larger number of feature channels, and the spliced ​​vector feature is determined as the sample spliced ​​image feature.

[0217] For example, the feature dimensions of the reference image coding feature, the background image coding feature, and the mask image coding feature are all W*H*4, where W is the feature length of the reference image coding feature, the background image coding feature, and the mask image coding feature, H is the feature height of the reference image coding feature, the background image coding feature, and the mask image coding feature, and 4 is the number of feature channels of the reference image coding feature, the background image coding feature, and the mask image coding feature. After the above feature splicing operation, the feature dimension of the obtained sample splicing image feature is W*H*12.

[0218] The benefit of this embodiment is that the image information of the noise reference image, the background template image, and the template mask image are all converted from the pixel space to the latent vector space, and the image information (reference image coding features, background image coding features, and mask image coding features) of the noise reference image, the background template image, and the template mask image in the latent vector space are spliced ​​to form a sample spliced ​​image feature having expected image information containing noise, template image information, and reference object mask information. Furthermore, the sample spliced ​​image feature is used as the input of the image generation model during model training, so that the input data of the model incorporates the image generation effect information, the background template information, and the reference object information in the background template, which can better improve the richness and comprehensiveness of the feature information of the sample spliced ​​image feature, and is conducive to the training model to learn and mine a variety of image information, thereby improving the image generation accuracy of the model.

[0219] Please refer to Figure 8 In one embodiment, the template mask image is determined by:

[0220] Step 810: determining an object contour region of a reference object in the background template image;

[0221] Step 820: In the background template image, replace the pixel value of each pixel point within the object contour area with a first value, and replace the pixel value of each pixel point outside the object contour area with a second value, to obtain a template mask image.

[0222] Steps 810-820 are described in detail below.

[0223] In step 810, the object contour area is used to indicate the minimum circumscribed rectangular area corresponding to the object contour of the reference object.

[0224] In the specific implementation of this embodiment, first, each pixel point used to represent the reference object is determined in the background template image. Then, a two-dimensional coordinate system is constructed with the pixel point in the upper left corner of the background template image as the origin, the height direction of the background template image as the vertical axis, the width direction of the background template image as the horizontal axis, and the distance between two adjacent pixels as a unit length. Further, based on the constructed two-dimensional coordinate system, the coordinate data of each pixel point used to represent the reference object is determined. The maximum value of the horizontal coordinate is selected from the coordinate data of each pixel point. , minimum value of horizontal axis , maximum value of vertical coordinate , minimum vertical coordinate Finally, based on the maximum value of the horizontal coordinate, the minimum value of the horizontal coordinate, the maximum value of the vertical coordinate, and the minimum value of the vertical coordinate, the minimum bounding rectangle area corresponding to the object contour of the reference object is determined, and the minimum bounding rectangle area is determined as the object contour area of ​​the reference object. Among them, the coordinates of the four endpoints of the minimum bounding rectangle area are ( )、( )、( )、( ).

[0225] In step 820 , the first value refers to a value of 1 that makes the pixel appear white, and the second value refers to a value of 0 that makes the pixel appear black.

[0226] In the specific implementation of this embodiment, first, in the background template image, it is divided into an object contour area and other areas outside the object contour area. Then, for each pixel point in the object contour area, the pixel value of the pixel point is replaced with a first value, so that the object contour area appears white. For each pixel point outside the object contour area, the pixel value of the pixel point is replaced with a second value, so that the object contour area appears black, thereby obtaining a template mask image according to the change of the pixel value of each pixel point of the background template image. The template mask image is often displayed as a black and white image.

[0227] like Fig. 9AThe figure shows a brief illustration of mask processing at the pixel level. Specifically, in the background template image with an image size of 8×8, the minimum circumscribed rectangular area corresponding to the object contour of the reference object is a 4×4 image area, wherein the object contour area contains 3 pixels with a pixel value of 9, 2 pixels with a pixel value of 8, 2 pixels with a pixel value of 1, 2 pixels with a pixel value of 4, and 7 pixels with a pixel value of 2. Based on this, the pixel values ​​of these 16 pixels are all replaced with 1, and the pixel values ​​of the pixels other than these 16 pixels in the background template image are all replaced with 0, so as to obtain a template mask image with a pixel value of 0 or 1. In the template mask image, the object contour area of ​​the reference object is displayed in white, and the other parts except the object contour area are displayed in black.

[0228] like Fig. 9B The figure shows a brief illustration of mask processing at the image level. Specifically, the background template image contains a reference object (person) and several other objects (pentagrams and polygons). Based on this, the minimum bounding rectangle corresponding to the outline of the reference object (person) is first determined, and the pixel value of each pixel point within the minimum bounding rectangle is set to 1, and the pixel value of each pixel point outside the minimum bounding rectangle in the background template image is set to 0, so as to implement mask processing of the background template image and obtain a black and white template mask image, in which the object outline area is a white rectangular area.

[0229] The benefit of this embodiment is that by determining the object contour area of ​​the reference object in the background template image, the image position of the reference object in the background template image can be clearly determined, and by converting the pixel value of each pixel point, the background template image can be binarized (masked). This can effectively expand the distinction between the pixel positions occupied by the reference object and the non-reference object in the background template image, so that the model can better explore the object contour features of the reference object based on the template mask image, thereby improving the accuracy of replacing the reference object with the target object.

[0230] Step 330 is described in detail below.

[0231] In step 330, based on the contour features of the reference object in the background template image, the image description information, and the sample object image, the denoising network control information of the image generation model is determined.

[0232] Please refer to Fig.10 In one embodiment, step 330 specifically includes but is not limited to the following steps 1010-1030:

[0233] Step 1010: Encode the image description information to obtain an image description embedding vector;

[0234] Step 1020: extract features from the sample object image to obtain sample object feature data;

[0235] Step 1030: Based on the image description embedding vector, the sample object feature data, and the contour features of the reference object, control information is generated through a preset control network to obtain denoising network control information.

[0236] Steps 1010-1030 are described in detail below.

[0237] In step 1010, the image description embedding vector is used to indicate a vector representation of the conditional constraints on the denoising process in the image description information.

[0238] In the specific implementation of this embodiment, the image description information can be encoded using a text encoder to convert the image description information from the data space to the vector space, thereby obtaining an image description embedding vector. The text encoder includes a word segmenter, an embedding layer, and a text attention calculation module.

[0239] Specifically, first, the image description information is input into the word segmenter, and the word segmenter is used to segment the image description information to obtain multiple description words. Then, the embedding layer is used to embed each description word, and each description word is converted into a vector form to obtain the description word vector corresponding to each description word. Finally, the text attention calculation module is used to perform attention calculation on the description word vector of each description word to obtain the image description embedding vector.

[0240] In step 1020, the sample object feature data is used to indicate the object features of the sample object to be replaced; the sample object feature data can guide the denoising network of the image generation model to restore the object in the image to be more closely aligned with the sample object during the denoising process.

[0241] For example, when the sample object is a person, the sample object feature data includes but is not limited to facial contour, facial features, etc.

[0242] It should be noted that the sample object feature data can be obtained through a fine-tuning network generated by a fine-tuning technology (LoRA technology) based on a deep learning model. The fine-tuning network is a neural network based on a cross-attention algorithm.

[0243] In the specific implementation of this embodiment, first, the sample object image is input into the fine-tuning network, and the fine-tuning network linearly projects the sample object image to generate the key vector, value vector and query vector corresponding to the sample object image. Then, the key vector, value vector and query vector are used to perform cross-attention calculation to obtain the calculation result, and the calculation result is converted into a vector form to obtain the sample object feature data.

[0244] In step 1030, the preset control network is used to generate control information for the denoising network of the image generation model according to a variety of input data. The input data allowed by the preset control network include conditional constraints of the image to be generated, the outline of the object in the background template image, the object features of the object to be replaced, etc.

[0245] It should be noted that in order to improve the accuracy of the denoising network control information output by the control network, the control network of the embodiment of the present disclosure may also be a neural network based on the cross-attention algorithm.

[0246] The denoising network control information is used to guide and control the image generation model's attention to and learning of various feature information during the denoising process. The denoising network control information is also used to indicate the degree of fine-tuning of various image feature information during the denoising process.

[0247] To save space, the specific process of generating control information through a preset control network to obtain denoising network control information in the embodiment of the present disclosure will be described in detail below and will not be repeated here.

[0248] The benefit of this embodiment is that the denoising network control information of the image generation model is jointly generated by using the image description information, the contour features of the reference object in the background template image, and the object features of the sample object, so that denoising can be performed according to a variety of constraint information during the image denoising process, and accurate fine-tuning and flexible control of image denoising are achieved. This method enables the model to perform image denoising under the constraints of multiple dimensions, improves the image denoising ability of the model, is conducive to the model generating image content that is more consistent with the image description, and can also make the object in the image finally generated by the model closer to the action and posture of the reference object in the template image.

[0249] Please refer to Fig.11 In one embodiment, the contour features of the reference object in the background template image are determined by:

[0250] Step 1110, performing object detection on the background template image to obtain an object skeleton graph of the reference object;

[0251] Step 1120, extracting posture features from the object skeleton graph to obtain a plurality of object posture key points;

[0252] Step 1130: Determine contour features based on multiple object posture key points.

[0253] Steps 1110 - 1130 are described in detail below.

[0254] In step 1110, an object skeleton map is used to indicate a skeleton outline of a reference object in a background template image.

[0255] In the specific implementation of this embodiment, first, a preset detection algorithm is used to locate the object in the background template image to identify the location of the reference object and obtain an object detection result, which is formed by multiple pixel points constituting the reference object. The preset detection algorithm includes but is not limited to the YOLO algorithm, the SSD algorithm, etc. Then, the object skeleton map of the reference object is determined based on the pixel points included in the object detection result.

[0256] In step 1120, the object posture key points are used to indicate the action and posture of the reference object in the background template image.

[0257] In the specific implementation of this embodiment, first, the object skeleton graph is input into the preset posture estimation model, and the pixel points representing the important parts of the reference object in the object skeleton graph are located by using the preset posture estimation model to obtain a set of key point coordinates. Then, the coordinates of each key point output by the posture estimation model are determined as the object posture key points. Among them, the preset posture estimation model includes but is not limited to neural network models based on deep learning algorithms such as PoseNet and AlphaPose.

[0258] In step 1130, first, multiple object posture key points are connected according to the relative positions and associations of each object posture key point to form a complete object line drawing. Then, the object line drawing is converted into an image expression form acceptable to the control network to obtain the contour features of the reference object.

[0259] like Fig.12 As shown in FIG. 1 , it is a key point detection process for a person (reference object) in a background template image. Specifically, the key point extraction algorithm is used to extract the key points of the person in the background template image to obtain the facial key points and skeletal key points of the reference object. Among them, the facial key points are used to reflect the facial contour characteristics and facial features of the reference object, and the skeletal key points are used to reflect the posture characteristics of the reference object in the background template image. Based on this, the facial key points and skeletal key points are jointly determined as the object posture key points of the reference object.

[0260] The benefit of this embodiment is that when determining the contour features of the reference object, the reference object is first located in the background template image, and the skeleton features of the reference object are constructed according to the location of the reference object. Furthermore, by using the posture estimation model to perform key point detection in the skeleton image, the efficiency and accuracy of determining the posture key points can be improved, so that the contour features of the reference object can be drawn according to the relative positions of multiple posture key points, which can improve the accuracy of determining the contour features and is also conducive to improving the accuracy of the denoising network control information.

[0261] Since the image description information is converted into an embedded vector in a conventional encoding method, the conditional constraint content of the image generation is often inaccurate. The disclosed embodiment provides a scheme for encoding the image description information based on fine-tuning technology, which can improve the accuracy of the generated image description embedding vector, thereby improving the effectiveness of the conditional constraint content used to generate denoising network control information.

[0262] It should be noted that the encoding process of the image description information in the embodiment of the present disclosure is implemented based on a preset text encoder, wherein the text encoder includes a tokenizer, an embedding layer, and a text attention calculation module (text transformer).

[0263] Please refer to Fig.13 In one embodiment, step 1010 specifically includes but is not limited to the following steps 1310-1340:

[0264] Step 1310: segment the image description information to obtain multiple description words;

[0265] Step 1320: determine a target word from the multiple description words, and find a target word embedding feature corresponding to the target word based on a preset dictionary;

[0266] Step 1330: For other description words except the target word among the multiple description words, perform word embedding processing on each other description word to obtain description word embedding features of the other description words;

[0267] Step 1340: Integrate the target word embedding features and the description word embedding features into an image description embedding vector.

[0268] Steps 1310 - 1340 are described in detail below.

[0269] In step 1310, the description word is used to indicate the vocabulary information included in the image description information.

[0270] In the specific implementation of this embodiment, first, the image description information can be input into the word segmenter of the text encoder. Then, the word segmenter will segment the image description information according to spaces, punctuation marks or separators to obtain multiple words. Furthermore, stop words in the multiple words are removed to obtain multiple description words.

[0271] In step 1320, the target word refers to a word in the image description information that needs to be searched through a vocabulary to find a corresponding embedded vector representation, and the target word embedding feature is used to indicate the vector representation of the target word in the image description information.

[0272] The preset dictionary is pre-set in the embedding layer, and the preset dictionary of the embedding layer is used to indicate the corresponding relationship between the index of each description word and the word embedding feature.

[0273] In the specific implementation of this embodiment, first, for multiple description words, pre-set description words to be represented by fixed characters are screened out from the multiple description words as target words. Then, the index corresponding to the target word is input into the embedding layer of the text encoder, and a feature search is performed in the preset dictionary of the embedding layer based on the index to find the word embedding feature corresponding to the index as the target word embedding feature.

[0274] In step 1330, the description word embedding feature is used to indicate the vector representation of other description words in the image description information.

[0275] In the specific implementation of this embodiment, for other description words except the target word among the multiple description words, first, the index of each other description word is determined according to the word segmentation result of the word segmenter. Then, the embedding layer of the text encoder is used to perform word embedding processing on each other description word, and the word embedding features corresponding to the index of each other description word are found in the preset dictionary of the embedding layer to obtain the description word embedding features of the other description words.

[0276] In step 1340, first, the target word embedding features and the description word embedding features are input into the text attention calculation module, and the text attention calculation module outputs the description word embedding vectors of each description word. Next, the number of each description word is determined according to the order of each description word in the image description information. Further, according to the number corresponding to the target word embedding feature and the number corresponding to the description word embedding feature, the description word embedding vectors are spliced ​​in the order of the number to obtain a complete description word embedding sequence. Finally, the spliced ​​description word embedding sequence is determined as the image description embedding vector.

[0277] like Fig.14 As shown in FIG. 1 , it is a specific illustration of the process of generating an image description vector based on image description information as a conditional constraint and controlling image denoising based on the conditional constraint. Specifically, the input image instance is a clock image. For the image description information of the input image instance is “A Photo of clock”, the “clock” in the image description information is used as the target word, and the target word is represented as “S * ”. At this time, the image description information becomes “A Photo of S *Based on this, the image description information is input into the word segmenter, and the image description information is segmented by the word segmenter, and the index of each word is determined according to the preset index corresponding to each candidate word in the preset vocabulary index table. Among them, the index corresponding to the description word "A" is 508, the index corresponding to the description word "Photo" is 701, the index corresponding to the description word "of" is 73, and the index corresponding to the description word "S * "The corresponding index is *. Further, the index of each descriptive word is embedded through the embedding layer, and the index corresponding to each descriptive word is mapped from the numerical space to the vector space to obtain the word embedding feature corresponding to each descriptive word. Among them, the word embedding feature corresponding to the description word "A" is " "; The word embedding feature corresponding to the description word "Photo" is " "; The word embedding feature corresponding to the description word "of" is " "; Descriptor "S * "The corresponding word embedding feature is" Furthermore, the word embedding features of each description word are input into the text attention calculation module for attention calculation, and the image description vector is output through the text attention calculation module. , the image description vector is used as a conditional constraint for denoising the noisy image instance through the image generator, so that the predicted image instance output by the image generator fits the content represented by the image description information. In addition, the predicted image instance is obtained by performing four diffusion processes (four noise addition operations) on the input image instance to obtain the noisy image instance, and then the image generator performs four denoising processes on the noisy image instance according to the image description vector.

[0278] The benefit of this embodiment is that, through the fine-tuning technology, the description words in the image description information that are pre-set to be represented by fixed characters are used as target words, and the text encoder is used to fine-tune and search the word embedding representation of the target word to obtain the target word embedding feature corresponding to the target word, and other description words are processed by word embedding to convert each description word into an embedding vector. This method can bind the object description content in the image description information to the image description embedding vector, which can improve the accuracy of the generated image description embedding vector, and thereby improve the effectiveness of the conditional constraint content used to generate denoising network control information.

[0279] In the embodiment of the present disclosure, the control network includes a first control sub-network and a second control sub-network.

[0280] The first control sub-network and the second control sub-network are neural network structures that can perform cross-attention calculations. The first control sub-network and the second control sub-network have the same network structure, but their network parameters are different.

[0281] The sample object feature data includes a first sample object feature, a second sample object feature, a third sample object feature, and a fourth sample object feature, wherein the first sample object feature, the second sample object feature, the third sample object feature, and the fourth sample object feature are obtained by respectively extracting features from the sample object image.

[0282] The first sample object feature, the second sample object feature, the third sample object feature, and the fourth sample object feature are all used to fine-tune the denoising process of the image generation model, but the first sample object feature, the second sample object feature, the third sample object feature, and the fourth sample object feature are fine-tuned at different stages. The first sample object feature, the second sample object feature, the third sample object feature, and the fourth sample object feature are all obtained through the above-mentioned fine-tuning network. However, the network parameters of the fine-tuning network used to extract the first sample object feature, the second sample object feature, the third sample object feature, and the fourth sample object feature are different.

[0283] Please refer to Fig.15 In one embodiment, step 1030 specifically includes but is not limited to the following steps 1510-1550:

[0284] Step 1510: input the image description embedding vector, the first sample object feature, and the contour feature into the first control subnetwork to generate control information, thereby obtaining first control information;

[0285] Step 1520: input the image description embedding vector and the second sample object feature into the second control subnetwork to generate control information, thereby obtaining second control information;

[0286] Step 1530: Determine upsampling network control information based on the third sample object feature and the fourth sample object feature;

[0287] Step 1540: Determine downsampling network control information based on the first control information, the second control information, the first sample object feature, and the second sample object feature;

[0288] Step 1550: Integrate the up-sampling network control information and the down-sampling network control information into denoising network control information.

[0289] Steps 1510-1550 are described in detail below.

[0290] In step 1510, the first control information is used to fine-tune the intermediate result of the denoising network of the image generation model during downsampling.

[0291] In the specific implementation of this embodiment, first, the image description embedding vector, the first sample object feature, and the contour feature are input into the first control sub-network. Then, the first sample object feature and the contour feature are spliced ​​to obtain a spliced ​​feature vector. Further, the spliced ​​feature vector is linearly projected through the first control sub-network to obtain a query matrix vector; and the image description embedding vector is linearly projected through the first control sub-network to obtain a key matrix vector and a value matrix vector. Further, a cross-attention calculation is performed based on the query matrix vector, the key matrix vector and the value matrix vector to obtain an attention calculation result. Finally, the attention calculation result is converted from the numerical space to the vector space through the first control sub-network to obtain the first control information.

[0292] Among them, the specific process of performing cross attention calculation based on the query matrix vector, the key matrix vector and the value matrix vector to obtain the attention calculation result can be expressed as shown in formula (1):

[0293] Formula (1);

[0294] in, is the result of attention calculation; Q is the query matrix vector; is the key matrix vector, is a matrix vector of values. is the characteristic dimension of the key matrix vector, is the transposed result of the key matrix vector.

[0295] In step 1520, the second control information is used to fine-tune the result produced by the denoising network of the image generation model after downsampling.

[0296] When this embodiment is implemented, the specific process of step 1520 is similar to the above step 1510. The difference is that the input information of the first control sub-network in step 1510 is the image description embedding vector, the first sample object feature and the contour feature; while the input information of the second control sub-network in step 1520 is the image description embedding vector and the second sample object feature. The input information of the two is different, and the generated control information constrains the network part in the denoising network differently. To save space, it will not be repeated.

[0297] In step 1530, the upsampling network control information is used to conditionally constrain the upsampling process of the denoising network of the image generation model to fine-tune and correct the upsampling process.

[0298] In the specific implementation of this embodiment, the third sample object feature and the fourth sample object feature are included in the same set, the object feature information in the set is regarded as a whole, and all the object feature information in the set is determined as upsampling network control information.

[0299] In step 1540, the downsampling network control information is used to conditionally constrain the downsampling process of the denoising network of the image generation model to fine-tune and correct the downsampling process.

[0300] In a specific implementation of this embodiment, the first control information, the second control information, the first sample object feature, and the second sample object feature are included in the same set, and all information in the set is determined as the down-sampling network control information.

[0301] In step 1550, the up-sampling network control information and the down-sampling network control information are included in the same set, the control information in the set is regarded as a whole, and all the information in the set is determined as the denoising network control information.

[0302] like Fig.16 As shown, the sample object image is subjected to feature extraction using a fine-tuning network with different model parameters, and the first sample object feature, the second sample object feature, the third sample object feature, and the fourth sample object feature are obtained respectively. Then, the third sample object feature and the fourth sample object feature are integrated into upsampling network control information for constraining the upsampling process. Further, the first sample object feature, the second sample object feature, the pre-acquired image description embedding vector, and the contour feature of the reference object are input into the control network together, and the control network outputs the first control information and the second control information, and the first control information, the second control information, the first sample object feature, and the second sample object feature are integrated into downsampling network control information for constraining the downsampling process. Based on this, the upsampling network control information and the downsampling network control information are used to realize the full process control of the denoising process of the denoising network, which can improve the accuracy of the denoising process.

[0303] The advantage of this embodiment is that denoising network control information is jointly generated based on image description information, sample object features in the sample object image, and contour features of the reference object in the background template image, so that the conditional constraints of the denoising network for the image generation model not only contain a description of the image to be generated, but also contain object fine-tuning information determined based on the contour characteristics of the reference object and the object characteristics of the sample object, which is beneficial to improving the comprehensiveness and accuracy of the generated denoising network control information.

[0304] Step 340 is described in detail below.

[0305] In step 340, based on the sample splicing image features and the denoising network control information, noise prediction is performed through the image generation model to obtain a noise prediction result of the noise reference image.

[0306] In the disclosed embodiment, the image generation model includes a diffusion network and a denoising network.

[0307] The diffusion network is used to implement the gradual noise addition processing on the sample splicing image features until the input sample splicing image features approach pure noise.

[0308] The denoising network is used to gradually denoise the latent space vector output by the diffusion network until the image features corresponding to the sample splicing image features are generated.

[0309] Please refer to Fig.17 In one embodiment, step 340 specifically includes but is not limited to the following steps 1710-1730:

[0310] Step 1710: compress the sample spliced ​​image features to obtain sample compressed image features;

[0311] Step 1720: Perform diffusion processing on the sample compressed image features based on the diffusion network to obtain the sample latent space feature vector;

[0312] Step 1730: Based on the denoising network control information, the sample latent space feature vector is denoised through the denoising network to obtain a noise prediction result.

[0313] Steps 1710-1730 are described in detail below.

[0314] In step 1710, since the sample spliced ​​image feature is composed of three image features, the feature dimension of the sample spliced ​​image feature will be higher than the feature dimension of the input feature that the diffusion network can accept. Based on this, first, the sample spliced ​​image feature is compressed to achieve dimensionality reduction of the sample spliced ​​image feature. While keeping the image feature information of the sample spliced ​​image feature unchanged, the feature dimension of the sample spliced ​​image feature is reduced to obtain the sample compressed image feature. Among them, the feature dimension of the sample compressed image feature is W*H*4, which meets the feature dimension of the input feature that the diffusion network can accept.

[0315] In step 1720, the sample latent space feature vector is used to indicate the result of adding noise to the sample spliced ​​image features at a fixed time step through the diffusion network.

[0316] In the specific implementation of this embodiment, when the sample compressed image features are diffused based on the diffusion network, noise is added to the sample compressed image features one by one through the diffusion network until the sample compressed image features approach pure noise. The diffusion process of the embodiment of the present disclosure can be a parameterized Markov chain as a whole.

[0317] For example, the fixed time step is set to T, and the sample compressed image features are denoised T times through the forward process of the diffusion network to generate a latent space representation corresponding to the noise reference image, and the generated latent space representation is determined as the sample latent space feature vector, where T is a positive integer.

[0318] Specifically, noise is added to the sample compressed image features through the diffusion processing of the diffusion network, and the sample compressed image features will lose their features one by one. After T times of noise addition, the sample compressed image features will become a latent space representation without any features, and the latent space representation is determined as the sample latent space feature vector.

[0319] It should be noted that the sample latent space feature vector refers to the representation of the pure noise image without image features corresponding to the noise reference image. The form of the sample latent space feature vector is the same as the form of the object representation, which can be a vector representation or a matrix representation without limitation.

[0320] In step 1730, when the sample latent space feature vector is denoised by the denoising network, the sample latent space feature vector is denoised one by one according to the denoising network control information as a constraint condition, until the sample latent space feature vector is restored to an image feature that satisfies the constraint requirements of the image description information. The backward process of the denoising network as a whole can also be a parameterized Markov chain.

[0321] To save space, the specific process of performing denoising on the sample latent space feature vector through the denoising network to obtain the noise prediction result in the embodiment of the present disclosure will be described in detail below. No further description will be given here.

[0322] like Fig.18 As shown in FIG. 1 , it is the noise prediction process of the image generation model. Specifically, the sample splicing image features are input into the image generation model. First, the sample splicing image features are compressed by the image generation model to form a sample compressed image feature with a smaller feature dimension than the sample splicing image features. Then, the sample compressed image features are subjected to T noise addition operations through the diffusion network to convert the sample compressed image features into image features close to pure noise, and the sample latent space feature vector is obtained, wherein the sample latent space feature vector can no longer reflect the image information possessed by the sample splicing image features. Further, through the denoising network, based on the given denoising network control information, the sample latent space feature vector is subjected to T denoising operations to eliminate the noise carried by the sample latent space feature vector, and the sample latent space feature vector is restored to the form of image features to obtain the noise prediction result. Among them, the noise prediction result can reflect the image information possessed by the sample splicing image features to a certain extent.

[0323] The benefit of this embodiment is that the sample splicing image features are first compressed into sample compressed image features, so that the input sample compressed image features meet the input requirements of the image generation model. Then, the sample compressed image features are denoised multiple times using a diffusion network to reduce the details and clarity of the sample compressed image features, and obtain a sample latent space feature vector. Furthermore, the denoising network control information is used as a constraint condition, and the sample latent space feature vector is denoised one by one through the denoising network until the sample latent space feature vector is restored to an image feature that meets the constraint requirements of the image description information, and a noise prediction result is obtained. This method introduces image description information, contour features of reference objects, and object features of sample objects to fine-tune the denoising process, which can effectively improve the denoising ability of the model and is conducive to improving the accuracy of the model in generating target images.

[0324] In the disclosed embodiment, the denoising network may be a U-type network structure (U-net network), and the denoising network includes an upsampling attention network and a downsampling attention network; the denoising network control information includes an upsampling network control information and a downsampling network control information.

[0325] The upsampling attention network is used to downsample the sample latent space feature vector to obtain more low-dimensional features.

[0326] The downsampling attention network is used to upsample the output results of the upsampling attention network and restore the output results to denoised image features with the same feature dimension as the sample latent space feature vector.

[0327] Please refer to Fig.19 In one embodiment, step 1730 specifically includes but is not limited to the following steps 1910-1920:

[0328] Step 1910: fuse the down-sampling network control information into the first attention matrix of the down-sampling attention network to update the first attention matrix, and fuse the up-sampling network control information into the second attention matrix of the up-sampling attention network to update the second attention matrix;

[0329] Step 1920, denoising the sample latent space feature vector by using the downsampling attention network after updating the first attention matrix and the upsampling attention network after updating the second attention matrix to obtain a noise prediction result.

[0330] Steps 1910-1920 are described in detail below.

[0331] In step 1910, the first attention matrix is ​​used to perform attention calculation in the downsampling process of the denoising network to capture the correlation between different input features (sample latent space feature vectors, image description embedding vectors); the second attention matrix is ​​used to perform attention calculation in the upsampling process of the denoising network to capture the correlation between different input features (output results of the downsampling attention network, image description embedding vectors).

[0332] In the specific implementation of this embodiment, the downsampling attention network includes an attention downsampling module, and the attention downsampling module includes a first attention matrix and a residual block structure. When the first attention matrix is ​​updated, the first sample object features and the second sample object features in the downsampling network control information are weighted to the output of the first attention matrix, and the first control information and the second control information in the downsampling network control information are weighted to the output of the attention downsampling module. Similarly, the upsampling attention network includes an attention upsampling module, and the attention upsampling module includes a second attention matrix and a residual block structure. When the second attention matrix is ​​updated, the third sample object features and the fourth sample object features in the upsampling network control information are weighted to the output of the second attention matrix.

[0333] like Fig. 20 As shown, the downsampling attention network includes two attention downsampling modules, each of which has a first attention matrix, and the first sample object feature is weighted to the output of the first first attention matrix; the second sample object feature is weighted to the output of the second first attention matrix. At the same time, the first control information is weighted to the output of the first attention downsampling module; the second control information is weighted to the output of the second attention downsampling module.

[0334] like Fig.21 As shown, the upsampling attention network includes two attention upsampling modules, each of which has a second attention matrix. The third sample object feature is weighted to the output of the first second attention matrix; the fourth sample object feature is weighted to the output of the second second attention matrix.

[0335] In step 1920, when the sample latent space feature vector is denoised by the down-sampling attention network after updating the first attention matrix and the up-sampling attention network after updating the second attention matrix, first, the sample latent space feature vector and the image description embedding vector are input into the denoising network of the image generation model, and the sample latent space feature vector is linearly projected to obtain the query feature Q corresponding to the sample latent space feature vector, and then the image description embedding vector is linearly projected to obtain the key feature K and value feature V corresponding to the image description embedding vector. Then, the query feature Q, the key feature K and the value feature V are cross-attention calculated using the first attention matrix of the first attention down-sampling module of the down-sampling attention network to obtain a first attention calculation result, and the first attention calculation result and the first sample object feature are weighted according to a preset weight ratio to obtain a first weighted result. Further, the first weighted result is residually processed by the residual block structure of the first attention down-sampling module to obtain a first residual processing result, and the first control information and the first residual processing result are weighted according to the preset weight to obtain a second weighted result. Next, the second weighted result is linearly projected to obtain a new query feature Q, and the first attention matrix of the second attention downsampling module of the downsampling attention network is used to perform cross-attention calculation on the key feature K, the value feature V, and the new query feature Q to obtain a second attention calculation result, and the second attention calculation result and the second sample object feature are weighted according to a preset weight ratio to obtain a third weighted result. Further, the third weighted result is residually processed by the residual block structure of the second attention downsampling module to obtain a second residual processing result, and the second control information and the second residual processing result are weighted according to the preset weight to obtain a fourth weighted result, wherein the fourth weighted result is the output result of the downsampling attention network.

[0336] Further, the fourth weighted result and the image description embedding vector are input into the upsampling attention network, and the fourth weighted result is first linearly projected to obtain the query feature, and then the image description embedding vector is linearly projected to obtain the key feature and value feature corresponding to the image description embedding vector. Then, the key feature, value feature, and query feature are cross-attention calculated using the second attention matrix of the first attention upsampling module of the upsampling attention network to obtain the third attention calculation result, and the third attention calculation result and the third sample object feature are weighted according to the preset weight ratio to obtain the fifth weighted result. Further, the fifth weighted result is residually processed by the residual block structure of the first attention upsampling module to obtain the third residual processing result. Finally, the third residual processing result is linearly projected to obtain a new query feature, and the key feature, value feature, and the new query feature are cross-attention calculated using the second attention matrix of the second attention upsampling module of the upsampling attention network to obtain the fourth attention calculation result, and the fourth attention calculation result and the fourth sample object feature are weighted according to the preset weight ratio to obtain the sixth weighted result. Furthermore, the sixth weighted result is subjected to residual processing through the residual block structure of the second attention upsampling module to obtain the denoising result of the sample latent space feature vector generated by the denoising network for the prediction time step T; the above process is repeated, and the denoising operation is continued for T-1 times on the denoising result of the sample latent space feature vector to obtain the noise prediction result.

[0337] The benefit of this embodiment is that the denoising network control information is introduced in different links of the denoising process to fine-tune the denoising process. Specifically, the first sample object feature and the second sample object feature in the downsampling network control information are fused to the first attention matrix of the downsampling attention network, and the third sample object feature and the fourth sample object feature in the upsampling network control information are fused to the second attention matrix of the upsampling attention network, so that the output results of multiple attention matrices in the denoising network can be corrected. In addition, the embodiment of the present disclosure also corrects the output results of the downsampling attention network through the first control information and the second control information, and performs multiple fine-tuning in each denoising process, which can improve the stability and accuracy of noise prediction, make the final noise prediction results more in line with real needs, and improve the model training effect.

[0338] Step 350 is described in detail below.

[0339] In step 350, an image generation model is trained based on the comparison of noise reference images and noise prediction results of multiple image-text sample pairs.

[0340] Please refer to Fig. 22In one embodiment, step 350 specifically includes but is not limited to the following steps 2210-2230:

[0341] Step 2210: for each image-text sample pair, obtain the reference noise in the noise reference image, and calculate the sub-loss function based on the comparison between the reference noise and the noise prediction result;

[0342] Step 2220: Determine a total loss function based on the sub-loss function of each image-text sample pair;

[0343] Step 2230: Based on the total loss function, train the image generation model.

[0344] Steps 2210-2230 are described in detail below.

[0345] In step 2210, the reference noise is used to indicate the degree of adding noise to the expected result, and the sub-loss function is used to indicate the degree of difference between the reference noise and the predicted noise of a single image-text sample pair.

[0346] In the specific implementation of this embodiment, first, for each image-text sample pair, the noise reference image is subjected to noise extraction to obtain the reference noise in the noise reference image. Then, the noise difference between the reference noise and the noise prediction result is calculated to obtain the noise difference result. Finally, the sub-loss function is calculated according to the noise difference result.

[0347] In step 2220, the total loss function is used to indicate the overall difference between the reference noise and the predicted noise of all image-text sample pairs. The smaller the total loss function, the smaller the overall difference between the reference noise and the predicted noise of all image-text sample pairs, and the higher the image generation accuracy of the image generation model.

[0348] When this embodiment is implemented, the sub-loss functions of each image-text sample pair are averaged to obtain the total loss function. Specifically, first, the total number of image-text sample pairs is determined. Then, the sub-loss functions of all image-text sample pairs are added to obtain the sum of the sub-loss functions. Finally, the sub-loss functions are divided by the total number of image-text sample pairs to obtain the total loss function.

[0349] In step 2230, the model parameters of the image generation model are adjusted with the training goal of minimizing the total loss function, and the above steps 310-350 are repeated to implement iterative training of the image generation model. The model parameters that minimize the total loss function are used as the final model parameters, and the image generation model with the final model parameters is used as the trained image generation model.

[0350] The advantage of this embodiment is that, based on a supervised learning approach, the sub-loss function of each image-text sample pair is determined according to the noise difference between the reference noise and the noise prediction result of each image-text sample pair, and the total loss function is constructed based on multiple sub-loss functions. This approach can train the image generation model by minimizing the difference between the reference noise and the noise prediction result, which is beneficial to improving the model training effect, and then improving the model's prediction accuracy for the generated image.

[0351] In the disclosed embodiment, the noise prediction result is obtained by prediction at multiple prediction time steps.

[0352] The prediction time step is used to indicate the frequency of adding noise and denoising the sample spliced ​​image features of the input image generation model.

[0353] Please refer to Fig.23 In one embodiment, step 2210 specifically includes but is not limited to the following steps 2310-2330:

[0354] Step 2310: Determine the prediction noise of the last prediction time step based on the noise prediction result;

[0355] Step 2320: performing regularization term calculation based on the reference noise and the predicted noise to obtain a regularization term calculation result;

[0356] Step 2330: Determine a sub-loss function based on the calculation result of the regularization term.

[0357] Steps 2310-2330 are described in detail below.

[0358] In step 2310, the prediction noise is used to indicate the noise contained in the denoising result (denoised image) generated by the image generation model at the last prediction time step.

[0359] In the specific implementation of this embodiment, since the image generation model denoises the denoising result (denoised image) generated in the previous prediction time step again at each prediction time step, and after denoising processing for multiple prediction time steps, a noise prediction result is predicted. Among them, the noise contained in the denoising results of different prediction time steps is different. Based on this, the noise prediction result contains the denoising result (denoised image) generated in the last prediction time step. The prediction noise up to the last prediction time step can be directly extracted from the noise prediction result.

[0360] In step 2320, the regularization term calculation result is used to indicate the degree of difference between the reference noise and the predicted noise.

[0361] In the specific implementation of this embodiment, firstly, for each image-text sample pair, the reference noise and the predicted noise are calculated to obtain the noise difference. Then, the noise difference is regularized to obtain the regularization term calculation result.

[0362] In step 2330, the regularization term calculation result is converted based on the denoising network control information, the regularization term calculation result is converted into the form of a conditional loss function, and the converted loss function is determined as a sub-loss function. The sub-loss function of the embodiment of the present disclosure can be expressed as shown in formula (2):

[0363] Formula (2);

[0364] in, is the sub-loss function; is the reference noise, Indicates that the reference noise follows a standard normal distribution (mean 0, variance 1). t represents the prediction time step, which is used to gradually update the sample latent space feature vector during the image generation process. represents the sample latent space feature vector at the prediction time step t, is the result of adding noise to the sample compressed image feature z at the prediction time step t. Both y and c refer to the denoising network control information, which is used to condition the image generation process. x is the noisy reference image used for training. To indicate the encoder The expectation for the input x. Refers to the conditional constraints , at the prediction time step t, the latent space feature vector of the sample Prediction noise after denoising. is the result of the regularization calculation.

[0365] The benefit of this embodiment is that by calculating the regularization term loss between the reference noise and the noise prediction result of the image-text sample pair, the regularization term calculation result of each image-text sample pair is obtained, and the regularization term calculation result (L2 loss) is used as a sub-loss function to train the image generation model. The denoising network control information can be used to better adjust the image generation process of the image generation model, making the generation process more controllable. At the same time, conditional information (denoising network control information) is added to the sub-loss function, which can make the generated noise prediction result closely related to the given conditions, thereby improving the consistency and accuracy of the generated image of the model, and thereby improving the image quality of the target image generated by the model.

[0366] like Fig.24 , which is an overall flow chart of the model training of the embodiment of the present disclosure. Specifically, the background template image, the expected effect image, and the image description information of the expected effect image are used as input.

[0367] First, a reference noise is generated using a random number i, and the reference noise is added to the expected effect image to obtain a noise reference image, and the specific process is similar to the above steps 510-530. Next, the background template image is masked to obtain an object replacement mask (template mask image), and the specific process is similar to the above steps 810-820.

[0368] Furthermore, the template mask image, the noise reference image, and the background template image are encoded by the encoder respectively, and the three encoding results are spliced ​​into the sample spliced ​​image feature. The sample spliced ​​image feature is compressed into the sample compressed image feature Z through the image generation model, and the sample compressed image feature Z is diffused through the diffusion network, and the sample compressed image feature Z is denoised T times to obtain the sample latent space feature vector Z T . Further, the image description information of the expected effect image is used as a conditional constraint and converted into a text form that meets the input requirements of the text encoder τ, and the image description information of the expected effect image is input into the text encoder, and the text encoder outputs the image description embedding vector, and the specific process is similar to the above steps 1310-1340. Further, the object frame corresponding to the background template image is extracted, and the contour line drawing (contour feature) of the reference object in the background template image is generated based on the extracted object frame, and the specific process is similar to the above steps 1110-1130. At the same time, based on the sample object graph of the sample object, sample object feature data is generated, wherein the sample object feature data includes a first object feature QKV1-A*, a second object feature QKV2-A*, a third object feature QKV3-A*, and a fourth object feature QKV4-A*. Furthermore, the first object feature QKV1-A*, the second object feature QKV2-A*, the contour feature and the image description embedding vector are input into the control network, the first control subnetwork of the control network outputs the first control information, and the second control subnetwork of the control network outputs the second control information.

[0369] Next, in the denoising network, the sample latent space feature vector Z T When denoising, firstly, based on the first control information, the first object feature QKV1-A*, and the second object feature QKV2-A*, the sample latent space feature vector Z is denoised by each attention matrix of the downsampling attention network of the denoising network. T Down-sampling is performed to obtain a down-sampling result, and the down-sampling result is corrected by using the second control information to obtain a corrected down-sampling result; then based on the third object feature QKV3-A* and the fourth object feature QKV4-A*, the corrected down-sampling result is up-sampled by each attention matrix of the up-sampling attention network of the denoising network to obtain a denoising result Z at a prediction time step of T T-1'. Further, the denoising network is used to denoise the result Z at the prediction time step T T-1' According to the above process, denoising is performed. After T-1 denoising times, the denoising result Z is obtained. ’ , and the specific process is similar to the above steps 1910-1920.

[0370] Finally, based on the denoising result Z ’ Noise prediction is performed to obtain a noise prediction result, a loss function LOSS is constructed based on the reference noise and the noise prediction result, and the image generation model is iteratively trained based on the loss function LOSS until the image generation model meets the training requirements. The specific process is similar to the above step 350. To save space, it will not be repeated.

[0371] The following is a detailed description of an image generation method according to an embodiment of the present disclosure.

[0372] According to an embodiment of the present disclosure, a method for generating an image is provided.

[0373] This image generation method is generally used in business scenarios where objects in a fixed background image need to be replaced with target persons, target objects, etc., for example Figure 2A-2C The video production scene, item display scene, etc. shown in the figure. The disclosed embodiment provides a solution for image generation through an image generation model based on image description information and object information (contour information of a reference object in a background image, object features of a target object to be replaced), which can improve the accuracy of target image generation.

[0374] like Fig.25 As shown, the image generation method according to an embodiment of the present disclosure may be executed by an electronic device, which may be Figure 1 The image processing server or the object terminal shown, the image generation method may include:

[0375] Step 2510, obtaining a target object image, a target background image, and target description information of a target object;

[0376] Step 2520: determining target stitching image features based on the target background image, the preset noise image, and the target mask image;

[0377] Step 2530, determining denoising control information of the image generation model based on the contour features of the reference object in the target background image, the target description information, and the target object image;

[0378] Step 2540: Based on the target spliced ​​image features and the denoising control information, an image generation model is used to generate an image to obtain a target image.

[0379] Steps 2510-2540 are described in detail below.

[0380] In step 2510, a target object image, a target background image, and target description information of the target object are obtained.

[0381] The target object image of the target object refers to a series of images that can reflect the object characteristics of the target object.

[0382] The target background image refers to a background image to which the target object is to be added, wherein the target background image contains a reference object to be replaced by the target object in the target object image.

[0383] The target description information is used to describe the replacement from the reference object to the target object.

[0384] In the specific implementation of this embodiment, the specific process of step 2510 is similar to the specific process of obtaining the sample object image, target background image, and target description information of the sample object in the above 310. To save space, it will not be repeated.

[0385] In step 2520, target stitching image features are determined based on the target background image, the preset noise image, and the target mask image.

[0386] The preset noise image is a noise image that obeys Gaussian distribution and is generated based on random numbers, and its specific generation method is similar to the above step 520. The difference is that the random number for generating the preset noise image in step 2520 is different from the random number in step 520, and it will not be repeated for the sake of space.

[0387] The target mask image is obtained by masking the reference object in the target background image, and the specific process is similar to the above steps 810-820. To save space, it will not be described again.

[0388] The target stitching image feature is used to indicate the feature stitching result of the target background image, the preset noise image, and the target mask image.

[0389] To save space, the specific process of determining the target stitching image features based on the target background image, the preset noise image and the target mask image in the embodiment of the present disclosure will be described in detail below. No further details will be given here.

[0390] In step 2530, denoising control information of the image generation model is determined based on the contour features of the reference object in the target background image, the target description information, and the target object image.

[0391] The image generation model is generated according to the image generation model training method of the above embodiment.

[0392] The denoising control information is used as a conditional constraint to assist the image generation model in performing image denoising during image generation, so as to improve the accuracy of image denoising and make the image denoising effect meet the actual requirements.

[0393] When this embodiment is implemented, the specific process of step 2530 is similar to the specific process of the above step 330. To save space, it will not be repeated.

[0394] In step 2540, based on the target stitching image features and the denoising control information, an image generation model is used to generate an image to obtain a target image.

[0395] The target image is used to indicate a result of replacing a reference object in a target background image with a target object of the target object image.

[0396] To save space, the specific process of obtaining the target image by performing image generation through the image generation model based on the target spliced ​​image features and denoising control information in the embodiment of the present disclosure will be described in detail below.

[0397] Through steps 2510-2540, in the embodiment of the present disclosure, when the image generation model is used to generate an image, the image features of the target background image, the preset noise image, and the target mask image are integrated into the target spliced ​​image features, so that the target spliced ​​image features have the background image information and the reference object information of the target background image, and the noise information is also integrated into the target spliced ​​image features, so that the target spliced ​​image features can fit the real situation. Further, the contour features of the reference object in the target background image, the target description information, and the target object image are introduced to jointly generate the denoising control information for the denoising network of the image generation model, so that the image generation model can perform object fine-tuning in the denoising link, so that the object in the generated target image meets the conditional constraints of the target description information, the object characteristics of the target object, and the contour characteristics of the reference object, so that the target object and the background of the target image have good consistency and coordination, thereby improving the accuracy of the model generating the target image.

[0398] Please refer to Fig.26 In one embodiment, step 2520 specifically includes but is not limited to the following steps 2610-2640:

[0399] Step 2610: Perform a first encoding process on a preset noise image to obtain noise image features;

[0400] Step 2620, performing a second encoding process on the target background image to obtain target background image features;

[0401] Step 2630: Perform a third encoding process on the target mask image to obtain target mask image features;

[0402] Step 2640: splice the noise image features, the target background image features, and the target mask image features to obtain the target spliced ​​image features.

[0403] Steps 2610-2640 are described in detail below.

[0404] The reference image coding feature is used to indicate the result of converting the preset noise image from the data space to the pixel space.

[0405] The background image encoding feature is used to indicate the result of converting the target background image from the data space to the pixel space.

[0406] The mask image encoding feature is used to indicate the result of converting the target mask image from the data space to the pixel space.

[0407] In the specific implementation of this embodiment, the specific process of steps 2610-2640 is similar to the above steps 710-740, and will not be described in detail to save space.

[0408] The advantage of this embodiment is that the image information of the preset noise image, the target background image, and the target mask image are all converted from the pixel space to the latent vector space, and the image information (noise image features, target background image features, and target mask image features) of the preset noise image, the target background image, and the target mask image in the latent vector space are spliced ​​to form a target spliced ​​image feature with multiple image information. Further, the target spliced ​​image feature is used as the input of the image generation model during image generation, so that the input data of the model incorporates the noise information, the target background information, and the reference object information in the target background, which can better improve the richness and comprehensiveness of the feature information of the template spliced ​​image feature, which is conducive to improving the image generation accuracy of the model, and making the target image finally generated more realistic and more accurate.

[0409] In an embodiment of the present disclosure, the image generation model includes a diffusion network, a denoising network, and a decoding network.

[0410] The decoding network is used to transform the image features in the target denoising result from the latent vector space to the pixel space.

[0411] Please refer to Fig. 27 In one embodiment, step 2540 specifically includes but is not limited to the following steps 27710-2740:

[0412] Step 2710: compress the target spliced ​​image features to obtain target compressed image features;

[0413] Step 2720: Perform diffusion processing on the target compressed image features based on the diffusion network to obtain the target latent space feature vector;

[0414] Step 2730: Based on the denoising control information, denoising is performed on the target latent space feature vector through a denoising network to obtain a target denoising result;

[0415] Step 2740: Perform feature decoding on the target denoising result based on the decoding network to obtain a target image.

[0416] Steps 2710-2740 are described in detail below.

[0417] The target compressed image feature is used to indicate the feature dimension reduction result of the target spliced ​​image feature, wherein the target compressed image feature has the same image feature information as the target spliced ​​image feature, but the feature dimension of the target compressed image feature is lower than the feature dimension of the target spliced ​​image feature.

[0418] The target latent space feature vector is used to indicate the result of adding noise to the target compressed image features at a fixed time step through the diffusion network.

[0419] The target denoising result is used to indicate the image features that meet the constraint requirements of the image description information after the target latent space feature vector is denoised by the denoising network at a fixed time step.

[0420] In the specific implementation of this embodiment, the specific process of steps 2710-2730 is similar to the above steps 1710-1730, and will not be described in detail to save space.

[0421] In step 2740, the target denoising result is input into the decoding network, and the image features in the target denoising result are mapped from the latent vector space back to the original pixel space through the decoding network to generate a noise-free target image that is consistent with the target description information.

[0422] The benefit of this embodiment is that the target spliced ​​image features are first compressed into target compressed image features, so that the input target compressed image features meet the input requirements of the image generation model. Then, the target compressed image features are denoised multiple times using a diffusion network to reduce the details and clarity of the target compressed image features and obtain a target latent space feature vector. Furthermore, the target latent space feature vector is denoised multiple times using a denoising network to achieve prediction of the source image. In this process, the predicted image features are fine-tuned using denoising control information so that the object features in the final predicted target denoising result are more in line with the actual requirements. Finally, the target denoising result is decoded using a decoding network to obtain a predicted target image, which can improve the image quality of the target image and make the object and background in the target image better coordinated.

[0423] like Fig.28As shown, it is a schematic diagram of a specific application module of the image generation method of the embodiment of the present disclosure. Specifically, first, for a background image containing a reference object, the background image is subjected to an object face masking process to obtain a masked background image, and the specific process is similar to the above steps 810-820; the background image is subjected to an object masking part key point to obtain the contour feature of the reference object of the background image, and the specific process is similar to the above steps 1110-1130. In addition, for the target object to replace the reference object, the target object image of the target object is subjected to feature extraction to obtain the object fine-tuning feature data of the target object. Further, a latent space input is constructed based on a random noise image, a background image and a masked background image to obtain the target spliced ​​image feature, and the specific process is similar to the above steps 2610-2640. Then, the control network is driven by using the contour feature, the target description information of the target image to be generated, etc., and the denoising control information is output through the control network as an auxiliary (conditional constraint), and the target spliced ​​image feature is subjected to diffusion processing and denoising processing through the image generation model to obtain the target denoising result. Finally, the target denoising result is converted into a target image by using a decoding network for output, thereby generating a target image with the background image as the background and the target object as the foreground. The specific process is similar to the above steps 2710-2740. To save space, it will not be repeated.

[0424] like Fig.29 FIG. 1 is an overall flow chart of image generation based on an image generation model according to an embodiment of the present disclosure. Specifically, a target background image and target description information corresponding to the image to be generated are taken as input.

[0425] First, a random noise image is generated using a random number i. Next, the target background image is masked to obtain an object replacement mask (target mask image), and the specific process is similar to the above steps 810-820. Further, the random noise image, the target mask image, and the target background image are encoded using an encoder respectively, and the three encoding results are spliced ​​into a target spliced ​​image feature.

[0426] Furthermore, the target spliced ​​image features are compressed into target compressed image features Z through the image generation model, and the target compressed image features Z are diffused through the diffusion network, and the target compressed image features Z are denoised T times to obtain the target latent space feature vector Z T. Further, the target description information corresponding to the image to be generated is used as a conditional constraint, converted into a text form that meets the input requirements of the text encoder τ, and the target description information is input into the text encoder, and the text encoder outputs the image description embedding vector, and the specific process is similar to the above steps 1310-1340. Further, the object frame corresponding to the target background image is extracted, and the contour line drawing (contour feature) of the reference object in the target background image is generated based on the extracted object frame, and the specific process is similar to the above steps 1110-1130. At the same time, based on the target object image of the target object, the target object feature data is generated, wherein the target object feature data includes a first object feature QKV1-A*, a second object feature QKV2-A*, a third object feature QKV3-A*, and a fourth object feature QKV4-A*. Further, the first object feature QKV1-A*, the second object feature QKV2-A*, the contour feature and the image description embedding vector are input into the control network, and the first control subnetwork of the control network outputs the first control information, and the second control subnetwork of the control network outputs the second control information.

[0427] Next, in the denoising network, the target latent space feature vector Z T When denoising, firstly, based on the first control information, the first object feature QKV1-A*, and the second object feature QKV2-A*, the target latent space feature vector Z is denoised by each attention matrix of the down-sampling attention network of the denoising network. T Down-sampling is performed to obtain a down-sampling result, and the down-sampling result is corrected by using the second control information to obtain a corrected down-sampling result; then based on the third object feature QKV3-A* and the fourth object feature QKV4-A*, the corrected down-sampling result is up-sampled by each attention matrix of the up-sampling attention network of the denoising network to obtain a denoising result Z at a prediction time step of T T-1' . Further, the denoising network is used to denoise the result Z at the prediction time step T T-1' According to the above process, denoising is performed. After T-1 denoising times, the denoising result Z is obtained. ’ The specific process is similar to the above steps 1910-1920. Finally, the denoising result Z is calculated based on the decoding network. ’ Feature decoding is performed to obtain the target image I, and the specific process is similar to the above step 2740. To save space, it will not be repeated.

[0428] The following describes the apparatus and devices of the embodiments of the present disclosure.

[0429] It is to be understood that, although the steps in the above-mentioned flowcharts are sequentially displayed according to the characterization of arrows, these steps are not necessarily executed in sequence according to the order of arrow characterization. Unless there is a clear description in the present embodiment, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the above-mentioned flowcharts can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the steps or stages in other steps.

[0430] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on data related to the characteristics of the target object such as the target object attribute information or attribute information set, the permission or consent of the target object will be obtained first, and the collection, use and processing of these data will comply with relevant laws, regulations and standards. In addition, when the embodiment of the present application needs to obtain the attribute information of the target object, the separate permission or separate consent of the target object will be obtained through a pop-up window or jump to a confirmation page. After clearly obtaining the separate permission or separate consent of the target object, the necessary target object-related data used to enable the normal operation of the embodiment of the present application is obtained.

[0431] Fig.30 A schematic diagram of the structure of a training device 3000 for an image generation model provided in an embodiment of the present disclosure. The training device 3000 for an image generation model includes:

[0432] A first acquisition unit 3010 is used to acquire a plurality of image-text sample pairs, wherein each image-text sample pair includes a background template image, a noise reference image, image description information corresponding to the noise reference image, and a sample object image of a sample object, wherein the noise reference image is obtained by adding noise to an expected result of replacing a reference object in the background template image with the sample object;

[0433] A first determining unit 3020 is used to determine the sample stitching image features based on the noise reference image, the background template image, and the template mask image, wherein the template mask image is obtained by masking the reference object in the background template image;

[0434] A second determining unit 3030 is used to determine denoising network control information of the image generation model based on the contour features of the reference object in the background template image, the image description information, and the sample object image;

[0435] A prediction unit 3040 is used to perform noise prediction through an image generation model based on sample splicing image features and denoising network control information to obtain a noise prediction result of a noise reference image;

[0436] The training unit 3050 is used to train the image generation model based on the comparison between the noise reference image and the noise prediction results of multiple image-text sample pairs.

[0437] Optionally, the training unit 3050 includes:

[0438] A calculation module (not shown), configured to obtain, for each image-text sample pair, a reference noise in a noise reference image, and calculate a sub-loss function based on a comparison between the reference noise and a noise prediction result;

[0439] A determination module (not shown) is used to determine a total loss function based on the sub-loss function of each image-text sample pair;

[0440] A training module (not shown) is used to train the image generation model based on the total loss function.

[0441] Optionally, the noise prediction result is obtained by prediction at multiple prediction time steps;

[0442] The computing module (not shown) is used to:

[0443] Based on the noise prediction results, determine the prediction noise of the last prediction time step;

[0444] A regularization term is calculated based on the reference noise and the predicted noise to obtain a regularization term calculation result;

[0445] Based on the calculation results of the regularization term, the sub-loss function is determined.

[0446] Optionally, the first determining unit 3020 is configured to:

[0447] Performing a first encoding process on the noise reference image to obtain a reference image encoding feature;

[0448] Performing a second encoding process on the background template image to obtain a background image encoding feature;

[0449] Performing a third encoding process on the template mask image to obtain a mask image encoding feature;

[0450] The reference image coding features, the background image coding features, and the mask image coding features are spliced ​​to obtain sample spliced ​​image features.

[0451] Optionally, the second determining unit 3030 includes:

[0452] An encoding module (not shown), configured to encode the image description information to obtain an image description embedding vector;

[0453] An extraction module (not shown), used to extract features from the sample object image to obtain sample object feature data;

[0454] A generation module (not shown) is used to generate control information through a preset control network based on the image description embedding vector, sample object feature data, and contour features of the reference object to obtain denoising network control information.

[0455] Optionally, the encoding module (not shown) is used to:

[0456] Segment the image description information to obtain multiple description words;

[0457] Determine a target word from multiple description words, and find the target word embedding feature corresponding to the target word based on a preset dictionary;

[0458] For other description words except the target word among the multiple description words, each other description word is subjected to word embedding processing to obtain description word embedding features of the other description words;

[0459] The target word embedding features and the description word embedding features are integrated into the image description embedding vector.

[0460] Optionally, the control network includes a first control subnetwork and a second control subnetwork; the sample object feature data includes a first sample object feature, a second sample object feature, a third sample object feature, and a fourth sample object feature, wherein the first sample object feature, the second sample object feature, the third sample object feature, and the fourth sample object feature are obtained by respectively extracting features from the sample object image;

[0461] A generation module (not shown) is used to:

[0462] Inputting the image description embedding vector, the first sample object feature, and the contour feature into the first control subnetwork to generate control information to obtain first control information;

[0463] Inputting the image description embedding vector and the second sample object feature into the second control subnetwork to generate control information, thereby obtaining second control information;

[0464] Determining upsampling network control information based on the third sample object feature and the fourth sample object feature;

[0465] Determine downsampling network control information based on the first control information, the second control information, the first sample object feature, and the second sample object feature;

[0466] The up-sampling network control information and the down-sampling network control information are integrated into the denoising network control information.

[0467] Optionally, a noise floor image is generated by:

[0468] determining an expected result of replacing a reference object in a background template image with a sample object, wherein the expected result is image data;

[0469] Generate a random number that obeys a Gaussian distribution based on a predetermined random number generation model;

[0470] For each pixel in the expected result, a random number is added to the pixel value of the pixel to obtain a noise reference image.

[0471] Optionally, the image generation model includes a diffusion network and a denoising network;

[0472] The prediction unit 3040 includes:

[0473] A compression module (not shown) is used to compress the sample spliced ​​image features to obtain sample compressed image features;

[0474] A diffusion module (not shown), used to perform diffusion processing on the sample compressed image features based on a diffusion network to obtain a sample latent space feature vector;

[0475] The denoising module (not shown) is used to denoise the sample latent space feature vector through the denoising network based on the denoising network control information to obtain the noise prediction result.

[0476] Optionally, the denoising network includes an upsampling attention network and a downsampling attention network; the denoising network control information includes upsampling network control information and downsampling network control information;

[0477] The denoising module (not shown) is used to:

[0478] The down-sampling network control information is fused into the first attention matrix of the down-sampling attention network to update the first attention matrix, and the up-sampling network control information is fused into the second attention matrix of the up-sampling attention network to update the second attention matrix;

[0479] The sample latent space feature vector is denoised by the downsampling attention network after updating the first attention matrix and the upsampling attention network after updating the second attention matrix to obtain the noise prediction result.

[0480] Optionally, a sample object image is generated by:

[0481] Get a sample image of a sample object;

[0482] Performing image segmentation on the sample image based on a preset object segmentation model to obtain a sample segmentation image having the sample object;

[0483] Perform image enhancement on the sample segmentation image to obtain a sample object image.

[0484] Optionally, a template mask image is generated by:

[0485] determining an object contour region of a reference object in a background template image;

[0486] In the background template image, the pixel value of each pixel point in the object contour area is replaced with a first value, and the pixel value of each pixel point outside the object contour area is replaced with a second value to obtain a template mask image.

[0487] Optionally, the contour features of the reference object in the background template image are determined by:

[0488] Perform object detection on the background template image to obtain an object skeleton map of the reference object;

[0489] Extract posture features from the object skeleton graph to obtain multiple object posture key points;

[0490] Determine contour features based on multiple object pose key points.

[0491] Fig.31 The following is a schematic diagram of the structure of an image generating device 3100 provided in an embodiment of the present disclosure. The image generating device 3100 includes:

[0492] A second acquisition unit 3110 is configured to acquire a target object image, a target background image, and target description information of a target object, wherein the target background image includes a reference object to be replaced by the target object in the target object image, and the target description information is used to describe the replacement from the reference object to the target object;

[0493] A third determining unit 3120 is used to determine the target stitching image features based on the target background image, the preset noise image, and the target mask image, wherein the target mask image is obtained by masking the reference object in the target background image;

[0494] A fourth determining unit 3130 is used to determine denoising control information of an image generation model based on contour features of a reference object in a target background image, target description information, and a target object image, wherein the image generation model is generated by the training method of the image generation model described above;

[0495] The image generation unit 3140 is used to generate an image through an image generation model based on the target spliced ​​image features and denoising control information to obtain a target image, wherein the target image is used to indicate the result of replacing a reference object in a target background image with a target object in the target object image.

[0496] Optionally, the third determining unit 3120 is configured to:

[0497] Performing a first encoding process on a preset noise image to obtain noise image features;

[0498] Performing a second encoding process on the target background image to obtain target background image features;

[0499] Performing a third encoding process on the target mask image to obtain target mask image features;

[0500] The noise image features, the target background image features, and the target mask image features are spliced ​​to obtain the target spliced ​​image features.

[0501] Optionally, the image generation model includes a diffusion network, a denoising network, and a decoding network;

[0502] The image generation unit 3140 is used for:

[0503] Compressing the target spliced ​​image features to obtain target compressed image features;

[0504] Based on the diffusion network, the target compressed image features are diffused to obtain the target latent space feature vector;

[0505] Based on the denoising control information, the target latent space feature vector is denoised through the denoising network to obtain the target denoising result;

[0506] The target denoising result is feature decoded based on the decoding network to obtain the target image.

[0507] Reference Fig.32 , Fig.32 A structural block diagram of a terminal for implementing the training method of the image generation model or the image generation method of the embodiment of the present disclosure, which terminal may be Figure 1 The terminal includes: a radio frequency (RF) circuit 3210, a memory 3215, an input unit 3230, a display unit 3240, a sensor 3250, an audio circuit 3260, a wireless fidelity (WiFi) module 3270, a processor 3280, and a power supply 3290. Those skilled in the art will understand that Fig.32The terminal structure shown does not constitute a limitation on the mobile phone or computer, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0508] The RF circuit 3210 may be used for receiving and sending signals during information transmission or calls. In particular, after receiving the downlink information from the base station, it is sent to the processor 3280 for processing; in addition, the designed uplink data is sent to the base station.

[0509] The memory 3215 may be used to store software programs and modules. The processor 3280 executes various functional applications and data processing of the target terminal by running the software programs and modules stored in the memory 3215 .

[0510] The input unit 3230 may be used to receive input digital or character information and generate key signal input related to the setting and function control of the target terminal. Specifically, the input unit 3230 may include a touch panel 3231 and other input devices 3232.

[0511] The display unit 3240 may be used to display input information or provided information and various menus of the target terminal. The display unit 3240 may include a display panel 3241.

[0512] The audio circuit 3260 , the speaker 3261 , and the microphone 3262 may provide an audio interface.

[0513] In this embodiment, the processor 3280 included in the terminal can execute the image generation model training method or image generation method of the previous embodiment.

[0514] Fig.33 A structural block diagram of a server for implementing the training method of the image generation model or the image generation method of the embodiment of the present disclosure. The server may be Figure 1 The image processing server shown. The server may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 3322 (for example, one or more processors) and memory 3332, one or more storage media 3330 (for example, one or more mass storage devices) storing application programs 3342 or data 3344. Among them, the memory 3332 and the storage medium 3330 can be short-term storage or permanent storage. The program stored in the storage medium 3330 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Furthermore, the central processing unit 3322 can be configured to communicate with the storage medium 3330 to execute a series of instruction operations in the storage medium 3330 on the server.

[0515] The server may also include one or more power supplies 3326, one or more wired or wireless network interfaces 3350, one or more input and output interfaces 3358, and / or one or more operating systems 3341, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.

[0516] The central processor 3322 in the server can be used to execute the training method or image generation method of the image generation model of the embodiment of the present disclosure.

[0517] The embodiments of the present disclosure also provide a computer-readable storage medium, which is used to store a computer program, and the computer program is used to execute the image generation model training method or image generation method of the aforementioned embodiments.

[0518] The present disclosure also provides a computer program product, which includes a computer program. A processor of an electronic device reads and executes the computer program, so that the electronic device executes the training method or image generation method for implementing the above-mentioned image generation model.

[0519] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present disclosure described herein can, for example, be implemented in an order other than those illustrated or described herein. In addition, the terms "comprises" and "comprising" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0520] It should be understood that in the present disclosure, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0521] It should be understood that in the description of the embodiments of the present disclosure, the meaning of multiple (or multiple items) is more than two, greater than, less than, exceed, etc. are understood as not including the number, and above, below, within, etc. are understood as including the number.

[0522] In the several embodiments provided in the present disclosure, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0523] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0524] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0525] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present disclosure is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the various embodiments of the present disclosure. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store program codes.

[0526] It should also be understood that the various implementations provided in the embodiments of the present disclosure can be combined arbitrarily to achieve different technical effects.

[0527] The above is a specific description of the implementation methods of the present disclosure, but the present disclosure is not limited to the above implementation methods. Technical personnel familiar with the art can also make various equivalent modifications or substitutions without violating the spirit of the present disclosure. These equivalent modifications or substitutions are all included in the scope defined by the claims of the present disclosure.

Claims

1. A training method for an image generation model, characterized in that: The training method comprises: Acquire a plurality of image-text sample pairs, wherein each of the image-text sample pairs comprises a background template image, a noise reference image, image description information corresponding to the noise reference image, and a sample object image of a sample object, wherein the noise reference image is obtained by adding noise to an expected result of replacing a reference object in the background template image with a sample object; Determining sample stitching image features based on the noise reference image, the background template image, and the template mask image, wherein the template mask image is obtained by masking the reference object in the background template image; Determining denoising network control information of the image generation model based on the contour features of the reference object in the background template image, the image description information, and the sample object image; Based on the sample splicing image features and the denoising network control information, noise prediction is performed through the image generation model to obtain a noise prediction result of the noise reference image; The image generation model is trained based on the comparison between the noise reference image and the noise prediction results of the plurality of image-text sample pairs.

2. The training method of the image generation model according to claim 1, characterized in that: The comparison between the noise reference image and the noise prediction result based on the plurality of image-text sample pairs to train the image generation model includes: For each of the image-text sample pairs, obtain a reference noise in the noise reference image, and calculate a sub-loss function based on a comparison between the reference noise and the noise prediction result; Determine a total loss function based on the sub-loss function of each of the image-text sample pairs; Based on the total loss function, the image generation model is trained.

3. The training method of the image generation model according to claim 2, characterized in that: The noise prediction result is obtained by prediction of multiple prediction time steps; The calculating of the sub-loss function based on the comparison between the reference noise and the noise prediction result includes: Based on the noise prediction result, determining the prediction noise of the last prediction time step; Performing regularization term calculation based on the reference noise and the predicted noise to obtain a regularization term calculation result; Based on the calculation result of the regularization term, the sub-loss function is determined.

4. The training method of the image generation model according to claim 1, characterized in that: The step of determining the sample stitching image features based on the noise reference image, the background template image, and the template mask image includes: Performing a first encoding process on the noise reference image to obtain a reference image encoding feature; Performing a second encoding process on the background template image to obtain a background image encoding feature; Performing a third encoding process on the template mask image to obtain a mask image encoding feature; The reference image coding feature, the background image coding feature, and the mask image coding feature are spliced ​​to obtain the sample spliced ​​image feature.

5. The training method of the image generation model according to claim 1, characterized in that: The step of determining the denoising network control information of the image generation model based on the contour features of the reference object in the background template image, the image description information, and the sample object image comprises: Encoding the image description information to obtain an image description embedding vector; Extracting features from the sample object image to obtain sample object feature data; Based on the image description embedding vector, the sample object feature data, and the contour feature of the reference object, control information is generated through a preset control network to obtain the denoising network control information.

6. The method for training an image generation model according to claim 5, characterized in that: The encoding process of the image description information to obtain an image description embedding vector includes: Segmenting the image description information to obtain a plurality of description words; Determine a target word from the plurality of description words, and search for a target word embedding feature corresponding to the target word based on a preset dictionary; For other description words except the target word among the plurality of description words, perform word embedding processing on each of the other description words to obtain description word embedding features of the other description words; The target word embedding feature and the description word embedding feature are integrated into the image description embedding vector.

7. The method for training an image generation model according to claim 5, characterized in that: The control network includes a first control subnetwork and a second control subnetwork; the sample object feature data includes a first sample object feature, a second sample object feature, a third sample object feature, and a fourth sample object feature, wherein the first sample object feature, the second sample object feature, the third sample object feature, and the fourth sample object feature are obtained by performing feature extraction on the sample object image respectively; The generating of control information based on the image description embedding vector, the sample object feature data, and the contour feature of the reference object through a preset control network to obtain the denoising network control information includes: Inputting the image description embedding vector, the first sample object feature, and the contour feature into the first control subnetwork to generate control information to obtain first control information; Inputting the image description embedding vector and the second sample object feature into the second control subnetwork to generate control information, thereby obtaining second control information; Determining upsampling network control information based on the third sample object feature and the fourth sample object feature; Determine downsampling network control information based on the first control information, the second control information, the first sample object feature, and the second sample object feature; The up-sampling network control information and the down-sampling network control information are integrated into the denoising network control information.

8. The method for training an image generation model according to claim 1, characterized in that: The noise reference image is generated by: Determining an expected result of replacing a reference object in the background template image with a sample object, wherein the expected result is image data; Generate a random number that obeys a Gaussian distribution based on a predetermined random number generation model; For each pixel point in the expected result, the random number is added to the pixel value of the pixel point to obtain the noise reference image.

9. The method for training an image generation model according to claim 1, characterized in that: The image generation model includes a diffusion network and a denoising network; The step of performing noise prediction based on the sample spliced ​​image features and the denoising network control information through the image generation model to obtain a noise prediction result of the noise reference image includes: Compressing the sample spliced ​​image features to obtain sample compressed image features; Performing diffusion processing on the sample compressed image features based on the diffusion network to obtain a sample latent space feature vector; Based on the denoising network control information, the sample latent space feature vector is denoised by the denoising network to obtain the noise prediction result.

10. The method for training an image generation model according to claim 9, characterized in that: The denoising network includes an upsampling attention network and a downsampling attention network; the denoising network control information includes upsampling network control information and downsampling network control information; The step of performing denoising processing on the sample latent space feature vector through the denoising network based on the denoising network control information to obtain the noise prediction result includes: Fusion the downsampling network control information into a first attention matrix of the downsampling attention network to update the first attention matrix, and fusion the upsampling network control information into a second attention matrix of the upsampling attention network to update the second attention matrix; The noise prediction result is obtained by denoising the sample latent space feature vector through the downsampling attention network after updating the first attention matrix and the upsampling attention network after updating the second attention matrix.

11. The method for training an image generation model according to claim 1, characterized in that: The sample object image is generated in the following manner: Acquire a sample image of the sample object; Performing image segmentation on the sample image based on a preset object segmentation model to obtain a sample segmented image having the sample object; Perform image enhancement on the sample segmented image to obtain the sample object image.

12. The method for training an image generation model according to claim 1, characterized in that: The template mask image is generated in the following way: determining an object contour region of the reference object in the background template image; In the background template image, the pixel value of each pixel point within the object contour area is replaced with a first value, and the pixel value of each pixel point outside the object contour area is replaced with a second value to obtain the template mask image.

13. The method for training an image generation model according to claim 1, characterized in that: The contour features of the reference object in the background template image are determined by: Performing object detection on the background template image to obtain an object skeleton graph of the reference object; Extracting posture features from the object skeleton graph to obtain a plurality of object posture key points; The contour feature is determined based on the plurality of object posture key points.

14. An image generation method, characterized in that: The image generation method comprises: Acquire a target object image, a target background image, and target description information of a target object, wherein the target background image includes a reference object to be replaced by the target object in the target object image, and the target description information is used to describe the replacement from the reference object to the target object; Determining target stitching image features based on the target background image, a preset noise image, and a target mask image, wherein the target mask image is obtained by masking a reference object in the target background image; Determining denoising control information of an image generation model based on contour features of the reference object in the target background image, the target description information, and the target object image, wherein the image generation model is generated according to the training method for an image generation model according to any one of claims 1 to 13; Based on the target stitching image features and the denoising control information, image generation is performed through the image generation model to obtain a target image, wherein the target image is used to indicate a result of replacing the reference object in the target background image with the target object of the target object image.

15. The image generation method according to claim 14, characterized in that: The image generation model includes a diffusion network, a denoising network, and a decoding network; The step of generating an image based on the target spliced ​​image features and the denoising control information by using the image generation model to obtain a target image includes: Performing compression processing on the target spliced ​​image features to obtain target compressed image features; Performing diffusion processing on the target compressed image features based on the diffusion network to obtain a target latent space feature vector; Based on the denoising control information, denoising the target latent space feature vector is performed through the denoising network to obtain a target denoising result; The target denoising result is feature decoded based on the decoding network to obtain the target image.

16. A training device for an image generation model, characterized in that: The training device of the image generation model comprises: A first acquisition unit is used to acquire a plurality of image-text sample pairs, wherein each of the image-text sample pairs includes a background template image, a noise reference image, image description information corresponding to the noise reference image, and a sample object image of a sample object, wherein the noise reference image is obtained by adding noise to an expected result of replacing a reference object in the background template image with a sample object; A first determining unit, configured to determine a sample stitching image feature based on the noise reference image, the background template image, and a template mask image, wherein the template mask image is obtained by masking the reference object in the background template image; A second determining unit, configured to determine denoising network control information of the image generation model based on the contour features of the reference object in the background template image, the image description information, and the sample object image; A prediction unit, configured to perform noise prediction through the image generation model based on the sample splicing image features and the denoising network control information, to obtain a noise prediction result of the noise reference image; A training unit is used to train the image generation model based on the comparison between the noise reference image and the noise prediction result of the plurality of image-text sample pairs.

17. An image generating device, characterized in that: The image generating device comprises: a second acquisition unit, configured to acquire a target object image, a target background image, and target description information of a target object, wherein the target background image includes a reference object to be replaced by the target object in the target object image, and the target description information is used to describe the replacement from the reference object to the target object; a third determining unit, configured to determine a target stitching image feature based on the target background image, a preset noise image, and a target mask image, wherein the target mask image is obtained by masking a reference object in the target background image; a fourth determining unit, configured to determine denoising control information of an image generation model based on a contour feature of the reference object in the target background image, the target description information, and the target object image, wherein the image generation model is generated according to the training method for an image generation model according to any one of claims 1 to 13; An image generation unit is used to generate an image through the image generation model based on the target spliced ​​image features and the denoising control information to obtain a target image, wherein the target image is used to indicate the result of replacing the reference object in the target background image with the target object of the target object image.

18. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, it implements the training method of the image generation model according to any one of claims 1 to 13 or the image generation method according to any one of claims 14 to 15.

19. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, it implements the training method of the image generation model according to any one of claims 1 to 13 or the image generation method according to any one of claims 14 to 15.

20. A computer program product, comprising a computer program, wherein the computer program is read and executed by a processor of an electronic device, so that the electronic device executes the training method of the image generation model according to any one of claims 1 to 13 or the image generation method according to any one of claims 14 to 15.