Method and device for generating image based on text, electronic equipment and storage medium

Through the combination of a large language model and a text editor model, the target cross-adapter model is used to enhance text features, which solves the problem of poor performance of text-to-image generation models under complex descriptions and achieves more accurate and rich image generation.

CN118674829APending Publication Date: 2024-09-20NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 0 Cites 8 Cited by

Patent Information

Application Number
CN202410675747.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-28
Publication Date
2024-09-20

AI Technical Summary

Technical Problem

When existing text-to-image generation models handle complex and dense prompt descriptions, the generated images are not effective and lack semantic understanding and information expression capabilities.

Method used

By inputting the target descriptive text into a large language model and a text editor model to obtain semantic embedding features and text embedding features, and inputting it into the target cross adapter model for fusion processing, the target enhanced text features are generated, and the input text is combined with the noise image to generate an image model, generating more accurate and richer images.

Benefits of technology

The ability to capture the semantic correspondence between text and images is significantly improved, and the generated images are more accurate and richer, solving the problem of poor performance of existing models under complex descriptions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118674829A
    Figure CN118674829A
Patent Text Reader

Abstract

The invention relates to the technical field of artificial intelligence, in particular to a text-based image generation method and device, electronic equipment and a storage medium. The method comprises the following steps: inputting a target descriptive text of a to-be-generated image into a large language model to obtain a target semantic embedding feature, and inputting the target descriptive text into a text editor model to obtain a target text embedding feature; inputting the target semantic embedding feature and the target text embedding feature into a target cross adapter model to obtain a target enhanced text feature; and further, inputting the target enhanced text feature and the noise image into a target text to generate an image model, and generating a target image corresponding to the target descriptive text. Therefore, the semantic expression capability of the text-to-image model is enhanced by using the large language model, and the semantic correspondence between the text and the image can be better captured, so that more accurate and abundant images are generated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a method, device, electronic device and storage medium for generating images based on text. Background Art

[0002] Nowadays, artificial intelligence technology is developing faster and faster, and Text-to-Image AI has become a frontier field where art and technology meet. This technology can convert text descriptions into specific images, providing artists, designers and ordinary users with new creative tools and expressions.

[0003] At present, diffusion models have made significant progress in text-to-image generation models, such as Denoising Diffusion Probabilistic Models (DDPM), Multimodal Pre-training Model DALL-E, and Wenshengtu Large Model Imagen. However, they often encounter challenges when generating images with complex and dense prompt descriptions (such as attribute binding, direction descriptions, and multiple objects), resulting in poor generated images.

[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention

[0005] In view of this, the embodiments of the present application at least provide a method, device, electronic device and storage medium for generating images based on text, which can generate more accurate and rich images.

[0006] This application mainly includes the following aspects:

[0007] In a first aspect, an embodiment of the present application provides a method for generating an image based on text, the method comprising:

[0008] Get the target descriptive text of the image to be generated;

[0009] Inputting the target descriptive text into a large language model to obtain a target semantic embedding feature, and inputting the target descriptive text into a text editor model to obtain a target text embedding feature;

[0010] Inputting the target semantic embedding feature and the target text embedding feature into a target cross adapter model for fusion processing to obtain a target enhanced text feature;

[0011] The target enhanced text features and the noise image are input into a target text generation image model to generate a target image corresponding to the target descriptive text.

[0012] In a second aspect, an embodiment of the present application further provides a device for generating an image based on text, the device comprising:

[0013] An acquisition module, used to acquire target descriptive text of the image to be generated;

[0014] A first determination module is used to input the target descriptive text into a large language model to obtain a target semantic embedding feature, and input the target descriptive text into a text editor model to obtain a target text embedding feature;

[0015] A second determination module is used to input the target semantic embedding feature and the target text embedding feature into a target cross adapter model for fusion processing to obtain a target enhanced text feature;

[0016] The generation module is used to input the target enhanced text features and the noise image into the target text generation image model to generate a target image corresponding to the target descriptive text.

[0017] In a third aspect, an embodiment of the present application further provides an electronic device, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate through the bus, and the machine-readable instructions are executed by the processor to execute the steps of the method for generating images based on text described in the first aspect above.

[0018] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method for generating an image based on text described in the first aspect are executed.

[0019] The method, device, electronic device and storage medium for generating images based on text provided in the embodiments of the present application obtain target semantic embedding features obtained according to a large language model and target text embedding features obtained according to a text editor model by inputting them into a target cross adapter model to obtain target enhanced text features, and then inputting the target enhanced text features and the noise image into a target text generation image model to generate a target image corresponding to the target descriptive text. Compared with diffusion models in related technologies such as DDPM, DALL-E, Imagen and other models, which often encounter challenges when generating images with complex and dense prompt descriptions, resulting in poor generated images, the present application utilizes a large language model to enhance the semantic expression ability of the text generation image model, and can better capture the semantic correspondence between text and image, thereby generating more accurate and rich images.

[0020] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0022] Figure 1 A flowchart of a method for generating an image based on text provided in an embodiment of the present application is shown;

[0023] Figure 2 A schematic diagram showing the principle of generating an image based on text provided in an embodiment of the present application;

[0024] Figure 3 A flowchart of a text-to-image model training process in a method for generating images based on text provided in an embodiment of the present application is shown;

[0025] Figure 4 One of the functional module diagrams of a device for generating an image based on text provided in an embodiment of the present application is shown;

[0026] Figure 5 The second functional module diagram of a device for generating an image based on text provided in an embodiment of the present application is shown;

[0027] Figure 6 A schematic structural diagram of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0028] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can be implemented out of sequence, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art, under the guidance of the content of the present application, can add one or more other operations to the flowchart, or remove one or more operations from the flowchart.

[0029] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0030] In order to enable those skilled in the art to use the contents of this application, the following implementation is given in combination with the specific application scenario of "text generation image". For those skilled in the art, the general principles defined here can be applied to other embodiments and application scenarios without departing from the spirit and scope of this application.

[0031] The following methods, devices, electronic devices or computer-readable storage media of the embodiments of the present application can be applied to any scenario where text needs to be generated into images. The embodiments of the present application are not limited to specific application scenarios. Any scheme using the methods, devices, electronic devices and storage media for generating images based on text provided by the embodiments of the present application is within the scope of protection of the present application.

[0032] It is worth noting that before the present application was proposed, diffusion models in related schemes such as DDPM, DALL-E, Imagen, etc. often encountered challenges when generating images with complex and dense prompt descriptions, resulting in poor generated images.

