Image generation method, image denoising model training method and device

By combining noise images and guidance information in the diffusion model for denoising, a target noise-free image that matches the guidance information is generated, which solves the problem of low matching of noise-free images in the existing technology and improves the accuracy of image generation. and richness of detail.

CN115222630BActive Publication Date: 2024-09-20INST OF AUTOMATION CHINESE ACAD OF SCI
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210948018.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-09
Publication Date
2024-09-20
Estimated Expiration
2042-08-09

AI Technical Summary

Technical Problem

In the diffusion model scenario, the generated target noise-free image has a poor match with the semantic contour image, resulting in inaccurate generated noise-free images.

Method used

By obtaining the noise image to be processed, the guidance information corresponding to the noise image, the target noise adding stage and the empty guidance information, combined with the image denoising model in the diffusion model, the noise image is denoised to generate information that matches the guidance information content. The target noise-free image includes inputting the noise image and guidance information into the image denoising model, generating the first and second parameters, updating the noise adding stage until the threshold is reached, and fusing the mean and variance to generate a noise-free image.

Benefits of technology

The accuracy of the generated target noise-free image is improved, so that the matching degree with the information content of the guidance information is greater than the threshold, the texture details are richer, and the object shape is more regular.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115222630B
    Figure CN115222630B
Patent Text Reader

Abstract

The present invention provides an image generation method, a training method and a device for an image denoising model, which relate to the field of image generation technology and solve the problem of how to generate a target noise-free image that matches the information content of guide information. The method includes: first obtaining a noise image to be processed, guide information corresponding to the noise image, a target noise addition stage and empty guide information; the guide information includes a semantic contour image, or includes a semantic contour image and a target text; and based on the noise image, the guide information, the target noise addition stage and the empty guide information, denoising the noise image to generate a target noise-free image; wherein the matching degree between the image content of the target noise-free image and the information content of the guide information is greater than a first threshold. In this way, the noise image is denoised in combination with the guide information and the empty guide information, so that a target noise-free image that matches the information content of the guide information can be generated, thereby improving the accuracy of the generated target noise-free image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image generation technology, and in particular to an image generation method, a training method and a device for an image denoising model. Background Art

[0002] In the image denoising sampling process in the diffusion model scenario, the semantic contour image is usually used as guiding information to generate a target noise-free image matching the semantic contour image based on the Generative adversarial nets (GAN). However, the generated target noise-free image has a poor match with the semantic contour image.

[0003] Therefore, how to generate a target noise-free image that matches the information content of the guidance information, thereby improving the accuracy of the generated target noise-free image, is a problem that needs to be solved urgently by those skilled in the art. Summary of the invention

[0004] The present invention provides an image generation method, an image denoising model training method and a device, which can generate a target noise-free image that matches the information content of guidance information, thereby improving the accuracy of the generated target noise-free image.

[0005] The present invention provides an image generation method, which may include:

[0006] A noise image to be processed, guidance information corresponding to the noise image, a target noise addition stage and empty guidance information are obtained; wherein the guidance information includes a semantic contour image; or the guidance information includes a semantic contour image and a target text.

[0007] Based on the noise image, the guidance information, the target noise addition stage and the empty guidance information, the noise image is denoised to generate a target noise-free image; wherein the image content of the target noise-free image matches the information content of the guidance information to a degree greater than a first threshold.

[0008] According to an image generation method provided by the present invention, based on the noise image, the guide information, the target noise adding stage and the empty guide information, the noise image is denoised to generate a target noise-free image, including:

[0009] S1. Input the noise image, the guide information and the target noise adding stage into the image denoising model in the diffusion model to obtain the first parameter; and input the noise image, the empty guide information and the target noise adding stage into the image denoising model to obtain the second parameter.

[0010] S2. Generate a noise-free image corresponding to the noisy image in the target noise adding stage according to the first parameter and the second parameter.

[0011] S3. Update the target noise adding stage, and determine whether the updated noise adding stage is equal to a second threshold.

[0012] S4. When it is determined that the updated noise adding stage is equal to the second threshold, the noise-free image corresponding to the noise image in the target noise adding stage is determined as the target noise-free image.

[0013] S5. When it is determined that the updated noise addition stage is greater than the second threshold, the noise image corresponding to the previous noise addition stage of the target noise addition stage is determined, and the noise image corresponding to the previous noise addition stage is determined as the noise image to be processed, and the updated noise addition stage is determined as the target noise addition stage. The above S1-S5 are repeatedly executed until the updated noise addition stage is equal to the second threshold, and the noise-free image corresponding to the noise image after the updated noise addition stage is determined as the target noise-free image.

[0014] According to an image generation method provided by the present invention, the first parameter includes a first mean and a first variance, the second parameter includes a second mean, and generating a noise-free image corresponding to the noise image in the target noise addition stage according to the first parameter and the second parameter, comprising:

[0015] The first mean and the second mean are fused to obtain a corresponding target mean.

[0016] A noise-free image corresponding to the noisy image in the target noise adding stage is generated according to the target mean and the first variance.

[0017] According to an image generation method provided by the present invention, fusing the first mean value and the second mean value to obtain a corresponding target mean value includes:

[0018] A difference between the first mean and the second mean is determined, and a product of the difference and a corresponding weight is determined.

[0019] The sum of the second mean and the product is determined as the target mean.

[0020] According to an image generation method provided by the present invention, the step of determining a noise image corresponding to a noise adding stage before the target noise adding stage comprises:

[0021] A noise image corresponding to the previous noise adding stage is generated according to the noise image, the noise-free image corresponding to the noise image in the target noise adding stage, and the first variance in the first parameter.

[0022] According to an image generation method provided by the present invention, generating a noise image corresponding to the previous noise addition stage according to the noise image, the noise-free image corresponding to the noise image in the target noise addition stage, and the first variance, comprises:

[0023] A third mean is determined according to the noise image, the noise-free image corresponding to the noise image in the target noise adding stage, and the first variance.

[0024] A second variance is determined based on the first variance.

[0025] A noise image corresponding to the previous noise adding stage is generated according to the third mean and the second variance.

[0026] The present invention also provides a method for training an image denoising model, which may include:

[0027] Acquire multiple clean image samples, the guide information and noise adding stage corresponding to each of the multiple clean image samples, and the noise image samples corresponding to each of the noise adding stages; wherein the multiple clean image samples include clean image samples whose corresponding guide information is non-empty guide information and clean image samples whose corresponding guide information is empty guide information, and the guide information includes a semantic contour image; or, the guide information includes a semantic contour image and a target text.

[0028] The noise image samples corresponding to each of the multiple clean image samples in the noise adding stage, the guide information and the noise adding stage are input into the initial image denoising model in the initial diffusion model to obtain the mean and variance of the noise contained in the noise image samples corresponding to each of the multiple clean image samples in the noise adding stage.

[0029] The model parameters of the initial image denoising model are updated according to the multiple clean image samples and the mean and variance of the noise contained in the noisy image samples corresponding to the multiple clean image samples in the denoising stage to obtain the image denoising model.

[0030] According to a training method for an image denoising model provided by the present invention, the model parameters of the initial image denoising model are updated according to the multiple clean image samples and the mean and variance of the noise contained in the noisy image samples corresponding to the multiple clean image samples in the denoising stage, including:

[0031] According to the mean and variance of the noise contained in the noisy image samples respectively corresponding to the multiple clean image samples in the noisy stage, the predicted clean image samples respectively corresponding to the multiple clean image samples in the noisy stage are obtained.

[0032] The model parameters of the initial image denoising model are updated according to the multiple clean image samples and the predicted clean image samples corresponding to the multiple clean image samples in the denoising stage.

[0033] According to a training method for an image denoising model provided by the present invention, the model parameters of the initial image denoising model are updated according to the multiple clean image samples and the predicted clean image samples corresponding to the multiple clean image samples in the denoising stage, including:

[0034] For each clean image sample, the mean square error loss corresponding to the clean image sample is constructed according to the mean of the clean image sample and the mean of the predicted clean image sample corresponding to the clean image sample in the noisy stage; and the variational lower bound loss corresponding to the clean image sample is constructed according to the value of the noisy stage and the noisy image sample corresponding to the clean image sample in the noisy stage; based on the mean square error loss and the variational lower bound loss corresponding to the clean image sample, the target loss corresponding to the clean image sample is determined.

[0035] The model parameters of the initial image denoising model are updated according to the target loss corresponding to each clean image sample.

[0036] According to a training method for an image denoising model provided by the present invention, constructing a variational lower bound loss corresponding to the clean image sample according to the value taken in the denoising stage and the noisy image sample corresponding to the clean image sample in the denoising stage, comprising:

[0037] In the case where the value of the noise adding stage is the lower boundary value of the noise adding stage range, the discrete Gaussian mixture likelihood is determined according to the clean image samples, the variance of the clean image samples and the noise image samples corresponding to the clean image samples in the noise adding stage, and the discrete Gaussian mixture likelihood is determined as the variational lower bound loss corresponding to the clean image samples.

[0038] In the case where the value of the denoising stage is not a lower boundary value, the corresponding target divergence is determined according to the first predicted noise image sample and the second predicted noise image sample corresponding to the clean image sample in the previous denoising stage of the denoising stage; and based on the target divergence, the variational lower bound loss corresponding to the clean image sample is constructed; wherein the first predicted noise image sample is generated based on the clean image sample, the variance of the clean image sample, and the noise image sample corresponding to the clean image sample in the denoising stage, and the second predicted noise image sample is generated based on the predicted clean image sample corresponding to the clean image sample in the denoising stage, the variance of the predicted clean image sample, and the noise image sample corresponding to the clean image sample in the denoising stage.

