Image generation method and apparatus
By training and masking the image generation model, the confusion problem of the diffusion model in multi-concept text generation is solved, the accuracy of image generation is improved, and the generated image is ensured to contain multiple types of entity objects.
Patent Information
- Application Number
- PCT/SG2024/050213
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-04-28
- Filing Date
- 2024-04-01
- Publication Date
- 2024-10-31
AI Technical Summary
When existing images are generated based on diffusion models, confusion easily occurs when facing multi-concept texts, resulting in generated images that do not meet user needs and have low accuracy.
By obtaining the target text, inputting the image generation model, training the pre-trained image generation model based on the sample text containing at least two types of entity information, masking the neurons in each iteration, using the target threshold to adjust the network parameters, reducing The sparsity of image feature generation improves the accuracy of generation.
It achieves higher accuracy of the image generation model, ensuring that the generated images are more in line with user needs and contain multiple types of entity objects.
Smart Images

Figure SG2024050213_31102024_PF_FP_ABST
Abstract
Description
[0001]Image Generation Method and Apparatus Cross-Reference This disclosure claims priority to Chinese patent application No. 202310493536.0, filed with the China Patent Office on April 28, 2023, entitled "Image Generation Method and Apparatus," the entire contents of which are incorporated herein by reference. Technical Field The present disclosure relates to the field of computer technology, and more particularly to an image generation method. Background Art With the continuous advancement of image processing technology, the method of generating images from text based on trained diffusion models has greatly improved image generation efficiency and reduced the time users spend generating images. Currently, generating single-concept images based on diffusion models is effective, for example, generating an image containing a dog based on the text "a dog." However, when text contains multiple concepts, such as generating images containing both a cat and a dog, the image output by the diffusion model may be confusing, resulting in the generated image not meeting user requirements. Therefore, there is a need to provide a more reliable image generation method to improve the accuracy of the image output by the model. SUMMARY OF THE INVENTION In view of this, the present disclosure provides an image generation method. One or more embodiments of the present disclosure relate to an image generation apparatus, an image generation model training method, a target image generation method, a computing device, a computer-readable storage medium, and a computer program to address technical deficiencies in the prior art. According to a first aspect of an embodiment of the present disclosure, an image generation method is provided, comprising: obtaining target text; inputting the target text into an image generation model; and obtaining a target image corresponding to the target text based on the correspondence between entity information and neurons learned by the image generation model. The image generation model is obtained by training a pretrained image generation model based on sample text containing at least two types of entity information. In each iteration of the training, neurons in the pretrained image generation model are masked based on a target threshold, where the target threshold is determined based on a steamed filling loss value, a network parameter of the pretrained image generation model. According to a second aspect of an embodiment of the present disclosure, an image generation device is provided, comprising: an acquisition module configured to acquire a target text; an input module configured to input the target text into an image generation model, and obtain a target image corresponding to the target text based on a correspondence between entity information and neurons learned by the image generation model, wherein the image generation model is obtained by training a pre-trained image generation model based on sample text containing at least two types of entity information, and in each iteration of the training, the neurons in the pre-trained image generation model are masked based on a target threshold, and the target threshold is determined based on a steaming loss value of a network parameter of the pre-trained image generation model.According to a third aspect of an embodiment of the present disclosure, an image generation model training method is provided, which is applied to a cloud-side device and includes: obtaining a sample pair, wherein the sample pair includes a sample text and a sample label, the sample text includes at least two types of entity information, and the sample label is a sample image; inputting the sample pair into a pre-trained image generation model to obtain a predicted image, wherein the predicted image includes an entity object generated based on various types of entity information; obtaining initial network parameters and target network parameters corresponding to the pre-trained image generation model, and calculating a model loss value based on the sample image, the predicted image, the initial network parameters, and the target network parameters; adjusting the network parameters of the pre-trained image generation model based on the model loss value until a trained image generation model is obtained; and returning the model parameters of the image generation model to the end-side device in response to a model acquisition request sent by an end-side device. According to a fourth aspect of an embodiment of the present disclosure, another image generation method is provided, which is applied to a cloud-side device and includes: receiving target text sent by an end-side device; inputting the target text into an image generation model, and obtaining a target image corresponding to the target text based on a correspondence between entity information and neurons learned by the image generation model, wherein the image generation model is obtained by training a pre-trained image generation model based on sample text containing at least two types of entity information, and in each iteration of the training, masking the neurons in the pre-trained image generation model based on a target threshold, wherein the target threshold is determined based on a network parameter steam loss value of the pre-trained image generation model; and returning the target image to the end-side device. According to a fifth aspect of the embodiments of the present disclosure, a target image generation method is provided, comprising: obtaining target text, wherein the target text contains at least two types of entity information; inputting the target text into an image generation model, and obtaining a target image corresponding to the target text based on the correspondence between entity information and neurons learned by the image generation model, wherein the target image contains at least two types of entity objects; the image generation model is obtained by training a pre-trained image generation model based on sample text containing at least two types of entity information; in each iteration of the training, masking neurons in the pre-trained image generation model based on a target threshold, wherein the target threshold is determined based on a network parameter steaming loss of the pre-trained image generation model. According to a sixth aspect of the embodiments of the present disclosure, a computing device is provided, comprising: a memory and a processor; the memory is configured to store computer-executable instructions, and the processor is configured to execute the computer-executable instructions, wherein the computer-executable instructions, when executed by the processor, implement the steps of the above-mentioned image generation method.According to a seventh aspect of the embodiments of the present disclosure, a computer-readable storage medium is provided, storing computer-executable instructions. When executed by a processor, the instructions implement the steps of the aforementioned image generation method. According to an eighth aspect of the embodiments of the present disclosure, a computer program is provided. When executed on a computer, the computer is caused to perform the steps of the aforementioned image generation method. One embodiment of the present disclosure implements obtaining a target text; inputting the target text into an image generation model; and obtaining a target image corresponding to the target text based on the correspondence between entity information and neurons learned by the image generation model. The image generation model is obtained by training a pre-trained image generation model based on sample text containing at least two types of entity information. In each iteration of the training, neurons in the pre-trained image generation model are masked based on a target threshold, where the target threshold is determined based on a steamed filling loss value, a network parameter of the pre-trained image generation model. By masking the neurons in the pre-trained image generation model during the training of the image processing model, the network parameters are selectively used, the sparsity of image feature generation is reduced, and the generation accuracy of the image generation model is improved. The target text is then input into the trained image generation model to obtain a target image with higher accuracy. BRIEF DESCRIPTION OF THE DRAWINGS FIG1 is a schematic diagram of a scenario of an image generation method provided by one embodiment of the present disclosure; FIG2 is a flowchart of an image generation method provided by one embodiment of the present disclosure; FIG3 is a flowchart of an image generation model training method provided by one embodiment of the present disclosure; FIG4 is a flowchart of another image generation training method provided by one embodiment of the present disclosure; FIG5 is a flowchart of the processing process of a target image generation method provided by one embodiment of the present disclosure; FIG6 is a schematic diagram of the structure of an image generation apparatus provided by one embodiment of the present disclosure; and FIG7 is a block diagram of the structure of a computing device provided by one embodiment of the present disclosure. DETAILED DESCRIPTION The following description sets forth numerous specific details to facilitate a thorough understanding of the present disclosure. However, the present disclosure can be implemented in many other ways than those described herein, and those skilled in the art may make similar generalizations without departing from the scope of the present disclosure. Therefore, the present disclosure is not limited to the specific implementations disclosed below. The terminology used in one or more embodiments of the present disclosure is for the purpose of describing specific embodiments and is not intended to limit the present disclosure. As used in one or more embodiments of the present disclosure and the appended claims, the singular forms "a," "an," "the," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.It should also be understood that the terms 'first' and / or 'second' used in one or more embodiments of the present disclosure refer to and encompass any and all possible combinations of one or more associated listed items. It should be understood that while terms such as 'first', 'second', and so on may be used to describe various information in one or more embodiments of the present disclosure, such information should not be limited to these terms. These terms are used to distinguish information of the same type from one another. For example, 'first' could also be referred to as 'second', and similarly, 'second' could also be referred to as 'first', without departing from the scope of one or more embodiments of the present disclosure. Depending on the context, the term "if" as used herein can be interpreted as "at the time of," "when," or "in response to a determination." Furthermore, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, and displayed data, etc.) involved in one or more embodiments of this disclosure are all authorized by the user or fully authorized by all parties. The collection, use, and processing of relevant data must comply with the relevant laws, regulations, and standards of relevant countries and regions, and corresponding operation portals are provided for users to choose to authorize or refuse. First, the terms used in one or more embodiments of this disclosure are explained. Diffusion model: A diffusion model is a parametric neural network that learns image distributions through gradual denoising. Inspired by non-equilibrium thermodynamics, it is a new SOTA in deep generative models. Customized Generation: A task that generates relevant concepts given by the user. Image noise: Image noise refers to unnecessary or redundant interference information present in image data. To further explore the scalability of the diffusion model, Numerous works have been devoted to diffusion-based conditional generation, which can be roughly divided into two categories. The first, known as classifier-guided methods, utilize classifiers to facilitate the sampling process of pre-trained unconditional models. The second, known as classifier-free methods, directly collect large amounts of data for joint optimization under the guarantee of conditional probability inference. This approach can produce highly detailed results but requires a large amount of data and computational resources. Advances in language and cross-modal grounding models have led to the emergence of numerous text-to-image works using classifier-free techniques, facilitating explicit control over semantics and style. However, the expressive power of text remains limited, and more work aims to leverage additional, conditional information such as reference images, backgrounds, and sketches to further guide global control. Diffusion models for text-to-image use textual cues describing image content to guide this denoising process.Typically, this is achieved by training a custom generation model by denoising a noisy image. A given topic is then embedded into the diffusion model and associated with a unique text identifier to indicate its presence. This allows the model to generate various representations of the topic under the guidance of the text prompt. This disclosure also provides an image generation method, an image generation apparatus, a computing device, and a computer-readable storage medium, each of which is described in detail in the following embodiments. 1 shows a schematic diagram of an image generation method according to an embodiment of the present disclosure. The specific image generation process is as follows: The client-side device in FIG1 obtains an image generation request generated by a user based on target text. Specifically, the client-side device can implement interaction with the user and display the interaction results, such as a laptop, desktop computer, tablet computer, smart device, etc., and the specific form of the client-side device is not specifically limited. In this embodiment, the target text is "a dog and a cat," that is, the target text is text containing multiple types of entity information. The client-side device sends the obtained image generation request to the cloud-side device. Specifically, the cloud-side device can be a device that trains and stores image generation models. Based on the image generation request, the cloud-side device can query the model parameters stored on the cloud-side device for model parameters corresponding to the image generation request and return the model parameters to the client-side device. Based on the image generation request, the cloud-side device queries the model parameters of the trained image generation model and returns the model parameters to the client-side device. The client-side device receives the model parameters. The image generation model trained by the cloud-side device is called based on the model parameters, so that the cloud-side device inputs the target text into the image generation model to obtain the target image output by the image generation model, where the output target image contains two entities, a cat and a dog.To ensure the processing accuracy of the image generation model, the cloud-side device trains the image generation model based on the following method: obtaining a sample set, wherein the sample set includes sample pairs; the sample pairs include sample text and sample labels, where the sample text is text containing at least two types of entity information, and the sample label is a sample image corresponding to the sample text; obtaining a pre-trained image generation model, which is a model that has been trained and has the function of outputting corresponding images based on input text; to enable the pre-trained image generation model to output images with higher accuracy, the method disclosed herein further adjusts the pre-trained image generation model based on the sample set, namely, after normalizing the prompt text, i.e., the sample text, the pre-trained image generation model is input into the text embedding layer. The specific process is as follows: setting a weight threshold and determining the network parameters corresponding to the pre-trained image generation model. The weight threshold can be set based on the project scenario or randomly; selecting a network parameter from the network parameters whose corresponding weight value is less than the weight threshold as the target network parameter; performing a masking operation on the target network parameter, i.e., adjusting the network weight corresponding to the target network parameter to 0; determining the target sample pair in the sample set, The sample text containing at least two types of entity information in the sample pair is input into the pre-trained image generation model; and a predicted image output by the pre-trained image generation model is determined. Obtain the initial network parameters and target network parameters corresponding to the pre-trained image generation model, and calculate the network parameter steaming loss based on the initial network parameters and the target network parameters; obtain the sample noise corresponding to the sample image in the sample pair and the predicted noise of the predicted image output by the pre-trained image generation model, and calculate the noise loss based on the sample noise and the predicted noise; generate associated text based on the sample text, and input the associated text into the pre-trained image generation model to obtain a prior image; for example, if the sample text is "a standing dog", the associated text may be "a lying dog"; calculate the prior loss based on the prior image and the predicted image; use the sum of the noise loss, the network parameter steaming loss, and the prior loss as the model loss, and adjust the weight threshold based on the model loss to obtain a target weight threshold, i.e., the weight threshold obtained in this round of training; obtain the current network parameters corresponding to the pre-trained image generation model based on the weight threshold; among the current network parameters, filter the target network parameters whose weight values are less than the target weight threshold based on the target weight threshold, thereby performing a masking operation on the target network parameters; again determine a new sample pair from the sample set, The next round of model training is carried out, and the above training steps are repeated until the model training stops and adjustments are made, a trained image generation model is obtained, and the image generation model is stored.The image generation method disclosed herein obtains target text; inputs the target text into an image generation model; and obtains a target image corresponding to the target text based on the correspondence between entity information and neurons learned by the image generation model. The image generation model is obtained by training a pre-trained image generation model based on sample text containing at least two types of entity information. In each iteration of the training, neurons in the pre-trained image generation model are masked based on a target threshold, where the target threshold is determined based on the network parameter loss of the pre-trained image generation model. By masking the neurons in the pre-trained image generation model during the training of the image processing model, selective use of network parameters is achieved, reducing the sparseness of image feature generation and improving the generation accuracy of the image generation model. The target text is input into the trained image generation model to obtain a target image with higher accuracy. Referring to FIG. 2 , FIG. 2 shows a flowchart of an image generation method provided according to an embodiment of the present disclosure, specifically comprising the following steps: Step 202: Obtain target text. The target text refers to the text set to generate the corresponding target image. The target text can be user-written based on needs, extracted from existing text, randomly generated using a text synthesizer, and so on. In practical applications, the target text can contain one, two, or multiple types of entity information. For example, if the target text is "a dog," the target text contains one type of entity information. Another example is if the target text is "a stream, a cat, and a dog," the target text contains three types of entity information. Specifically, an image generation request is obtained; the image generation request is parsed to obtain the target text or target text identifier set to generate the image. If the target text is obtained, subsequent operations can be performed directly. If the target text identifier is obtained, the target text can be obtained from the corresponding text source based on the target text identifier. In a specific embodiment of the present disclosure, the terminal receives the target text "a cat" input by the user, triggers the image generation operation at the first level, and generates an image generation request. The image generation request is then parsed to determine the target text set to generate the image. By obtaining the target text, it is convenient to subsequently generate the corresponding image based on the determined target text.Step 204: Input the target text into an image generation model. Based on the correspondence between entity information and neurons learned by the image generation model, obtain a target image corresponding to the target text. The image generation model is obtained by training a pre-trained image generation model based on sample text containing at least two types of entity information. In each iteration of the training, the neurons in the pre-trained image generation model are masked based on a target threshold value. The target threshold value is determined based on the network parameter loss value of the pre-trained image generation model. In practical applications, after determining the target text, the target text is input into the image generation model, thereby completing image generation based on the image generation model. The image generation model is obtained by training a pre-trained image generation model based on sample text containing at least two types of entity information. In each iteration of the training, neurons in the pre-trained image generation model are masked based on a target threshold. Neurons refer to a set of network parameters of the image generation model, and the network parameter set includes one or more network parameters. The target threshold is determined based on a network parameter loss value of the pre-trained image generation model. The target image refers to an image output by the image processing model based on the target text. Entity information refers to information corresponding to an entity contained in the sample text. The sample text is text used to train the image generation model. The pre-trained image generation model refers to a model that, through pre-training, enables the model to output a corresponding image based on the input text. The target threshold refers to a threshold set for screening target network parameters that need to be adjusted among the network parameters. Masking refers to adjusting the weight values of the network parameters to 0. The network parameter loss value refers to the loss value between the network parameters of the model. Specifically, the determined target text is input into a trained image generation model to obtain a target image output by the image processing model. The image processing model is obtained by training a pre-trained image generation model based on sample text containing at least two types of entity information. During each training iteration, neurons in the pre-trained image generation model are masked based on a target threshold value determined based on a network parameter steaming loss value of the pre-trained image generation model. In one embodiment of the present disclosure, a target text "a cat" and a trained image generation model are determined. The image processing model is obtained by training the pre-trained image generation model based on sample text containing at least two types of entity information. During each training iteration, neurons in the pre-trained image generation model are masked based on a target threshold value determined based on a network parameter steaming loss value of the pre-trained image generation model. The target text is input into the image generation model to obtain a target image output by the image generation model, wherein the target image contains a cat.The above describes the application process of the image generation model. To ensure that the image generation model has high processing accuracy even for models containing multiple types of entity information, the image processing model is trained on a pre-trained image generation model based on sample text containing at least two types of entity information. In each training iteration, the neurons in the pre-trained image generation model are masked based on a target threshold. The target threshold is determined based on the evaporation loss value of the network parameters of the pre-trained image generation model. Specifically, before inputting the target text into the image generation model, the method further includes: obtaining a sample pair, wherein the sample pair includes a sample text and a sample label, the sample text is a text including at least two types of entity information, and the sample label is a sample image; inputting the sample text including at least two types of entity information into a pre-trained image generation model to obtain a predicted image, wherein the predicted image includes entity objects corresponding to each type of entity information; obtaining initial network parameters and target network parameters corresponding to the pre-trained image generation model, and calculating a model loss value based on the sample image, the predicted image, the initial network parameters, and the target network parameters; and adjusting the network parameters of the pre-trained image generation model based on the model loss value until a trained image generation model is obtained. Here, a sample pair refers to a data pair consisting of a sample text and a sample label; the sample text contains at least two types of entity information, for example, the sample text is "a dog and a cat", and another example is "a dog, a cat and a person"; the sample image refers to the image corresponding to the sample text, for example, if the sample text is "a white dog", then the entity object in the sample image is a white dog; the predicted image refers to the image output by the pre-trained image generation model based on the sample text; the initial network parameters refer to the initial values of the network parameters of the pre-trained image generation model, that is, the network parameters before model training, for example, the initial values of the network parameters are 0; the target network parameters refer to the network parameters of the pre-trained image generation model after training; and the model loss value refers to the loss value set to adjust the network parameters of the image generation model.Specifically, a pre-trained image generation model and a sample set are obtained; the sample set includes sample pairs, the sample pairs include sample text and sample labels, the sample text includes at least two types of entity information, and the sample label is a sample image corresponding to the sample text; a target sample pair is determined in the sample set, and the sample text containing at least two types of entity information in the target sample pair is input into the pre-trained image generation model to obtain an output predicted image; initial network parameters and target network parameters corresponding to the pre-trained image generation model are obtained; a model loss value is calculated based on the sample image, the predicted image, the initial network parameters, and the target network parameters; and the network parameters of the pre-trained image generation model are adjusted based on the model loss value until a stop condition for model training is met, thereby completing the adjustment of the pre-trained image generation model and obtaining an image generation model. In a specific embodiment of the present disclosure, a sample pair H and a pre-trained image generation model are obtained from a sample set, where the sample pair H includes sample text and a sample image. The sample text "a dog and a cat" in the sample pair H is input into the pre-trained image generation model to obtain a predicted image. Initial network parameters and target network parameters of the pre-trained image generation model are obtained. A model loss value is calculated based on the initial network parameters, target network parameters, the sample image, and the predicted image. The network parameters of the pre-trained image generation model are adjusted based on the model loss value until a trained image generation model is obtained. By obtaining the initial network parameters and target network parameters and calculating the model loss value based on the initial network parameters, target network parameters, the sample image, and the predicted image, the network parameters of the image processing model can be adjusted based on the model loss value, which includes the loss between the network parameters. This reduces semantic drift and thereby improves the accuracy of subsequent image generation from text by the image generation model. In practical applications, image generation models are typically diffusion models. Diffusion models achieve the effect of text-based image generation through a process of adding and reducing noise. Therefore, during the training of the image processing model, the loss value generated by noise needs to be considered. Specifically, before calculating the model loss value based on the sample image, the predicted image, the initial network parameters, and the target network parameters, the method further includes: determining sample noise corresponding to the sample image and predicted noise corresponding to the predicted image. The predicted noise is output by the pre-trained image generation model based on the sample text containing at least two types of entity information. In practical applications, a noise label, i.e., the sample noise corresponding to the sample image, can be pre-set for the sample image. The pre-trained image generation model calculates the predicted noise during the process of generating the predicted image. In other words, the pre-trained image generation model can output the predicted image and the predicted noise.Accordingly, calculating the loss value based on the sample image, the predicted image, the initial network parameters, and the target network parameters includes: The features of the prior image when t is t are obtained. In a specific embodiment of the present disclosure, a priori loss value si, a noise loss value s2, and a network parameter evaporation loss value S3 are determined; the sum of the priori loss value, the noise loss value, and the network parameter evaporation loss value s = s1 + s2 + s3 is calculated and used as the model loss value. In practical applications, before inputting the sample image into the pre-trained image generation model, the method further includes: determining the network parameters of the pre-trained image generation model and the weight values corresponding to the network parameters; screening the network parameters for weight values less than a weight threshold as target network parameters; and performing a masking operation on the target network parameters. The weight value refers to the weight applied in feature calculation based on the network parameters, for example, the weight value corresponding to network parameter a is 0.4, the weight value corresponding to network parameter b is 0.6, and so on; the weight threshold refers to the threshold of the network parameter weight value; if the weight value of a network parameter is less than the weight threshold, the network parameter is designated as a network parameter requiring masking. Specifically, the network parameters corresponding to the pre-trained image generation model are determined, and the weight values corresponding to each network parameter are obtained; a weight threshold is obtained, which can be set based on needs and is not specifically limited in this disclosure; network parameters whose weight values are less than the weight threshold are selected from the network parameters corresponding to the pre-trained image generation model as target network parameters; and a masking operation is performed on each target network parameter, i.e., the weight values corresponding to each target network parameter are adjusted to 0. In one specific embodiment of the present disclosure, the network parameters and weight values of the pre-trained image generation model are determined as follows: network parameter c1 and a weight value of 0.2, network parameter c2 and a weight value of 0.5, and network parameter c3 and a weight value of 0.3 are determined; a weight threshold of 0.25 is obtained, network parameter c1 with a weight value less than the weight threshold is screened, and a masking operation is performed on network parameter c1, adjusting the weight value 0.2 to 0. The above-described process preprocesses the pre-trained image processing model based on a weight threshold. After subsequently calculating a model loss value, the weight threshold can be adjusted based on the model loss value, thereby selecting network parameters requiring masking based on the obtained target weight threshold. Specifically, adjusting the network parameters of the pre-trained image generation model based on the model loss value includes: adjusting the weight threshold based on the model loss value to obtain a target weight threshold; determining the current network parameters of the pre-trained image generation model and the weight values corresponding to the current network parameters; selecting the current network parameters whose weight values are less than the target weight threshold as target network parameters; and performing a masking operation on the target network parameters.The target weight threshold is obtained by adjusting the weight threshold based on the model loss value; the current network parameters refer to the network parameters of the pre-trained image generation model; in practical applications, during the training process of the image generation model, the weight threshold is adjusted based on the model loss value, so that the image generation model can learn the mapping relationship between different entity information in the sample text and neurons, that is, determine which neurons are used to generate the image. Specifically, after calculating and obtaining the model loss value, the preset weight threshold is adjusted based on the model loss value to obtain a target weight threshold; the current network parameters of the pre-trained image generation model and the weight values corresponding to the current network parameters are determined; the target network parameters whose weight values are less than the target weight threshold are selected from the current network parameters, and a mask operation is performed on the target network parameters, that is, the weight values of the adjusted target network parameters are adjusted to 0. In a specific embodiment of the present disclosure, the weight threshold of 0.2 is adjusted to the target weight threshold of 0.3 based on the model loss value e; the current network parameters corresponding to the pre-trained image generation model are determined, that is, the network parameters remaining after masking the network parameters with weight values less than the weight threshold by the weight threshold; the weight values corresponding to each current network parameter are determined, the current network parameters with weight values less than the target weight threshold of 0.3 are screened from the current network parameters as the target network parameters, and the mask operation is performed on the target network parameters. The weight threshold is adjusted based on the model loss value to obtain a target weight threshold. The target network parameters are then selected based on the target weight threshold, and the weight values of the target network parameters are adjusted. This allows the image generation model to utilize some of the network parameters during image generation without adjusting the network parameters themselves. In practical applications, the network parameters corresponding to the pre-trained image generation model can be used to determine the concept neurons (i.e., the network parameters requiring masking) using the following formula 4. The mask corresponding to the concept neural network can then be determined using the following formula 5. k+ 1 = 0 k O (1 - pO k o V s £ cosl (0 fe )) Formula 4 Parameters, where * represents the K-th network parameter. In practical applications, in order to make the image generation model have higher generation accuracy and be able to generate images containing multiple concepts, the concept neurons can be further fine-tuned after connecting multiple concepts, thereby avoiding retraining the image generation model. Specifically, an image processing model that can generate corresponding images based on single-concept texts is determined. Each image processing model can generate images for different concepts. For example, image generation model a and image generation model b are determined. Image generation model a can generate an image containing a dog based on the text "a dog", and image generation model b can generate an image containing a person based on the text "a dancing person". Then, the network parameters of each image generation model can be spliced to jointly adjust the target network parameters and achieve the training of each image generation model, so that each image generation model can output an image containing multiple entity objects based on a text containing multiple types of entity information. For example, the network parameters of image generation model a and image generation model b are jointly trained, so that the trained image generation model a and image generation model b can both generate images containing multiple entity objects based on a text containing multiple types of entity information. The specific steps of determining the target network parameters and masking the target network parameters are the same as the above steps and will not be elaborated here. By jointly training the trained image processing models, compared with the method of retraining a new image generation model, the processing effect is stable and the processing efficiency is higher. The image generation method of the present disclosure obtains a target text; inputs the target text into an image generation model, and obtains a target image corresponding to the target text based on the corresponding relationship between the entity information learned by the image generation model and the neurons, where the image generation model is trained based on a sample text containing at least two types of entity information for a pre-trained image generation model, and in each iteration of the training, neurons in the pre-trained image generation model are masked based on a target threshold, and the target threshold is determined based on the distillation loss value of the network parameters of the pre-trained image generation model. By masking the neurons in the pre-trained image generation model during the training of the image processing model, the selective use of network parameters is achieved, the sparsity of image feature generation is reduced, and the generation accuracy of the image generation model is improved; the target text is input into the trained image generation model to obtain a target image with higher accuracy. Refer to FIG. 3, which shows a flowchart of an image generation model training method according to an embodiment of the present disclosure, applied to a cloud-side device, and specifically includes the following steps.Step 302: Obtain a sample pair, wherein the sample pair includes sample text and a sample label, wherein the sample text includes at least two types of entity information, and the sample label is a sample image. Step 304: Input the sample pair into a pre-trained image generation model to obtain a predicted image, wherein the predicted image includes entity objects generated based on the various types of entity information. Step 306: Obtain initial network parameters and target network parameters corresponding to the pre-trained image generation model, and calculate a model loss value based on the sample image, the predicted image, the initial network parameters, and the target network parameters. Step 308: Adjust the network parameters of the pre-trained image generation model based on the model loss value until a trained image generation model is obtained. Step 310: In response to a model acquisition request sent by a client-side device, return the model parameters of the image generation model to the client-side device. Specifically, the cloud-side device trains the pre-trained image generation model based on sample pairs in the sample set to obtain a trained image generation model. The user can send a model acquisition request to the cloud-side device through the end-side device. Based on the acquisition request, the cloud-side device returns the model parameters of the trained image generation model to the end-side device. The end-side device can complete image generation by calling the image generation model of the cloud-side device, avoiding occupying the computing resources of the end-side device for model training and reducing the computing pressure on the end-side device. The image generation model training method disclosed herein obtains a sample pair, wherein the sample pair includes sample text and a sample label, the sample text includes at least two types of entity information, and the sample label is a sample image; inputs the sample pair into a pretrained image generation model to obtain a predicted image, wherein the predicted image includes entity objects generated based on various types of entity information; obtains initial network parameters and target network parameters corresponding to the pretrained image generation model, and calculates a model loss value based on the sample image, the predicted image, the initial network parameters, and the target network parameters; adjusts the network parameters of the pretrained image generation model based on the model loss value until a trained image generation model is obtained; and returns the model parameters of the image generation model to the end-side device in response to a model acquisition request sent by an end-side device. By masking neurons in the pretrained image generation model and training the model based on sample text containing at least two types of entity information, selective use of network parameters is achieved, reducing the sparsity of image feature generation, and improving the generation accuracy of the image generation model. 4 , which shows a flowchart of another image generation training method provided according to an embodiment of the present disclosure, which is applied to a cloud-side device and specifically includes the following steps.Step 402: Receive target text sent by the client-side device. Step 404: Input the target text into an image generation model. Based on the correspondence between entity information and neurons learned by the image generation model, obtain a target image corresponding to the target text. The image generation model is obtained by training a pre-trained image generation model based on sample text containing at least two types of entity information. In each iteration of the training, the neurons in the pre-trained image generation model are masked based on a target threshold, where the target threshold is determined based on the steamed filling loss value of the network parameters of the pre-trained image generation model. Step 406: Return the target image to the client-side device. Specifically, a user can send a model acquisition request containing the target text to a cloud-side device via the client-side device. The cloud-side device returns the model parameters of the trained image generation model to the client-side device based on the acquisition request. The client-side device uses the model parameters to call the trained image generation model. The target image is generated by the cloud-side device and returned to the client-side device, avoiding consuming the client-side device's computing resources for model application and reducing the computing pressure on the client-side device. The following, with reference to FIG5 , further illustrates the image generation method provided by the present disclosure, using its application to target text as an example. FIG5 shows a flowchart of a process for a target image generation method provided by one embodiment of the present disclosure, specifically comprising the following steps: Step 502: Obtain target text, wherein the target text contains at least two types of entity information. Step 504: Input the target text into an image generation model, and based on the correspondence between entity information and neurons learned by the image generation model, obtain a target image corresponding to the target text, wherein the target image contains at least two types of entity objects. The image generation model is obtained by training a pre-trained image generation model based on sample text containing at least two types of entity information. In each iteration of the training, neurons in the pre-trained image generation model are masked based on a target threshold, wherein the target threshold is determined based on the network parameter steaming loss of the pre-trained image generation model. Specifically, the image generation method of the present disclosure, based on the image generation model, can process target text containing multiple types of entity information, thereby enabling the image generation model to output an image containing multiple types of entity objects. In order to further improve the accuracy of the image generation model, after obtaining the target image corresponding to the target text, the method further includes: sending the target image to the user; receiving feedback information from the user regarding the target image; and adjusting the image generation model according to the feedback information.Feedback information refers to information generated by the user based on the target image output by the model. For example, feedback information may include: the pose of a person in the image is inconsistent with the text input to the image generation model. Specifically, after displaying the target image to the user, user feedback regarding the target image is obtained; based on the feedback information, the trained image generation model is further fine-tuned to continuously improve the image generation accuracy of the image generation model, making the output image more consistent with the text input by the user. The image generation method disclosed herein obtains target text, wherein the target text contains at least two types of entity information; inputs the target text into an image generation model; and obtains a target image corresponding to the target text based on the correspondence between entity information and neurons learned by the image generation model, wherein the target image contains at least two types of entity objects; the image generation model is obtained by training a pre-trained image generation model based on sample text containing at least two types of entity information. In each iteration of the training, neurons in the pre-trained image generation model are masked based on a target threshold, where the target threshold is determined based on the steaming loss of the network parameters of the pre-trained image generation model. During the training of the image processing model, neurons in the pre-trained image generation model are masked, enabling selective use of network parameters, reducing the sparsity of image feature generation, and improving the generation accuracy of the image generation model. Inputting target text containing at least two types of entity information into the trained image generation model yields a more accurate target image that contains entity objects corresponding to each type of entity information. Corresponding to the aforementioned method embodiments, the present disclosure also provides an embodiment of an image generation device. Figure 6 shows a schematic structural diagram of an image generation device provided by one embodiment of the present disclosure. As shown in Figure 6, the device includes: an acquisition module 602, configured to acquire target text; an input module 604, configured to input the target text into an image generation model, and obtain a target image corresponding to the target text based on the correspondence between entity information and neurons learned by the image generation model, wherein the image generation model is obtained by training a pre-trained image generation model based on sample text containing at least two types of entity information, and in each iteration of the training, the neurons in the pre-trained image generation model are masked based on a target threshold, and the target threshold is determined based on a network parameter steaming loss value of the pre-trained image generation model.In a specific embodiment of the present disclosure, the device also includes a training module, which is configured to: obtain a sample pair, wherein the sample pair includes a sample text and a sample label, the sample text is a text containing at least two types of entity information, and the sample label is a sample image; input the sample text containing at least two types of entity information into a pre-trained image generation model to obtain a predicted image, wherein the predicted image contains entity objects corresponding to each type of entity information; obtain initial network parameters and target network parameters corresponding to the pre-trained image generation model, and calculate a model loss value based on the sample image, the predicted image, the initial network parameters and the target network parameters; adjust the network parameters of the pre-trained image generation model based on the model loss value until a trained image generation model is obtained. In a specific embodiment of the present disclosure, the device also includes a determination module, configured to: determine the sample noise corresponding to the sample image and the predicted noise corresponding to the predicted image, wherein the predicted noise is output by the pre-trained image generation model based on the sample text containing at least two types of entity information; accordingly, calculate the loss value based on the sample image, the predicted image, the initial network parameters and the target network parameters, including: calculating the noise loss value based on the sample noise and the predicted noise; calculating the network parameter steaming loss value according to the initial network parameters and the target network parameters; and calculating the model loss value based on the noise loss value and the parameter steaming loss value. In a specific embodiment of the present disclosure, the apparatus further includes a calculation module configured to: generate associated text based on the sample text; input the associated text into the pre-trained image generation model to obtain a prior image; and accordingly, calculate a loss value based on the sample image, the predicted image, the initial network parameters, and the target network parameters, including: calculating the prior loss value based on the prior image and the predicted image; and calculating a model loss value based on the prior loss value, the noise loss value, and the network parameter steamed filling loss value. In a specific embodiment of the present disclosure, the apparatus further includes a masking module configured to: determine network parameters of the pre-trained image generation model and weight values corresponding to the network parameters; select network parameters with weight values less than a weight threshold from the network parameters as target network parameters; and perform a masking operation on the target network parameters.In a specific embodiment of the present disclosure, the device further includes an adjustment module configured to: adjust the weight threshold based on the model loss value to obtain a target weight threshold; determine current network parameters of the pre-trained image generation model and the weight values corresponding to the current network parameters; filter the current network parameters whose weight values are less than the target weight threshold as target network parameters; and perform a masking operation on the target network parameters. The image generation device of the present disclosure includes an acquisition module configured to acquire target text; an input module configured to input the target text into the image generation model, and obtain a target image corresponding to the target text based on the correspondence between entity information and neurons learned by the image generation model. The image generation model is obtained by training a pre-trained image generation model based on sample text containing at least two types of entity information. In each iteration of the training, the neurons in the pre-trained image generation model are masked based on the target threshold, and the target threshold is determined based on the steamed filling loss value of the network parameters of the pre-trained image generation model. By masking the neurons in the pre-trained image generation model and training the model based on sample text containing at least two types of entity information, selective use of network parameters is achieved, reducing the sparsity of image feature generation and improving the generation accuracy of the image generation model. The above is a schematic diagram of an image generation device according to this embodiment. It should be noted that the technical solution of this image generation device and the technical solution of the aforementioned image generation method share the same concept. For details not described in detail in the technical solution of the image generation device, please refer to the description of the technical solution of the aforementioned image generation method. Figure 7 shows a block diagram of a computing device 700 according to one embodiment of the present disclosure. The components of computing device 700 include, but are not limited to, a memory 710 and a processor 720. The processor 720 is connected to the memory 710 via a bus 730. A database 750 is configured to store data. Computing device 700 also includes an access device 740, which enables computing device 700 to communicate via one or more networks 760. Examples of these networks include the Public Switched Telephone Network (PSTN), a Local Area Network (LAN), a Wide Area Network (WAN), a Personal Area Network (PAN), or a combination of communication networks such as the Internet.Access device 740 may include one or more of any type of wired or wireless network interface (e.g., a network interface card (NIC)), such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a Worldwide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, or a Near Field Communication (NFC) interface. In one embodiment of the present disclosure, the aforementioned components of computing device 700 and other components not shown in FIG. 7 may also be connected to each other, for example, via a bus. It should be understood that the computing device structure block diagram shown in FIG. 7 is for illustrative purposes only and does not limit the scope of the present disclosure. Those skilled in the art may add or replace other components as needed. Computing device 700 can be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., tablet computer, personal digital assistant, laptop computer, notebook computer, netbook, etc.), a mobile phone (e.g., smartphone), a wearable computing device (e.g., smartwatch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or personal computer (PC). Computing device 700 can also be a mobile or stationary server. Processor 720 is configured to execute the following computer-executable instructions, which, when executed by the processor, implement the steps of the aforementioned image generation method. The above is a schematic diagram of a computing device in this embodiment. It should be noted that the technical solutions of this computing device and the technical solutions of the aforementioned image generation method are based on the same concept. For details not described in detail in the technical solutions of the computing device, please refer to the description of the technical solutions of the aforementioned image generation method. An embodiment of the present disclosure also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by the processor, implement the steps of the aforementioned image generation method. The above is an illustrative solution of a computer-readable storage medium of this embodiment.It should be noted that the technical solution of this storage medium and the technical solution of the aforementioned image generation method are based on the same concept. Any details not described in detail in the technical solution of the storage medium can be found in the description of the technical solution of the aforementioned image generation method. One embodiment of the present disclosure also provides a computer program. When executed on a computer, the computer executes the steps of the aforementioned image generation method. The above is an illustrative embodiment of a computer program of this embodiment. It should be noted that the technical solution of this computer program and the technical solution of the aforementioned image generation method are based on the same concept. Any details not described in detail in the technical solution of the computer program can be found in the description of the technical solution of the aforementioned image generation method. The above describes specific embodiments of the present disclosure. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that described in the embodiments and still achieve the desired results. In addition, the processes depicted in the figures do not necessarily require the specific order or sequential order shown to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous. The computer instructions include computer program code, which may be in source code form, object code form, executable files, or some intermediate form. The computer-readable medium may include any entity or device capable of carrying the computer program code, recording media, USB flash drives, removable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signals, telecommunication signals, and software distribution media. It should be noted that the content of the computer-readable medium may be appropriately increased or decreased based on the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media do not include electric carrier signals and telecommunication signals. It should be noted that for ease of description, the aforementioned method embodiments are described as a series of actions. However, those skilled in the art should be aware that the embodiments of the present disclosure are not limited by the order of the actions described, as certain steps may be performed in a different order or simultaneously according to the embodiments of the present disclosure. Furthermore, those skilled in the art should also be aware that the embodiments described in this specification are preferred embodiments, and the actions and modules involved are not necessarily required for the embodiments of the present disclosure. In the above embodiments, the description of each embodiment has its own focus. For parts not described in detail in a particular embodiment, reference can be made to the relevant descriptions of other embodiments. The preferred embodiments of the present disclosure disclosed above are merely provided to help illustrate the present disclosure.The optional embodiments do not describe all details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and variations are possible based on the content of the embodiments of this disclosure. This disclosure selects and specifically describes these embodiments to better explain the principles and practical applications of the embodiments of this disclosure, thereby enabling those skilled in the art to better understand and utilize this disclosure. This disclosure is limited by the claims and their full scope and equivalents. Industrial Applicability: The image generation method and apparatus provided in the embodiments of this disclosure are applied to cloud-side devices. During the training of the image processing model, neurons in the pre-trained image generation model are masked to achieve selective use of network parameters, reduce the sparsity of image feature generation, and improve the generation accuracy of the image generation model. By inputting the target text into the trained image generation model, a more accurate target image is obtained.
Claims
Claims 1. A method for generating an image, comprising: Get the target text; The target text is input into an image generation model, and a target image corresponding to the target text is obtained based on the correspondence between entity information and neurons learned by the image generation model, wherein the image generation model is obtained by training a pre-trained image generation model based on sample texts containing at least two types of entity information, and in each iteration of the training, a mask process is performed on the neurons in the pre-trained image generation model based on a target threshold, and the target threshold is determined based on a steaming loss value of a network parameter of the pre-trained image generation model.
2. The method according to claim 1, before inputting the target text into the image generation model, further comprising: A sample pair is obtained, wherein the sample pair includes a sample text and a sample label, the sample text is a text including at least two types of entity information, and the sample label is a sample image; the sample text including at least two types of entity information is input into a pre-trained image generation model to obtain a predicted image, wherein the predicted image includes entity objects corresponding to each type of entity information; initial network parameters and target network parameters corresponding to the pre-trained image generation model are obtained, and a model loss value is calculated based on the sample image, the predicted image, the initial network parameters and the target network parameters; the network parameters of the pre-trained image generation model are adjusted based on the model loss value until a trained image generation model is obtained.
3. The method according to claim 2, before calculating the model loss value based on the sample image, the predicted image, the initial network parameters and the target network parameters, further comprising: Determine a sample noise corresponding to the sample image and a predicted noise corresponding to the predicted image, wherein the predicted noise is output by the pre-trained image generation model based on the sample text containing at least two types of entity information; accordingly, calculate a loss value based on the sample image, the predicted image, the initial network parameters and the target network parameters, including: calculating a noise loss value based on the sample noise and the predicted noise; calculating a network parameter steaming loss value according to the initial network parameters and the target network parameters; and calculating a model loss value based on the noise loss value and the parameter steaming loss value.
4. The method according to claim 3, before calculating the model loss value based on the sample image, the predicted image, the initial network parameters and the target network parameters, further comprising: generating associated text based on the sample text; Inputting the associated text into the pre-trained image generation model to obtain a priori image; Accordingly, calculating the loss value based on the sample image, the predicted image, the initial network parameters and the target network parameters includes: calculating the priori loss value based on the priori image and the predicted image; The model loss value is calculated according to the prior loss value, the noise loss value and the network parameter steaming loss value.
5. The method according to claim 2, before inputting the sample image into the pre-trained image generation model, further comprising: Determine the network parameters of the pre-trained image generation model and the weight values corresponding to the network parameters; Select network parameters whose weight values are less than the weight threshold from among the network parameters as target network parameters; A mask operation is performed on the target network parameters.
6. The method of claim 5, adjusting the network parameters of the pre-trained image generation model based on the model loss value, comprising: Adjusting the weight threshold based on the model loss value to obtain a target weight threshold; Determining the current network parameters of the pre-trained image generation model and the weight values corresponding to the current network parameters; Selecting the current network parameters whose weight values are less than the target weight threshold from the current network parameters as the target network parameters; A mask operation is performed on the target network parameters.
7. A method for training an image generation model, applied to a cloud-side device, comprising: A sample pair is obtained, wherein the sample pair includes a sample text and a sample label, the sample text includes at least two types of entity information, and the sample label is a sample image; the sample pair is input into a pre-trained image generation model to obtain a predicted image, wherein the predicted image includes an entity object generated based on various types of entity information; initial network parameters and target network parameters corresponding to the pre-trained image generation model are obtained, and a model loss value is calculated based on the sample image, the predicted image, the initial network parameters and the target network parameters; the network parameters of the pre-trained image generation model are adjusted based on the model loss value until a trained image generation model is obtained; in response to a model acquisition request sent by an end-side device, the model parameters of the image generation model are returned to the end-side device.
8. An image generation method, applied to a cloud-side device, comprising: The target text sent by the receiving device; The target text is input into an image generation model, and a target image corresponding to the target text is obtained based on the correspondence between entity information and neurons learned by the image generation model, wherein the image generation model is obtained by training a pre-trained image generation model based on a sample text containing at least two types of entity information, and in each iteration of the training, the neurons in the pre-trained image generation model are masked based on a target threshold, and the target threshold is determined based on a steaming loss value of a network parameter of the pre-trained image generation model; and the target image is returned to the terminal side device.
9. A target image generation method, comprising: A target text is obtained, wherein the target text contains at least two types of entity information; the target text is input into an image generation model, and a target image corresponding to the target text is obtained based on a correspondence between entity information and neurons learned by the image generation model, wherein the target image contains at least two types of entity objects; the image generation model is obtained by training a pre-trained image generation model based on sample text containing at least two types of entity information, and in each iteration of the training, neurons in the pre-trained image generation model are masked based on a target threshold, and the target threshold is determined based on a network parameter steaming loss of the pre-trained image generation model.
10. The method according to claim 9, after obtaining the target image corresponding to the target text, further comprising: sending the target image to a user; receiving user feedback information regarding the target image; The image generation model is adjusted according to the feedback information.
11. An image generating device, comprising: An acquisition module, configured to acquire target text; An input module is configured to input the target text into an image generation model, and obtain a target image corresponding to the target text based on the correspondence between entity information and neurons learned by the image generation model, wherein the image generation model is obtained by training a pre-trained image generation model based on sample text containing at least two types of entity information, and in each iteration of the training, the neurons in the pre-trained image generation model are masked based on a target threshold, and the target threshold is determined based on a network parameter steaming loss value of the pre-trained image generation model.
12. A computing device, comprising: Memory and processor; The memory is configured to store computer executable instructions, and the processor is configured to execute the computer executable instructions. When the computer executable instructions are executed by the processor, the steps of the method according to any one of claims 1 to 10 are implemented.
13. A computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions, when executed by a processor, implement the steps of the method according to any one of claims 1 to 10. 17
Citation Information
Patent Citations
Image generation method, neural network compression method and related devices and equipment
CN110084281A
Short-term photovoltaic power generation prediction method considering correlation degree of weather and meteorological factors
CN111260126A
Pruning type image compressed sensing method and system for lightweight deployment
CN115797477A
Cited By
Short text-to-image model training method and system, short text-to-image generation method, electronic equipment and storage medium
CN119181102A
Figure graph model training method with anti-editing concept erasing function
CN119888011A
Object detection based on image generation model
WO2026200493A1