[0033] In view of the above problems, the embodiment of the present application obtains the target semantic embedding features by inputting the target descriptive text of the image to be generated into a large language model, and obtains the target text embedding features by inputting the target descriptive text into a text editor model; then, the target semantic embedding features and the target text embedding features are input into a target cross adapter model to obtain the target enhanced text features; further, the target enhanced text features and the noise image are input into the target text generation image model to generate the target image corresponding to the target descriptive text. In this way, the present application can better capture the semantic correspondence between text and image by utilizing a large language model to enhance the semantic expression ability of the text generation image model, thereby generating a more accurate and rich image.

[0034] To facilitate the understanding of the present application, the technical solution provided by the present application is described in detail below in conjunction with specific embodiments.

[0035] Figure 1 A flowchart of a method for generating an image based on text provided in an embodiment of the present application. Figure 1As shown, the method for generating an image based on text provided in an embodiment of the present application includes the following steps:

[0036] S101: Obtain target descriptive text of the image to be generated.

[0037] Here, the descriptive text is also called text description. The descriptive text can be a series of words and phrases arranged coherently, with complete and independent meanings, used to describe the image to be generated (i.e., the image to be generated). The content of the descriptive text may include but is not limited to entities, the number of entities, the location of entities, the logical position relationship between different entities, etc. Among them, entities usually refer to objects that exist in the real world, such as people, tables, rooms, animals, flowers, trees, fruits, etc.

[0038] For example, the descriptive text may be "a beautifully decorated living room with a white sofa on which blue and gray pillows are placed neatly along the backrest", where "living room", "sofa", and "pillows" are entities; the descriptive text may be "a spotted dog wearing a blue cowboy hat playing on the grass", where "grass", "cowboy hat", and "dog" are entities.

[0039] It should be noted that the descriptive text in this application can be a long descriptive text or a short descriptive text. The long descriptive text is relative to the short descriptive text. The long descriptive text is different from the short descriptive text in terms of text length, structural complexity, information density and processing difficulty. Among them, the long descriptive text is usually longer and takes a longer time to read and understand, while the short descriptive text is relatively short and can be read quickly; the long descriptive text can usually provide more information and details, while the short descriptive text has less information and its features are sparser. Therefore, the long descriptive text is also used to describe the text description method used when generating complex and dense prompt descriptions (such as attribute binding, direction description and multiple objects) of the image.

[0040] S102: Inputting the target descriptive text into a large language model to obtain target semantic embedding features, and inputting the target descriptive text into a text editor model to obtain target text embedding features.

[0041] In a specific implementation, the target descriptive text of the image to be generated can be input into a large language model to extract semantics and encode to obtain target semantic embedding features, and the target descriptive text can be input into a text editor model for text encoding to obtain target text embedding features. Here, the large language model in the embodiment of the present application has rich language understanding and generation capabilities, and can understand and express more complex and abstract semantic structures, so the target semantic embedding features obtained by the large language model can characterize the semantic content and semantic structure of the target descriptive text; the text editor model in the embodiment of the present application has text encoding capabilities, and the target description text can be converted into a digital representation that can be recognized by a machine through the text editor model, that is, the target text embedding features.

[0042] It should be noted that the large language model (Large Language Model, LLM) provided by the embodiment of the present application is a language model based on deep learning, which is used to understand natural language, i.e. semantic understanding. Here, the working principle of the large language model is to train through a large-scale data set to learn the language patterns and rules in the data, and generate semantic representations (i.e., semantic embedding features) that conform to grammar and semantics. Therefore, a large amount of text data can be analyzed and processed by a trained large language model, and a fluent, accurate and context-related semantic representation output can be generated, that is, a large language model can not only understand the basic structure of human language, but also grasp its semantics and emotions at a deeper level, and identify the semantic information in the text data. Based on this, considering that the traditional text generation image model may have insufficient semantic understanding or information loss when processing complex descriptions, the embodiment of the present application enhances the semantic expression ability of the text generation image model by utilizing a large language model, and can better capture the semantic correspondence between text and image, and by embedding a large language model into the text to image generation process, its powerful language comprehension ability can be used to explain and understand the complex description in the text, which can help solve the problem of generating complex and intensive prompt descriptions in the related art, resulting in poor image effects.

[0043] In addition, the text editor model (A Text Encoder) provided in the embodiment of the present application converts text data into a digital representation containing the meaning of the text that can be recognized by a machine, which is called embedding. The process of converting text into a digital representation can be divided into two parts: splitting the text data input into individual words, and then using a lookup table to convert each word into a number; converting the digital representation of each word into a feature representation (text embedding feature) containing the semantic information of the text.

[0044] Here, the text editor model provided in the embodiment of the present application can be a contrastive language-image pre-training model (Contrastive Language-Image Pre-Training, CLIP). The core idea of ​​the CLIP model is to use a large amount of paired data of images and texts for pre-training to learn the alignment relationship between images and texts. Therefore, the CLIP model is used to assist the text in generating image models, which can further improve the correspondence between the generated images and descriptive texts, thereby reducing the cost in training resources and time. Specifically, the CLIP model has two modes, one is the text mode and the other is the visual mode, including two main parts, one part is the text encoder (Text Encoder) for converting text into a low-dimensional vector representation, and the other part is the image encoder (Image Encoder) for converting images into similar vector representations. In the prediction stage, the CLIP model generates predictions by calculating the cosine similarity between text and image vectors. In the embodiment of the present application, the text conversion ability of the CLIP model is mainly used. Among them, the CLIP model is particularly suitable for zero-sample learning tasks, that is, the CLIP model does not need to see new training examples of images or texts to make predictions, and the CLIP model performs well in multiple fields, such as image text retrieval, image-text generation, etc.

[0045] S103: Input the target semantic embedding feature and the target text embedding feature into a target cross adapter model for fusion processing to obtain a target enhanced text feature.

[0046] In a specific implementation, the target semantic embedding features obtained by processing the target descriptive text based on the large language model and the target text embedding features obtained by processing the target descriptive text based on the text editor model are input into the target cross adapter model for fusion processing to obtain the target enhanced text features. Among them, the target enhanced text features are used to represent the text embedding representation that enhances the semantic features of the target descriptive text.

[0047] Here, considering that it is possible to start from the perspective of model structure, by adding additional training modules, that is, for downstream specific tasks, "adapting" based on small set parameters, that is, setting adapters between each model, it is possible to efficiently use transfer learning in natural language processing, especially when facing multiple downstream tasks, it is possible to avoid fine-tuning the model completely for each task, thereby improving the efficiency of parameter use. Based on this, the embodiment of the present application designs a target cross-adapter model (Cross-Adapter Module), and adds a target cross-adapter model between a large language model and a text editor model and a target text generation image model, and implicitly integrates the target semantic embedding features and the target text embedding features through the target cross-adapter model to obtain the target enhanced text features. In the model training stage of text generation image, large language models and text editor models can be used directly, that is, there is no need to train large language models and text editor models, and only the target cross-adapter model and the target text generation image model are trained and parameter adjusted, so that the application requirements of the final text generation image can be achieved.