[0039] According to a training method for an image denoising model provided by the present invention, the semantic contour image corresponding to the clean image sample is a non-empty semantic contour image, and the target loss corresponding to the clean image sample is determined according to the mean square error loss and the variational lower bound loss corresponding to the clean image sample, including:

[0040] According to the semantic category to which each pixel in the semantic contour image corresponding to the clean image sample belongs, the area of ​​the semantic block corresponding to each semantic category among the multiple semantic categories included in the semantic contour image is determined; and according to the area of ​​the semantic block corresponding to each semantic category, the target weight corresponding to the semantic contour image is determined.

[0041] According to the target weight corresponding to the semantic contour image, a first weight corresponding to the mean square error loss and a second weight corresponding to the variational lower bound loss are determined respectively; and a first product of the first weight and the mean square error loss, and a second product of the second weight and the variational lower bound loss are determined.

[0042] A target loss corresponding to the clean image sample is determined according to the first product and the second product.

[0043] According to a training method for an image denoising model provided by the present invention, determining the target weight corresponding to the semantic contour image according to the area of ​​the semantic block corresponding to each semantic category includes:

[0044] For each semantic category, a first value is determined according to the area of ​​the semantic block corresponding to the semantic category, and a second value is determined according to the first value and the areas of the semantic blocks corresponding to each of the multiple semantic categories other than the semantic category; the ratio of the first value to the second value is determined as the weight corresponding to each pixel in the semantic block corresponding to the semantic category.

[0045] Among the multiple semantic categories, the weight corresponding to each pixel in the semantic block corresponding to each semantic category constitutes the target weight corresponding to the semantic contour image.

[0046] According to a training method for an image denoising model provided by the present invention, obtaining a noise image sample corresponding to each of the plurality of clean image samples in the noise adding stage includes:

[0047] The multiple clean image samples and the noise addition stages corresponding to the multiple clean image samples are input into the noise addition processing algorithm in the initial diffusion model to obtain noise image samples corresponding to the multiple clean image samples in the noise addition stages.

[0048] The present invention also provides an image generating device, which may include:

[0049] The first acquisition unit is used to acquire a noise image to be processed, guidance information corresponding to the noise image, a target noise addition stage and empty guidance information; wherein the guidance information includes a semantic contour image; or the guidance information includes a semantic contour image and a target text.

[0050] A generating unit is used to denoise the noise image based on the noise image, the guiding information, the target noise adding stage and the empty guiding information to generate a target noise-free image; wherein the image content of the target noise-free image matches the information content of the guiding information to a degree greater than a first threshold.

[0051] According to an image generating device provided by the present invention, the generating unit is specifically used to execute:

[0052] S1. Input the noise image, the guide information and the target noise adding stage into the image denoising model in the diffusion model to obtain the first parameter; and input the noise image, the empty guide information and the target noise adding stage into the image denoising model to obtain the second parameter.

[0053] S2. Generate a noise-free image corresponding to the noisy image in the target noise adding stage according to the first parameter and the second parameter.

[0054] S3. Update the target noise adding stage, and determine whether the updated noise adding stage is equal to a second threshold.

[0055] S4. When it is determined that the updated noise adding stage is equal to the second threshold, the noise-free image corresponding to the noise image in the target noise adding stage is determined as the target noise-free image.

[0056] S5. When it is determined that the updated noise addition stage is greater than the second threshold, the noise image corresponding to the previous noise addition stage of the target noise addition stage is determined, and the noise image corresponding to the previous noise addition stage is determined as the noise image to be processed, and the updated noise addition stage is determined as the target noise addition stage. The above S1-S5 are repeatedly executed until the updated noise addition stage is equal to the second threshold, and the noise-free image corresponding to the noise image after the updated noise addition stage is determined as the target noise-free image.

[0057] According to an image generating device provided by the present invention, the first parameter includes a first mean and a first variance, and the second parameter includes a second mean.

[0058] The generating unit is specifically used to fuse the first mean and the second mean to obtain a corresponding target mean; and generate a noise-free image corresponding to the noise image in the target noise adding stage according to the target mean and the first variance.

[0059] According to an image generating device provided by the present invention, the generating unit is specifically used to determine the difference between the first mean and the second mean, and determine the product between the difference and the corresponding weight; and determine the sum of the second mean and the product as the target mean.

[0060] According to an image generating device provided by the present invention, the generating unit is specifically used to generate the noise image corresponding to the previous noise adding stage according to the noise image, the noise-free image corresponding to the noise image in the target noise adding stage, and the first variance in the first parameter.

[0061] According to an image generating device provided by the present invention, the generating unit is specifically used to determine a third mean according to the noise image, the noise-free image corresponding to the noise image in the target noise adding stage, and the first variance; determine a second variance based on the first variance; and generate a noise image corresponding to the previous noise adding stage according to the third mean and the second variance.

[0062] The present invention also provides a training device for an image denoising model, which may include:

[0063] The second acquisition unit is used to acquire multiple clean image samples, the guidance information and noise addition stage corresponding to each of the multiple clean image samples, and the noise image samples corresponding to each of the noise addition stages; wherein the multiple clean image samples include clean image samples whose corresponding guidance information is non-empty guidance information and clean image samples whose corresponding guidance information is empty guidance information, and the guidance information includes a semantic contour image; or, the guidance information includes a semantic contour image and a target text.

[0064] The first generating unit is used to input the noise image samples corresponding to each of the multiple clean image samples in the noise adding stage, the guide information and the noise adding stage into the initial image denoising model in the initial diffusion model to obtain the mean and variance of the noise contained in the noise image samples corresponding to each of the multiple clean image samples in the noise adding stage.

[0065] The second generating unit is used to update the model parameters of the initial image denoising model according to the multiple clean image samples and the mean and variance of the noise contained in the noise image samples corresponding to each of the multiple clean image samples in the denoising stage to obtain the image denoising model.

[0066] According to a training device for an image denoising model provided by the present invention, the second generating unit is specifically used to obtain predicted clean image samples corresponding to each of the multiple clean image samples in the denoising stage based on the mean and variance of noise contained in the noise image samples corresponding to each of the multiple clean image samples in the denoising stage; and update the model parameters of the initial image denoising model based on the multiple clean image samples and the predicted clean image samples corresponding to each of the multiple clean image samples in the denoising stage.

[0067] According to a training device for an image denoising model provided by the present invention, the second generating unit is specifically used to construct, for each clean image sample, a mean square error loss corresponding to the clean image sample according to the mean of the clean image sample and the mean of the predicted clean image sample corresponding to the clean image sample in the denoising stage; and to construct a variational lower bound loss corresponding to the clean image sample according to the value taken in the denoising stage and the noisy image sample corresponding to the clean image sample in the denoising stage; determine a target loss corresponding to the clean image sample according to the mean square error loss and the variational lower bound loss corresponding to the clean image sample; and update the model parameters of the initial image denoising model according to the target loss corresponding to each clean image sample.

[0068] According to a training device for an image denoising model provided by the present invention, the second generating unit is specifically used to determine the discrete Gaussian mixture likelihood according to the clean image sample, the variance of the clean image sample and the noise image sample corresponding to the clean image sample in the noisy stage when the value of the noisy stage is the lower boundary value of the noisy stage range, and determine the discrete Gaussian mixture likelihood as the variational lower bound loss corresponding to the clean image sample; when the value of the noisy stage is not the lower boundary value, determine the corresponding target divergence according to the first predicted noise image sample and the second predicted noise image sample corresponding to the clean image sample in the previous noisy stage of the noisy stage; and construct the variational lower bound loss corresponding to the clean image sample based on the target divergence; wherein the first predicted noise image sample is generated based on the clean image sample, the variance of the clean image sample and the noise image sample corresponding to the clean image sample in the noisy stage, and the second predicted noise image sample is generated based on the predicted clean image sample corresponding to the clean image sample in the noisy stage, the variance of the predicted clean image sample and the noise image sample corresponding to the clean image sample in the noisy stage.

[0069] According to a training device for an image denoising model provided by the present invention, the semantic contour image corresponding to the clean image sample is a non-empty semantic contour image.

[0070] The second generating unit is specifically used to determine the area of ​​the semantic block corresponding to each semantic category among the multiple semantic categories included in the semantic contour image according to the semantic category to which each pixel belongs in the semantic contour image corresponding to the clean image sample; and determine the target weight corresponding to the semantic contour image according to the area of ​​the semantic block corresponding to each semantic category; determine the first weight corresponding to the mean square error loss and the second weight corresponding to the variational lower bound loss according to the target weight corresponding to the semantic contour image; and determine the first product of the first weight and the mean square error loss, and the second product of the second weight and the variational lower bound loss; and determine the target loss corresponding to the clean image sample according to the first product and the second product.

[0071] According to a training device for an image denoising model provided by the present invention, the second generating unit is specifically used to determine, for each semantic category, a first value according to the area of ​​a semantic block corresponding to the semantic category, and to determine a second value according to the first value and the area of ​​semantic blocks corresponding to each of the multiple semantic categories other than the semantic category; a ratio of the first value to the second value is determined as a weight corresponding to each pixel in the semantic block corresponding to the semantic category; and the weight corresponding to each pixel in the semantic block corresponding to each semantic category in the multiple semantic categories constitutes a target weight corresponding to the semantic contour image.

[0072] According to a training device for an image denoising model provided by the present invention, the second acquisition unit is specifically used to input the multiple clean image samples and the denoising stages corresponding to each of the multiple clean image samples into the denoising processing algorithm in the initial diffusion model to obtain the noise image samples corresponding to each of the multiple clean image samples in the denoising stage.

[0073] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the image generation method or the image denoising model training method as described above is implemented.

