Image generation method and device, electronic equipment and readable storage medium
Through the combination of multi-modal diffusion models and diversified conditional encoders, the problem of insufficient image generation details and authenticity in the existing technology is solved, the details and authenticity of images are significantly improved, and the controllability and diversity are enhanced. , achieving high-quality image generation.
Patent Information
- Application Number
- CN202410772854.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-14
- Publication Date
- 2024-10-01
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing text-guided image generation technology based on the diffusion model has deficiencies in image details and authenticity, resulting in distortion and blurring of the generated images, and limited controllability and diversity.
Using a multi-modal diffusion model, combining text encoders, image encoders and diverse conditional encoders (such as character feature encoders, image style encoders, spatial structure encoders), images are generated through inverse noise diffusion generators. Provide richer feature information to improve image details and realism, and improve generation quality through variational autoencoders and attention mechanisms.
It significantly improves the details and authenticity of generated images, enhances controllability and diversity, improves the distortion and blur problems of existing models, and improves the quality and resolution of image generation.
Smart Images

Figure CN118736038A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image generation, and in particular to an image generation method, device, electronic device and readable storage medium. Background Art
[0002] With the continuous advancement of artificial intelligence technology, text-guided image generation has become an important field of cross-integration between computer vision and natural language processing technology. Its core goal is to generate an image that accurately matches a given text description. The core of this technology is to parse the deep semantic information in the text and successfully convert it into a visual image, achieving accurate conversion from text to image.
[0003] At present, image generation technology based on multimodal learning, especially text-guided image generation (T2I) based on diffusion model, can generate corresponding images based on natural language text descriptions provided by users. This has achieved the conversion from text to image to a certain extent. However, although the existing T2I model has achieved certain results in generating images related to text descriptions, there is still room for improvement in image quality and details. That is, the images generated by the existing technology are insufficient in details and authenticity, and sometimes distortion and blurring may occur. Summary of the invention
[0004] In view of this, the embodiments of the present application provide an image generation method, device, electronic device and readable storage medium to solve the problem that images generated by the prior art are insufficient in details and authenticity, resulting in distortion and blurring of images.
[0005] According to a first aspect of an embodiment of the present application, there is provided an image generation method, comprising:
[0006] Acquire text description and image information, input the text description and image information into a multimodal diffusion model, wherein the multimodal diffusion model includes a text encoder, an image encoder, at least one conditional encoder and a diffusion generator, and the text description and image information are associated; encode the text description using the text encoder to obtain a first feature vector, and encode the image information using the image encoder to obtain a second feature vector; extract features from the image information using at least one conditional encoder to obtain at least one conditional feature vector; input the first feature vector, the second feature vector and the at least one conditional feature vector into the diffusion generator to obtain a target image output by the diffusion generator.
[0007] According to a second aspect of the embodiments of the present application, there is provided an image generating device, including:
[0008] The acquisition module is configured to acquire text description and image information, and input the text description and image information into a multimodal diffusion model, wherein the multimodal diffusion model includes a text encoder, an image encoder, at least one conditional encoder and a diffusion generator, and the text description and image information are associated; the encoding module is configured to encode the text description using the text encoder to obtain a first feature vector, and encode the image information using the image encoder to obtain a second feature vector; the auxiliary module is configured to extract features from the image information using at least one conditional encoder to obtain at least one conditional feature vector; the generation module is configured to input the first feature vector, the second feature vector and the at least one conditional feature vector into the diffusion generator to obtain a target image output by the diffusion generator.
[0009] According to a third aspect of an embodiment of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0010] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, which stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.
[0011] Compared with the prior art, the embodiments of the present invention have at least the following beneficial effects:
[0012] Obtain text description and image information, and input the text description and image information into a multimodal diffusion model, wherein the multimodal diffusion model includes a text encoder, an image encoder, at least one conditional encoder, and a diffusion generator, and the text description and image information are associated; use the text encoder to encode the text description to obtain a first feature vector, and use the image encoder to encode the image information to obtain a second feature vector; use at least one conditional encoder to extract features of the image information to obtain at least one conditional feature vector; input the first feature vector, the second feature vector, and at least one conditional feature vector into the diffusion generator to obtain a target image output by the diffusion generator. The present application adopts an improved multimodal diffusion model to obtain feature information of text description and image information, and by introducing a variety of conditional encoders, extracts features of the image from different angles and levels, and provides the diffusion generator with richer and more detailed information. The improved multimodal diffusion model can greatly improve the distortion and blurring problems existing in the existing model, thereby significantly improving the details and authenticity of the generated image. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] In order to more clearly illustrate the technical solutions in the embodiments of the present application, 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 only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0014] Figure 1 It is a flowchart of an image generation method provided in an embodiment of the present application;
[0015] Figure 2 is a flowchart of another image generation method provided in an embodiment of the present application;
[0016] Figure 3 is a structural schematic diagram of an image generating device provided in an embodiment of the present application;
[0017] Figure 4 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0018] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0019] The term "including" and its variations used in this document are open inclusions, that is, "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one other embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions of other terms will be given in the description below. It should be noted that the concepts of "first", "second", etc. mentioned in this application are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0020] It should be noted that the modifications of "one" and "plurality" mentioned in the present application are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0021] Existing image generation technologies based on a single modality, such as generative adversarial networks and autoencoders, can generate high-quality images, but their generation effect depends largely on training data and it is difficult to achieve accurate text guidance. In order to overcome these shortcomings, image generation technologies based on multimodal learning have emerged, such as text-guided image generation (text-to-image, T2I). T2I technology can generate corresponding images based on the natural language text description entered by the user, thereby achieving text-to-image conversion to a certain extent. However, the existing T2I technology still has some problems:
[0022] First, the details and authenticity of the generated images need to be further improved. Although the existing T2I model can generate images related to text descriptions, the quality and details of the generated images are not ideal, and there are certain distortions and blurs.
[0023] Secondly, the controllability and diversity of generated images need to be further enhanced. Although the existing T2I model can generate corresponding images based on text descriptions, its ability to finely control image attributes (such as color, material, composition, etc.) is weak, and the diversity of generated images is also relatively limited.
[0024] In view of the above technical problems, the prior art has proposed a variety of solutions:
[0025] First, the T2I generation method based on the diffusion model. The diffusion model is an emerging type of generative model that generates high-quality and realistic images by reverse noise diffusion, and has achieved good results in T2I tasks. Representative works include GLIDE, Imagen, DALL·E 2, etc.
[0026] Second, there are T2I generation methods based on latent space. This type of method uses a pre-trained autoencoder to encode the image into the latent space, and then trains and infers the diffusion model on the latent space to generate high-resolution images. Representative works include LDM and Stable Diffusion.
[0027] Although these existing solutions have solved the problem of T2I generation to some extent, they still have the following disadvantages:
[0028] (1) The details and authenticity of the generated images need to be further improved. Although the existing T2I method based on the diffusion model has made great progress in the quality of generated images, there are still some distortions and blurring of details.
[0029] (2) The controllability and diversity of generated images are limited. Most existing methods can only introduce a single condition, such as text or image, and there is still a lack of effective solutions for more complex multi-condition control generation.
[0030] Therefore, in summary, how to further improve the generation quality and controllability of the T2I model is an important issue worthy of in-depth study. This application aims to provide a new image generation method that can effectively solve the problems existing in the prior art.
[0031] An image generating method, device, electronic device and readable storage medium according to an embodiment of the present application will be described in detail below with reference to the accompanying drawings.
[0032] Figure 1 is a flow chart of an image generation method provided in an embodiment of the present application. Figure 1 As shown, the method includes:
[0033] S101, obtaining text description and image information, and inputting the text description and image information into a multimodal diffusion model, wherein the multimodal diffusion model includes a text encoder, an image encoder, at least one conditional encoder and a diffusion generator, and the text description and image information are associated;
[0034] S102, encoding the text description using a text encoder to obtain a first feature vector, and encoding the image information using an image encoder to obtain a second feature vector;
[0035] S103, using at least one conditional encoder to extract features from the image information to obtain at least one conditional feature vector;
[0036] S104, inputting the first eigenvector, the second eigenvector and at least one conditional eigenvector into a diffusion generator to obtain a target image output by the diffusion generator.
[0037] Specifically, text description and image information are obtained. These two parts of information can be input by the user or obtained from other data sources. The text description is a natural language description of the image content, which provides the semantic information required for image generation. The image information can be one or more images associated with the text description, which provide the visual information required for image generation. This information is input into the multimodal diffusion model, and the model can use this information to generate the target image.
[0038] It can be understood that the multimodal diffusion model in the present application includes a text encoder, an image encoder, at least one conditional encoder and a diffusion generator. The text encoder is responsible for converting the text description into a feature vector that the model can understand, that is, a first feature vector. The image encoder converts the image information into a second feature vector. The conditional encoder is used to extract other auxiliary features of the image, such as color, texture, etc., to generate at least one conditional feature vector. These feature vectors together provide the rich information required to generate the target image. Further, these feature vectors are input into the diffusion generator. The diffusion generator is a generator based on a diffusion model, which can generate high-quality, realistic images by reverse noise diffusion. In this process, the diffusion generator will comprehensively consider the feature vectors of the text description and image information, as well as the conditional feature vectors, to generate a target image that is consistent with the target description and image information. In this way, the image generation method of the embodiment of the present application further improves the details and authenticity of the generated image by introducing multimodal information (text and image). Secondly, by introducing the conditional encoder, the controllability and diversity of the generated image are enhanced. Finally, by the generation method based on the diffusion model, the quality and resolution of the generated image are significantly improved.
[0039] In summary, this embodiment adopts an improved multimodal diffusion model to obtain feature information of text description and image information, and extracts image features from different angles and levels by introducing diversified conditional encoders, thereby providing richer and more detailed information for the diffusion generator, thereby significantly improving the details and authenticity of the generated images. The improved multimodal diffusion model can greatly improve the distortion and blurring problems existing in the existing model, thereby improving the controllability and diversity of the generated images.
[0040] In some embodiments, the at least one conditional encoder includes at least one of a character feature encoder, an image style encoder, and a spatial structure encoder; the at least one conditional encoder is used to extract features from the image information to obtain at least one conditional feature vector, including at least one of the following:
[0041] The character feature encoder is used to extract the character features in the input image to obtain a character feature vector; the image style encoder is used to extract the image style features in the input image to obtain an image style feature vector; the spatial structure encoder is used to extract the spatial structure features in the input image to obtain a spatial structure feature vector.
[0042] Specifically, conditional encoders can include multiple types, such as character feature encoders, image style encoders, and spatial structure encoders. These encoders can extract image features from different angles and levels, providing richer and more detailed information for the diffusion generator.
[0043] Character feature encoder: This encoder focuses on extracting character features from images. For example, it can identify character postures, facial expressions, clothing, and other features in an image, and generate a character feature vector, which can help the diffusion generator maintain the consistency and accuracy of character features when generating images. Specifically, pre-trained face recognition models such as FaceNet and VGG-Face can be used to extract character features from images.
[0044] Image style encoder: This encoder is responsible for extracting style features from the image. For example, it can analyze the artistic style of the image, such as color, texture, and brushstrokes, and generate an image style feature vector. This vector can guide the diffusion generator to maintain a similar style to the original image when generating images. This can be done by using style transfer techniques (such as Neural Style Transfer by Gatys et al.) or pre-trained models (such as StyleGAN).
[0045] Spatial structure encoder: This encoder focuses on the spatial structural features of the image, such as layout, perspective, scale, etc. It can extract key spatial information in the image and generate a spatial structure feature vector. This vector is crucial to ensure the rationality of the spatial structure of the generated image. Semantic segmentation networks (such as U-Net) or deep convolutional networks are used to identify spatial structural features in images.
[0046] By combining these conditional encoders, the image generation method of the embodiment of the present application can more comprehensively extract and utilize image information to generate images with more details, authenticity and diversity. In this way, not only can the quality of the generated image be improved, but also the controllability of the generated image can be enhanced to meet the different needs of different users.
[0047] It should be noted that the type of conditional encoder can be freely designed or added according to different task requirements to adapt to different image generation scenarios, and the specific type and quantity are not specifically limited in this embodiment.
[0048] In this way, the technical solution of the embodiment of the present application realizes the comprehensive extraction and utilization of image information by combining multiple conditional encoders, and generates images with more details, authenticity and diversity. This method not only improves the quality and controllability of the generated images, but also enhances the flexibility and scalability of the image generation method.
[0049] In addition, in some embodiments, the multimodal diffusion model includes a first variational autoencoder and a second variational autoencoder; before inputting the first feature vector, the second feature vector, and the at least one conditional feature vector into the diffusion generator, it also includes:
[0050] The first feature vector is input into the first variational autoencoder to obtain the first variational feature output by the first variational autoencoder, and the second feature vector is input into the second variational autoencoder to obtain the second variational feature output by the second variational autoencoder; the first variational feature, the second variational feature and at least one conditional feature vector are input into the diffusion generator.
[0051] Specifically, in order to further improve the parameter efficiency of the model, this embodiment adds two variational autoencoders to the multimodal diffusion model: a first variational autoencoder and a second variational autoencoder. The two variational autoencoders receive and process the first eigenvector and the second eigenvector, respectively, so as to extract more refined and representative variational features.
[0052] It can be understood that the first variational autoencoder and the second variational autoencoder can effectively compress the input feature vector, reduce the parameter scale entering the diffusion generator, and thus reduce the volume of the entire model. In addition, the first variational autoencoder and the second variational autoencoder can also respectively learn the distribution characteristics of the first feature vector and the second feature vector to the potential feature space, which helps the diffusion generator to better restore the target image from the noise, and further improve the quality and accuracy of the generated image. In addition, by using the variational autoencoder, this embodiment can also achieve dimensionality reduction of feature vectors, reduce computational complexity, and speed up the training and reasoning speed of the model. At the same time, the introduction of the variational autoencoder can also make the model more flexible and scalable, and new feature vectors can be easily added to adapt to different tasks and data sets.
[0053] In addition, the first variational autoencoder receives the first feature vector as input, and extracts the first variational features through a series of calculations and transformations. These features have stronger representativeness and generalization capabilities, and can better describe the essential characteristics of the input data. Similarly, the second variational autoencoder also receives the second feature vector as input and extracts the second variational features. These two variational feature vectors and other conditional feature vectors are input into the diffusion generator together to generate the target image.
[0054] According to the technical solution provided by this embodiment, by introducing two variational autoencoders, it is possible to better adapt to different input data and improve the quality and accuracy of the generated image. At the same time, due to the compression and dimensionality reduction of the feature vector by the variational autoencoder, the parameter efficiency of the model is further improved. This makes the model more efficient during training and reasoning, and can complete the image generation task more quickly.
[0055] In addition, in some embodiments, the first feature vector, the second feature vector, and at least one conditional feature vector are input into a diffusion generator to obtain a target image output by the diffusion generator, including:
[0056] An initial noise image is obtained through a diffusion generator; at each time step processed by the diffusion generator, the first eigenvector, the second eigenvector and at least one conditional eigenvector are fused with the initial noise image using an attention mechanism and / or a fusion layer; after fusion processing of multiple time steps, a target image output by the diffusion generator is obtained according to the fusion result of the last time step.
[0057] Specifically, in order to further improve the quality and diversity of the generated images, this embodiment introduces an attention mechanism and / or a fusion layer in the processing of the diffusion generator. These mechanisms or layers can fuse the first feature vector, the second feature vector, and at least one conditional feature vector with the initial noise image at each time step, thereby ensuring that the generated image can fully utilize these feature information.
[0058] The attention mechanism can help the model focus on important feature information and ignore unimportant information when generating images. By assigning different weights to each feature vector, the attention mechanism can enable the model to focus on different features at different stages of generating images, thereby improving the quality and diversity of generated images. For example, in the early stages of generating images, the model can pay more attention to global features such as color, texture, etc.; while in the later stages of generating images, the model can pay more attention to local features such as the shape and structure of objects.
[0059] The fusion layer can directly fuse different feature vectors with the initial noise image, and obtain the fused feature vector through linear or nonlinear combination. This fusion method can ensure that the model can make full use of various feature information when generating images, and improve the quality and diversity of generated images. For example, by fusing global features and local features, the model can generate images with both global beauty and local details.
[0060] During the fusion process at each time step, the model can gradually combine various feature information to generate more realistic, diverse and high-quality images. Finally, based on the fusion results of the last time step, the model can output the final target image. This image will contain information from various feature vectors and have a high degree of authenticity and diversity.
[0061] According to the technical solution provided by this embodiment, by introducing the attention mechanism and / or fusion layer, the model can better utilize various feature information when generating images, thereby improving the quality and diversity of the generated images. This enables the model to generate more realistic, diverse, and high-quality images. At the same time, the introduction of the attention mechanism and fusion layer also enhances the flexibility and scalability of the model, and can be easily combined with other technologies to further improve the effect of image generation.
[0062] In some embodiments, before encoding the input text using a text encoder to obtain the first feature vector, the method further includes:
[0063] A multilingual data training set is obtained, wherein the multilingual data training set includes multiple English texts and multiple language texts corresponding to the English texts; a multilingual language model is trained based on the multilingual data training set, and the multilingual language model is used to understand and generate texts in multiple languages; and the multilingual knowledge of the multilingual language model is transferred to the text encoder using the knowledge distillation method, so that the text encoder can imitate the representation of the multilingual language model on non-English texts.
[0064] Specifically, most existing text-to-image generation models are trained based on English corpus, and their performance will degrade when processing other languages. If the model trained directly in English is applied to non-English languages, the quality and relevance of the generated images will be greatly reduced. In order to improve the cross-language capability of the text encoder so that it can understand and generate texts in multiple languages, this embodiment introduces a multilingual language model and transfers its multilingual knowledge to the text encoder through knowledge distillation. In this way, the text encoder can imitate the representation of the multilingual language model on non-English texts, thereby realizing the understanding and generation of texts in multiple languages.
[0065] In one example, a multilingual data training set is obtained, which includes multiple English texts and multiple language texts corresponding to these English texts. This multilingual data training set can provide rich cross-language learning resources, which is helpful for training a multilingual language model with strong cross-language capabilities.
[0066] Furthermore, a multilingual language model is trained based on the multilingual data training set. For example, the model can be a multilingual generative pre-trained transformer (GPT) model based on a decoder architecture, which can understand and generate texts in multiple languages, including Chinese, English, French, German, Spanish, etc. In this way, no matter which language the text is input, the multilingual language model can effectively process and generate it.
[0067] Furthermore, the multilingual knowledge of the multilingual language model is transferred to the text encoder using the knowledge distillation method. The knowledge distillation method is an effective model transfer learning method, which trains the student model by imitating the behavior of the teacher model, so that the student model can inherit the powerful capabilities of the teacher model. In this embodiment, the multilingual language model is used as the teacher model, and the text encoder is used as the student model. The knowledge distillation method is used to enable the text encoder to imitate the representation of the multilingual language model on non-English texts. In this way, the text encoder can have strong cross-language capabilities and realize the understanding and generation of texts in multiple languages.
[0068] According to the technical solution of the embodiment of the present application, by introducing a multilingual language model and using the knowledge distillation method for model transfer learning, the embodiment significantly improves the cross-language capability of the text encoder. This enables the text encoder to better understand and generate text in multiple languages, providing more accurate and rich text information for subsequent image generation tasks. At the same time, this method also enhances the flexibility and scalability of the model, and can be easily extended to other languages to adapt to different application scenarios and needs.
[0069] In addition, in some embodiments, after obtaining the target image output by the diffusion generator, the method further includes:
[0070] The loss of the target image and the real label corresponding to the target image is calculated to obtain the loss value; a differentiated loss function is constructed according to the loss value, and the text encoder, the image encoder and at least one conditional encoder are trained using the differentiated loss function. When the loss value is less than or equal to the preset value, the training of the multimodal diffusion model is completed.
[0071] Specifically, in order to further improve the performance of the multimodal diffusion model, this embodiment also introduces a differential loss function training method. After completing the generation of the target image, the method calculates the loss of the generated target image and the corresponding real label to obtain a loss value. This loss value can reflect the gap between the model-generated image and the real image, and can be used to measure the performance of the model. According to this loss value, a differential loss function can be constructed. For example, for text encoders and text descriptions, a traditional loss function based on semantic similarity can be used, requiring the generated image to accurately reflect the text content. For image style encoders and image style feature vectors, a loss function based on style transfer can be used, requiring the generated image to present the target style. For character feature encoders and character feature vectors, a loss function based on face recognition can be used, requiring the characters in the generated image to meet the given features, and the differential loss function can be flexibly designed according to specific application scenarios and requirements to meet different optimization goals.
[0072] Furthermore, the text encoder, image encoder, and at least one conditional encoder are trained using this differentiated loss function. During the training process, the model will continuously adjust its parameters to reduce the loss value according to the guidance of the differentiated loss function. When the loss value is less than or equal to the preset value, it can be considered that the performance of the model has reached a relatively satisfactory level, and the training of the multimodal diffusion model can be completed. Through the design of differentiated loss functions, the model can better balance and integrate these diverse conditional information.
[0073] Additionally, in some embodiments, the method further comprises:
[0074] Receive user ratings and / or text comments on the target image; construct a user feedback vector based on the ratings and / or text comments; input the user feedback vector into the multimodal diffusion model, and use the user feedback vector to fine-tune the multimodal diffusion model.
[0075] Specifically, in actual applications, users can rate and / or provide text comments on the generated target image. For example, the user's rating and / or text comments on the target image can be received. The rating can be in numerical form, such as a score from 1 to 5, indicating the user's satisfaction with the image. The text comment can be a detailed description, suggestion or opinion of the user on the image, providing richer feedback information.
[0076] Furthermore, a user feedback vector is constructed based on the received ratings and / or text comments. This user feedback vector is a numerical representation of the user feedback information and can be used for gradient updates in model training. In order to construct the user feedback vector, the text comments can be converted into numerical form. At the same time, the rating can also be directly used as part of the user feedback vector. The constructed user feedback vector is input into the multimodal diffusion model, and the multimodal diffusion model is fine-tuned using the user feedback vector. During the fine-tuning process, the model can adjust its parameters according to the guidance of the user feedback vector to better meet the needs of the user. Specifically, the model adjusts the parameters of the text encoder, image encoder, and conditional encoder based on the information in the user feedback vector to improve the quality and relevance of the generated image.
[0077] According to the technical solution of the embodiment of the present application, by introducing a user feedback mechanism, this embodiment enables the multimodal diffusion model to better adapt to the needs and preferences of different users. At the same time, user feedback can also serve as an important basis for model improvement and optimization, thereby promoting continuous improvement of model performance.
[0078] Figure 2 is a schematic diagram of another image generation method provided in an embodiment of the present application. Figure 2 As shown, the method includes:
[0079] First, a multilingual language model is trained based on a multilingual data training set, and the multilingual knowledge of the multilingual language model is transferred to the text encoder using the knowledge distillation method, so that the text encoder can imitate the representation of the multilingual language model on non-English text.
[0080] Then, a text encoder and an image encoder are used to encode the text description and the image information respectively to obtain a first eigenvector and a second eigenvector, and the first eigenvector is input into a first variational autoencoder to obtain a first variational feature output by the first variational autoencoder, and the second eigenvector is input into a second variational autoencoder to obtain a second variational feature output by the second variational autoencoder, so as to use the variational autoencoder to effectively compress the input eigenvector and reduce the parameter scale entering the diffusion generator, thereby reducing the volume of the entire model.
[0081] Secondly, a conditional encoder is used to extract features of the image information. The conditional encoder of the present application may include at least one of a character feature encoder, an image style encoder, and a spatial structure encoder, so that the model can extract features of the image from different angles and levels, providing the diffusion generator with richer and more detailed information.
[0082] Finally, the first variational feature, the second variational feature and at least one conditional feature vector are input into the diffusion generator, and the first variational feature, the second variational feature and at least one conditional feature vector are fused with the initial noise image using an attention mechanism and / or a fusion layer; after a fusion process of multiple time steps, a high-quality target image output by the diffusion generator is obtained from the initial noise image.
[0083] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described in detail here.
[0084] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the process of the embodiments of the present application.
[0085] Figure 3 Schematic diagram of an image generating device provided in an embodiment of the present application. Figure 3 As shown, the device comprises:
[0086] An acquisition module 301 is configured to acquire text description and image information, and input the text description and image information into a multimodal diffusion model, wherein the multimodal diffusion model includes a text encoder, an image encoder, at least one conditional encoder and a diffusion generator, and the text description and image information are associated;
[0087] The encoding module 302 is configured to encode the text description using a text encoder to obtain a first feature vector, and encode the image information using an image encoder to obtain a second feature vector;
[0088] The auxiliary module 303 is configured to extract features from the image information using at least one conditional encoder to obtain at least one conditional feature vector;
[0089] The generating module 304 is configured to input the first feature vector, the second feature vector and at least one conditional feature vector into the diffusion generator to obtain a target image output by the diffusion generator.
[0090] In some embodiments, at least one conditional encoder includes at least one of a character feature encoder, an image style encoder, and a spatial structure encoder, and the auxiliary module 303 is also used to use the character feature encoder to extract character features in the input image to obtain a character feature vector; use the image style encoder to extract image style features in the input image to obtain an image style feature vector; use the spatial structure encoder to extract spatial structure features in the input image to obtain a spatial structure feature vector.
[0091] In some embodiments, the multimodal diffusion model includes a first variational autoencoder and a second variational autoencoder, and the generation module 304 is further used to input the first feature vector into the first variational autoencoder to obtain the first variational feature output by the first variational autoencoder, and input the second feature vector into the second variational autoencoder to obtain the second variational feature output by the second variational autoencoder; the first variational feature, the second variational feature and at least one conditional feature vector are input into the diffusion generator.
[0092] In some embodiments, the generation module 304 is also used to obtain an initial noise image through a diffusion generator; at each time step processed by the diffusion generator, the first eigenvector, the second eigenvector and at least one conditional eigenvector are fused with the initial noise image using an attention mechanism and / or a fusion layer; after fusion processing for multiple time steps, the target image output by the diffusion generator is obtained according to the fusion result of the last time step.
[0093] In some embodiments, the encoding module 302 is further used to obtain a multilingual data training set, wherein the multilingual data training set includes multiple English texts and multiple language texts corresponding to the English texts; a multilingual language model is trained based on the multilingual data training set, and the multilingual language model is used to understand and generate texts in multiple languages, and the multilingual knowledge of the multilingual language model is transferred to the text encoder using the knowledge distillation method, so that the text encoder can imitate the representation of the multilingual language model on non-English texts.
[0094] In some embodiments, the generation module 304 is also used to calculate the loss between the target image and the real label corresponding to the target image to obtain a loss value; construct a differentiated loss function based on the loss value, and use the differentiated loss function to train the text encoder, the image encoder, and at least one conditional encoder. When the loss value is less than or equal to a preset value, the training of the multimodal diffusion model is completed.
[0095] In some embodiments, the generation module 304 is further used to receive user ratings and / or text comments on the target image; construct a user feedback vector based on the ratings and / or text comments; input the user feedback vector into the multimodal diffusion model, and use the user feedback vector to fine-tune the multimodal diffusion model.
[0096] The device provided in the embodiment of the present application can implement all the method steps of the above method embodiment and achieve the same technical effect, which will not be repeated here.
[0097] Figure 4 Schematic diagram of an electronic device 4 provided in an embodiment of the present application. Figure 4 As shown, the electronic device 4 of this embodiment includes: a processor 401, a memory 402, and a computer program 403 stored in the memory 402 and executable on the processor 401. When the processor 401 executes the computer program 403, the steps in the above-mentioned method embodiments are implemented. Alternatively, when the processor 401 executes the computer program 403, the functions of the modules / units in the above-mentioned device embodiments are implemented.
[0098] The electronic device 4 may be a desktop computer, a notebook, a PDA, a cloud server, or other electronic device. The electronic device 4 may include, but is not limited to, a processor 401 and a memory 402. Those skilled in the art will appreciate that Figure 4 The electronic device 4 is merely an example and does not limit the electronic device 4 , and may include more or less components than those shown in the figure, or different components.
[0099] The processor 401 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0100] The memory 402 may be an internal storage unit of the electronic device 4, for example, a hard disk or memory of the electronic device 4. The memory 402 may also be an external storage device of the electronic device 4, for example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 4. The memory 402 may also include both an internal storage unit and an external storage device of the electronic device 4. The memory 402 is used to store computer programs and other programs and data required by the electronic device.
[0101] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units.
[0102] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the present application implements all or part of the process in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. The computer program may include computer program code, which may be in source code form, object code form, executable file or some intermediate form. The readable storage medium may include: any entity or device that can carry computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc.
[0103] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application 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. 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 application, and should all be included in the protection scope of the present application.
Claims
1. An image generation method, characterized in that: include: Acquire a text description and image information, input the text description and the image information into a multimodal diffusion model, wherein the multimodal diffusion model includes a text encoder, an image encoder, at least one conditional encoder, and a diffusion generator, and the text description and the image information are associated; Using the text encoder to encode the text description to obtain a first feature vector, and using the image encoder to encode the image information to obtain a second feature vector; Using the at least one conditional encoder to extract features from the image information to obtain at least one conditional feature vector; The first feature vector, the second feature vector and the at least one conditional feature vector are input into the diffusion generator to obtain a target image output by the diffusion generator.
2. The method according to claim 1, characterized in that: The at least one conditional encoder includes at least one of a character feature encoder, an image style encoder, and a spatial structure encoder; the step of extracting features from the image information using the at least one conditional encoder to obtain at least one conditional feature vector includes at least one of the following: Extracting character features in the input image using the character feature encoder to obtain a character feature vector; Extracting image style features from the input image using the image style encoder to obtain an image style feature vector; The spatial structure encoder is used to extract spatial structure features in the input image to obtain a spatial structure feature vector.
3. The method according to claim 1, characterized in that The multimodal diffusion model includes a first variational autoencoder and a second variational autoencoder; before inputting the first feature vector, the second feature vector and the at least one conditional feature vector into the diffusion generator, it also includes: Inputting the first feature vector into the first variational autoencoder to obtain a first variational feature output by the first variational autoencoder, and inputting the second feature vector into the second variational autoencoder to obtain a second variational feature output by the second variational autoencoder; The first variational feature, the second variational feature, and at least one conditional feature vector are input into a diffusion generator.
4. The method according to claim 1, characterized in that The step of inputting the first feature vector, the second feature vector, and the at least one conditional feature vector into the diffusion generator to obtain a target image output by the diffusion generator includes: Obtaining an initial noise image through the diffusion generator; At each time step processed by the diffusion generator, the first feature vector, the second feature vector, and the at least one conditional feature vector are fused with the initial noise image using an attention mechanism and / or a fusion layer; After fusion processing of multiple time steps, the target image output by the diffusion generator is obtained according to the fusion result of the last time step.
5. The method according to claim 1, characterized in that Before encoding the input text using a text encoder to obtain a first feature vector, the method further includes: Acquire a multilingual data training set, wherein the multilingual data training set includes a plurality of English texts and a plurality of language texts corresponding to the English texts; A multilingual language model is trained based on the multilingual data training set, and the multilingual language model is used to understand and generate texts in multiple languages. The multilingual knowledge of the multilingual language model is transferred to the text encoder using the knowledge distillation method, so that the text encoder can imitate the representation of the multilingual language model on non-English text.
6. The method according to claim 1, characterized in that After obtaining the target image output by the diffusion generator, the method further includes: Perform loss calculation on the target image and the real label corresponding to the target image to obtain a loss value; A differentiated loss function is constructed according to the loss value, and the text encoder, the image encoder and at least one conditional encoder are trained using the differentiated loss function. When the loss value is less than or equal to a preset value, the training of the multimodal diffusion model is completed.
7. The method according to any one of claims 1 to 6, characterized in that: The method further comprises: receiving a user's rating and / or text comment on the target image; Constructing a user feedback vector based on the rating and / or the text comment; The user feedback vector is input into the multimodal diffusion model, and the multimodal diffusion model is fine-tuned using the user feedback vector.
8. An image generating device, characterized in that: include: an acquisition module configured to acquire text description and image information, and input the text description and the image information into a multimodal diffusion model, wherein the multimodal diffusion model includes a text encoder, an image encoder, at least one conditional encoder, and a diffusion generator, and the text description and the image information are associated; an encoding module configured to encode the text description using the text encoder to obtain a first feature vector, and to encode the image information using the image encoder to obtain a second feature vector; an auxiliary module, configured to extract features from the image information using the at least one conditional encoder to obtain at least one conditional feature vector; The generating module is configured to input the first feature vector, the second feature vector and the at least one conditional feature vector into the diffusion generator to obtain a target image output by the diffusion generator.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Text image generation method and diffusion generation model training method
CN116797868A
Image generation method and device
CN116883528A
Method, model and device for training text graph model, and electronic equipment
CN116894880A
Method for expanding language ability of multi-modal model
CN117010331A
Image generation method, model training method and corresponding device
CN117593400A
Cited By
Diffusion model fusion method and device and electronic equipment
CN119295840A
Image generation method and device and display equipment
CN119520934A
Image generation method, apparatus and display device
CN119520934B
Image text feature fusion domain adaptive target detection method for intelligent driving scene
CN119810600A
Image generation method and device based on diffusion implicit model, equipment and medium
CN121053245A