[0048] It should be noted that in the embodiment of the present application, the target cross-adapter model can be a model based on the cross-attention mechanism, which processes the semantic relationship between the two sequences by calculating attention on two different sequences (target semantic embedding features and target text embedding features) to obtain target enhanced text features that enhance the semantic features of the target descriptive text.

[0049] S104: Inputting the target enhanced text features and the noise image into a target text generation image model to generate a target image corresponding to the target descriptive text.

[0050] In a specific implementation, the target enhanced text features and the noise image obtained based on the target cross adapter model are input into the target text generation image model for processing, so as to obtain the target image corresponding to the target descriptive text.

[0051] Here, the noise image in the implementation of the present application can be an image obtained by randomly adding noise to a blank image. "Noise" can be theoretically defined as "random error that is unpredictable and can only be understood by probabilistic statistical methods." The noise image can be regarded as obtained by a multidimensional random process, and the description of the random process can be used to describe the noise, that is, using its probability distribution function and probability density distribution function.

[0052] It should be noted that the text-generated image model is a machine learning model. The model is usually trained with a large amount of image and text data to learn how to convert text descriptions into corresponding visual representations. Usually, the text-generated image model can take natural language descriptions as input and generate images that match the description. The text-generated image model belongs to a generative model. Generative models and discriminative models are two different types of models in machine learning. The goal of the generative model is to learn the generative distribution of data and to generate new samples similar to the training data. These models perform well in tasks such as image generation, text generation, and sample generation, and are often used to generate new training samples and data enhancement, etc. Here, the text-generated image model in the embodiment of the present application can use any model that can generate images from text.

[0053] Taking into account that in the related arts, text-generated image models such as the denoising diffusion probability model DDPM, the multimodal pre-trained model DALL-E, and the large text-generated image model Imagen have poor generated image effects when generating images with complex and dense prompt descriptions, the embodiments of the present application, in addition to using the traditional text-generated image models, also utilize the advantages of large language models in semantic expression when performing text-generated images, and use the text editor model and the target cross-adapter model to obtain target enhanced text features. The target enhanced text features can better capture the semantic correspondence between text and image, thereby generating more accurate and rich images.

[0054] Specifically, the traditional text-generated image model may have problems with insufficient semantic understanding or information loss when processing complex descriptions, while the large language model, with its powerful language understanding and generation capabilities, can provide more accurate and rich semantic expressions. Specifically, the target enhanced text features obtained by the target cross-adapter model are used as the input of the target text-generated image model, rather than directly using the target text embedding features as the input of the target text-generated image model. In this way, the target enhanced text features can be used as conditional vectors and embedded in the target text-generated image model to guide the image generation process. In other words, the embodiment of the present application aims to utilize the semantic representation capabilities of a large language model and directly integrate it into the text-generated image model. In this way, the semantic knowledge learned by the large language model can be effectively combined with the target text-generated image model, so that the target text-generated image model can better understand and express the semantic information in the descriptive text, and generate an image that is more in line with the target descriptive text, thereby achieving more accurate and detailed image generation.

[0055] In an embodiment of the present application, the target descriptive text of the image to be generated is input into a large language model to obtain the target semantic embedding feature, and the target descriptive text is input into a text editor model to obtain the target text embedding feature; then, the target semantic embedding feature and the target text embedding feature are input into a target cross adapter model to obtain the target enhanced text feature; further, the target enhanced text feature and the noise image are input into the target text generation image model to generate the target image corresponding to the target descriptive text. In this way, the present application can better capture the semantic correspondence between text and image by using a large language model to enhance the semantic expression ability of the text generation image model, thereby generating a more accurate and rich image.

[0056] In a possible implementation, the working principle of the target cross adapter model is described, that is, the step of inputting the target semantic embedding feature and the target text embedding feature into the target cross adapter model to obtain the target enhanced text feature in S103 includes the following steps:

[0057] Step 1031: cross-attention fusion processing is performed on the target semantic embedding feature and the target text embedding feature to obtain a semantic fusion feature.

[0058] Step 1032: serially connect the semantic fusion feature and the target text embedding feature to obtain a target enhanced text feature.

[0059] In the specific implementation, the target semantic embedding features and the target text embedding features are first cross-attention fused to obtain semantic fusion features, and then the obtained semantic fusion features and the target text embedding features are serially connected to obtain target enhanced text features.

[0060] Here, the target cross-adapter model can be a model based on a cross-attention mechanism, which can also be called a cross-attention model. Specifically, cross-attention is a type of attention mechanism used to process two related but different sequences. Specifically, two different sequences are cross-calculated for attention to obtain the correlation between them (which can also be understood as similarity), and weights are assigned to each element based on the correlation, and then the weighted element vector is used as output.

[0061] It should be noted that the target cross-adapter model uses cross-attention on the representations of large language models that are only encoded and only decoded (such as Llama and T5) while taking the target text embedding features as input, and then concatenates the fused semantic fusion features with the target text embedding features. In this way, the target cross-adapter model can integrate the semantic embedding features of large language models that are only encoded (such as LLaMA-v2) and large language models that are only decoded (such as T5-XL), thereby enhancing the ability of the text-to-image model. Through this design of the target cross-adapter model, the representation of the large language model can be seamlessly integrated into the target text embedding features output by the text editor model, providing more semantic information and learning capabilities for the text-to-image model.

[0062] Among them, the cross-attention fusion processing can be processed by the normalization function softmax, and the serial connection processing can be processed by the connection function concat.

[0063] Exemplarily, if the target cross-adapter model is a cross-attention model, let Q = W q (cl), K = W k (ct), V = W v (ct), cl represents the target semantic embedding feature, ct represents the target text embedding feature, then the target semantic embedding feature cl and the target text embedding feature ct are cross-attention fused to obtain the semantic fusion feature cl′ (i.e., cross-attention calculation) formula:

[0064] cl′=CrossAttention(Q,K,V)=Softmax(Q·K T) ·V;

[0065] Among them, the target semantic embedding feature is used as the query sequence Q (q1, q2, ..., qm) in the cross-attention mechanism, the target text embedding feature is used as the key sequence K (k1, k2, ..., kn) in the cross-attention mechanism, and the target text embedding feature is also used as the value sequence V (v1, v2, ..., vn) in the cross-attention mechanism. The output is the sum of the weighted vectors of each element in the query sequence, and the weight is determined by the attention score with the key sequence. For each row vector, its attention weight for all row vectors is given.