[0074] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the above-described image generation methods or image denoising model training methods.

[0075] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the above-described image generation methods or image denoising model training methods.

[0076] The image generation method, image denoising model training method and device provided by the present invention can first obtain the noise image to be processed, the guidance information corresponding to the noise image, the target noise addition stage and the empty guidance information when generating the target noise-free image matching the information content of the guidance information; wherein the guidance information includes the semantic contour image, or includes the semantic contour image and the target text; and based on the noise image, the guidance information, the target noise addition stage and the empty guidance information, the noise image is denoised to generate the target noise-free image; wherein the matching degree between the image content of the target noise-free image and the information content of the guidance information is greater than the first threshold. In this way, the noise image is denoised in combination with the guidance information and the empty guidance information, so that the target noise-free image matching the information content of the guidance information can be generated, thereby improving the accuracy of the generated target noise-free image. BRIEF DESCRIPTION OF THE DRAWINGS

[0077] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0078] Figure 1 A schematic diagram of a flow chart of an image generation method provided by an embodiment of the present invention;

[0079] Figure 2 A schematic diagram of a process for denoising a noisy image provided by an embodiment of the present invention;

[0080] Figure 3 A schematic diagram of an input of an image denoising model provided by an embodiment of the present invention;

[0081] Figure 4 A schematic diagram of a flow chart of a method for training an image denoising model provided by an embodiment of the present invention;

[0082] Figure 5 A schematic diagram of the structure of an image generating device provided by an embodiment of the present invention;

[0083] Figure 6 A schematic diagram of the structure of a training device for an image denoising model provided by an embodiment of the present invention;

[0084] Figure 7 A schematic diagram of the physical structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0085] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0086] In the embodiments of the present invention, "at least one" means one or more, and "more" means two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. In the text description of the present invention, the character " / " generally indicates that the associated objects before and after are in an "or" relationship.

[0087] The technical solution provided by the embodiment of the present invention can be applied to image generation scenarios, and in particular, can be applied to denoising scenarios in diffusion models. In the image denoising sampling process in the diffusion model scenario, the semantic contour image is usually used as the guiding information, and a target noise-free image matching the semantic contour image is generated based on GAN. However, the generated target noise-free image has a poor match with the semantic contour image.

[0088] In order to generate a target noise-free image that matches the information content of the guidance information, thereby improving the accuracy of the generated target noise-free image, an embodiment of the present invention provides an image generation method, in which, during the image denoising sampling process, the guidance information and the empty guidance information can be combined to perform denoising on the noisy image to generate a target noise-free image that matches the information content of the guidance information, thereby improving the accuracy of the generated target noise-free image. The guidance information includes a semantic contour image, or includes a semantic contour image and a target text, thereby achieving pixel-level image guidance.

[0089] The image generation method provided by the present invention will be described in detail below through the following specific embodiments. It is understandable that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.

[0090] Figure 1 This is a flow chart of an image generation method provided by an embodiment of the present invention. The image generation method can be executed by software and / or hardware devices. For example, see Figure 1 As shown, the image generation method may include:

[0091] S101, obtaining a noise image to be processed, guidance information corresponding to the noise image, a target noise addition stage and empty guidance information; wherein the guidance information includes a semantic contour image; or the guidance information includes a semantic contour image and a target text.

[0092] Among them, the noise image usually includes three RGB channels, while the semantic contour image is a grayscale image containing only one channel. The semantic contour image can be understood as the semantic contour image information of the noise-free image to be generated based on the noise image. The target text can be understood as the descriptive text of the noise-free image to be generated based on the noise image. It can be understood that in the embodiment of the present invention, the guide information and the empty guide information are used together as the guide information in the denoising process to combine the guide information and the empty guide information to generate a target noise-free image that matches the information content of the guide information.

[0093] For example, when obtaining the noise image to be processed, the noise image can be received from other electronic devices, the noise image can be searched and obtained from local storage, or the noise image can be obtained from other third-party databases, etc. The specific settings can be made according to actual needs. Here, the embodiment of the present invention does not make any specific restrictions on the method for obtaining the noise image to be processed.

[0094] Among them, the noise image can be understood as the original clean image obtained by performing noise processing based on the target noise stage. Assuming that in the diffusion model scenario, the number of diffusion steps is set to T steps, and the target noise stage is represented by t, then the noise stage range can be determined to be 0-T, and the target noise stage t is a random number within 0-T. For example, assuming that the randomly determined target noise stage is t=5, the noise processing algorithm in the diffusion model can continuously perform noise processing on the original clean image five times, wherein the second noise processing is performed on the basis of the noise image obtained by the first noise processing, the third noise processing is performed on the basis of the noise image obtained by the second noise processing, the fourth noise processing is performed on the basis of the noise image obtained by the third noise processing, and the fifth noise processing is performed on the basis of the noise image obtained by the fourth noise processing. In this way, by performing five noise processing on the original clean image, the noise image of the original clean image at the target noise stage t=5 can be obtained.

[0095] For example, when the noise processing algorithm in the diffusion model performs noise processing on the original clean image, a linear noise adding method can be used to perform gradual noise processing, which can make the noise adding process smoother and better retain the relevant information of the original clean image during the diffusion process; of course, other noise adding methods can also be used for noise processing, which can be specifically set according to actual needs. Here, the embodiment of the present invention only takes the use of a linear noise adding method for noise processing as an example for explanation, but it does not mean that the embodiment of the present invention is limited to this.

[0096] After respectively obtaining the noise image to be processed, the guidance information corresponding to the noise image, the target noise adding stage and the empty guidance information, the following S102 can be executed:

[0097] S102, based on the noise image, the guidance information, the target noise adding stage and the empty guidance information, denoising the noise image to generate a target noise-free image; wherein the image content of the target noise-free image matches the information content of the guidance information to a degree greater than a first threshold.

[0098] The value of the first threshold may be set according to actual needs. The embodiment of the present invention does not impose any specific limitation on the specific value of the first threshold.

[0099] Typically, in a diffusion model scenario, a target denoising stage that conforms to a Gaussian probability distribution can be randomly initialized first. The denoising algorithm in the diffusion model performs step-by-step denoising on the original clean image based on the target denoising stage. After obtaining the noisy image, the noisy image obtained by the denoising process can be denoised layer by layer through an inverse diffusion process to obtain a predicted target noise-free image. For example, when the noisy image obtained by the denoising process is denoised layer by layer through an inverse diffusion process, the noisy image can be denoised layer by layer based on the value of the target denoising stage, that is, the denoising operation is performed cyclically to obtain the predicted target noise-free image. It can be understood that in an embodiment of the present invention, in the process of denoising the noise image layer by layer based on the value of the target denoising stage, the guidance information corresponding to the noise images at different denoising stages is the same as the empty guidance information.

[0100] For example, when denoising the noise image based on the noise image, the guidance information, the target noise adding stage and the empty guidance information, the denoising process may include:

[0101] S1. Input the noise image, guidance information and target noise adding stage into the image denoising model in the diffusion model to obtain the first parameter; and input the noise image, empty guidance information and target noise adding stage into the image denoising model to obtain the second parameter. For example, see Figure 2 As shown, Figure 2 A schematic diagram of a process of denoising a noisy image provided by an embodiment of the present invention. After obtaining the first parameter and the second parameter, the following S2 may be performed:

[0102] S2. Generate a noise-free image corresponding to the noise image in the target noise adding stage according to the first parameter and the second parameter.

[0103] S3. Update the target noise adding stage, and determine whether the updated noise adding stage is equal to the second threshold.

[0104] S4. When it is determined that the updated noise adding stage is equal to the second threshold, a noise-free image corresponding to the noise image at the target noise adding stage is determined as a target noise-free image.

[0105] S5. When it is determined that the updated noise adding stage is greater than the second threshold, the noise image corresponding to the previous noise adding stage of the target noise adding stage is determined, and the noise image corresponding to the previous noise adding stage is determined as the noise image to be processed, and the updated noise adding stage is determined as the target noise adding stage. The above S1-S5 are repeatedly executed until the updated noise adding stage is equal to the second threshold, and the noise-free image corresponding to the noise image in the updated noise adding stage is determined as the target noise-free image.

[0106] The value of the second threshold can be set according to actual needs. For example, when the noise adding stage range is 0-T, the second threshold is 0.

[0107] For example, the image denoising model can be a UNet neural network model, which mainly includes an input layer, an intermediate layer and an output layer. The input layer is mainly composed of a stack of several residual blocks, attention blocks and downsampling blocks, which are used to extract the features of the noisy image; the intermediate block is composed of a residual block, an attention block and another residual block, which are used to further integrate the extracted features; the output block is composed of a stack of several residual blocks, attention blocks and upsampling blocks, which are used to restore the features integrated in the intermediate layer, thereby obtaining the mean and variance of the noise contained in the noisy image.

[0108] For example, the image denoising model is obtained by training the initial image denoising model in the initial diffusion model based on multiple clean image samples, the guidance information and denoising stages corresponding to each of the multiple clean image samples, and the noise images corresponding to each of the denoising stages. The training process of the initial image denoising model will be described in detail later.

[0109] For example, in the above S1, when the noise image, the guidance information and the target noise adding stage are input into the image denoising model in the diffusion model, considering that the noise image usually includes three RGB channels, and the semantic contour image included in the guidance information is a grayscale image containing only one channel, therefore, the semantic contour image can be spliced ​​onto the noise image as the fourth channel, and the spliced ​​multi-channel image and the target noise adding stage are input into the image denoising model in the diffusion model. For example, see Figure 3 As shown, Figure 3 An input schematic diagram of an image denoising model provided in an embodiment of the present invention, before the denoising stage is input into the image denoising model, the denoising stage can be first encoded by a time encoder to obtain a time coding feature, and the time coding is input into each residual block in the image denoising model; in addition, when the guiding information includes a target text, the target text can be used as a supplementary condition to further improve the accuracy of the generated target noise-free image. In this case, before the target text is input into the image denoising model, the target text can be first serialized by a text serializer to obtain a serialized text, and the serialized text can be encoded by a text encoder to generate a text coding feature, and then the text coding feature is input into the attention block in the image denoising model, and the text coding feature is fused by using an attention mechanism, and finally the mean and variance contained in the noise image corresponding to the target denoising stage are output, that is, the first parameter, and the first parameter includes the mean and variance, which can be correspondingly recorded as the first mean and the first variance.

[0110] Similarly, when the noisy image, empty guidance information and target denoising stage are input into the image denoising model, the semantic contour image in the empty guidance information can be represented by a matrix with a value of 0, and used as the input of the image denoising model together with the empty text. Considering that the noisy image usually includes three RGB channels, and the empty semantic contour image included in the empty guidance information is a grayscale image containing only one channel, the empty semantic contour image can be spliced ​​onto the noisy image as the fourth channel, and the spliced ​​multi-channel image and the target denoising stage are input into the image denoising model in the diffusion model. Before inputting the denoising stage into the image denoising model, the denoising stage can be encoded by a time encoder to obtain a time coding feature, and the time coding is input into each residual block in the image denoising model; in addition, when the empty guide information includes empty text, the empty text can be used as a supplementary condition to further improve the accuracy of the generated target noise-free image. In this case, before inputting the empty text into the image denoising model, the empty text can be serialized by a text serializer to obtain a serialized text, and the serialized text can be encoded by a text encoder to generate text coding features, and then the text coding features are input into the attention block in the image denoising model, and the text coding features are fused by the attention mechanism, and finally the mean and variance contained in the noise image corresponding to the target denoising stage are output, that is, the second parameter. The second parameter includes the mean, which can be correspondingly recorded as the second mean. Since the variance included in it is not involved in the subsequent processing process for the time being, it can be distinguished first.

[0111] For example, in the above S2, when generating a noise-free image corresponding to the noise image in the target noise addition stage according to the first parameter and the second parameter, the diffusion model can adopt the idea of ​​no classifier guidance, first fuse the first mean and the second mean to obtain the corresponding target mean; then generate the noise-free image corresponding to the noise image in the target noise addition stage according to the fused target mean and the first variance. In this way, the idea of ​​no classifier guidance is adopted to generate the noise-free image corresponding to the noise image in the target noise addition stage, which can improve the image quality and accuracy of the generated noise-free image to a certain extent compared with the unguided generation method.

[0112] For example, when fusing the first mean and the second mean, the difference between the first mean and the second mean can be determined first, and the product between the difference and its corresponding weight can be determined; the sum of the second mean and the product can be determined as the target mean. For ease of understanding, for example, in a scenario, the guidance information only includes the semantic contour image, assuming that the target noise addition stage is t, represents the noise image of the target noise adding stage t, Represents the semantic contour image in the guidance information, Represents the empty semantic contour image in the empty guidance information, and adds the noise image of the target noise stage t , semantic contour image , and the target noise stage t is input to the image denoising model, and the first mean of its output can be recorded as , add the noise image of the target at stage t , empty semantic contour image , and the target noise stage t are input to the image denoising model, and the second mean of its output can be recorded as , then for the first mean and the second mean The target mean can be obtained by fusion as shown in the following formula 1:

[0113]

[0114] in, represents the target mean obtained by fusion, Indicates the weight corresponding to the difference between the first mean and the second mean.

[0115] In another scenario, the guidance information includes the semantic contour image and the target text. It is also assumed that the target noise addition stage is t. represents the noise image of the target noise adding stage t, Represents the semantic contour image in the guidance information, represents the empty semantic contour image in the empty guidance information, Indicates the target text in the guide information. Represents the empty text in the empty guidance information, and adds the noise image of the target to the noise stage t , semantic contour image , target text And the target noise stage t is input to the image denoising model, and the first mean of its output can be recorded as , add the noise image of the target at stage t , empty semantic contour image , Empty text And the target noise stage t is input to the image denoising model, and the second mean of its output can be recorded as , then for the first mean and the second mean The target mean can be obtained by fusion as shown in the following formula 2:

[0116]

[0117] in, represents the target mean obtained by fusion, Indicates the weight corresponding to the difference between the first mean and the second mean.

[0118] After fusing the first mean and the second mean to obtain the corresponding target mean, a noise-free image corresponding to the noise image in the target noise addition stage can be generated according to the target mean and the first variance. For its specific implementation, please refer to the related method in the prior art for generating a noise-free image corresponding to the noise image in the noise addition stage based on the mean and variance. Here, the embodiments of the present invention will not be described in detail.

[0119] After executing the above S2 to generate the noise-free image corresponding to the noise image in the target noisy stage, the noise-free image cannot be directly determined as the target noise-free image obtained by denoising the noise image. Instead, the noise addition stage needs to be further updated. For example, each time the noise addition stage is updated, the value of the target noise addition stage can be subtracted by 1 to obtain the updated noise addition stage; and it is determined whether the updated noise addition stage is greater than the second threshold. For example, the second threshold can be set to 0, which can be set according to actual needs. When it is determined that the updated noise addition stage is equal to the second threshold, the noise-free image corresponding to the noise image in the target noise addition stage can be directly determined as the final target noise-free image; on the contrary, when it is determined that the updated noise addition stage is greater than the second threshold, it is necessary to further execute the above S5 to determine the noise image corresponding to the previous noise addition stage of the target noise addition stage. , and the noise image corresponding to the previous noise adding stage Determine the noise image to be processed in the above S1, determine the updated noise addition stage as the target noise addition stage, repeat the above S1-S5 until the updated noise addition stage is equal to the second threshold, and determine the noise-free image corresponding to the noise image in the updated noise addition stage as the final target noise-free image.

[0120] For example, in the above S5, when determining the noise image corresponding to the previous noise addition stage of the target noise addition stage, the noise image corresponding to the previous noise addition stage can be generated according to the noise image, the noise-free image corresponding to the noise image in the target noise addition stage, and the first variance in the first parameter, thereby obtaining the noise image corresponding to the previous noise addition stage.

[0121] For example, when generating a noise image corresponding to a previous noise addition stage based on a noise image, a noise-free image corresponding to the noise image in a target noise addition stage, and a first variance, a third mean can be determined based on the noise image, the noise-free image corresponding to the noise image in the target noise addition stage, and the first variance; and a second variance can be determined based on the first variance; and then a noise image corresponding to the previous noise addition stage can be generated based on the third mean and the second variance.

[0122] For example, when determining the third mean according to the noise image, the noise-free image corresponding to the noise image in the target noise adding stage, and the first variance, refer to Formula 3:

[0123]

[0124] in, represents the third mean, represents the noise image of the target noise adding stage t, Represents a noisy image The noise-free image corresponding to the target noise addition stage t is: Represents the noise image of the target noise adding stage t The first variance of the included noise, , s represents the sth noise adding stage in the noise adding stages 1-t, Represents the noisy image at the noise adding stage s The variance of the included noise.

[0125] For example, when determining the second variance based on the first variance, refer to Formula 4:

[0126]

[0127] in, Represents the noise image of the target noise adding stage t The second variance of the included noise.

[0128] For example, based on the third mean and the second variance, a noise image corresponding to the previous noise adding stage is generated. , see formula 5:

[0129]

[0130] in, represents a Gaussian process, Represents random noise that conforms to the normal distribution.

[0131] By combining the above formulas 3, 4 and 5, the noise image corresponding to the previous noise adding stage can be generated.

[0132] It can be seen that in the embodiment of the present invention, when generating a target noise-free image that matches the information content of the guidance information, the noise image to be processed, the guidance information corresponding to the noise image, the target noise addition stage and the empty guidance information can be first obtained; wherein the guidance information includes a semantic contour image, or includes a semantic contour image and a target text; and based on the noise image, the guidance information, the target noise addition stage and the empty guidance information, the noise image is denoised to generate a target noise-free image; wherein the image content of the target noise-free image matches the information content of the guidance information greater than the first threshold. In this way, the noise image is denoised in combination with the guidance information and the empty guidance information, and a target noise-free image that matches the information content of the guidance information can be generated, thereby improving the accuracy of the generated target noise-free image. In addition, the image generation method provided by the embodiment of the present invention can also make the texture details of the generated target noise-free image richer and the shape of the object more regular.

[0133] Above Figure 1 The embodiment shown in the figure describes in detail how to generate a target noise-free image that matches the information content of the guidance information during the image denoising sampling process. Figure 4 The illustrated embodiment describes in detail how to train and generate an image denoising model.

[0134] Figure 4 This is a flow chart of a training method for an image denoising model provided by an embodiment of the present invention, which can be executed by software and / or hardware devices. Figure 4 As shown, the training method of the image denoising model may include:

[0135] S401, obtaining a plurality of clean image samples, the guidance information and the noise adding stage corresponding to each of the plurality of clean image samples, and the noise image samples corresponding to each of the noise adding stages; wherein the plurality of clean image samples include clean image samples whose corresponding guidance information is non-empty guidance information and clean image samples whose corresponding guidance information is empty guidance information, and the guidance information includes a semantic contour image; or the guidance information includes a semantic contour image and a target text.

[0136] For example, when obtaining multiple clean image samples and their corresponding semantic contour images, multiple clean image samples and their corresponding semantic contour images can be obtained through the ADE20K dataset, the COCO-Stuff dataset, and the Cityscapes dataset, wherein the ADE20K dataset and the Cityscapes dataset usually contain clean image samples and their corresponding semantic contour images, and the COCO-Stuff dataset also includes target text corresponding to the clean image samples.