[0066] In addition, the semantic fusion feature cl′ and the target text embedding feature ct are serially connected to obtain the formula of the target enhanced text feature ct′:

[0067] ct′=Concat(λ*cl′,ct);

[0068] Among them, λ is the weight coefficient.

[0069] In a possible implementation, the first feature dimension of the target enhanced text feature is the same as the second feature dimension of the target text embedding feature.

[0070] It should be noted that the target text generation image model in the embodiment of the present application can be a part of the stable diffusion model (SD), which is also called the latent diffusion model (Latent Diffusion Model). The stable diffusion model can be regarded as a special diffusion model, which is a deep learning model that can generate images given a text prompt word. Generally, the stable diffusion model includes three components: a text encoder (such as a CLIP model), an autoencoder (such as a variational autoencoder model VAE), and a denoising model (such as a diffusion model Unet).

[0071] Here, the embodiment of the present application functionally splits the stable diffusion model, splits the stable diffusion model into a text editor model and a target text generation image model (autoencoder + denoising model), and combines other models (large language model, target cross adapter model) to apply text generation images. Generally, the purpose of the text editor model in the stable diffusion model is to convert the text into an embedded representation through a trained text editor model, and this embedded representation is used as one of the inputs of the denoising model. For the embodiment of the present application, the present application can still use the target text embedding features output by the text editor model, but the target text embedding features are no longer directly used as the input of the denoising model, but through the target cross adapter model, the first feature dimension of the target enhanced text feature and the second feature dimension of the target text embedding feature are the same, so that the target semantic embedding feature and the target text embedding feature can be directly fused to obtain the target enhanced text feature as the input of the denoising model.

[0072] It should be noted that the embodiment of the present application makes the first feature dimension of the target enhanced text feature output by the designed target cross-adapter model the same as the second feature dimension of the target text embedding feature output by the text editor model. In this way, the original semantic prior representation can be integrated using the rich representation of the large language model. The target cross-adapter model can not only implicitly promote the rich representation of the large language model in a cross-attention fusion manner, so that it can perform semantic-image representation alignment with the denoising model in the text-generated image model. This design not only does not require a large amount of training data and resources to adjust the consistency alignment of the semantic embedding features (latent vectors) and denoising vectors of the large language model, but also provides richer semantic information for the text-generated image model, thereby enhancing its performance and generalization ability. In addition, the embodiment of the present application also retains the original representation generated by the text encoder, thereby reducing the requirement for a large amount of training data.

[0073] In a possible implementation, the third feature dimension of the semantic fusion feature is the same as the second feature dimension of the target text embedding feature.

[0074] In a specific implementation, when designing the internal network structure of the target cross-adapter model, the third feature dimension of the semantic fusion feature obtained in the middle of the model is made the same as the second feature dimension of the target text embedding feature. In this way, it is easier to achieve the same first feature dimension of the target enhanced text feature and the second feature dimension of the target text embedding feature.

[0075] In a possible implementation, the target text image generation model includes a variational autoencoder model and a target denoising model, and the variational autoencoder model includes an image encoder and an image decoder; the step of inputting the target enhanced text features and the noise image into the target text image generation model in S104 to generate a target image corresponding to the target descriptive text includes the following steps:

[0076] Step 1041: input the noise image into the image encoder to obtain noise potential features.

[0077] Step 1042: inputting the noise latent features and the target enhanced text features into the target denoising model to obtain target denoised image latent features;

[0078] Step 1043: input the target denoised image potential features into the image decoder to obtain the target image corresponding to the target descriptive text.

[0079] In a specific implementation, the target text generation image model in the embodiment of the present application includes a variational autoencoder model and a target denoising model, and the variational autoencoder model includes an image encoder and an image decoder. The working process of the target text generation image model in the embodiment of the present application is described below. First, any randomly generated noise image is input into the variational autoencoder model image encoder for image encoding, and the noise potential features are predicted. Then, the noise potential features output by the image encoder and the target enhanced text features output by the target cross adapter model are input into the target denoising model together to obtain the target denoising image potential features of the target enhanced text features with the noise features removed. Further, the target denoising image potential features that only contain the image features corresponding to the target enhanced text features are input into the image decoder, and the target image corresponding to the target descriptive text can be obtained.

[0080] It should be noted that the variational autoencoder model (VAE) is a generative model that combines the ideas of autoencoders and probabilistic graph models. The variational autoencoder model can generate new data samples by learning the potential distribution of data. The core of the variational autoencoder model is to map the input data to the distribution in the potential space and maximize the conditional probability between the data and the potential variables during the training process. Specifically, the variational autoencoder model includes two parts: an image encoder and an image decoder. The image encoder encodes the input data into the parameters of the potential distribution, and the image decoder samples and generates new data from this distribution, that is, the image encoder compresses and encodes the original image to obtain potential features, and then the image decoder obtains the restored image based on the potential features. This generation method is not only limited to generating new data, but also allows interpolation and operation in the potential space, thereby providing powerful feature learning and data generation capabilities. The target text generation image model can perform text generation image tasks without a variational autoencoder model, but the reason for using the variational autoencoder model in the embodiment of the present application is to reduce the computational time for generating high-resolution images. The target text generated image can be diffused in this latent space produced by the variational autoencoder model. Once the desired latent output is produced through the diffusion process, it can be converted back to a high-resolution image using the image decoder of the variational autoencoder model.

[0081] It should also be noted that the target denoising model can be a diffusion model UNet, and UNet can include a neural network module (ResNet blocks), and the neural network module can include multiple convolutional layers, batch normalization layers, and identity mappings. Exemplarily, the neural network module consists of two convolutional layers, two batch normalization layers, and a ReLU activation function. For the embodiment of the present application, the UNet in the target text generation image model can also have an attention layer, through which the output can be controlled and adjusted according to the provided text description (target enhanced text features), wherein the attention layer is usually added between the encoder and decoder of the U-Net.

[0082] Typically, UNet includes two inputs, one is a noise latent space representation (Noisy latent / Noise), and the other is a text embedding representation (Text embeddings). Among them, the noise latent space representation is mainly generated by the image encoder of the variational autoencoder model and noise is added on its basis. For the embodiment of the present application, one of the corresponding inputs of the target denoising model is a noise latent feature, which only uses pure noise (noise image) as input; the text embedding representation is a text embedding feature obtained based on the text editor model. For the embodiment of the present application, another corresponding input of the target denoising model is a target enhanced text feature. In addition, in addition to predicting the target denoising image latent features, the target denoising model can also predict the noise of the noise image.

[0083] For example, Figure 2 A schematic diagram showing the principle of generating an image based on text provided in an embodiment of the present application; Figure 2It includes a large language model, a text editor model, a target cross adapter model, and a target text-to-image generation model. The target text-to-image generation model includes a variational autoencoder model and a target denoising model, and the variational autoencoder model includes an image encoder and an image decoder. In the actual application process of text-generated image, the target descriptive text used to describe the image to be generated is first input into a large language model to obtain the target semantic embedding feature. In addition, the target descriptive text is also input into a text editor model to obtain the target text embedding feature. Then, the target semantic embedding feature and the target text embedding feature are input into the target cross adapter together to obtain the target enhanced text feature. Further, the noise image and the target enhanced text feature are input into the target text-generated image model together to obtain the target image corresponding to the target descriptive text. Specifically, the noise image is first input into the image encoder of the variational autoencoder model to obtain the noise latent feature z that encodes the noise feature information of the noise image. The noise latent feature z is fused through the attention layer and the target enhanced text feature in the target denoising model, that is, the noise latent feature z is iteratively denoised using the target denoising model. The target enhanced text feature is used to control and guide the feature fusion process of the noise latent feature z, so that the generated target image can be consistent with the target descriptive text. Finally, the fused target denoised image latent feature z′ can generate a target image in RGB format, for example, through the image decoder of the variational autoencoder model. In this way, due to the guiding role of the target enhanced text features, the embodiment of the present application can make the generated target image consistent with the given target descriptive text and can reflect the semantic content of the descriptive text.

[0084] Figure 3 A flowchart of a text-to-image model training process in a method for generating images based on text provided in an embodiment of the present application is shown; Figure 3 As shown, the target text generation image model is trained according to the following steps in the embodiment of the present application:

[0085] S301: Acquire a long text image sample data set, wherein any long text image sample pair in the long text image sample data set includes a sample image and a sample long text of the sample image.

[0086] In a specific implementation, unlike the text-to-image generation method in the related art that uses short text-image pairs to train the model, the embodiment of the present application uses a long text-image sample dataset to train the model. In this way, the problem of short text length or inconsistency with the image in the text-image pair dataset in the related art can be solved. This method of training the model using a long text-image sample dataset can help the model better understand the semantics in the text and provide more detailed and rich description information, thereby improving the accuracy and performance of the model in the task of generating complex images.

[0087] It should be noted that this application can successfully integrate the semantic representation capabilities of large language models into the target text generation image model by innovatively designing a target cross-adapter model and using a long text image sample dataset for model training, thereby significantly enhancing the text semantic expression capabilities and bringing more precise and detailed semantic guidance to image generation tasks, which has important technical and application value.

[0088] Here, the embodiment of the present application does not limit the method of determining the long text image sample data set. The following examples illustrate two methods of determining the long text image sample data set. Method 1 is to determine the long text image sample data set as the model training data set based on the sample image set and the multimodal large model, which can supplement the image descriptions in the existing text image data set. Method 2 is to obtain multiple long text image pairs based on the short text image sample data set and the multimodal large model, fuse the long text and short text of each sample image, and determine the long text image sample data set as the model training data set. Such a training data set contains both the original short text image sample pairs and the newly generated long text-image pairs, providing the model with richer and more comprehensive training samples.

[0089] Method 1: Obtain the long text image sample data set according to the following steps: obtain a plurality of the sample images; for any of the sample images, input the sample image and image description requirement information into a multimodal large model to obtain the first long text of the sample image; determine each of the first long texts and the sample image of the first long text as the long text image sample data set.

[0090] Method 2: Obtain the long text image sample data set according to the following steps: obtain a short text image sample data set; any short text image sample pair in the short text image sample data set includes a sample image and a sample short text of the sample image; for any of the short text image sample pairs, input the sample image and image description requirement information into a multimodal large model to obtain a second long text of the sample image; for any of the sample images, splice the second long text of the sample image and the sample short text to obtain a spliced ​​sample; each of the spliced ​​samples and the sample image of the spliced ​​sample are determined as the long text image sample data set.

[0091] It should be noted that the multimodal large model is a multimodal large language model, through which descriptive text can be generated, such as LLaVA. The architecture of the multimodal large model allows the fusion of image and language information and processing in the same feature space. By fine-tuning the generated data, the performance of the model can be further optimized. This approach helps to improve the performance of multimodal tasks and provides a powerful capability for mutual understanding between images and languages. For an embodiment of the present application, the input of the multimodal large model includes a sample image and image description requirement information (text information), and the output of the multimodal large model is a long text of the sample image, that is, a long text description can be generated by the multimodal large model. Among them, the image description requirement information is the requirement for the long text describing the sample image.

[0092] Here, the embodiment of the present application innovatively proposes a method for expanding the image text description. Through a multimodal large model, a long text image sample data set can be directly obtained through a sample image set, or the original short text image sample data set can be expanded into a long text image sample data set. In this way, a richer and more comprehensive training sample can be provided for the model, thereby improving the accuracy and performance of the model in generating complex image tasks.

[0093] Exemplarily, the image description requirement information is "Describe this picture in detail in more than 50 words, specifying the main objects and their relationships". The sample image and the image description requirement information are input into the multimodal large model, and the first long text of the sample image is obtained as "The picture depicts a beautifully decorated living room with a white sofa with blue and gray pillows arranged neatly along the backrest. The sofa is placed against the wall and there is a subtle pattern on the wallpaper."

[0094] S302: For any of the long text image sample pairs, input the sample long text into the large language model to obtain sample semantic embedding features, and input the sample long text into the text editor model to obtain sample text embedding features.

[0095] S303: Input the sample semantic embedding features and the sample text embedding features into an initial cross adapter model to obtain sample enhanced text features.

[0096] S304: Based on the sample enhanced text features corresponding to each of the long text image samples, the sample image and the sample noise information, the initial text generation image model is trained to obtain the target text generation image model.

[0097] Here, the initial text generation image model can be trained through the sample enhanced text features, sample images and sample noise information corresponding to each long text image sample in the long text image sample data set, wherein the sample noise information can be used as a noise label, and the sample noise information is added to the sample image for processing during model training, and further, the target text generation image model is trained.

[0098] In a possible implementation, the step of training the initial text generation image model based on the sample enhanced text features corresponding to each of the long text image samples, the sample image, and the sample noise information to obtain the target text generation image model in S304 includes the following steps:

[0099] Step 3041: For any of the long text image sample pairs, the sample image is input into the image encoder in the initial text generation image model to obtain potential features of the sample image.

[0100] Step 3042: Fusing the sample image potential features and the sample noise information to obtain fused image noise potential features.