[0137] For example, when obtaining noise image samples corresponding to each of the multiple clean image samples in the noise adding stage, the multiple clean image samples and the noise adding stages corresponding to each of the multiple clean image samples can be input into the noise adding processing algorithm in the initial diffusion model. The noise adding processing algorithm performs noise adding on the clean image samples layer by layer based on the values ​​of the noise adding stages to obtain noise image samples corresponding to each of the multiple clean image samples in the noise adding stage.

[0138] The number of diffusion steps is set to T, and the noise stage is represented by t. Then the noise stage range can be determined to be 0-T, and the noise stage t is a random number within 0-T. For example, the maximum value of T can be 1000. For the ADE20K dataset and COCO-Stuff dataset, the corresponding batch_size can be set to 256, and for the Cityscapes dataset, the corresponding batch_size can be set to 32. The noise image sample corresponding to the clean image sample at the noise stage t can be recorded as .

[0139] For example, assuming that the noise stage t=5 corresponds to a clean image sample, the clean image sample and the corresponding noise stage are input into the noise processing algorithm in the initial diffusion model, and the noise processing algorithm in the diffusion model can continuously perform noise processing on the original clean image five times, wherein the second noise processing is performed on the basis of the noise image obtained by the first noise processing, the third noise processing is performed on the basis of the noise image obtained by the second noise processing, the fourth noise processing is performed on the basis of the noise image obtained by the third noise processing, and the fifth noise processing is performed on the basis of the noise image obtained by the fourth noise processing. In this way, by continuously performing noise processing on the clean image sample five times, the noise image sample of the clean image sample at the noise stage t=5 can be obtained. Using a similar method, the noise image samples corresponding to each of the multiple clean image samples at the noise stage can be obtained.

[0140] S402, inputting the noise image samples corresponding to each of the multiple clean image samples in the noise adding stage, the guide information and the noise adding stage into the initial image denoising model in the initial diffusion model, and obtaining the mean and variance of the noise contained in the noise image samples corresponding to each of the multiple clean image samples in the noise adding stage.

[0141] For example, the initial image denoising model can be a UNet neural network model, which mainly includes an input layer, an intermediate layer and an output layer. The input layer is mainly composed of a stack of several residual blocks, attention blocks and downsampling blocks, which are used to extract the features of the noisy image samples; the intermediate block is composed of a residual block, an attention block and another residual block, which are used to further integrate the extracted features; the output block is composed of a stack of several residual blocks, attention blocks and upsampling blocks, which are used to restore the features integrated in the intermediate layer, thereby obtaining the mean and variance of the noise contained in the noisy image samples.

[0142] For example, in an embodiment of the present invention, the input layer may be composed of 17 residual blocks, 6 attention blocks and 10 downsampling blocks; the middle layer may be composed of 2 residual blocks and 1 attention block; the output layer may be composed of 23 residual blocks, 9 attention blocks and 10 upsampling blocks.

[0143] For example, when the noisy image sample, the guide information and the target denoising stage are input into the image denoising model in the diffusion model, the semantic contour image can be spliced ​​onto the noisy image as the fourth channel, and the spliced ​​multi-channel image and the target denoising stage are input into the image denoising model in the diffusion model. The image denoising model can use a sinusoidal encoding method to embed the time step into a vector with a length equal to the channel of the image denoising model, so as to superimpose the obtained encoding features into each residual block in the image denoising model; in addition, when the guide information includes text, the text can be used as a supplementary condition to further improve the accuracy of the generated predicted clean image sample. In this case, the image denoising model can also use a word segmenter to segment and serialize the text, and input the serialized text features into the attention block, and use the attention mechanism to fuse the text features, and finally output the mean and variance of the noise contained in the noise image samples corresponding to each of the multiple clean image samples in the denoising stage.

[0144] After obtaining the mean and variance of the noise contained in the noise image samples corresponding to each of the multiple clean image samples in the noise adding stage, the model parameters of the initial image denoising model can be updated according to the multiple clean image samples and the mean and variance of the noise contained in the noise image samples corresponding to each of the multiple clean image samples in the noise adding stage, that is, the following S403 is executed:

[0145] S403, updating the model parameters of the initial image denoising model according to the multiple clean image samples and the mean and variance of the noise contained in the noisy image samples corresponding to the multiple clean image samples in the denoising stage, so as to obtain the image denoising model.

[0146] It is understandable that in the embodiment of the present invention, when the initial diffusion model is updated, only the model parameters of the initial image denoising model in the initial diffusion model are updated, and the parameters of the noise processing algorithm and other calculation methods in the initial diffusion model are usually not updated.

[0147] For example, when the model parameters of the initial image denoising model are updated according to multiple clean image samples and the mean and variance of the noise contained in the noise image samples corresponding to each of the multiple clean image samples in the denoising stage, the diffusion model can obtain the predicted clean image samples corresponding to each of the multiple clean image samples in the denoising stage according to the multiple clean image samples and the predicted clean image samples corresponding to each of the multiple clean image samples in the denoising stage; thereafter, the model parameters of the initial image denoising model are updated according to the multiple clean image samples and the predicted clean image samples corresponding to each of the multiple clean image samples in the denoising stage.

[0148] For example, when the model parameters of the initial image denoising model are updated according to multiple clean image samples and the predicted clean image samples corresponding to each of the multiple clean image samples in the noisy stage, for each clean image sample, the mean square error loss corresponding to the clean image sample can be constructed according to the mean of the clean image sample and the mean of the predicted clean image samples corresponding to the clean image sample in the noisy stage; and the variational lower bound loss corresponding to the clean image sample can be constructed according to the value in the noisy stage and the noisy image sample corresponding to the clean image sample in the noisy stage; the target loss corresponding to the clean image sample is determined according to the mean square error loss and the variational lower bound loss corresponding to the clean image sample; and the model parameters of the initial image denoising model are updated according to the target loss corresponding to each clean image sample.

[0149] For example, when constructing the variational lower bound loss corresponding to the clean image sample based on the value of the noisy stage and the noisy image sample corresponding to the clean image sample in the noisy stage, it can be divided into two cases for discussion. In one case, when the value of the noisy stage is the lower boundary value of the noisy stage range, the discrete Gaussian mixture likelihood can be determined based on the clean image sample, the variance of the clean image sample and the noisy image sample corresponding to the clean image sample in the noisy stage, and the discrete Gaussian mixture likelihood is determined as the variational lower bound loss corresponding to the clean image sample, thereby obtaining the mean square error loss corresponding to the clean image sample.

[0150] In another case, when the value of the denoising stage is not a lower boundary value, the corresponding target divergence can be determined based on the first predicted noise image sample and the second predicted noise image sample corresponding to the clean image sample in the previous denoising stage; and based on the target divergence, the variational lower bound loss corresponding to the clean image sample is constructed, thereby obtaining the variational lower bound loss corresponding to the clean image sample.

[0151] Among them, the first predicted noise image sample is generated based on the clean image sample, the variance of the clean image sample and the noise image sample corresponding to the clean image sample in the noise adding stage, and the second predicted noise image sample is generated based on the predicted clean image sample corresponding to the clean image sample in the noise adding stage, the variance of the predicted clean image sample and the noise image sample corresponding to the clean image sample in the noise adding stage.

[0152] After respectively determining the mean square error loss and the variational lower bound loss corresponding to the clean image sample, the target loss corresponding to the clean image sample can be jointly determined based on the mean square error loss and the variational lower bound loss corresponding to the clean image sample. By way of example, to jointly determine the target loss corresponding to the clean image sample based on the mean square error loss and the variational lower bound loss corresponding to the clean image sample, it is usually necessary to first determine the weights corresponding to the mean square error loss and the variational lower bound loss, respectively. In order to distinguish the weights corresponding to the mean square error loss and the variational lower bound loss, by way of example, in an embodiment of the present invention, the weight corresponding to the mean square error loss can be recorded as the first weight, and the weight corresponding to the variational lower bound loss can be recorded as the second weight. After respectively determining the first weight corresponding to the mean square error loss and the second weight corresponding to the variational lower bound loss, the first product of the first weight and the mean square error loss, and the second product of the second weight and the variational lower bound loss can be determined; then, based on the first product and the second product, the target loss corresponding to the clean image sample is determined, as shown in the following formula 6:

[0153]

[0154] in, represents the target loss corresponding to the clean image sample, Indicates a mean calculation method, here is a square bracket The sum of the matrix elements in is divided by the sum of the corresponding weight matrix elements, represents the first weight corresponding to the mean square error loss, represents a clean image sample, represents the mean of clean image samples, Represents the predicted clean image sample corresponding to the clean image sample at the noise adding stage t The mean of represents the second weight corresponding to the variational lower bound loss, represents the noisy image sample corresponding to the clean image sample in the noise addition stage 1, Represents a clean image sample The noise image sample corresponding to the noise adding stage t is: Represents a clean image sample In the noise adding stage The corresponding first predicted noise image sample, Represents a clean image sample In the noise adding stage The corresponding second predicted noise image sample, represents the divergence function.

[0155] For example, when determining the first weight corresponding to the mean square error loss and the second weight corresponding to the variational lower bound loss respectively, the semantic contour image in the guidance information and the empty semantic contour image in the empty guidance information can be considered. On the one hand, when the semantic contour image is the empty semantic contour image in the empty guidance information, the target weight corresponding to the semantic contour image is 1; on the other hand, when the semantic contour image is the non-empty semantic contour image in the guidance information, the area of ​​the semantic block corresponding to each semantic category in the multiple semantic categories included in the semantic contour image can be determined according to the semantic category to which each pixel belongs in the semantic contour image corresponding to the clean image sample; and the target weight corresponding to the semantic contour image is determined according to the area of ​​the semantic block corresponding to each semantic category; according to the target weight corresponding to the semantic contour image, the first weight corresponding to the mean square error loss and the second weight corresponding to the variational lower bound loss are determined respectively, thereby determining the first weight corresponding to the mean square error loss and the second weight corresponding to the variational lower bound loss.

[0156] For example, when determining the target weight corresponding to the semantic contour image according to the area of ​​the semantic block corresponding to each semantic category, for each semantic category, a first value is determined according to the area of ​​the semantic block corresponding to the semantic category, and a second value is determined according to the first value and the area of ​​the semantic blocks corresponding to each of the multiple semantic categories other than the semantic category; the ratio of the first value to the second value is determined as the weight corresponding to the semantic category, as shown in the following formula 7, where the weight corresponding to the semantic category is the weight corresponding to each pixel in the semantic block corresponding to the semantic category, and the weight corresponding to each pixel in the semantic block corresponding to each semantic category in the multiple semantic categories constitutes the target weight corresponding to the semantic contour image.

[0157]

[0158] in, Representing semantic categories , represents the number of semantic categories included in the semantic contour image, express The first semantic categories, Representing semantic categories The area of ​​the corresponding semantic block, Indicates The area of ​​the semantic block corresponding to the semantic category, represents the first value, represents the second value, Representing semantic categories The corresponding weight.

[0159] After determining the target weight corresponding to the semantic contour image in combination with the above formula 6, the first weight corresponding to the mean square error loss and the second weight corresponding to the variational lower bound loss can be determined respectively according to the target weight corresponding to the semantic contour image. For example, when determining the first weight corresponding to the mean square error loss and the second weight corresponding to the variational lower bound loss respectively according to the target weight corresponding to the semantic contour image, it is considered that the area sizes corresponding to different semantic categories may be greatly different. This difference in area size may cause the smaller semantic categories to not receive enough attention during the training stage. Therefore, when calculating the mean square error loss and the variational lower bound loss, the weight of the semantic category corresponding to the smaller area can be appropriately increased and the weight of the semantic category corresponding to the larger area can be reduced on the basis of the determined target weight corresponding to the semantic contour image to balance the area size difference, thereby determining the first weight corresponding to the mean square error loss and the second weight corresponding to the variational lower bound loss.

[0160] It can be seen that in the embodiment of the present invention, when training the image denoising model, multiple clean image samples, guidance information and denoising stages corresponding to each of the multiple clean image samples, and noise image samples corresponding to each of the noise stages can be first obtained; wherein the guidance information includes a semantic contour image; or the guidance information includes a semantic contour image and a target text; the noise image samples corresponding to each of the multiple clean image samples in the noise stage, the guidance information, and the noise stage are input into the initial image denoising model in the initial diffusion model to obtain the mean and variance of the noise contained in the noise image samples corresponding to each of the multiple clean image samples in the noise stage; according to the multiple clean image samples, and the mean and variance of the noise contained in the noise image samples corresponding to each of the multiple clean image samples in the noise stage, the model parameters of the initial image denoising model are updated to obtain the image denoising model. This can not only improve the training efficiency of the image denoising model, but also effectively enhance the denoising performance of the image denoising model.

[0161] Figure 5 FIG. 5 is a schematic diagram of the structure of an image generating device 50 provided in an embodiment of the present invention. For example, see Figure 5 As shown, the image generating device 50 may include:

[0162] The first acquisition unit 501 is used to acquire the noise image to be processed, the guidance information corresponding to the noise image, the target noise addition stage and the empty guidance information; wherein the guidance information includes the semantic contour image; or the guidance information includes the semantic contour image and the target text.

[0163] The generating unit 502 is used to perform denoising processing on the noise image based on the noise image, the guiding information, the target noise adding stage and the empty guiding information to generate a target noise-free image; wherein the image content of the target noise-free image matches the information content of the guiding information to a degree greater than a first threshold.

[0164] Optionally, the generating unit 502 is specifically configured to execute:

[0165] S1. Input the noise image, guidance information and target noise adding stage into the image denoising model in the diffusion model to obtain the first parameter; and input the noise image, empty guidance information and target noise adding stage into the image denoising model to obtain the second parameter.

[0166] S2. Generate a noise-free image corresponding to the noise image in the target noise adding stage according to the first parameter and the second parameter.

[0167] S3. Update the target noise adding stage, and determine whether the updated noise adding stage is equal to the second threshold.

[0168] S4. When it is determined that the updated noise adding stage is equal to the second threshold, a noise-free image corresponding to the noise image at the target noise adding stage is determined as a target noise-free image.

[0169] S5. When it is determined that the updated noise adding stage is greater than the second threshold, the noise image corresponding to the previous noise adding stage of the target noise adding stage is determined, and the noise image corresponding to the previous noise adding stage is determined as the noise image to be processed, and the updated noise adding stage is determined as the target noise adding stage. The above S1-S5 are repeatedly executed until the updated noise adding stage is equal to the second threshold, and the noise-free image corresponding to the noise image in the updated noise adding stage is determined as the target noise-free image.

[0170] Optionally, the first parameter includes a first mean and a first variance, and the second parameter includes a second mean.

[0171] The generating unit 502 is specifically configured to fuse the first mean and the second mean to obtain a corresponding target mean; and generate a noise-free image corresponding to the noise image in the target noise adding stage according to the target mean and the first variance.

[0172] According to an image generating device 50 provided by the present invention, the generating unit 502 is specifically used to determine the difference between the first mean and the second mean, and determine the product between the difference and the corresponding weight; and determine the sum of the second mean and the product as the target mean.

[0173] Optionally, the generating unit 502 is specifically configured to generate a noise image corresponding to a previous noise adding stage according to the noise image, the noise-free image corresponding to the noise image in the target noise adding stage, and the first variance in the first parameter.

[0174] Optionally, the generating unit 502 is specifically used to determine a third mean based on the noise image, the noise-free image corresponding to the noise image in the target noise addition stage, and the first variance; determine the second variance based on the first variance; and generate a noise image corresponding to the previous noise addition stage based on the third mean and the second variance.

[0175] The image generating device 50 provided in an embodiment of the present invention can execute the technical solution of the image generating method in any of the above-mentioned embodiments. Its implementation principle and beneficial effects are similar to those of the image generating method. Please refer to the implementation principle and beneficial effects of the image generating method, and no further details will be given here.

[0176] Figure 6 A structural diagram of a training device 60 for an image denoising model provided in an embodiment of the present invention, for example, see Figure 6 As shown, the training device 60 of the image denoising model may include:

[0177] The second acquisition unit 601 is used to acquire multiple clean image samples, the guidance information and noise adding stage corresponding to each of the multiple clean image samples, and the noise image samples corresponding to each of the noise adding stages; wherein the multiple clean image samples include clean image samples whose corresponding guidance information is non-empty guidance information and clean image samples whose corresponding guidance information is empty guidance information, and the guidance information includes a semantic contour image; or the guidance information includes a semantic contour image and a target text.

[0178] The first generating unit 602 is used to input the noise image samples corresponding to each of the multiple clean image samples in the noise adding stage, the guide information and the noise adding stage into the initial image denoising model in the initial diffusion model, and obtain the mean and variance of the noise contained in the noise image samples corresponding to each of the multiple clean image samples in the noise adding stage.

[0179] The second generating unit 603 is used to update the model parameters of the initial image denoising model according to the multiple clean image samples and the mean and variance of the noise contained in the noise image samples corresponding to the multiple clean image samples in the denoising stage to obtain the image denoising model.

[0180] Optionally, the second generation unit 603 is specifically used to obtain predicted clean image samples corresponding to each of the multiple clean image samples in the noisy stage according to the mean and variance of the noise contained in the noisy image samples corresponding to each of the multiple clean image samples in the noisy stage; and update the model parameters of the initial image denoising model according to the multiple clean image samples and the predicted clean image samples corresponding to each of the multiple clean image samples in the noisy stage.

[0181] Optionally, the second generation unit 603 is specifically used to construct, for each clean image sample, a mean square error loss corresponding to the clean image sample according to the mean of the clean image sample and the mean of the predicted clean image sample corresponding to the clean image sample in the noisy stage; and construct a variational lower bound loss corresponding to the clean image sample according to the value in the noisy stage and the noisy image sample corresponding to the clean image sample in the noisy stage; determine the target loss corresponding to the clean image sample according to the mean square error loss and the variational lower bound loss corresponding to the clean image sample; and update the model parameters of the initial image denoising model according to the target loss corresponding to each clean image sample.

[0182] Optionally, the second generating unit 603 is specifically used to determine the discrete Gaussian mixture likelihood according to the clean image samples, the variance of the clean image samples and the noise image samples corresponding to the clean image samples in the noisy stage when the value of the noisy stage is the lower boundary value of the noisy stage range, and determine the discrete Gaussian mixture likelihood as the variational lower bound loss corresponding to the clean image samples; when the value of the noisy stage is a non-lower boundary value, determine the corresponding target divergence according to the first predicted noise image samples and the second predicted noise image samples corresponding to the clean image samples in the previous noisy stage of the noisy stage; and construct the variational lower bound loss corresponding to the clean image samples based on the target divergence; wherein the first predicted noise image samples are generated based on the clean image samples, the variance of the clean image samples and the noise image samples corresponding to the clean image samples in the noisy stage, and the second predicted noise image samples are generated based on the predicted clean image samples corresponding to the clean image samples in the noisy stage, the variance of the predicted clean image samples and the noise image samples corresponding to the clean image samples in the noisy stage.