[0101] Step 3043: Input the fused image noise potential features and the sample enhanced text features into the initial denoising model in the initial text generation image model to obtain the sample denoised image potential features and the sample predicted noise features.

[0102] Step 3044: Based on the loss value between the sample prediction noise feature and the sample noise information corresponding to each of the long text image samples, the initial text generation image model is trained to obtain the target text generation image model.

[0103] In a specific implementation, during the training process of the initial text generation image model, for each long text image sample in the long text image sample data set, the sample image in the long text image sample is first input into the image encoder of the variational autoencoder model in the initial text generation image model to obtain the sample image potential feature that characterizes the image feature of the sample image, and then some noise is added to the sample image potential feature of the sample image, that is, the sample noise information is added to obtain the fused image noise potential feature that fuses the sample image potential feature and the sample noise information; further, the fused image noise potential feature and the sample enhanced text feature output by the initial cross adapter model are input together into the initial denoising model in the initial text generation image model to obtain the sample denoising image potential feature, so that the sample enhanced text feature guides the model to output the expected result in a text conditional manner, the initial denoising model performs noise prediction in the latent space to obtain the sample prediction noise feature, determines the loss value between the predicted sample prediction noise feature and the sample noise information, and based on the loss value between the corresponding sample prediction noise feature and the sample noise information of each long text image sample pair, the initial text generation image model is trained to obtain the target text generation image model.

[0104] In a possible implementation, in step 3044, based on the loss value between the sample prediction noise feature and the sample noise information corresponding to each of the long text image samples, the initial text generation image model is trained to obtain the target text generation image model, including the following steps:

[0105] Based on the loss values ​​corresponding to each pair of long text image samples, the first model parameters of the initial cross adapter model and the second model parameters of the initial denoising model are updated until the initial text generation image model meets the model convergence conditions, thereby generating the target text generation image model.

[0106] In a specific implementation, before performing the text-generated image application, the embodiment of the present application can directly use the large language model and text editor model that have been trained in the prior art. When performing the text-generated image training, the model parameters of the large language model and the text editor model are fixed, and only the initial cross adapter model and the initial text-generated image model are trained. Specifically, after determining the loss value corresponding to each long text image sample pair in the long text image sample data set, the loss value obtained each time is back-propagated to the initial denoising model and the initial cross adapter model in the initial text-generated image to update the parameters. In this way, by optimizing these parameters, the model can learn a better text-image correspondence, thereby generating higher quality images.

[0107] The model convergence condition may be that the training round reaches a preset round threshold, or the model convergence condition may be that the loss value corresponding to a certain training round is less than a preset loss threshold. The loss value between the sample prediction noise feature and the sample noise information corresponding to each sample image may be calculated using a target loss function such as a mean square error loss function (MSE), which is a loss function of the denoising model.

[0108] It should also be noted that the target cross-adapter model designed in the embodiment of the present application can use the powerful representation ability of the large language model to enhance the original text representation ability of the target text generation image model, while other methods in the related art that use large language models to improve the semantic generation ability of the diffusion model require the use of a lot of computing resources and training data. For example, the LLM-guidance model and the LLM-alignment model in the related art require a lot of training data. The embodiment of the present application significantly reduces the training data requirements and computing costs. Figure 1 The method of generating images from text in the paper only uses 2M data, which is 90% less than the ELLA model, and only requires 32 GPUs for training, which is much lower than PixArt (25 million data, 753 GPUs) and ParaDiffusion (500 million data, 392 GPUs). The embodiments of the present application can significantly reduce the cost of training data and computing, while setting a new standard for performance efficiency. However, despite using less training data and computing resources, the embodiments of the present application can still outperform the text-image diffusion model in the related art in terms of sample quality and image-text alignment, and can bring semantic supplements to the original text generation graph model.

[0109] Based on the same application concept, the embodiments of the present application also provide a text-based image generation device corresponding to the text-based image generation method provided in the above embodiments. Since the principle of solving the problem by the device in the embodiments of the present application is similar to the text-based image generation method in the above embodiments of the present application, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0110] like Figures 4 to 5 As shown, Figure 4 This is one of the functional module diagrams of a device 400 for generating an image based on text provided in an embodiment of the present application. Figure 5 This is a second functional module diagram of a device 400 for generating an image based on text provided in an embodiment of the present application. Figure 4As shown, the apparatus 400 for generating an image based on text includes: an acquisition module 410, used to acquire a target descriptive text of an image to be generated; a first determination module 420, used to input the target descriptive text into a large language model to obtain a target semantic embedding feature, and input the target descriptive text into a text editor model to obtain a target text embedding feature; a second determination module 430, used to input the target semantic embedding feature and the target text embedding feature into a target cross adapter model for fusion processing to obtain a target enhanced text feature; and a generation module 440, used to input the target enhanced text feature and a noise image into a target text generation image model to generate a target image corresponding to the target descriptive text.

[0111] In a possible specific implementation, Figure 4 As shown, the second determination module 430 is used to obtain the target enhanced text feature according to the following steps: cross-attention fusion processing is performed on the target semantic embedding feature and the target text embedding feature to obtain a semantic fusion feature; and the semantic fusion feature and the target text embedding feature are serially connected to obtain a target enhanced text feature.

[0112] In a possible specific implementation, Figure 4 As shown, the target text generation image model includes a variational autoencoder model and a target denoising model, and the variational autoencoder model includes an image encoder and an image decoder; the generation module 440 is used to generate a target image corresponding to the target descriptive text according to the following steps: inputting the noise image into the image encoder to obtain noise latent features; inputting the noise latent features and the target enhanced text features into the target denoising model to obtain target denoised image latent features; inputting the target denoised image latent features into the image decoder to obtain the target image corresponding to the target descriptive text.

[0113] In a possible specific implementation, Figure 5As shown, the apparatus 400 for generating images based on text also includes a training module 450; the training module 450 is used to train the target text generation image model according to the following steps: obtaining a long text image sample data set, wherein any long text image sample pair in the long text image sample data set includes a sample image and a sample long text of the sample image; for any of the long text image sample pairs, inputting the sample long text into the large language model to obtain a sample semantic embedding feature, and inputting the sample long text into the text editor model to obtain a sample text embedding feature; inputting the sample semantic embedding feature and the sample text embedding feature into the initial cross adapter model to obtain a sample enhanced text feature; based on the sample enhanced text features corresponding to each of the long text image sample pairs, the sample image and the sample noise information, the initial text generation image model is trained to obtain the target text generation image model.