[0183] Optionally, the semantic contour image corresponding to the clean image sample is a non-empty semantic contour image.

[0184] The second generation unit 603 is specifically used to determine the area of ​​the semantic block corresponding to each semantic category in the multiple semantic categories included in the semantic contour image according to the semantic category to which each pixel belongs in the semantic contour image corresponding to the clean image sample; and determine the target weight corresponding to the semantic contour image according to the area of ​​the semantic block corresponding to each semantic category; determine the first weight corresponding to the mean square error loss and the second weight corresponding to the variational lower bound loss according to the target weight corresponding to the semantic contour image; and determine the first product of the first weight and the mean square error loss, and the second product of the second weight and the variational lower bound loss; determine the target loss corresponding to the clean image sample according to the first product and the second product.

[0185] Optionally, the second generation unit 603 is specifically used to determine, for each semantic category, a first value according to the area of ​​a semantic block corresponding to the semantic category, and to determine a second value according to the first value and the area of ​​semantic blocks corresponding to each of the multiple semantic categories other than the semantic category; the ratio of the first value to the second value is determined as the weight corresponding to each pixel in the semantic block corresponding to the semantic category; among the multiple semantic categories, the weight corresponding to each pixel in the semantic block corresponding to each semantic category constitutes the target weight corresponding to the semantic contour image.

[0186] Optionally, the second acquisition unit 601 is specifically used to input multiple clean image samples and the noise addition stages corresponding to each of the multiple clean image samples into the noise addition processing algorithm in the initial diffusion model to obtain noise image samples corresponding to each of the multiple clean image samples in the noise addition stage.

[0187] The image denoising model training device 60 provided in an embodiment of the present invention can execute the technical solution of the image denoising model training method in any of the above-mentioned embodiments. Its implementation principle and beneficial effects are similar to the implementation principle and beneficial effects of the image denoising model training method. Please refer to the implementation principle and beneficial effects of the image denoising model training method, which will not be repeated here.

[0188] Figure 7 A schematic diagram of the physical structure of an electronic device provided by an embodiment of the present invention, such as Figure 7 As shown, the electronic device may include: a processor 710, a communication interface 720, a memory 730 and a communication bus 740, wherein the processor 710, the communication interface 720 and the memory 730 communicate with each other through the communication bus 740. The processor 710 may call the logic instructions in the memory 730 to execute the image generation method or the training method of the image denoising model. The image generation method may include: obtaining a noise image to be processed, guidance information corresponding to the noise image, a target noise addition stage and empty guidance information; wherein the guidance information includes a semantic contour image; or the guidance information includes a semantic contour image and a target text; based on the noise image, the guidance information, the target noise addition stage and the empty guidance information, the noise image is denoised to generate a target noise-free image; wherein the image content of the target noise-free image matches the information content of the guidance information more than a first threshold.

[0189] The training method of the image denoising model may include: obtaining multiple clean image samples, the guidance information and the denoising stage corresponding to each of the multiple clean image samples, and the noise image samples corresponding to each of the noise stages; wherein the multiple clean image samples include clean image samples whose corresponding guidance information is non-empty guidance information and clean image samples whose corresponding guidance information is empty guidance information, and the guidance information includes a semantic contour image; or the guidance information includes a semantic contour image and a target text; inputting the noise image samples, the guidance information and the denoising stage corresponding to each of the multiple clean image samples in the denoising stage into the initial image denoising model in the initial diffusion model, and obtaining the mean and variance of the noise contained in the noise image samples corresponding to each of the multiple clean image samples in the denoising stage; updating the model parameters of the initial image denoising model according to the multiple clean image samples and the mean and variance of the noise contained in the noise image samples corresponding to each of the multiple clean image samples in the denoising stage, so as to obtain the image denoising model.

[0190] In addition, the logic instructions in the above-mentioned memory 730 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable 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 method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0191] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the image generation method or the image denoising model training method provided by the above methods. The image generation method may include: obtaining a noise image to be processed, guidance information corresponding to the noise image, a target noise addition stage, and empty guidance information; wherein the guidance information includes a semantic contour image; or, the guidance information includes a semantic contour image and a target text; based on the noise image, the guidance information, the target noise addition stage, and the empty guidance information, the noise image is denoised to generate a target noise-free image; wherein the image content of the target noise-free image matches the information content of the guidance information to a degree greater than a first threshold.

[0192] The training method of the image denoising model may include: obtaining multiple clean image samples, the guidance information and the denoising stage corresponding to each of the multiple clean image samples, and the noise image samples corresponding to each of the noise stages; wherein the multiple clean image samples include clean image samples whose corresponding guidance information is non-empty guidance information and clean image samples whose corresponding guidance information is empty guidance information, and the guidance information includes a semantic contour image; or the guidance information includes a semantic contour image and a target text; inputting the noise image samples, the guidance information and the denoising stage corresponding to each of the multiple clean image samples in the denoising stage into the initial image denoising model in the initial diffusion model, and obtaining the mean and variance of the noise contained in the noise image samples corresponding to each of the multiple clean image samples in the denoising stage; updating the model parameters of the initial image denoising model according to the multiple clean image samples and the mean and variance of the noise contained in the noise image samples corresponding to each of the multiple clean image samples in the denoising stage, so as to obtain the image denoising model.

[0193] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented by the processor to execute the image generation method or the image denoising model training method provided by the above methods. The image generation method may include: obtaining a noise image to be processed, guidance information corresponding to the noise image, a target noise addition stage, and empty guidance information; wherein the guidance information includes a semantic contour image; or the guidance information includes a semantic contour image and a target text; based on the noise image, the guidance information, the target noise addition stage, and the empty guidance information, denoising the noise image to generate a target noise-free image; wherein the image content of the target noise-free image matches the information content of the guidance information to a degree greater than a first threshold.

[0194] The training method of the image denoising model may include: obtaining multiple clean image samples, the guidance information and the denoising stage corresponding to each of the multiple clean image samples, and the noise image samples corresponding to each of the noise stages; wherein the multiple clean image samples include clean image samples whose corresponding guidance information is non-empty guidance information and clean image samples whose corresponding guidance information is empty guidance information, and the guidance information includes a semantic contour image; or the guidance information includes a semantic contour image and a target text; inputting the noise image samples, the guidance information and the denoising stage corresponding to each of the multiple clean image samples in the denoising stage into the initial image denoising model in the initial diffusion model, and obtaining the mean and variance of the noise contained in the noise image samples corresponding to each of the multiple clean image samples in the denoising stage; updating the model parameters of the initial image denoising model according to the multiple clean image samples and the mean and variance of the noise contained in the noise image samples corresponding to each of the multiple clean image samples in the denoising stage, so as to obtain the image denoising model.

[0195] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0196] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0197] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. An image generation method, characterized in that: include: Acquire a noise image to be processed, guidance information corresponding to the noise image, a target noise adding stage and empty guidance information; wherein the guidance information includes a semantic contour image; or the guidance information includes a semantic contour image and a target text; Based on the noise image, the guide information, the target noise adding stage and the empty guide information, the noise image is denoised to generate a target noise-free image; wherein the image content of the target noise-free image matches the information content of the guide information to a degree greater than a first threshold; The step of performing denoising on the noise image based on the noise image, the guidance information, the target noise adding stage and the empty guidance information to generate a target noise-free image includes: S1, inputting the noise image, the guide information and the target noise adding stage into the image denoising model in the diffusion model to obtain a first parameter; and inputting the noise image, the empty guide information and the target noise adding stage into the image denoising model to obtain a second parameter; S2. Generate a noise-free image corresponding to the noise image in the target noise adding stage according to the first parameter and the second parameter; S3, updating the target noise adding stage, and determining whether the updated noise adding stage is equal to a second threshold; S4, when it is determined that the updated noise adding stage is equal to the second threshold, determining the noise-free image corresponding to the noise image at the target noise adding stage as the target noise-free image; S5. When it is determined that the updated noise addition stage is greater than the second threshold, the noise image corresponding to the previous noise addition stage of the target noise addition stage is determined, and the noise image corresponding to the previous noise addition stage is determined as the noise image to be processed, and the updated noise addition stage is determined as the target noise addition stage. The above S1-S5 are repeatedly executed until the updated noise addition stage is equal to the second threshold, and the noise-free image corresponding to the noise image after the updated noise addition stage is determined as the target noise-free image.

2. The image generation method according to claim 1, characterized in that: The first parameter includes a first mean and a first variance, the second parameter includes a second mean, and generating a noise-free image corresponding to the noise image in the target noise adding stage according to the first parameter and the second parameter, comprising: fusing the first mean and the second mean to obtain a corresponding target mean; A noise-free image corresponding to the noisy image in the target noise adding stage is generated according to the target mean and the first variance.

3. The image generation method according to claim 2, characterized in that: The fusing the first mean and the second mean to obtain a corresponding target mean includes: Determine a difference between the first mean and the second mean, and determine a product of the difference and a corresponding weight; The sum of the second mean and the product is determined as the target mean.

4. The image generation method according to any one of claims 1 to 3, characterized in that: The determining of the noise image corresponding to the previous noise adding stage of the target noise adding stage includes: A noise image corresponding to the previous noise adding stage is generated according to the noise image, the noise-free image corresponding to the noise image in the target noise adding stage, and the first variance in the first parameter.

5. The image generation method according to claim 4, characterized in that: The generating, according to the noise image, the noise-free image corresponding to the noise image in the target noise adding stage, and the first variance, a noise image corresponding to the previous noise adding stage comprises: Determine a third mean value according to the noise image, the noise-free image corresponding to the noise image in the target noise adding stage, and the first variance; determining a second variance based on the first variance; A noise image corresponding to the previous noise adding stage is generated according to the third mean and the second variance.