[0114] In a possible specific implementation, Figure 5 As shown, the training module 450 is used to obtain the long text image sample data set according to the following steps: obtain a plurality of the sample images; for any of the sample images, input the sample image and image description requirement information into a multimodal large model to obtain the first long text of the sample image; and determine each of the first long texts and the sample image of the first long text as the long text image sample data set.

[0115] In a possible specific implementation, Figure 5 As shown, the training module 450 is used to obtain the long text image sample data set according to the following steps: obtain a short text image sample data set; any short text image sample pair in the short text image sample data set includes a sample image and a sample short text of the sample image; for any of the short text image sample pairs, input the sample image and image description requirement information into the multimodal large model to obtain the second long text of the sample image; for any of the sample images, splice the second long text of the sample image and the sample short text to obtain a spliced ​​sample; each of the spliced ​​samples and the sample image of the spliced ​​sample are determined as the long text image sample data set.

[0116] In a possible specific implementation, Figure 5As shown, the training module 450 is used to train the initial text generation image model according to the following steps to obtain the target text generation image model: for any of the long text image sample pairs, the sample image is input into the image encoder to obtain the sample image potential features; the sample image potential features and the sample noise information are fused to obtain the fused image noise potential features; the fused image noise potential features and the sample enhanced text features are input into the initial denoising model to obtain the sample denoising image potential features; based on the loss value between the sample predicted noise features and the sample noise information corresponding to each of the long text image sample pairs, the initial text generation image model is trained to obtain the target text generation image model.

[0117] In a possible specific implementation, Figure 5 As shown, the training module 450 is specifically used to train the initial text generation image model according to the following steps to obtain the target text generation image model: based on the loss values ​​corresponding to each of the long text image sample pairs, the first model parameters of the initial cross adapter model and the second model parameters of the initial denoising model are updated until the initial text generation image model meets the model convergence conditions, thereby generating the target text generation image model.

[0118] In an embodiment of the present application, the target descriptive text of the image to be generated is input into a large language model through the first determination module 420 to obtain the target semantic embedding feature, and the target descriptive text is input into the text editor model to obtain the target text embedding feature; then, the target semantic embedding feature and the target text embedding feature are input into the target cross adapter model through the second determination module 430 to obtain the target enhanced text feature; further, the target enhanced text feature and the noise image are input into the target text generation image model through the generation module 440 to generate the target image corresponding to the target descriptive text. In this way, the present application can better capture the semantic correspondence between text and image by using a large language model to enhance the semantic expression ability of the text generation image model, thereby generating a more accurate and rich image.

[0119] Based on the same application concept, see Figure 6 As shown, it is a schematic diagram of the structure of an electronic device 600 provided in an embodiment of the present application, including: a processor 610, a memory 620 and a bus 630, wherein the memory 620 stores machine-readable instructions executable by the processor 610, and when the electronic device 600 is running, the processor 610 communicates with the memory 620 through the bus 630, and the machine-readable instructions are executed by the processor 610 when running to perform the steps of the method for generating an image based on text as described in any of the above embodiments.

[0120] Specifically, when the machine-readable instructions are executed by the processor 610, the following processing can be performed: obtaining the target descriptive text of the image to be generated; inputting the target descriptive text into a large language model to obtain target semantic embedding features, and inputting the target descriptive text into a text editor model to obtain target text embedding features; inputting the target semantic embedding features and the target text embedding features into a target cross-adapter model for fusion processing to obtain target enhanced text features; inputting the target enhanced text features and the noise image into a target text generation image model to generate a target image corresponding to the target descriptive text.

[0121] Specifically, when the machine-readable instructions are executed by the processor 610, the following processing can be performed: inputting the noisy image into the image encoder to obtain noise latent features; inputting the noise latent features and the target enhanced text features into the target denoising model to obtain target denoised image latent features; inputting the target denoised image latent features into the image decoder to obtain the target image corresponding to the target descriptive text.

[0122] Specifically, when the machine-readable instructions are executed by the processor 610, the following processing can be performed: obtaining a long text image sample data set, wherein any long text image sample pair in the long text image sample data set includes a sample image and a sample long text of the sample image; for any of the long text image sample pairs, inputting the sample long text into the large language model to obtain a sample semantic embedding feature, and inputting the sample long text into the text editor model to obtain a sample text embedding feature; inputting the sample semantic embedding feature and the sample text embedding feature into an initial cross adapter model to obtain a sample enhanced text feature; based on the sample enhanced text features corresponding to each of the long text image sample pairs, the sample image and the sample noise information, training the initial text generation image model to obtain the target text generation image model.

[0123] Specifically, when the machine-readable instructions are executed by the processor 610, the following processing can be performed: obtaining a plurality of the sample images; for any of the sample images, inputting the sample image and image description requirement information into a multimodal large model to obtain the first long text of the sample image; and determining each of the first long texts and the sample image of the first long text as the long text image sample data set.

[0124] Specifically, when the machine-readable instructions are executed by the processor 610, the following processing can be performed: obtaining a short text image sample data set; any short text image sample pair in the short text image sample data set includes a sample image and a sample short text of the sample image; for any of the short text image sample pairs, the sample image and the image description requirement information are input into the multimodal large model to obtain the second long text of the sample image; for any of the sample images, the second long text of the sample image and the sample short text are spliced ​​to obtain a spliced ​​sample; each of the spliced ​​samples and the sample image of the spliced ​​sample are determined as the long text image sample data set.

[0125] Specifically, when the machine-readable instructions are executed by the processor 610, the following processing can be performed: for any of the long text image sample pairs, the sample image is input into the image encoder to obtain the sample image potential features; the sample image potential features and the sample noise information are fused to obtain the fused image noise potential features; the fused image noise potential features and the sample enhanced text features are input into the initial denoising model to obtain the sample denoising image potential features; based on the loss value between the sample predicted noise features and the sample noise information corresponding to each of the long text image sample pairs, the initial text generation image model is trained to obtain the target text generation image model.

[0126] Specifically, when the machine-readable instructions are executed by the processor 610, the following processing can be performed: based on the loss values ​​corresponding to each pair of the long text image samples, the first model parameters of the initial cross-adapter model and the second model parameters of the initial denoising model are updated until the initial text generation image model meets the model convergence conditions, thereby generating the target text generation image model.

[0127] In an embodiment of the present application, the target descriptive text of the image to be generated is input into a large language model to obtain the target semantic embedding feature, and the target descriptive text is input into a text editor model to obtain the target text embedding feature; then, the target semantic embedding feature and the target text embedding feature are input into a target cross adapter model to obtain the target enhanced text feature; further, the target enhanced text feature and the noise image are input into the target text generation image model to generate the target image corresponding to the target descriptive text. In this way, the present application can better capture the semantic correspondence between text and image by using a large language model to enhance the semantic expression ability of the text generation image model, thereby generating a more accurate and rich image.