6. A training method for an image denoising model, characterized in that: include: Acquire a plurality of clean image samples, the guide information and noise adding stage corresponding to each of the plurality of clean image samples, and the noise image samples corresponding to each of the noise adding stages; wherein the plurality of clean image samples include clean image samples whose corresponding guide information is non-empty guide information and clean image samples whose corresponding guide information is empty guide information, and the guide information includes a semantic contour image; or the guide information includes a semantic contour image and a target text; Inputting the noise image samples corresponding to each of the multiple clean image samples in the noise adding stage, the guide information and the noise adding stage into the initial image denoising model in the initial diffusion model, and obtaining the mean and variance of the noise contained in the noise image samples corresponding to each of the multiple clean image samples in the noise adding stage; According to the multiple clean image samples and the mean and variance of the noise contained in the noise image samples corresponding to the multiple clean image samples in the noise adding stage, the model parameters of the initial image denoising model are updated to obtain the image denoising model; The updating of the model parameters of the initial image denoising model according to the multiple clean image samples and the mean and variance of the noise contained in the noisy image samples corresponding to the multiple clean image samples in the denoising stage includes: Obtain predicted clean image samples corresponding to the multiple clean image samples in the noisy stage according to the mean and variance of the noise contained in the noisy image samples corresponding to the multiple clean image samples in the noisy stage; updating the model parameters of the initial image denoising model according to the multiple clean image samples and the predicted clean image samples corresponding to the multiple clean image samples in the denoising stage; The updating of the model parameters of the initial image denoising model according to the multiple clean image samples and the predicted clean image samples corresponding to the multiple clean image samples in the denoising stage includes: For each clean image sample, construct the mean square error loss corresponding to the clean image sample according to the mean value of the clean image sample and the mean value of the predicted clean image sample corresponding to the clean image sample in the noisy stage; and construct the variational lower bound loss corresponding to the clean image sample according to the value of the noisy stage and the noisy image sample corresponding to the clean image sample in the noisy stage; determine the target loss corresponding to the clean image sample according to the mean square error loss and the variational lower bound loss corresponding to the clean image sample; The model parameters of the initial image denoising model are updated according to the target loss corresponding to each clean image sample.

7. The method for training an image denoising model according to claim 6, characterized in that: The step of constructing a variational lower bound loss corresponding to the clean image sample according to the value of the noisy stage and the noisy image sample corresponding to the clean image sample in the noisy stage includes: In the case where the value of the noise adding stage is the lower boundary value of the noise adding stage range, a discrete Gaussian mixture likelihood is determined according to the clean image sample, the variance of the clean image sample, and the noise image sample corresponding to the clean image sample in the noise adding stage, and the discrete Gaussian mixture likelihood is determined as the variational lower bound loss corresponding to the clean image sample; In the case where the value of the denoising stage is not a lower boundary value, the corresponding target divergence is determined according to the first predicted noise image sample and the second predicted noise image sample corresponding to the clean image sample in the previous denoising stage of the denoising stage; and based on the target divergence, the variational lower bound loss corresponding to the clean image sample is constructed; wherein the first predicted noise image sample is generated based on the clean image sample, the variance of the clean image sample, and the noise image sample corresponding to the clean image sample in the denoising stage, and the second predicted noise image sample is generated based on the predicted clean image sample corresponding to the clean image sample in the denoising stage, the variance of the predicted clean image sample, and the noise image sample corresponding to the clean image sample in the denoising stage.

8. The method for training an image denoising model according to claim 6 or 7, characterized in that: The semantic contour image corresponding to the clean image sample is a non-empty semantic contour image, and determining the target loss corresponding to the clean image sample according to the mean square error loss and the variational lower bound loss corresponding to the clean image sample includes: According to the semantic category to which each pixel belongs in the semantic contour image corresponding to the clean image sample, the area of ​​the semantic block corresponding to each semantic category among the multiple semantic categories included in the semantic contour image is determined; and according to the area of ​​the semantic block corresponding to each semantic category, the target weight corresponding to the semantic contour image is determined; According to the target weight corresponding to the semantic contour image, determine a first weight corresponding to the mean square error loss and a second weight corresponding to the variational lower bound loss respectively; and determine a first product of the first weight and the mean square error loss, and a second product of the second weight and the variational lower bound loss; A target loss corresponding to the clean image sample is determined according to the first product and the second product.

9. The method for training an image denoising model according to claim 8, characterized in that: The step of determining the target weight corresponding to the semantic contour image according to the area of ​​the semantic block corresponding to each semantic category includes: For each of the semantic categories, a first value is determined according to the area of ​​the semantic block corresponding to the semantic category, and a second value is determined according to the first value and the area of ​​the semantic blocks corresponding to other semantic categories among the multiple semantic categories except the semantic category; a ratio of the first value to the second value is determined as the weight corresponding to each pixel in the semantic block corresponding to the semantic category; Among the multiple semantic categories, the weight corresponding to each pixel in the semantic block corresponding to each semantic category constitutes the target weight corresponding to the semantic contour image.

10. The method for training an image denoising model according to claim 6 or 7, characterized in that: Obtaining the noise image samples corresponding to each of the plurality of clean image samples in the noise adding stage, comprising: The multiple clean image samples and the noise addition stages corresponding to the multiple clean image samples are input into the noise addition processing algorithm in the initial diffusion model to obtain noise image samples corresponding to the multiple clean image samples in the noise addition stages.

11. An image generating device, characterized in that: include: A first acquisition unit is used to acquire a noise image to be processed, guidance information corresponding to the noise image, a target noise addition stage and empty guidance information; wherein the guidance information includes a semantic contour image; or the guidance information includes a semantic contour image and a target text; A generating unit, configured to perform denoising processing on the noise image based on the noise image, the guide information, the target noise adding stage and the empty guide information to generate a target noise-free image; wherein the image content of the target noise-free image matches the information content of the guide information to a degree greater than a first threshold; The step of performing denoising on the noise image based on the noise image, the guidance information, the target noise adding stage and the empty guidance information to generate a target noise-free image includes: S1, inputting the noise image, the guide information and the target noise adding stage into the image denoising model in the diffusion model to obtain a first parameter; and inputting the noise image, the empty guide information and the target noise adding stage into the image denoising model to obtain a second parameter; S2. Generate a noise-free image corresponding to the noise image in the target noise adding stage according to the first parameter and the second parameter; S3, updating the target noise adding stage, and determining whether the updated noise adding stage is equal to a second threshold; S4, when it is determined that the updated noise adding stage is equal to the second threshold, determining the noise-free image corresponding to the noise image at the target noise adding stage as the target noise-free image; S5. When it is determined that the updated noise addition stage is greater than the second threshold, the noise image corresponding to the previous noise addition stage of the target noise addition stage is determined, and the noise image corresponding to the previous noise addition stage is determined as the noise image to be processed, and the updated noise addition stage is determined as the target noise addition stage. The above S1-S5 are repeatedly executed until the updated noise addition stage is equal to the second threshold, and the noise-free image corresponding to the noise image after the updated noise addition stage is determined as the target noise-free image.

12. A training device for an image denoising model, characterized in that: include: A second acquisition unit is used to acquire a plurality of clean image samples, the guide information and the noise adding stage corresponding to each of the plurality of clean image samples, and the noise image samples corresponding to each of the noise adding stages; wherein the plurality of clean image samples include clean image samples whose corresponding guide information is non-empty guide information and clean image samples whose corresponding guide information is empty guide information, and the guide information includes a semantic contour image; or the guide information includes a semantic contour image and a target text; A first generating unit is used to input the noise image samples corresponding to each of the multiple clean image samples in the noise adding stage, the guide information and the noise adding stage into the initial image denoising model in the initial diffusion model, and obtain the mean and variance of the noise contained in the noise image samples corresponding to each of the multiple clean image samples in the noise adding stage; A second generating unit is used to update the model parameters of the initial image denoising model according to the multiple clean image samples and the mean and variance of the noise contained in the noise image samples corresponding to the multiple clean image samples in the denoising stage, so as to obtain the image denoising model; The updating of the model parameters of the initial image denoising model according to the multiple clean image samples and the mean and variance of the noise contained in the noisy image samples corresponding to the multiple clean image samples in the denoising stage includes: Obtain predicted clean image samples corresponding to the multiple clean image samples in the noisy stage according to the mean and variance of the noise contained in the noisy image samples corresponding to the multiple clean image samples in the noisy stage; updating the model parameters of the initial image denoising model according to the multiple clean image samples and the predicted clean image samples corresponding to the multiple clean image samples in the denoising stage; The updating of the model parameters of the initial image denoising model according to the multiple clean image samples and the predicted clean image samples corresponding to the multiple clean image samples in the denoising stage includes: For each clean image sample, construct the mean square error loss corresponding to the clean image sample according to the mean value of the clean image sample and the mean value of the predicted clean image sample corresponding to the clean image sample in the noisy stage; and construct the variational lower bound loss corresponding to the clean image sample according to the value of the noisy stage and the noisy image sample corresponding to the clean image sample in the noisy stage; determine the target loss corresponding to the clean image sample according to the mean square error loss and the variational lower bound loss corresponding to the clean image sample; The model parameters of the initial image denoising model are updated according to the target loss corresponding to each clean image sample.

13. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, it implements the image generation method as described in any one of claims 1 to 5, or implements the image denoising model training method as described in any one of claims 6 to 10.

14. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, it implements the image generation method as described in any one of claims 1 to 5, or implements the image denoising model training method as described in any one of claims 6 to 10.