[0128] Based on the same application concept, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method for generating an image based on text provided in the above embodiment are executed.

[0129] Specifically, the storage medium can be a general storage medium, such as a mobile disk, a hard disk, etc. When the computer program on the storage medium is run, it can execute the above-mentioned method of generating images based on text. By utilizing a large language model to enhance the semantic expression ability of the text-to-image model, the semantic correspondence between text and image can be better captured, thereby generating more accurate and rich images.

[0130] In the embodiment of the present application, the computer program can also execute other machine-readable instructions when run by the processor to execute other methods described in the embodiment. For the specific execution method steps and principles, please refer to the description of the embodiment, which will not be repeated here.

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

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

[0133] In addition, each functional unit in the embodiments provided in the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0134] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0135] It should be noted that similar numbers and letters represent similar items in the following figures. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. In addition, the terms "first", "second", "third", etc. are only used to distinguish the description and are not to be understood as indicating or implying relative importance.

[0136] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above-mentioned embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-mentioned embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application. They should all be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. A method for generating an image based on text, characterized in that: The method comprises: Get the target descriptive text of the image to be generated; Inputting the target descriptive text into a large language model to obtain a target semantic embedding feature, and inputting the target descriptive text into a text editor model to obtain a target text embedding feature; Inputting the target semantic embedding feature and the target text embedding feature into a target cross adapter model for fusion processing to obtain a target enhanced text feature; The target enhanced text features and the noise image are input into a target text generation image model to generate a target image corresponding to the target descriptive text.

2. The method according to claim 1, characterized in that: The step of inputting the target semantic embedding feature and the target text embedding feature into a target cross adapter model to obtain a target enhanced text feature comprises: Performing cross-attention fusion processing on the target semantic embedding feature and the target text embedding feature to obtain a semantic fusion feature; The semantic fusion feature and the target text embedding feature are serially connected to obtain the target enhanced text feature.

3. The method according to claim 1 or 2, characterized in that: The first feature dimension of the target enhanced text feature is the same as the second feature dimension of the target text embedding feature.

4. The method according to claim 2, characterized in that: The third feature dimension of the semantic fusion feature is the same as the second feature dimension of the target text embedding feature.

5. The method according to claim 1, characterized in that The target text image generation model includes a variational autoencoder model and a target denoising model, and the variational autoencoder model includes an image encoder and an image decoder; the step of inputting the target enhanced text features and the noise image into the target text image generation model to generate a target image corresponding to the target descriptive text includes: Inputting the noise image into the image encoder to obtain noise potential features; Inputting the noise latent features and the target enhanced text features into the target denoising model to obtain the target denoised image latent features; The target denoised image potential features are input into the image decoder to obtain the target image corresponding to the target descriptive text.

6. The method according to claim 1, characterized in that The target text generation image model is trained according to the following steps: Acquire a long text image sample data set, wherein any long text image sample pair in the long text image sample data set includes a sample image and a sample long text of the sample image; For any of the long text image sample pairs, inputting the sample long text into the large language model to obtain sample semantic embedding features, and inputting the sample long text into the text editor model to obtain sample text embedding features; Inputting the sample semantic embedding features and the sample text embedding features into an initial cross adapter model to obtain sample enhanced text features; Based on the sample enhanced text features corresponding to each of the long text image samples, the sample image and the sample noise information, the initial text generation image model is trained to obtain the target text generation image model.

7. The method according to claim 6, characterized in that The long text image sample dataset is obtained according to the following steps: Acquire a plurality of the sample images; For any of the sample images, input the sample image and image description requirement information into the multimodal macro model to obtain a first long text of the sample image; Each of the first long texts and the sample images of the first long texts are determined as the long text image sample data set.

8. The method according to claim 6, characterized in that The long text image sample dataset is obtained according to the following steps: Acquire a short text image sample data set; any short text image sample pair in the short text image sample data set includes a sample image and a sample short text of the sample image; For any of the short text image sample pairs, input the sample image and image description requirement information into the multimodal large model to obtain a second long text of the sample image; For any of the sample images, splicing the second long text of the sample image and the sample short text to obtain a spliced ​​sample; Each of the spliced ​​samples and the sample images of the spliced ​​samples are determined as the long text image sample data set.

9. The method according to claim 6, characterized in that The training of the initial text generation image model based on the sample enhanced text features corresponding to each of the long text image samples, the sample image and the sample noise information to obtain the target text generation image model includes: For any of the long text image sample pairs, inputting the sample image into the image encoder in the initial text generation image model to obtain potential features of the sample image; Fusing the sample image potential features and the sample noise information to obtain a fused image noise potential feature; Inputting the fused image noise potential features and the sample enhanced text features into the initial denoising model in the initial text generation image model to obtain the sample denoised image potential features and the sample predicted noise features; The initial text generation image model is trained based on the loss value between the sample prediction noise feature and the sample noise information corresponding to each of the long text image samples to obtain the target text generation image model.

10. The method according to claim 9, characterized in that The training of the initial text generation image model based on the loss value between the sample prediction noise feature and the sample noise information corresponding to each of the long text image samples to obtain the target text generation image model includes: Based on the loss values ​​corresponding to each pair of the long text image samples, the first model parameters of the initial cross adapter model and the second model parameters of the initial denoising model are updated until the initial text generation image model meets the model convergence conditions, thereby generating the target text generation image model.

11. A device for generating an image based on text, characterized in that: The device comprises: An acquisition module, used to acquire target descriptive text of the image to be generated; A first determination module is used to input the target descriptive text into a large language model to obtain a target semantic embedding feature, and input the target descriptive text into a text editor model to obtain a target text embedding feature; A second determination module is used to input the target semantic embedding feature and the target text embedding feature into a target cross adapter model for fusion processing to obtain a target enhanced text feature; The generation module is used to input the target enhanced text features and the noise image into the target text generation image model to generate a target image corresponding to the target descriptive text.

12. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate through the bus, and the machine-readable instructions are executed by the processor to execute the steps of the method for generating an image based on text as described in any one of claims 1 to 10.

13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for generating an image based on text according to any one of claims 1 to 10 are executed.

Citation Information

Cited By

  • Potential space human motion generation method based on diffusion model

    CN119169205A

  • Diffusion model-based text graph and diffusion model training method, device and equipment

    CN119169434A

  • Content semantic separation image style representation learning method and device based on text inversion

    CN119339090A

  • Wild animal long-tail data enhancement method combining prior knowledge and diffusion model

    CN119360415A

  • Text-to-image generation method and system based on spatial perception decoupling

    CN120894456A