Image generation method and device, computer equipment and storage medium

Through the multi-level feature extraction and information exchange level fusion in the image generation method, the problem of image content feature conflict is solved and the image quality is improved.

CN118537428APending Publication Date: 2024-08-23TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410657858.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-22
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

When an image is generated based on multiple different description texts, conflicts easily occur between image content features, making it difficult for the generated image to satisfy the characteristics of different description texts at the same time, reducing image quality.

Method used

Through multi-level extraction of features of the first text and the second text, the feature information exchange level is triggered for feature fusion, and information exchange features are generated to reduce feature conflicts and improve image quality.

Benefits of technology

It is realized that the generated image can have the image content characteristics described by the first text and the second text at the same time, thereby improving the image quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118537428A
    Figure CN118537428A
Patent Text Reader

Abstract

The invention relates to an image generation method and device based on artificial intelligence, computer equipment, a storage medium and a computer program product. The method comprises the steps that first feature extraction of M hierarchies is carried out on first text features of a first text in sequence, and respective first middle features of the M hierarchies are obtained; based on a second text feature of the second text, second feature extraction of M hierarchies is carried out in sequence, information exchange features are obtained, when the ith hierarchy belongs to the hierarchy triggering feature information exchange, feature fusion is carried out on the first middle feature of the ith hierarchy and the second middle feature of the ith hierarchy, and the first middle feature of the ith hierarchy is obtained; obtaining an output feature of the ith level according to the obtained fusion feature; and generating an image of which the image content has a first image content feature described by the first text and a second image content feature described by the second text according to the information exchange feature. By adopting the method, the image quality of the generated image can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to an image generation method, apparatus, computer equipment, storage medium and computer program product. Background Art

[0002] With the development of computer technology, Text-to-Image technology, which uses artificial intelligence technology to generate corresponding customized images based on the description text entered by the user, has the advantages of being fast, diverse, customized, and breaking through traditional boundaries. It has been widely used in many fields such as artistic creation and entertainment, advertising design, and education. For example, in game production, the preliminary design of the scene, role, and props in the game can be generated based on Text-to-Image technology. In Text-to-Image technology, different description texts can each describe different image content features, such as different description texts can respectively describe the style of the image and the appearance of the characters in the image.

[0003] At present, when generating an image based on multiple different description texts, conflicts easily arise between the image content features described by the different description texts, resulting in the difficulty of the generated image to simultaneously meet the image content features described by the different description texts, resulting in low image quality of the generated image. Summary of the invention

[0004] Based on this, it is necessary to provide an image generation method, apparatus, computer device, computer-readable storage medium and computer program product that can improve the image quality of the generated image in response to the above technical problems.

[0005] In a first aspect, the present application provides an image generation method. The method comprises:

[0006] Acquire a first text feature of a first text and a second text feature of a second text, wherein the first text is used to describe a first image content feature, and the second text is used to describe a second image content feature;

[0007] Performing M-level first feature extraction on the first text feature in sequence to obtain first intermediate features outputted by each of the M levels, where M is an integer greater than or equal to 2;

[0008] Based on the second text feature, M levels of second feature extraction are sequentially performed to obtain information exchange features, wherein, in the second feature extraction of the M levels, when the i-th level belongs to the level that triggers feature information exchange, the first intermediate feature obtained in the first feature extraction of the i-th level and the second intermediate feature obtained in the second feature extraction of the i-th level are feature fused to obtain a fused feature of the second feature extraction of the i-th level, an output feature of the i-th level is obtained based on the fused feature, and when i is a positive integer less than M, the second feature extraction of the next level is performed based on the output feature, and when i is equal to M, the information exchange feature is obtained based on the output feature;

[0009] An image is generated according to the information exchange feature, and image content in the image has a first image content feature and a second image content feature.

[0010] In a second aspect, the present application also provides an image generation device. The device comprises:

[0011] A text feature acquisition module, used to acquire a first text feature of a first text and a second text feature of a second text, wherein the first text is used to describe a first image content feature, and the second text is used to describe a second image content feature;

[0012] A first feature extraction module is used to perform M-level first feature extraction on the first text feature in sequence to obtain first intermediate features outputted by each of the M levels, where M is an integer greater than or equal to 2;

[0013] A second feature extraction module is used to sequentially perform M-level second feature extraction based on the second text feature to obtain information exchange features, wherein, in the second feature extraction of the M levels, when the i-th level belongs to the level that triggers feature information exchange, the first intermediate feature obtained in the first feature extraction of the i-th level and the second intermediate feature obtained in the second feature extraction of the i-th level are feature fused to obtain a fused feature of the second feature extraction of the i-th level, an output feature of the i-th level is obtained based on the fused feature, and when i is a positive integer less than M, the second feature extraction of the next level is performed based on the output feature, and when i is equal to M, the information exchange feature is obtained based on the output feature;

[0014] The information exchange feature processing module is used to generate an image according to the information exchange feature, and the image content in the image has a first image content feature and a second image content feature.

[0015] In a third aspect, the present application further provides a computer device, wherein the computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the above image generation method are implemented.

[0016] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the above image generation method are implemented.

[0017] In a fifth aspect, the present application further provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the above image generation method are implemented.

[0018] The above-mentioned image generation method, device, computer equipment, storage medium and computer program product sequentially perform M-level first feature extraction on the first text feature of the first text to obtain the first intermediate features output by each of the M levels, and sequentially perform M-level second feature extraction based on the second text feature of the second text to obtain information exchange features, wherein, in the second feature extraction of the M levels, when the i-th level belongs to the level that triggers feature information exchange, the first intermediate feature obtained in the first feature extraction of the i-th level and the second intermediate feature obtained in the second feature extraction of the i-th level are feature fused to obtain the fused feature of the second feature extraction of the i-th level, the output feature of the i-th level is obtained based on the fused feature, and when i is a positive integer less than M, the second feature extraction of the next level is performed based on the output feature, and an image is generated based on the information exchange features, and the image content in the generated image has the first image content feature described by the first text and the second image content feature described by the second text. In the process of generating an image, for a first text and a second text describing different image content features, multiple levels of feature extraction are performed based on the first text feature and the second text feature of the second text, respectively. For the level that triggers feature information exchange, the first intermediate feature obtained by performing the first feature extraction on the first text feature at this level is fused with the second intermediate feature obtained by performing the second feature extraction on the second text feature at this level, and the output feature is obtained based on the fused feature obtained by the fusion, and the second feature extraction of the next level is performed based on the output feature. The first intermediate feature obtained for the first text feature can be selectively fused into the second feature extraction for the second text feature, so as to realize feature information exchange between the first feature extraction and the second feature extraction, so as to control the strength of different image content features in the obtained information exchange features, reduce the conflict between different image content features, and enable the image generated based on the information exchange features to simultaneously have the image content features described by the first text and the second text, thereby improving the image quality of the generated image. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. 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 creative work.

[0020] Figure 1 A diagram showing an application environment of an image generation method in an embodiment;

[0021] Figure 2 is a schematic flow chart of an image generating method in one embodiment;

[0022] Figure 3 is a schematic diagram of a flow chart of a first feature extraction process in an embodiment;

[0023] Figure 4 is a schematic diagram of fusing intermediate features of the i-th level in one embodiment;

[0024] Figure 5 It is a schematic diagram of obtaining output features based on fusion features in one embodiment;

[0025] Figure 6 is a flowchart of an image generating method in yet another embodiment;

[0026] Figure 7 A schematic diagram of fusing intermediate features of three levels in one embodiment;

[0027] Figure 8 A schematic diagram of a process of fusing intermediate features in first feature extraction in one embodiment;

[0028] Fig. 9 It is a schematic diagram of a process of fusing intermediate features in first feature extraction in yet another embodiment;

[0029] Fig.10 A schematic diagram of a process for obtaining attention features in one embodiment;

[0030] Fig.11 A schematic diagram of a process of enhancing fusion in one embodiment;

[0031] Fig.12 A schematic diagram of the effect of the fusion of the main concept and the auxiliary concept in an embodiment;

[0032] Fig.13 A schematic diagram of a structure of an image generation method based on an image generation model in one embodiment;

[0033] Fig.14A schematic diagram of a diffusion model structure in an embodiment;

[0034] Fig.15 A schematic diagram of a switch control vector adjusting characteristic AC in one embodiment;

[0035] Fig.16 A schematic diagram of the structure of a cross-U-Net feature exchange network module in one embodiment;

[0036] Fig.17 Schematic diagram of the structure of a self-attention module in one embodiment;

[0037] Fig.18 is a structural block diagram of an image generating device in one embodiment;

[0038] Fig.19 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

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

[0040] Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making. Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level technology and software-level technology. The basic technologies of artificial intelligence generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, pre-trained model technology, operation / interaction system, mechatronics, etc. Among them, the pre-trained model is also called the large model or basic model. After fine-tuning, it can be widely used in downstream tasks in various major directions of artificial intelligence. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0041] Pre-training model (PTM), also known as cornerstone model or big model, refers to a deep neural network (DNN) with large parameters. It is trained on massive unlabeled data, and uses the function approximation ability of large-parameter DNN to extract common features from the data. After fine tuning, parameter-efficient fine-tuning (PEFT), prompt-tuning and other technologies, it is suitable for downstream tasks. Therefore, the pre-training model can achieve ideal results in few-shot or zero-shot scenarios. PTM can be divided into language models (ELMO, BERT, GPT), visual models (swin-transformer, ViT, V-MOE), speech models (VALL-E), multimodal models (ViBERT, CLIP, Flamingo, Gato), etc. according to the data modality processed. Among them, the multimodal model refers to a model that establishes feature representations of two or more data modalities. Pre-trained models are important tools for outputting artificial intelligence generated content (AIGC), and can also serve as a general interface for connecting multiple specific task models.

[0042] Machine Learning (ML) is a multi-disciplinary subject involving probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning usually include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and learning by induction. The pre-trained model is the latest development of deep learning, which integrates the above technologies.

[0043] With the research and advancement of artificial intelligence technology, artificial intelligence technology has been studied and applied in many fields, such as common smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, driverless cars, autonomous driving, drones, digital twins, virtual humans, robots, artificial intelligence generated content (AIGC), conversational interaction, smart medical care, smart customer service, game AI, etc. It is believed that with the development of technology, artificial intelligence technology will be applied in more fields and play an increasingly important role.

[0044] The solutions provided in the embodiments of the present application involve technologies such as machine learning / deep learning of artificial intelligence, which are specifically illustrated by the following embodiments.

[0045] The image generation method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown, the terminal 102 communicates with the server 104 through a network. The data storage system can store data that the server 104 needs to process. The data storage system can be set up separately, integrated on the server 104, or placed on the cloud or other servers.

[0046] The user can edit the first text and the second text respectively describing different image content features through the terminal 102, and the terminal 102 can send the first text and the second text to the server 104 through the network. For the first text and the second text, the server 104 can obtain the first text feature of the first text and the second text feature of the second text. The server 104 can sequentially perform M-level first feature extraction on the first text feature of the first text to obtain the first intermediate features output by each of the M levels, and sequentially perform M-level second feature extraction based on the second text feature of the second text to obtain information exchange features. Among them, in the second feature extraction of the M levels, when the i-th level belongs to the level that triggers feature information exchange, the server 104 can perform feature fusion of the first intermediate feature obtained in the first feature extraction of the i-th level and the second intermediate feature obtained in the second feature extraction of the i-th level to obtain the fusion feature of the second feature extraction of the i-th level, and the server 104 can obtain the output feature of the i-th level based on the fusion feature, and perform the second feature extraction of the next level based on the output feature when i is a positive integer less than M, and obtain the information exchange feature based on the output feature when i is equal to M. The server 104 generates an image according to the information exchange feature, and the image content in the generated image has the first image content feature described by the first text and the second image content feature described by the second text. The server 104 can feed back the generated image to the terminal 102 .

[0047] In some embodiments, the image generation method may also be directly implemented by a computer device such as the terminal 102 or the server 104. For example, the terminal 102 may directly generate an image using the image generation method based on the first text and the second text edited by the user. For another example, the server 104 may directly obtain the first text feature of the first text and the second text feature of the second text from the data storage system, and generate an image using the image generation method.

[0048] The terminal 102 may be, but is not limited to, various desktop computers, laptop computers, smart phones, tablet computers, IoT devices, and portable wearable devices. The IoT devices may be smart speakers, smart TVs, smart air conditioners, smart vehicle-mounted devices, etc. The portable wearable devices may be smart watches, smart bracelets, head-mounted devices, etc. The server 104 may be implemented as an independent server or a server cluster consisting of multiple servers, or may be a cloud server.

[0049] In an exemplary embodiment, Figure 2 As shown, an image generation method is provided, which is executed by a computer device, and can be executed by a computer device such as a terminal or a server alone, or by a terminal and a server together. In the embodiment of the present application, the method is applied to Figure 1 The server in the example is used to illustrate, including the following steps 202 to 208. Among them:

[0050] Step 202: Acquire a first text feature of a first text and a second text feature of a second text, wherein the first text is used to describe a first image content feature, and the second text is used to describe a second image content feature.

[0051] The first text and the second text include description information for the image to be generated. The first text may describe the first image content feature, that is, the image to be generated should have the first image content feature, and the second text may describe the second image content feature, that is, the image to be generated should have the second image content feature. The image content feature may be a feature of the image content in the image to be generated, and may specifically include but is not limited to at least one of the image style, image foreground content, image background content, object type of the object included in the image, or object state of the object included in the image. In some embodiments, the image style may include but is not limited to at least one of various styles including retro style, watercolor style, cartoon style, or oil painting style; the image foreground content may refer to the subject or focus content in the image; the image background content may refer to the image content other than the foreground in the image; the object may refer to an object or a person in the image, and the object type may include various types such as humans, animals, plants, and objects; the object state may include but is not limited to at least one of the actions of the object and the attributes of the object. Different texts may describe different types of image content features, and the image content features described by the text may include at least one. For example, the first text may be "A's appearance", which describes the appearance of the character in the image to be generated, that is, the first image content feature may be the appearance of the character; the second text may be "anime-style character running", which describes the action and image style of the character in the image to be generated, that is, the second image content feature may include two types of image content features: character action and image style. Image content features can be used as concepts represented by corresponding generated images, that is, images generated based on different image content features can represent different concepts. Text features can be extracted from text to represent the characteristics of the corresponding text, such as the corresponding text features can be obtained by extracting features from text through a pre-trained feature extraction network.

[0052] Optionally, the server may determine the first text and the second text used to describe the image to be generated in the text map technology, and obtain the first text feature of the first text and the second text feature of the second text respectively. In a specific implementation, the server may receive the text sent by the user through the terminal, and extract the corresponding text features for the received text, such as after the server receives the first text and the second text sent by the terminal, the server may extract the first text feature and the second text feature for the first text and the second text respectively. In some embodiments, the server may input the first text and the second text into a pre-trained feature extraction network for feature extraction, and the feature extraction network outputs the first text feature of the first text and the second text feature of the second text respectively. Among them, the feature extraction network may specifically include but is not limited to at least one of a convolutional neural network, a recurrent neural network, Word2Vec (word to vector), a CLIP (Contrastive Language-Image Pre-training, Contrastive Language Image Pre-training) network, a Transformer network, or a BERT (Bidirectional Encoder Representations from Transformers, Bidirectional Encoder Representations from Transformers) network. In a specific application, the feature extraction network may be a CLIP network, through which the first text and the second text may be encoded and processed respectively to obtain the first text feature and the second text feature. In some embodiments, the server may also pre-store text features of each text, so that after determining the first text and the second text, the server may query and obtain the first text feature of the first text and the second text feature of the second text from the pre-stored text features.

[0053] Step 204 , performing M-level first feature extraction on the first text feature in sequence to obtain first intermediate features outputted by each of the M levels, where M is an integer greater than or equal to 2.

[0054] Among them, the M levels may include at least two levels, and each level may perform a first feature extraction on the input feature of the level to obtain the first intermediate feature of the level and the output feature of the level, and the output feature may be used as the input feature of the next level. The first feature extraction is a feature extraction process implemented in each level for the first text feature, which may be implemented by a preset feature extraction algorithm, such as the first feature extraction may be implemented based on at least one of the ORB (Oriented Features from Accelerated Segment Test and Rotated Binary Robust Independent Elementary Features) algorithm, the SURF (Speeded-Up Robust Feature) algorithm, or the SIFT (Scale-Invariant Feature Transform) algorithm. The first feature extraction can also be implemented through a pre-trained feature extraction network, and the feature extraction network can include but is not limited to a network based on at least one of a fully connected (FC) network, a convolutional neural network (CNN), a recurrent neural network (RNN), a deep residual network (ResNet) or an attention mechanism (Attention Mechanism). The first intermediate feature is an intermediate feature obtained by performing the first feature extraction on the first text feature. Performing the first feature extraction on the first text feature can also obtain the output feature of the corresponding level, and the output feature can be used as the input feature of the first feature extraction of the next level.

[0055] For example, the server can perform multiple levels of first feature extraction on the first text feature in sequence, that is, the first feature extraction process can be implemented once in each level, and the output features obtained in the current level are used as input features of the next level to perform the first feature extraction process of the next level. For each of the M levels, after the server extracts the first feature of the corresponding level, it can obtain the first intermediate feature of the corresponding level. In a specific application, such as Figure 3As shown, the dotted box is the process of performing M-level first feature extraction processing on the first text feature in sequence. Specifically, the server can use the first text feature as the input feature of the first level, perform the first feature extraction of the first level on the first text feature, and obtain the first intermediate feature of the first level. The output feature of the first level can be used as the input feature of the second level to perform the first feature extraction of the second level, and obtain the first intermediate feature of the second level. Each level is executed in sequence until the first feature extraction of the Mth level is achieved, thereby obtaining the first intermediate feature output of each level.

[0056] Step 206, based on the second text feature, perform second feature extraction of M levels in sequence to obtain information exchange features, wherein, in the second feature extraction of M levels, when the i-th level belongs to the level that triggers feature information exchange, perform feature fusion on the first intermediate feature obtained in the first feature extraction of the i-th level and the second intermediate feature obtained in the second feature extraction of the i-th level to obtain a fused feature of the second feature extraction of the i-th level, obtain the output feature of the i-th level based on the fused feature, and perform second feature extraction of the next level based on the output feature when i is a positive integer less than M, and obtain the information exchange feature based on the output feature when i is equal to M.

[0057] Among them, at least two levels of second feature extraction can be performed in sequence for the second text feature, and the number of levels for the second feature extraction for the second text feature matches the number of levels for the first feature extraction for the first text feature, and the specific number of levels can be the same, that is, both are M. The second feature extraction of each level can obtain the second intermediate feature of the level and the output feature of the level, and the output feature can be used as the input feature for the second feature extraction of the next level. The second feature extraction is a feature extraction process implemented in each level for the second text feature, which can be specifically implemented by a preset feature extraction algorithm, and can also be implemented by a pre-trained feature extraction network. The second intermediate feature is the intermediate feature obtained in the second feature extraction for the second text feature. The second feature extraction for the second text feature can also obtain the output feature of the corresponding level, and the output feature can be used as the input feature for the second feature extraction of the next level.

[0058] The level for triggering feature information exchange refers to the level at which the corresponding first intermediate feature and the second intermediate feature need to carry feature information for exchange, that is, the first intermediate feature and the second intermediate feature of the level for triggering feature information exchange need to be fused, such as by superposition (Add) or concatenation (Concatenation), the first intermediate feature and the second intermediate feature of the level for triggering feature information exchange can be fused to obtain the fusion feature corresponding to the level, the output feature of the level can be obtained according to the fusion feature, and the second feature of the next level can be extracted based on the output feature of the level, and the output feature of the level can be used as the input feature of the next level. The level for triggering feature information exchange can be configured according to actual needs, and can be configured based on multiple test results. The level for triggering feature information exchange can specifically include at least one level among M levels, that is, the number of levels for triggering feature information exchange can be greater than or equal to 1 and less than or equal to M. For example, the level for triggering feature information exchange can include the 5th level, the 6th level, the 7th level and the 8th level of the M levels, a total of four levels. The information exchange feature is a feature extraction result obtained after performing M-level second feature extraction on the second text feature in sequence. Specifically, it can be obtained according to the output feature of the second feature extraction of the M-th level. The information exchange feature can be used to generate an image.

[0059] Specifically, the server can sequentially perform multiple levels of second feature extraction based on the second text feature, that is, the second feature extraction process can be implemented once in each level, and the output feature obtained in the current level is used as the input feature of the next level to perform the second feature extraction process of the next level, and obtain the information exchange feature for generating the image based on the output feature of the last level. For each of the M levels, after the server performs the second feature extraction of the corresponding level, the second intermediate feature and the output feature in the corresponding level can be obtained. In the second feature extraction of the M levels, if the i-th (1≤i≤M) level belongs to the level that triggers feature information exchange, the server can perform feature fusion of the first intermediate feature and the second intermediate feature of the i-th level with the same level number, and specifically, the first intermediate feature obtained in the first feature extraction of the i-th level and the second intermediate feature obtained in the second feature extraction of the i-th level can be performed feature fusion, and the feature fusion can be performed by superposition or splicing to obtain the fusion feature of the i-th level. The server can obtain the output features of the i-th level based on the fused features, such as the server can further extract features for the fused features to obtain the output features of the i-th level. In some implementations, when i is a positive integer less than M, it indicates that the second feature extraction process of the next level needs to be performed, and the server extracts the second features of the next level (i+1 level) based on the output features; and when i is equal to M, it indicates that the second feature extraction of the last level has been performed, and the server obtains the information exchange features used to generate the image based on the output features of the last level.

[0060] By fusing the first intermediate features and the second intermediate features of the i-th level and obtaining the output features of the i-th level based on the obtained fused features, the information of the first text can be selectively introduced into the feature stream extracted by the second feature, so as to realize information exchange between the first text and the second text, reduce the conflict between different image content features, and enable the image generated based on the information exchange feature to simultaneously satisfy the image content features described by the first text and the second text, thereby improving the image quality of the generated image.

[0061] In a specific application, such as Figure 4As shown, the server can use the second text feature as the input feature of the first level, extract the second feature of the first level for the second text feature, and obtain the second intermediate feature of the first level, and the output feature of the first level can be used as the input feature of the second level, so as to extract the second feature of the second level, obtain the second intermediate feature and output feature of the second level, and execute each level in sequence until the second feature extraction of the Mth level is achieved, and obtain the information exchange feature according to the output feature of the Mth level. When the i-th level belongs to the level that triggers feature information exchange, the server can fuse the first intermediate feature of the i-th level and the second intermediate feature of the i-th level to obtain the fused feature of the i-th level, and obtain the output feature of the i-th level according to the fused feature. When i is less than M, the output feature of the i-th level can be used as the input feature of the i+1th level, and when i is equal to M, the information exchange feature used to generate the image can be obtained according to the output feature of the i-th level.

[0062] In a specific implementation, if Figure 5 As shown, when the server performs the second feature extraction processing of the i-th level, the server can use the output features of the i-1-th level as the input features of the i-th level to perform the second feature extraction, and obtain the second intermediate features of the i-th level. The i-th level belongs to the level that triggers the exchange of feature information. The server can perform feature fusion of the first intermediate features of the i-th level with the second intermediate features of the i-th level to obtain the fused features of the i-th level. The server can obtain the output features of the i-th level based on the fused features of the i-th level. Specifically, the server can perform further second feature extraction on the fused features of the i-th level to obtain the output features of the i-th level. The server can use the output features of the i-th level as the input features for the second feature extraction of the i+1-th level to perform the second feature extraction processing of the i+1-th level. When the i+1th level does not belong to the level that triggers the exchange of feature information, the server can use the output features of the i+1th level as the input features of the i+1th level, and directly perform second feature extraction of the i+1th level based on the input features to obtain the output features of the i+1th level. The output features of the i+1th level can be used as input features of the next level, that is, as input features of the i+2th level, to perform second feature extraction of the i+2th level.

[0063] Step 208: Generate an image according to the information exchange feature, wherein the image content in the image has a first image content feature and a second image content feature.

[0064] Among them, the corresponding image can be generated based on the information exchange feature using the text graph technology. The information exchange feature is obtained by extracting the second feature based on the second text feature of the second text, that is, the information exchange feature carries the information of the second text; in addition, in the process of extracting the second feature based on the second text feature of the second text to obtain the information exchange feature, the first intermediate feature corresponding to the level of triggering feature information exchange is also introduced, that is, the feature obtained by extracting the first feature from the first text feature of the first text is also introduced into the information exchange feature, so that the information exchange feature also carries the information of the first text, and the image generated based on the information exchange feature is obtained by combining the information of the first text and the information of the second text, so that the image content in the generated image has the first image content feature and the second image content feature, that is, the generated image satisfies the image content features described by the first text and the second text at the same time.

[0065] Exemplarily, the server can generate an image based on the information exchange features through a pre-trained image generation model, such as inputting the information exchange features into the image generation model, and the image generation model outputs an image generated according to the information exchange features. The type of image generation model can be set according to actual needs, such as the image generation model can include but is not limited to at least one of the text-to-image models including the Stable Diffusion model, the Transformer-based DALL-E model, the Imagen model, or the DreamDistribution model.

[0066] The generated image is generated based on the information exchange feature, and the information exchange feature carries the information of the first text and the second text, so the image content in the generated image has both the first image content feature described by the first text and the second image content feature described by the second text. In this embodiment, the information exchange feature is obtained by extracting the second features of M levels in sequence based on the second text feature, that is, the information exchange feature carries the features obtained by extracting the second features of each level in the M levels. On the other hand, for the level that triggers feature information exchange among the M levels, the first intermediate feature obtained in the first feature extraction belonging to the level is fused into the second feature extraction belonging to the level. When the level that triggers feature information exchange includes N (1≤N≤M), then for the first intermediate features in the first feature extraction of each of the M levels, N first intermediate features among the M first intermediate features are introduced into the second feature extraction, thereby introducing the information exchange feature.

[0067] The information exchange feature is obtained based on the output features extracted from the second features of M levels, and the information exchange feature carries the features extracted from M second features and the features extracted from N first features. The information exchange feature is mainly based on the information of the second text, and supplemented by the information of the first text. Therefore, the image content in the image generated based on the information exchange feature has the first image content feature and the second image content feature, and the second image content feature is the main content feature and the first image content feature is the auxiliary content feature. That is, the image content in the image generated based on the information exchange feature uses the first image content feature described by the first text as an auxiliary concept and the second image content feature described by the second text as the main concept. Furthermore, when the number of levels N that trigger feature information exchange is larger, the more the first text information is introduced, and the higher the intensity of the first image content feature in the generated image. By configuring the number N of levels that trigger feature information exchange and the sequence numbers of the levels, the first intermediate feature obtained for the first text feature can be selectively integrated into the second feature extraction for the second text feature to control the intensity of different image content features in the obtained information exchange feature, which can reduce the conflict between different image content features, so that the image generated based on the information exchange feature can simultaneously meet the image content features described by the first text and the second text, thereby improving the image quality of the generated image.

[0068] In some embodiments, whether the generated image has the first image content feature and the second image content feature can be realized by semantic understanding of the generated image. Specifically, for the generated image, the server can obtain a description text for the image based on the image-to-text technology. Among them, the image-to-text technology uses computer vision and natural language processing technology to convert the information in the image into a description text. Specifically, meaningful features such as color, shape, texture and other image features can be extracted from the image by computer vision technology, and the corresponding description text can be generated based on the extracted image features using natural language processing technology. For the description text for the generated image, the server can match the description text with the first text and the second text respectively, such as calculating the text similarity between the description text and the first text and the second text respectively, and determine whether the generated image has the first image content feature and the second image content feature according to the calculated text similarity. For example, when the text similarity between the description text and the first text exceeds a threshold value set based on experience, it can be considered that the generated image has the first image content feature described by the first text.

[0069] In a specific application, such as Figure 6As shown, the server performs M levels of feature extraction processing on the first text features of the first text and the second text features of the second text respectively. For the i-th level, which is the level that triggers feature information exchange, the server performs feature fusion on the first intermediate features of the i-th level and the second intermediate features of the i-th level, obtains the output features of the i-th level based on the obtained fused features, and performs second feature extraction on the next level based on the output features of the i-th level, until the second feature extraction of the M-th level outputs information exchange feature A. In addition to the features obtained by the second feature extraction of M levels, the information exchange feature A also introduces the features obtained by the first feature extraction of one level. The server generates image A based on the information exchange feature A.

[0070] In another specific application, Figure 7 As shown, the server performs M-level feature extraction processing on the first text feature of the first text and the second text feature of the second text respectively. For the i-th level, the j-th level and the k-th level, the three levels are all levels that trigger feature information exchange. The server performs feature fusion on the first intermediate feature of the i-th level with the second intermediate feature of the i-th level, obtains the output feature of the i-th level based on the obtained fusion feature, and extracts the second feature of the next level based on the output feature of the i-th level; the server performs feature fusion on the first intermediate feature of the j-th level with the second intermediate feature of the j-th level, and obtains the output feature of the i-th level based on the obtained fusion feature. The output feature of the j-th level is obtained, and the second feature of the next level is extracted according to the output feature of the j-th level; the server fuses the first intermediate feature of the k-th level with the second intermediate feature of the k-th level, obtains the output feature of the k-th level according to the obtained fused feature, and extracts the second feature of the next level according to the output feature of the k-th level, until the second feature extraction of the M-th level outputs the information exchange feature B. In addition to the features obtained by the second feature extraction of the M levels, the information exchange feature B also introduces the features obtained by the first feature extraction of the three levels. The server generates image B based on the information exchange feature B.

[0071] like Figure 6 and Figure 7 As shown, even if the first text feature and the second text feature are the same, and the first feature extraction process for the first text feature and the second feature extraction process for the second text feature are also the same, compared with the information exchange feature A, the information exchange feature B introduces more features obtained by the first feature extraction, that is, the information exchange feature B carries more information of the first text than the information exchange feature A, so that the intensity of the first image content feature in the image B generated based on the information exchange feature B is higher than the first image content feature in the image A generated based on the information exchange feature A.

[0072] In the above-mentioned image generation method, the first feature extraction of M levels is performed in sequence on the first text feature of the first text to obtain the first intermediate features output by each of the M levels, and the second feature extraction of M levels is performed in sequence based on the second text feature of the second text to obtain information exchange features, wherein, in the second feature extraction of M levels, when the i-th level belongs to the level that triggers feature information exchange, the first intermediate feature obtained in the first feature extraction of the i-th level and the second intermediate feature obtained in the second feature extraction of the i-th level are fused to obtain the fused feature of the second feature extraction of the i-th level, and the output feature of the i-th level is obtained based on the fused feature, and when i is a positive integer less than M, the second feature extraction of the next level is performed based on the output feature, and an image is generated based on the information exchange feature, and the image content in the generated image has the first image content feature described by the first text and the second image content feature described by the second text. In the process of generating an image, for a first text and a second text describing different image content features, multiple levels of feature extraction are performed based on the first text feature and the second text feature of the second text, respectively. For the level that triggers feature information exchange, the first intermediate feature obtained by performing the first feature extraction on the first text feature at this level is fused with the second intermediate feature obtained by performing the second feature extraction on the second text feature at this level, and the output feature is obtained based on the fused feature obtained by the fusion, and the second feature extraction of the next level is performed based on the output feature. The first intermediate feature obtained for the first text feature can be selectively fused into the second feature extraction for the second text feature, so as to realize feature information exchange between the first feature extraction and the second feature extraction, so as to control the strength of different image content features in the obtained information exchange features, reduce the conflict between different image content features, and enable the image generated based on the information exchange features to simultaneously have the image content features described by the first text and the second text, thereby improving the image quality of the generated image.

[0073] In an exemplary embodiment, Figure 8 As shown, the processing of fusing the intermediate features in the first feature extraction is to fuse the first intermediate feature obtained in the first feature extraction of the i-th level with the second intermediate feature obtained in the second feature extraction of the i-th level, to obtain the fused feature of the second feature extraction of the i-th level, and to obtain the output feature of the i-th level according to the fused feature, including:

[0074] Step 802, according to the feature splicing method, the first intermediate feature obtained in the first feature extraction of the i-th level and the second intermediate feature obtained in the second feature extraction of the i-th level are spliced ​​to obtain the spliced ​​feature of the second feature extraction of the i-th level.

[0075] Among them, the feature splicing method refers to the specific splicing method when the first intermediate feature and the second intermediate feature of the i-th level are merged based on the splicing method, such as feature splicing methods that can include different splicing orders. Specifically, the feature splicing method can include a splicing method of splicing the second intermediate feature to the end of the first intermediate feature to form a splicing feature of [first intermediate feature-second intermediate feature], and can also include a splicing method of splicing the first intermediate feature to the end of the second intermediate feature to form a splicing feature of [second intermediate feature-first intermediate feature]. The feature splicing method can be pre-configured according to actual needs. The splicing feature is the splicing result obtained by splicing the first intermediate feature and the second intermediate feature of the i-th level.

[0076] Exemplarily, the server may determine a feature splicing method that is pre-set based on experience or historical test results, and perform feature splicing on the first intermediate feature of the i-th level and the second intermediate feature according to the feature splicing method to obtain the splicing feature of the second feature extraction of the i-th level. Among them, the first intermediate feature is obtained by the server extracting the first feature of the i-th level based on the first text feature, and the second intermediate feature is obtained by the server extracting the second feature of the i-th level based on the second text feature. i is a positive integer not greater than M, that is, 1≤i≤M. When i=1, it means that the first level of the M levels belongs to the level that triggers feature information exchange. Then, the first intermediate feature of the first level can be directly extracted by the server for the first text feature, such as by the server directly performing a residual connection (Residual Connection) on the first text feature, and the residual connection can be implemented based on the residual network (Residual Network, ResNet); the second intermediate feature of the first level can be directly extracted by the server for the second text feature, specifically, it can be obtained by performing a residual connection on the second text feature. When 1<i≤M, there is feature extraction processing of the previous level for the i-th level, then the first intermediate feature of the first level can be obtained by the server performing the first feature extraction of the i-th level based on the output feature obtained by the first feature extraction of the previous level (i-1-th level), and the second intermediate feature of the i-th level can be obtained by the server performing the second feature extraction of the i-th level based on the output feature obtained by the server for the second feature extraction of the i-1-th level.

[0077] Step 804: Perform attention feature extraction based on the concatenated feature and the second intermediate feature obtained in the second feature extraction of the i-th level to obtain the attention feature of the i-th level.

[0078] Among them, attention feature extraction is implemented based on the attention mechanism. The basic principle of the attention mechanism is to imitate the human attention process, which can focus on the key information in the input data while ignoring the less relevant parts. The attention mechanism assigns different weights to different parts of the input data to extract more critical and important information, enhance the feature expression ability, and thus make more accurate judgments. Based on the attention feature extraction, the splicing feature and the second intermediate feature of the i-th level can be adaptively fused to obtain the attention feature of the i-th level. The attention feature is the result of attention feature extraction based on the splicing feature and the second intermediate feature of the i-th level.

[0079] Optionally, the server can extract attention features based on the attention mechanism for the concatenated features and the second intermediate features of the i-th level, such as performing self-attention feature extraction to obtain the attention features of the i-th level. In a specific implementation, the server can construct attention parameters based on the concatenated features and the second intermediate features of the i-th level, including a key parameter (K, Key), a value parameter (V, Value), and a query parameter (Q, Query). The server extracts attention features based on the attention parameters to obtain the attention features of the i-th level.

[0080] Step 806, according to the feature concatenation method, determine the updated adaptive fusion feature relative to the second intermediate feature from the attention feature of the i-th level.

[0081] Among them, the spliced ​​feature is obtained by splicing the first intermediate feature and the second intermediate feature of the i-th level, and the feature dimension of the spliced ​​feature is the sum of the feature dimensions of the first intermediate feature and the second intermediate feature. To ensure the consistency of the feature dimension, the server can determine the adaptive fusion feature from the attention feature of the i-th level, and the feature dimension of the adaptive fusion feature is the same as the feature dimension of the second intermediate feature.

[0082] Specifically, the server can perform feature filtering on the attention features of the i-th level based on the feature splicing method, and can specifically extract the updated adaptive fusion features relative to the second intermediate features from the attention features according to the feature splicing method. In a specific application, the feature splicing method can be a splicing method of splicing the N-dimensional first intermediate feature to the tail of the N-dimensional second intermediate feature to form a splicing feature with 2N dimensions in the form of [second intermediate feature-first intermediate feature]. The feature dimension of the obtained attention feature is also 2N, and the server can use the left N-dimensional features of the 2N-dimensional attention feature as the updated adaptive fusion features relative to the second intermediate feature, that is, the server can determine the distribution position of the second intermediate feature according to the feature splicing method, and determine the adaptive fusion features corresponding to the second intermediate feature from the attention feature according to the distribution position.

[0083] Step 808, performing cross-attention feature extraction on the adaptive fusion feature and the second text feature to obtain the output feature of the i-th level.

[0084] Among them, Cross-Attention is an attention mechanism, which is usually used when processing tasks involving two different input sequences. In the cross-attention mechanism, the query (Query) of one sequence interacts with the key (Key) and value (Value) of another sequence to calculate the attention weight and generate the output. By performing cross-attention feature extraction on the adaptive fusion feature and the second text feature, the output feature of the i-th level can be obtained. Exemplarily, the server can use the adaptive fusion feature and the second text feature as different sequences in the cross-attention mechanism, respectively, to perform cross-attention feature extraction on the adaptive fusion feature and the second text feature to obtain the output feature of the i-th level.

[0085] In a specific application, such as Fig. 9 As shown, the server can perform feature splicing on the first intermediate feature of the i-th level and the second intermediate feature of the i-th level according to a preset feature splicing method to obtain the splicing feature of the i-th level. Specifically, in the splicing feature of the i-th level, the second intermediate feature of the i-th level is spliced ​​at the tail of the first intermediate feature of the i-th level. The server can perform attention feature extraction based on the splicing feature of the i-th level and the second intermediate feature of the i-th level to obtain the attention feature of the i-th level. The attention feature of the i-th level may include feature A with the same feature dimension as the first intermediate feature of the i-th level and feature B with the same feature dimension as the second intermediate feature of the i-th level. The server can determine the adaptive fusion feature corresponding to the second intermediate feature from the attention feature of the i-th level according to the feature splicing method, and specifically, the feature B on the right side can be intercepted from the attention feature as the adaptive fusion feature. The server can perform cross-attention feature extraction based on the adaptive fusion feature and the second text feature to obtain the output feature of the i-th level.

[0086] In this embodiment, in the second feature extraction of M levels, for the i-th level that triggers feature information exchange, the server performs feature splicing on the first intermediate feature of the i-th level and the second intermediate feature according to the feature splicing method, performs attention feature extraction on the obtained splicing feature and the second intermediate feature of the i-th level, determines the adaptive fusion feature from the obtained attention feature according to the feature splicing method, and performs cross-attention feature extraction on the adaptive fusion feature and the second text feature to obtain the output feature of the i-th level, so that after the first intermediate feature and the second intermediate feature are spliced, adaptive feature fusion can be performed based on the attention mechanism, and the first intermediate feature can be adaptively fused into the output feature of the i-th level, avoiding the abrupt fusion of the image content features of the first text and the second text in the information exchange feature, reducing the impact of the conflict between different image content features, and thus improving the image quality of the generated image.

[0087] In an exemplary embodiment, attention feature extraction is performed based on the concatenated feature and the second intermediate feature obtained in the second feature extraction of the i-th level to obtain the attention feature of the i-th level, including: obtaining the key feature and the value feature based on the concatenated feature, and obtaining the query feature based on the second intermediate feature obtained in the second feature extraction of the i-th level; determining the feature relevance based on the query feature and the key feature; and adaptively merging the value feature according to the feature relevance to obtain the attention feature of the i-th level.

[0088] Among them, key features, value features and query features belong to the attention parameters in the attention mechanism. Key features belong to the key parameters (K) in the attention parameters, value features belong to the value parameters (V), and query features belong to the query parameters (Q). Key features and value features are obtained based on concatenated features. Specifically, the concatenated features can be directly used as key features and value features respectively; query features are obtained based on the second intermediate features of the i-th level. Specifically, the second intermediate features of the i-th level can be directly used as query features. Feature relevance is used to measure the similarity or correlation between key features and value features. Feature relevance is used to perform adaptive feature fusion for value features.

[0089] Optionally, the server can determine the key feature and the value feature respectively according to the concatenated feature, and determine the query feature according to the second intermediate feature of the i-th level. In some applications, the server can directly use the concatenated feature as the key feature and the value feature respectively, and directly use the second intermediate feature of the i-th level as the query feature; the server can also transform the concatenated feature and the second intermediate feature to obtain the key feature, the value feature and the query feature, such as the server can perform linear transformation on the concatenated feature and the second intermediate feature respectively, and the linear transformation can be implemented by defining a preset weight matrix and a bias term. The server can use the concatenated feature after the linear transformation as the key feature and the value feature respectively, and use the second intermediate feature after the linear transformation as the query feature. The server can determine the feature correlation between the query feature and the key feature, specifically by calculating the dot product between the query feature and the key feature, and performing normalized mapping on the dot product to obtain the feature correlation. The server can adaptively fuse the value feature according to the feature correlation, and the server can weightedly fuse the value feature through the feature correlation to obtain the attention feature of the i-th level.

[0090] In a specific application, such as Fig.10 As shown, after the server splices the second intermediate feature of the i-th level to the tail of the first intermediate feature of the i-th level to obtain the spliced ​​feature of the i-th level, the server can obtain the value feature V and the key feature K according to the spliced ​​feature, and determine the query feature Q according to the second intermediate feature of the i-th level. The server can determine the feature relevance based on the key feature K and the query feature Q, and perform adaptive feature fusion on the value feature V through the feature relevance to obtain the attention feature of the i-th level. The attention feature of the i-th level can include feature A with the same feature dimension as the first intermediate feature of the i-th level and feature B with the same feature dimension as the second intermediate feature of the i-th level.

[0091] In this embodiment, the server obtains the key feature and the value feature based on the splicing feature, obtains the query feature based on the second intermediate feature, and adaptively fuses the value feature according to the feature correlation between the query feature and the key feature. By performing self-attention feature extraction on the splicing feature and the second intermediate feature, the first intermediate feature is adaptively fused into the output feature of the i-th level, thereby avoiding abrupt fusion of the image content features of the first text and the second text in the information exchange feature, reducing the impact of the conflict between different image content features, and thus improving the image quality of the generated image.

[0092] In an exemplary embodiment, the image generation method also includes: enhancing and fusing the adaptive fusion feature and the second intermediate feature obtained from the second feature extraction of the i-th level to obtain an enhanced adaptive fusion feature; performing cross-attention feature extraction on the adaptive fusion feature and the second text feature to obtain an output feature of the i-th level, including: performing cross-attention feature extraction on the enhanced adaptive fusion feature and the second text feature to obtain an output feature of the i-th level.

[0093] Among them, the adaptive fusion feature is enhanced and fused with the second intermediate feature of the i-th level, so that the strength of the second intermediate feature can be enhanced. Specifically, the server can enhance and fuse the adaptive fusion feature through the second intermediate feature of the i-th level, and specifically, the second intermediate feature can be fused into the adaptive fusion feature by superposition to obtain the enhanced adaptive fusion feature. The server can perform cross-attention feature extraction based on the enhanced adaptive fusion feature, and specifically, the server can perform cross-attention feature extraction on the enhanced adaptive fusion feature and the second text feature, so as to obtain the output feature of the i-th level.

[0094] In a specific application, such as Fig.11 As shown, the obtained attention features of the i-th level include feature A with the same feature dimension as the first intermediate feature of the i-th level and feature B with the same feature dimension as the second intermediate feature of the i-th level. The server can determine the adaptive fusion feature corresponding to the second intermediate feature from the attention features of the i-th level according to the feature splicing method, and specifically can extract feature B on the right side from the attention features as the adaptive fusion feature. The server can enhance and fuse the second intermediate feature of the i-th level with respect to the adaptive fusion feature to obtain the enhanced adaptive fusion feature, and perform cross-attention feature extraction based on the enhanced adaptive fusion feature and the second text feature to obtain the output feature of the i-th level.

[0095] In this embodiment, after the server enhances and fuses the adaptive fusion feature through the second intermediate feature of the i-th level, cross-attention feature extraction is performed based on the enhanced adaptive fusion feature and the second text feature, so as to enhance the influence of the second intermediate feature in the output feature. Therefore, when generating an image based on the information exchange feature obtained from the output feature, it is ensured that the image content in the generated image can have the first image content feature and the second image content feature while taking the second image content feature as the core image content feature, thereby ensuring the image quality of the generated image.

[0096] In an exemplary embodiment, the image generation method further includes: determining a first feature type of a first image content feature and a second feature type of a second image content feature; and determining a level for triggering feature information exchange from among M levels based on the first feature type and the second feature type.

[0097] Among them, different texts can describe image content features of different feature types, and the feature types of image content features can include but are not limited to at least one of various types including image style, image foreground content, image background content, object type of objects included in the image, or object state of objects included in the image. For image content features of different feature types, different levels can be configured to trigger feature information exchange. Specifically, the server can respectively determine the feature types to which the first image content feature and the second image content feature belong, and configure each level in the M levels based on the feature types to which the first image content feature and the second image content feature belong, so as to determine the level for triggering feature information exchange. In a specific application, the server can determine the number of levels and the level sequence number of the level for triggering feature information exchange from the M levels based on the first feature type of the first image content feature and the second feature type of the second image content feature, such as the number of levels for triggering feature information exchange can be determined to be 4, and the level sequence numbers are 5, 6, 7 and 8 respectively, that is, the 5th level, the 6th level, the 7th level and the 8th level in the M levels belong to the level for triggering feature information exchange.

[0098] In a specific implementation, the server may combine the first feature type of the first image content feature and the second feature type of the second image content feature to preliminarily determine the number of candidate levels and the candidate level sequence number of the level that triggers the feature information exchange from the M levels. The server may conduct a feature information exchange test based on the number of candidate levels and the candidate level sequence number, and determine the level that triggers the feature information exchange from the M levels based on the number of candidate levels and the candidate level sequence number according to the test results.

[0099] In this embodiment, the server combines the first feature type of the first image content feature and the second feature type of the second image content feature, determines the level for triggering feature information exchange from M levels, and configures the level for triggering feature information exchange according to the feature type to which the image content feature belongs. The first intermediate feature obtained for the first text feature can be selectively integrated into the second feature extraction for the second text feature to control the intensity of different image content features in the obtained information exchange feature, which can reduce the conflict between different image content features, so that the image generated based on the information exchange feature can simultaneously meet the image content features described by the first text and the second text, thereby improving the image quality of the generated image.

[0100] In an exemplary embodiment, second feature extraction is performed on M levels in sequence based on the second text feature to obtain information exchange features, including: performing second feature extraction on the first level of the M levels based on the second text feature to obtain a second intermediate feature in the second feature extraction of the first level and a second output feature of the first level; performing second feature extraction on each level starting from the second level of the M levels based on the second output feature of the previous level to obtain a second intermediate feature in the second feature extraction of the level and a second output feature of the level, until the second output feature of the second feature extraction of the last level of the M levels is obtained, and obtaining the information exchange feature based on the second output feature of the second feature extraction of the last level.

[0101] Among them, when the second feature extraction processing of M levels is performed in sequence based on the second text feature, the second text feature can be directly implemented for the first level, and the feature extraction can be iteratively performed for the second level to the M-th level. Specifically, the output feature of the previous level can be used as the input feature of the current level, and the second feature extraction can be performed on the input feature of the current level to obtain the output feature of the current level, until the last level outputs the information exchange feature, that is, the information exchange feature is obtained according to the output feature of the M-th level.

[0102] Exemplarily, the server can extract the second feature of the first level based on the second text feature to obtain the second intermediate feature and the second output feature of the first level. For each level starting from the second level, the server can extract the second feature of the level based on the second output feature of the previous level, that is, the server uses the second output feature of the previous level as the input feature of the level to extract the second feature of the level, and obtains the second intermediate feature of the level and the second output feature of the level. The server traverses the second feature extraction of each level until the second output feature of the last level among the M levels is obtained, that is, the second output feature of the Mth level is obtained. The server can also obtain the information exchange feature based on the second output feature of the Mth level.

[0103] In this embodiment, for the first level, the server directly extracts the second feature of the first level based on the second text feature. For the second level to the Mth level, the server extracts the second feature of the current level based on the second output feature of the previous level, until the information exchange feature is obtained according to the second output feature of the Mth level. In this way, multi-level feature extraction can be performed on the second text feature, thereby enhancing the expressiveness of the information exchange feature. When an image is generated based on the information exchange feature, it is beneficial to improve the image quality of the generated image.

[0104] In an exemplary embodiment, the second feature extraction of the current level is performed based on the second output feature of the previous level to obtain the second intermediate feature in the second feature extraction of the current level and the second output feature of the current level, including: when the current level does not belong to the level that triggers feature information exchange, the residual connection of the current level is performed based on the second output feature of the previous level to obtain the second intermediate feature in the second feature extraction of the current level; the second self-attention feature of the current level is extracted based on the second intermediate feature; and the cross-attention feature extraction is performed based on the second self-attention feature and the second text feature to obtain the second output feature of the current level.

[0105] Among them, the M levels may include at least one level that triggers the exchange of feature information, that is, the M levels may include levels that do not trigger the exchange of feature information. For the level that does not trigger the exchange of feature information, there is no need to introduce the first intermediate feature for feature fusion, and the processing of this level can be directly implemented based on the second feature extraction process. The core idea of ​​the residual connection is to introduce a direct connection between one or more processes, so that the output of these processes includes not only the features that have undergone nonlinear transformation, but also the unprocessed input features. The residual connection can be implemented based on the residual network, that is, the residual connection can pass the input features directly to the subsequent network layer structure through a jump connection, thereby constructing a shortcut path, which can avoid the information attenuation and gradient disappearance problems caused by multiple activation functions and weight transformations in the deep network. The second self-attention feature can be extracted based on the second intermediate feature based on the self-attention mechanism.

[0106] Optionally, for each level starting from the second level of the M levels, when the level does not belong to the level that triggers the exchange of feature information, it indicates that the level does not need to introduce the corresponding first intermediate feature for fusion, and the server can directly perform a residual connection of the level based on the second output feature of the previous level to obtain the second intermediate feature of the level. The server can perform self-attention feature extraction on the second intermediate feature to obtain the second self-attention feature of the level. The server can perform cross-attention feature extraction on the second self-attention feature and the second text feature to obtain the second output feature of the level, and the second output feature of the level can be used as an input feature of the next level to perform second feature extraction processing on the next level.

[0107] In this embodiment, for the level that does not trigger feature information exchange, the server can perform residual connection of the level based on the second output feature of the previous level, extract the second self-attention feature based on the obtained second intermediate feature, and perform cross-attention feature extraction in combination with the second text feature to obtain the second output feature of the level, so as to perform multi-level feature extraction for the second text feature, enhance the expressive power of the information exchange feature, and when generating an image based on the information exchange feature, it is beneficial to improve the image quality of the generated image.

[0108] In an exemplary embodiment, second feature extraction of the first level among M levels is performed based on the second text feature to obtain a second intermediate feature in the second feature extraction of the first level and a second output feature of the first level, including: performing residual connection of the first level among M levels based on the second text feature to obtain a second intermediate feature in the second feature extraction of the first level; when the first level belongs to the level that triggers feature information exchange, performing feature fusion on the first intermediate feature obtained in the first feature extraction of the first level and the second intermediate feature to obtain a fused feature of the second feature extraction of the first level; extracting the fused feature to obtain a second self-attention feature of the first level; and performing cross-attention feature extraction based on the second self-attention feature and the second text feature to obtain the second output feature of the first level.

[0109] Specifically, for the second feature extraction processing of the first level in the M levels, the server can use the second text feature as the input feature of the first level, so as to directly perform the residual connection of the first level based on the second text feature to obtain the second intermediate feature of the first level. In some embodiments, the server can obtain the second noise feature map, which can be obtained by noise initialization. The server fuses the second text feature and the second noise feature map to obtain the second input feature of the first level, and performs the residual connection of the first level based on the second input feature of the first level to obtain the second intermediate feature of the first level. When the first level belongs to the level that triggers the exchange of feature information, it indicates that the first intermediate feature needs to be introduced in the second feature extraction of the first level. The server can perform feature fusion of the first intermediate feature of the first level with the second intermediate feature, such as feature splicing of the first intermediate feature of the first level with the second intermediate feature to obtain the fused feature of the first level. The server can extract the second self-attention feature of the first level based on the fused feature. Specifically, the server can extract the self-attention feature based on the self-attention mechanism based on the fused feature to obtain the second self-attention feature of the first level. The server may perform cross-attention feature extraction by combining the second self-attention feature and the second text feature to obtain the second output feature of the first level. The second output feature of the first level may be used as an input feature of the second level to perform second feature extraction processing on the first level.

[0110] In this embodiment, when the first level belongs to the level that triggers feature information exchange, the server performs a residual connection of the first level based on the second text feature, fuses the obtained second intermediate feature with the first intermediate feature of the first level, extracts the second self-attention feature based on the fused feature, and performs cross-attention feature extraction in combination with the second text feature. This can achieve adaptive fusion of the first intermediate feature and the second intermediate feature based on the attention mechanism in the first level, thereby reducing the conflict between different image content features, so that the image generated based on the information exchange feature can simultaneously meet the image content features described by the first text and the second text, thereby improving the image quality of the generated image.

[0111] In an exemplary embodiment, the second feature of the first level among M levels is extracted based on the second text feature to obtain the second intermediate feature in the second feature extraction of the first level and the second output feature of the first level, including: performing residual connection on the first level among M levels based on the second text feature to obtain the second intermediate feature in the second feature extraction of the first level; when the first level does not belong to the level that triggers feature information exchange, extracting the second intermediate feature to obtain the second self-attention feature of the first level; performing cross-attention feature extraction based on the second self-attention feature and the second text feature to obtain the second output feature of the first level.

[0112] Specifically, the server can use the second text feature as the input feature of the first level, and directly perform the residual connection of the first level based on the second text feature to obtain the second intermediate feature of the first level. When the first level does not belong to the level that triggers the exchange of feature information, it indicates that the first intermediate feature does not need to be introduced in the second feature extraction of the first level, and the server can directly extract the second self-attention feature from the second intermediate feature. Specifically, the server can perform self-attention feature extraction on the second intermediate feature based on the self-attention mechanism to obtain the second self-attention feature of the first level. The server can perform cross-attention feature extraction in combination with the second self-attention feature and the second text feature to obtain the second output feature of the first level.

[0113] In this embodiment, when the first level belongs to the level that triggers feature information exchange, the server performs residual connection of the first level based on the second text feature, extracts the second self-attention feature based on the obtained second intermediate feature, and performs cross-attention feature extraction in combination with the second text feature to obtain the second output feature of the first level, thereby realizing the second feature extraction processing of the first level based on the attention mechanism, ensuring the accuracy of the obtained second output feature, enhancing the expressiveness of the information exchange feature, and generating an image based on the information exchange feature, which is beneficial to improving the image quality of the generated image.

[0114] In an exemplary embodiment, the first feature extraction of M levels is performed on the first text feature in sequence to obtain the first intermediate features output by each of the M levels, including: extracting the first feature of the first level of the M levels on the first text feature to obtain the first intermediate feature and the first output feature of the first level; extracting the first feature of each level starting from the second level of the M levels based on the first output feature of the previous level to obtain the first intermediate feature and the first output feature of the level, until the first intermediate feature of the last level of the M levels is obtained.

[0115] Among them, when the first feature extraction processing of M levels is performed in sequence based on the first text feature, the first level can be directly implemented for the first text feature, and for the second level to the Mth level, feature extraction can be performed iteratively. Specifically, the output feature of the previous level can be used as the input feature of the current level, and the first feature extraction can be performed on the input feature of the current level to obtain the first intermediate feature and the first output feature of the level, until the first intermediate feature of the last level is obtained.

[0116] Exemplarily, the server may extract the first feature of the first level based on the first text feature to obtain the first intermediate feature and the first output feature of the first level. For each level starting from the second level, the server may extract the first feature of the level based on the first output feature of the previous level, that is, the server uses the first output feature of the previous level as the input feature of the level to extract the first feature of the level, and obtains the first intermediate feature of the level and the first output feature of the level. The server traverses the first feature extraction of each level until the first intermediate feature of the last level among the M levels is obtained, that is, the first intermediate feature of the Mth level is obtained.

[0117] In some embodiments, when extracting the first feature of the current level based on the first output feature of the previous level, if the server determines that the current level is the jth level among M levels, the server fuses the first output feature of the previous level and the first output feature of the M-j+1th level to obtain the input feature of the current level, where j is an integer greater than N and not greater than 2N, and 2N = M. The server extracts the first feature of the current level based on the input feature of the current level to obtain the first intermediate feature and the first output feature in the first feature extraction of the current level. By fusing the first output feature of the previous level and the first output feature of the M-j+1th level to obtain the input feature of the current level, a jump connection of the first output feature of the M-j+1th level can be achieved, which is beneficial to enhancing the feature expression capability of the input feature and improving the accuracy of feature extraction.

[0118] In this embodiment, for the first level, the server directly extracts the first feature of the first level based on the first text feature. For the second level to the Mth level, the server extracts the first feature of the current level based on the first output feature of the previous level, until the first intermediate feature of the Mth level is obtained. In this way, multi-level feature extraction can be performed on the first text feature, thereby enhancing the expressiveness of the information exchange feature. When generating an image based on the information exchange feature, it is beneficial to improve the image quality of the generated image.

[0119] In an exemplary embodiment, a first feature of a first level among M levels is extracted for a first text feature to obtain a first intermediate feature and a first output feature of the first level, including: performing a residual connection of the first level among M levels on the first text feature to obtain the first intermediate feature of the first level; and performing attention feature extraction of the first level based on the first intermediate feature of the first level to obtain the first output feature of the first level.

[0120] Among them, the attention feature extraction can be implemented based on the attention mechanism. Optionally, for the first feature extraction process of the first level among the M levels, the server can use the first text feature as the input feature of the first level, and directly perform the residual connection of the first level based on the first text feature to obtain the first intermediate feature of the first level. In some embodiments, the server can obtain a first noise feature map, and the first noise feature map can be obtained by noise initialization. The server fuses the first text feature and the first noise feature map to obtain the first input feature of the first level, and performs the residual connection of the first level based on the first input feature of the first level to obtain the first intermediate feature of the first level. The server can perform the first-level attention feature extraction on the first intermediate feature of the first level based on the attention mechanism to obtain the first output feature of the first level.

[0121] In this embodiment, the server performs residual connection of the first level based on the first text feature, performs attention feature extraction based on the obtained first intermediate feature, and obtains the first output feature of the first level, so that the first feature extraction processing of the first level can be implemented based on the attention mechanism, thereby ensuring the accuracy of the obtained first output feature, and enhancing the expressiveness of the information exchange feature. When generating an image based on the information exchange feature, it is beneficial to improve the image quality of the generated image.

[0122] In an exemplary embodiment, attention features of the first level are extracted based on the first intermediate features of the first level to obtain the first output features of the first level, including: extracting the first self-attention feature from the first intermediate features of the first level; and performing cross-attention feature extraction based on the first self-attention feature and the first text feature to obtain the first output feature of the first level.

[0123] Wherein, the first self-attention feature can be obtained based on the self-attention mechanism, and the cross-attention feature extraction can be implemented based on the cross-attention mechanism. Exemplarily, the server can perform self-attention feature extraction on the first intermediate feature of the first level based on the self-attention mechanism to obtain the first self-attention feature. The server can perform cross-attention feature extraction in combination with the first self-attention feature and the first text feature to obtain the first output feature of the first level.

[0124] In this embodiment, the first self-attention feature is extracted based on the first intermediate feature of the first level, and the cross-attention feature is extracted in combination with the first text feature to obtain the first output feature of the first level, so that the first feature extraction processing of the first level can be implemented based on the self-attention mechanism and the cross-attention mechanism, thereby ensuring the accuracy of the obtained first output feature, enhancing the expressiveness of the information exchange feature, and generating an image based on the information exchange feature, which is beneficial to improving the image quality of the generated image.

[0125] In an exemplary embodiment, obtaining a first text feature of a first text and a second text feature of a second text includes: obtaining the first text and the second text; encoding the first text and the second text respectively through a text encoding network to obtain the first text feature of the first text and the second text feature of the second text.

[0126] The first text and the second text are used to describe the image content features of the image to be generated, and the first text and the second text can be edited by the user and sent to the server through the terminal. The text encoding network is used to encode the input text to obtain the text features corresponding to the input text. The text encoding network can be a pre-trained network model, which can specifically include but is not limited to at least one of a convolutional neural network, a recurrent neural network, a Word2Vec network, a CLIP network, a Transformer network, or a BERT network.

[0127] Specifically, the server may obtain the first text and the second text, and the first text and the second text may be obtained by sending the first text and the second text to the server by the terminal. The terminal may obtain a pre-trained text encoding network, and encode the first text and the second text respectively through the text encoding network. Specifically, the server may input the first text and the second text into the text encoding network respectively, so that the text encoding network encodes them respectively, thereby obtaining the first text feature of the first text and the second text feature of the second text respectively.

[0128] In this embodiment, the server encodes the obtained first text and the second text respectively through a text encoding network to obtain first text features of the first text and second text features of the second text, and can trigger image generation processing based on the first text features and the second text features to obtain an image that simultaneously satisfies the image content features described by the first text and the second text.

[0129] In an exemplary embodiment, first feature extraction of M levels is performed on the first text feature in sequence to obtain first intermediate features output by each of the M levels, including: through a first image generation model, first feature extraction of M levels is performed on the first text feature in sequence, and the first intermediate features of each of the M levels are obtained from the first image generation model, the first image generation model includes M network layer structures, and each network layer structure in the first image generation model is used to realize first feature extraction of its own level.

[0130] Wherein, the first image generation model may include a Wensheng graph model pre-trained based on Wensheng graph technology, and the Wensheng graph model may specifically include but is not limited to at least one of the models including the Stable Diffusion model, the DALL-E model based on the Transformer, the Imagen model or the DreamDistribution model. Exemplarily, the server may query the pre-trained first image generation model, and sequentially perform the first feature extraction of M levels based on the first text feature through the first image generation model. Wherein, the first image generation model includes M network layer structures, and each network layer structure in the first image generation model is used to realize the first feature extraction of the corresponding level, so that by inputting the first text feature into the first image generation model, the first image generation model can realize the first feature extraction of M levels for the first text feature, and the server can obtain the first intermediate feature obtained in the first feature extraction of each level from the first image generation model. In a specific application, the first image generation model can be trained based on the first sample text, and the image content features described by the first sample text and the first text belong to the same feature type, such as the image content features described by the first sample text and the first text can both be the appearance of a person.

[0131] Furthermore, based on the second text feature, M levels of second feature extraction are performed in sequence to obtain information exchange features, including: through a second image generation model, based on the second text feature, M levels of second feature extraction are performed in sequence to obtain information exchange features, the second image generation model includes M network layer structures, and each network layer structure in the second image generation model is used to realize second feature extraction of its own level.

[0132] Wherein, the second image generation model may include a pre-trained Wensheng graph model based on Wensheng graph technology, and the Wensheng graph model may specifically include but is not limited to at least one of the models including the Stable Diffusion model, the DALL-E model based on the Transformer, the Imagen model or the DreamDistribution model. Optionally, the server may query the pre-trained second image generation model, and sequentially perform M-level second feature extraction based on the second text feature through the second image generation model to obtain information exchange features. Wherein, the second image generation model includes M network layer structures, and each network layer structure in the second image generation model is used to realize the second feature extraction of the corresponding level, so that by inputting the second text feature into the second image generation model, the second image generation model can realize M-level second feature extraction for the second text feature, and the server can obtain the information exchange features for generating images from the second image generation model. In a specific application, the second image generation model can be trained based on the second sample text, and the image content features described by the second sample text and the second text belong to the same feature type, such as the image content features described by the second sample text and the second text can both be image styles.

[0133] Furthermore, generating an image according to the information exchange features includes: decoding the information exchange features through a decoding network in the second image generation model to obtain the image output by the second image generation model.

[0134] Among them, the decoding network belongs to a subnetwork in the second image generation model, and the decoding network can decode the input information exchange features to output the corresponding generated image. Specifically, the information exchange features obtained in the second image generation model can be input into the decoding network in the second image generation model, so that the decoding network can decode the information exchange features, and the second image generation model can output the corresponding generated image, and the image content in the generated image has the first image content feature and the second image content feature. The decoding network is used to decode the information exchange features from the low-dimensional latent space to the pixel space, so as to obtain the corresponding image. The network structure of the decoding network can be configured according to actual needs, such as being configured as a variational autoencoder (VAE).

[0135] In this embodiment, for the first text and the second text that describe different image content features, the server performs multiple levels of feature extraction based on the first text features and the second text features of the second text respectively through the pre-trained first image generation model and the second image generation model. For the level that triggers feature information exchange, the first intermediate feature obtained by performing the first feature extraction on the first text feature at this level is fused with the second intermediate feature obtained by performing the second feature extraction on the second text feature at this level, and the output feature is obtained based on the fused feature obtained by the fusion, and the second feature extraction of the next level is performed based on the output feature. The first intermediate feature obtained for the first text feature can be selectively fused into the second feature extraction for the second text feature to control the intensity of different image content features in the obtained information exchange feature, which can reduce the conflict between different image content features, so that the image obtained by decoding the information exchange feature through the decoding network in the second image generation model can simultaneously meet the image content features described by the first text and the second text, thereby improving the image quality of the generated image.

[0136] The present application also provides an application scenario, and the application scenario applies the above-mentioned image generation method. Specifically, the application of the image generation method in the application scenario is as follows:

[0137] The image generation method provided in this embodiment involves personalized text image processing based on embedded concept fusion based on cross-model U-Net (U-type network) feature exchange. The method uses two Finetune (fine-tuned) models for matching and combining, and through cross-model information exchange, the concepts that have been Finetune embedded in the two models can be integrated with each other, and finally generate a picture with the Finetune concept attributes of the two models. Among them, the embedded concepts in the model are the image content features described by the text in the image generation method. The two models can embed different concepts respectively, that is, the description and generation capabilities of an object or object are integrated into the model, and each model can generate an image with corresponding image content features.

[0138] U-Net is one of the algorithms that uses a fully convolutional network for semantic segmentation. The name of the network is also taken from its U-shaped shape. At the same time, the U-Net network is also the basic backbone model of the Stable Diffusion model. Self Attention and Cross Attention modules are added to the U-Net network, so that the denoising function of the model can be built. Stable Diffusion is a variant of the Diffusion Model, called the Latent Diffusion Model (LDM). The Diffusion Model was introduced in 2015. Its purpose is to eliminate the continuous application of Gaussian noise to the training images. It can be regarded as a series of denoising autoencoders. StableDiffusion consists of 3 parts: Variational Autoencoder (VAE), U-Net, and a text encoder. Instead of learning to denoise image data, VAE is trained to convert images into a low-dimensional latent space. The process of adding and removing Gaussian noise is applied to this latent representation, and then the final denoised output is decoded into the pixel space. During the forward diffusion process, Gaussian noise is iteratively applied to the compressed latent representation. Each denoising step is done by a U-Net architecture containing a residual neural network, which obtains the latent representation by denoising from forward diffusion to the reverse direction. Finally, the VAE decoder generates the output image by converting the representation back to pixel space.

[0139] Furthermore, the Attention mechanism is a solution to the problem that imitates human attention. Simply put, it is to quickly filter out high-value information from a large amount of information. The attention mechanism is mainly used to solve the problem that it is difficult to obtain a reasonable final vector representation when the model inputs complex features. The approach is to retain the intermediate results of the model, learn it with a new model, and associate it with the output to achieve the purpose of information screening. Cross Attention in the StableDiffusion model refers to the cross-attention mechanism in the model, which is usually used to process the association between multiple input sequences in order to capture important information interactions between different sequences in the model. In the stable diffusion model, cross attention can help the model better understand the association between different parts, so as to more accurately predict changes and impacts in the diffusion process.

[0140] This embodiment constructs a cross-model feature communication method, by using two Stable Diffusion models that have been finetuned (fine-tuned) with concepts embedded, one backbone network and one auxiliary network, and then using the mechanism based on Attention adaptive fusion to generate adaptive fusion communication of features for each Cross Attention module of the U-Net model in the two networks, so that the concepts embedded in the two models can cooperate with each other to generate a finished picture with two Finetuned concepts. At the same time, the connection branches for generating feature information communication between the two U-Nets constructed in this embodiment can include more than a dozen, so the number of connection branches can be selected by itself during the generation process, so as to control the strength of the concepts in the auxiliary network in embedding and fusion into the backbone network, so as to achieve a controllable proportion between the two concepts in the generated picture. The image generation method provided in this embodiment is a cross-model concept fusion generation method that is completely pluggable by the Zero-Shot model. After constructing a complete cross-model U-Net generation feature adaptive communication transmission mechanism, the method does not need to be trained again, and can automatically fuse the feature generation effect. This method allows users to conveniently and flexibly use millions of open source Finetuned models in the community, increases personalized generation methods and gameplay, and provides a creative space for the fusion generation of various concepts.

[0141] At present, when custom images are generated based on multiple different description texts, that is, when multiple concepts need to be integrated to realize the text map, one method is to Finetune the two concepts that need to be fused and generated into a Stable Diffusion model, so that a model can be used to generate images with two concepts at one time. This method requires first preparing the image data related to the two concepts, and then inputting the images of the two concepts into the model at one time through a model fine-tuning method such as Dreambooth (generative model), and training the two concepts simultaneously, so as to obtain a text map model that embeds two specified concepts at the same time. The second method also needs to Finetuned the model based on certain data. This method also needs to prepare data in advance, but unlike the training of the first solution, the second method is a serial training method. In order to enable the model to distinguish between the main concept and the auxiliary concept, it first learns from the main concept data, and then adds the auxiliary concept data after a period of Finetune, so that the model can deepen the embedding strength of the main concept, so as to distinguish between the main concept and the auxiliary concept. This method can also be directly based on the community open source model, find a Finetune model embedded in the main concept, and then continue to learn based on the data of the auxiliary concept, so as to merge the two concepts into one model. The third method is to extract two Stable Diffusion models of the concepts you want from the community, and then generate a picture you want based on the main concept model, and input the picture into the auxiliary concept model to do Img2Img (Image to Image) conversion or inpainting, and use the ability of the auxiliary model to redraw the picture or part of the picture, so as to present the auxiliary concept in the picture of the main concept.

[0142] However, both the first and second methods require the preparation of a batch of data on related concepts and fine-tuning of the model Finetune, so as to inject the required two concept learning into one of the models. This method can integrate the two concepts into one model to a certain extent, but the work of preparing a batch of data in advance is time-consuming and costly. At the same time, the Finetune of Stable Diffusion also requires a lot of time and hardware, such as large-capacity graphics card GPU (Graphics Processing Unit) and other equipment, which greatly increases the time and cost of the entire project.

[0143] Although the second method reduces the model Finetune time by half compared to the first solution, and can also use the open source model of the AIGC community as the main concept model to integrate concepts, this method still cannot get rid of the time and cost of model Finetune, and it is also impossible to freely match model concepts and fully utilize the diversity of community models, which reduces the user experience.

[0144] In addition, using two concepts for learning fusion can easily lead to the inability to perfectly inject and present two concepts in one model. That is, when two concepts are injected and fused into one model at the same time, because the ratio of injected concepts is 1:1 by default, the concepts will affect each other, thus reducing the effect of the final generated graph. Even if they are injected into the model one after the other, the later injected concept will, to a certain extent, cover the training balance of the earlier injected concept when the model parameters are adjusted, thus affecting the final output graph of the earlier injected concept.

[0145] For the third method, the main concept model that has been open sourced in the community is used to first generate a picture represented by the concept, and then it is input into another open source auxiliary concept model for fine-tuning on Img2Img or regional inpainting, so as to use the auxiliary concept to merge into the main concept generated picture. This method is uncontrollable in terms of generation effect, because the auxiliary concept is fine-tuned directly on the generated picture, which can easily lead to conflicts in the attributes of certain concepts and cannot be adaptively merged. For example, if the main concept is a watercolor style and the auxiliary concept is the appearance of person a, a watercolor-style portrait of a person is generated using the main concept, and then the face is inpainted using the person a appearance model, which can easily lead to the redrawn face no longer being in watercolor style.

[0146] Therefore, the above three solutions all directly perform a 1:1 fusion of concepts when generating images or regenerating images, so that the main concept and the auxiliary concept are presented with the same semantic strength in the final generated image. For many application requirements, the fusion of concepts is uncontrollable, because the two concepts are divided into the main concept and the auxiliary concept, so to a certain extent, it is necessary to control the degree of fusion of the auxiliary concept into the main concept. The above uncontrollable methods will directly affect the use effect of the application, resulting in lower image quality of the generated image.

[0147] Based on this, the image generation method provided in this embodiment is mainly to be able to directly use two finetuned Stable Diffusion models to adaptively fuse concepts across models to generate images. The image generation method provided in this embodiment can directly use a large number of community open source models, flexibly match the concepts embedded in different models, and thus generate images with different model embedded concepts, thereby adding more gameplay and improving the utilization rate of community models. For example, the image generation method provided in this embodiment can be directly applied to the AIGC Wenshengtu community, such as the model open source community Civitai, by allowing users to choose to download different open source models in the community, and then using the image generation method provided in this embodiment to flexibly combine different models, thereby generating Wenshengtu results with cross-model concepts, providing community users with more model gameplay, thereby improving the activity of the Wenshengtu community and increasing users' interest in uploading and downloading models.

[0148] Moreover, the image generation method provided in this embodiment can be used in the application of personalized style portraits. It can directly randomly select from different style models, and then use the pluggable advantage of the solution to combine models of Finetuned appearances of different users and different style models, so as to quickly generate personalized portrait pictures of different styles for users, and can also use stylized images uploaded by users themselves to generate pictures of specified styles for users, which greatly improves the diversity of user gameplay. In addition, the image generation method provided in this embodiment can also be applied to artistic creation or design work. Through the image generation method provided in this embodiment, two artistic styles can be automatically and adaptively fused together, and the fusion strength between the two artistic styles can be adjusted, so as to create a new style that is richer and compatible with multiple arts, which increases the efficiency and creativity of artistic creation and design.

[0149] Specifically, the image generation method provided in this embodiment constructs a personalized text map solution with embedded concept fusion based on cross-model U-Net generated feature exchange. This method is a system for constructing a cross-model concept adaptive fusion generation map between two models that have been injected with concept Finetune. In the actual use of this system, a large number of open source Stable Diffusion models in the AIGC community can be directly used, which are divided into main concept models and auxiliary concept models. The image generation method provided in this embodiment is used to control the fusion, so as to generate a final generated map with main concepts and auxiliary concepts presented at the same time. In a specific application, such as Fig.12As shown in FIG. 1 , it is a schematic diagram of the effect after the main concept and the auxiliary concept are fused. Taking the fusion generation of the style / portrait concept and the character's appearance as an example, the character's appearance features injected into the auxiliary concept model are simultaneously fused into the image generation in the main concept model. Among them, the images A1, B1 and C1 in the first row are style / portrait pictures directly generated by the main concept model according to its Finetuned effect, the images A2, B2 and C2 in the second row are appearance feature pictures generated by the auxiliary model, and the images A, B and C in the third row are the ideal pictures after fusion. Specifically, image A carries the concepts of image A1 and image A2 at the same time, that is, the style / portrait of image A is the same as the style / portrait of image A1, and the appearance of the character in image A is the same as the appearance of the character in image A2; similarly, image B carries the concepts of image B1 and image B2 at the same time, and image C carries the concepts of image C1 and image C2 at the same time.

[0150] Specifically, the image generation method provided in this embodiment involves processing of personalized text maps based on embedded concept fusion based on cross-model U-Net generated feature communication. This method is based on two models that have already embedded concepts in Finetune. It uses the constructed innovative adaptive fusion module to connect the U-Net networks of the two models to achieve communication in the generated features, so that the semantics in the auxiliary concept model can be adaptively integrated into the main concept model. And the image generation method provided in this embodiment can achieve controllable fusion strength ratio between auxiliary concepts and main concepts when using this mechanism by controlling the number of communication connections of generated features between models. After fusion by the image generation method provided in this embodiment, a finished text map that integrates the semantics of embedded concepts of the two models can be generated in the main concept model after the auxiliary concept model is matched.

[0151] The image generation method provided in this embodiment belongs to the cross-model concept fusion generation method of Zero-Shot, so no additional training is required. The image generation method provided in this embodiment is based on two fine-tuned Stable Diffusion models. According to the concept generation target required by the system requirements, the two models are divided into a main concept model and an auxiliary concept model, wherein the main concept model often presents more concept semantics in the final generated product, and the auxiliary concept is to perform auxiliary generation of the picture fine-tuning on the basis of the main concept semantic expression. For example, the main concept model is used to generate an "anime-style man with tattoos and wearing a vest", and then the auxiliary concept model is a model that has been embedded with the appearance of character A. After the fusion of the image generation method provided in this embodiment, an anime-style man with tattoos and wearing a vest with the appearance of character A can be generated. In specific applications, the main concept and the auxiliary concept can be converted to each other according to actual needs.

[0152] Specifically, Fig.13 As shown, it is a system flow diagram of the image generation method provided in this embodiment. It can be seen from the figure that the entire model is constructed based on two Finetuned Stable Diffusion (fine-tuned diffusion models) models. The entire model does not need additional training. The innovative mechanism in the image generation method provided in this embodiment is used to directly generate communication and fusion of features between cross-model U-Nets, so as to achieve the purpose of generating images by fusion between embedded concepts.

[0153] Among them, the upper one is the Stable Diffusion model based on auxiliary concept fine-tuning, that is, the auxiliary concept model, and the lower one is the Stable Diffusion model based on main concept fine-tuning, that is, the main concept model. Because the two Stable Diffusion models are often not trained in the model fine-tuning stage of concept embedding, in order to save the space occupation loss of the entire system for the hardware GPU, the auxiliary model and the main concept model share a text encoder (CLIP Text Encoder) to encode the text concept. Among them, the CLIP model is an advanced deep learning model that can understand text and images. It is a multimodal model that has been trained to match text and images, and has learned to recognize the content in the image and the language describing the image. The main goal of the CLIP model is to learn to match images and texts through contrastive learning, which is to predict which image belongs to a given text by training the model and vice versa. During the training process, the model learns to encode images and texts into a unified vector space, which enables it to understand the relationship between them in language and vision. In this way, CLIP can identify elements such as objects, scenes, actions, etc. in the image, while also being able to understand the text associated with the image, such as tags, descriptions, titles, etc. CLIP has been shown to have excellent performance on both visual and language tasks.

[0154] Specifically, the auxiliary concept text (character A) and the main concept text sequence (an anime style man with tattoos and a tank top) are first input into the common text encoder Text Encoder to generate a text embedding set. In the input process, they are actually input separately, and the text embedding between the auxiliary concept and the main concept is completely independent and isolated. After obtaining the text embedding set, the embedding set is input into the network unit block (U-Net Block) or fusion network unit block (Merge U-Net Block) of the two models through the Cross Attention mechanism to inject and generate the concept. The network unit block (U-Net Block) and the fusion network unit block (Merge U-NetBlock) are the basic components of U-Net in the Stable Diffusion model. The Merge U-Net Block is used in the main concept model here to distinguish it. Specifically, the text embedding of the auxiliary concept text obtained through the text encoder can be input into the auxiliary concept model, and the auxiliary concept model performs feature extraction processing on the input text embedding and the initialized potential noise map (noise latent) based on multiple sequentially connected network unit blocks (U-NetBlock); for the main concept text, the text embedding of the main concept text obtained through the text encoder can be input into the main concept model, and the main concept model performs feature extraction processing on the input text embedding and the initialized potential noise map (noise latent) based on multiple sequentially connected fusion network unit blocks (Merge U-Net Block).

[0155] In the process of image generation, the number of connections between the two U-Net models is controlled by the feature exchange connection switch in the middle, so as to achieve controllable fusion of features. The U-Net Block of the auxiliary concept model inputs the generated features in its Unit into the Merge U-Net Block of the main concept model through the feature exchange connection. Through the transformation of Attention in the Merge U-Net Block, the generated feature map of the auxiliary concept model can be adaptively fused with the generated feature map of the main concept model, and a feature map with the same size as the original feature can be generated to continue to participate in the next calculation in the main concept model. The main concept model strengthens the auxiliary concept fusion through the Merge U-NetBlock controlled by multiple layers of switches, and can gradually adaptively fuse the two concepts, so as to achieve the purpose of personalized text map for the fusion of embedded concepts across models. Specifically in the main concept model, the output of the last fusion network unit block (Merge U-Net Block) can be input into the decoder (VAE decoder) for decoding to obtain the final image generation result.

[0156] For the Stable Diffusion model, it includes three parts: text encoder, U-Net and variational autoencoder. Among them, the text encoder will convert the input text prompt into an embedding space that U-Net can understand. The commonly used one is the Text Encoder module in the CLIP model, which is a simple Transformer-based encoder that maps the tag sequence to the potential text embedding sequence, so that good text prompts can be used to obtain better expected output. The variational autoencoder, that is, the autoencoder, consists of two main parts: the encoder and the decoder. During the model training process, the encoder will convert the image into a low-dimensional latent representation, which will serve as the input of the next component U-Net; the decoder will do the opposite, it will convert the latent representation back to the image. During the Diffusion training process, the encoder is used to obtain the latent representation of the input image in the forward diffusion process. The latent representation usually refers to the latent variable, that is, the variable that is not directly observed in the model, that is, the most basic feature in the entire model processing flow. These variables are very important for explaining the observed data and the behavior of the model. In the Stable Diffusion model, latent variables may represent unobserved factors, such as individual characteristics, behavior, style, and composition, which may affect the diffusion process. During inference, the VAE decoder will convert the latent signal back to an image.

[0157] Furthermore, U-Net also consists of an encoder and a decoder, both of which are composed of ResNet residual blocks. The encoder in U-Net compresses the image representation into a low-resolution image, and the decoder in U-Net decodes the low-resolution back to a high-resolution image. In order to prevent U-Net from losing important information when downsampling, a shortcut connection is usually added between the downsampled ResNet of the encoder and the upsampled ResNet of the decoder. A cross attention layer Cross Attention is added to the Diffusion U-Net to adjust the output of the text embedding. The cross attention layer is added between the encoder and decoder ResNet blocks of U-Net. At the same time, in order to make the quality of the image generated by U-Net more exquisite, a self-attention layer Self Attention is added between ResNet and the cross attention layer.

[0158] like Fig.14 As shown, for the Stable Diffusion model, you first need to train an autoencoder model (AutoEncoder, which includes an encoder and a decoder ). In this way, the encoder can be used to compress the image, then perform diffusion operations on the latent space, and finally restore it to the original pixel space using the decoder. This method is called perceptual compression in the model. This method of compressing high-dimensional features to low-dimensional and then operating on low-dimensional space is universal. Specifically in the pixel space, for the input image , through the encoder The feature map is obtained by encoding, and the diffusion process is realized in the latent space based on the feature map. Specifically, the feature map is To feature map Diffusion process; in the decoding process, the conditional mechanism is introduced, including various conditions such as semantic map, text, representations and images. Decode and recover. Specifically, when decoding, To feature map In the process, the Unet network is combined with the attention mechanism to achieve the feature map Combined with the previous restored image Get feature map , and through the decoder Get the output image in pixel space The main process of the Diffusion operation on the latent representation space is not much different from the standard diffusion model. The specific implementation of the diffusion model used is time-conditionalUNet (UNet based on time condition constraints). However, an important point is that the model introduces conditional mechanisms for the Diffusion operation, and implements multimodal training through Cross-Attention, so that conditional image generation tasks can also be achieved.

[0159] Furthermore, the image generation method provided in this embodiment mainly involves the transformation of the AC control switch and the Merge U-Net Block. Among them, the AC control switch controls the number of feature exchanges of the U-Net Block between the two models, and also represents the strength of the fusion of the auxiliary concept into the main concept model. The transformation of the Merge U-Net Block is mainly carried out in the Self Attention in each U-Net Block module, and at the same time, the switch mechanism needs to be taken into account, so that the model can perform calculations with and without fusion without perception, keep the overall feature map the same, and can also perform adaptive fusion between auxiliary concepts and main concepts.

[0160] For AC control switches, a switch control vector can be input into the module to control whether each connection point is open. The number of elements in this switch control vector corresponds to the number of feature AC connections across the U-Net network. The value of the element in the switch control vector is between 0 and 1, where 0 represents that the connection it controls is closed and 1 represents that the connection it controls is open. The generated features of the auxiliary concept are input into the Merge U-Net Block of the main concept model through the switch connection. Fig.15 As shown, the switch control vector is "00001111", which corresponds to the 5th U-Net Block, the 6th U-Net Block, the 7th U-Net Block and the 8th U-Net Block need to be activated for feature exchange.

[0161] In the actual use of the model mechanism, you can refer to the control range of different U-Net blocks in the Stable Diffusion model for the final generated image to adjust the switch vector. The U-Net network often controls the main component structure and basic style presentation of the entire picture in the DownBlock, while the Up Block often controls the depiction and generation of details in the picture and the supplementary fusion between different semantics. For example, if you want to generate an anime landscape picture with a watercolor style, this is a fusion of the two styles, so you need to focus on the feature exchange connection between the two U-Net Down Blocks. For another example, to generate an anime character with the appearance features of character A, the depiction of this appearance feature is a supplement to the details, so you need to pay special attention to the connection between the Up Blocks. In specific applications, how many blocks to choose for fusion and which blocks to choose for fusion can be determined by trying different switch ratios according to actual needs.

[0162] For the fusion network unit block Merge U-Net Block, such as Fig.16As shown in the figure, it is a structural diagram of the cross-U-Net feature exchange network module. The left side of the figure represents the U-Net network structure in the auxiliary concept model, and the right side represents the U-Net network structure in the main concept model. The basic unit in the U-Net network architecture is the network unit block U-Net Block. The U-Net in the auxiliary concept model on the left is the original U-Net Block module without any change. Each Block in the U-Net of the main concept on the right is transformed into a fusion network unit block Merge U-Net Block. Each Block consists of a residual block (ResNet), a self-attention module, and a cross-attention module connected in sequence. In the main concept model, the Self Attention module is changed to a fusion self-attention (Merge Self Attention) module. Compared with the basic Self Attention on the left, it receives two parts of input, namely, the ResNet output features of the corresponding Block in the U-Net of the auxiliary concept model on the left, and the calculated output features of the ResNet in the current Block. After receiving the calculated features of these two modules, the structure adaptively fuses the auxiliary concept semantic features with the main concept semantic features, and then regenerates the features and passes them to the Cross Attention module of the main concept model for subsequent calculations. Specifically, for the auxiliary concept model, in each level of the network unit block U-Net Block, the input is processed by the residual block, the self-attention module, and the cross-attention module in turn. For the cross-attention module, the text embedding of the auxiliary concept text is also introduced for processing. For the main concept model, in each level of the fusion network unit block MergeU-Net Block, the input is processed by the residual block, the fused self-attention module, and the cross-attention module in turn. In addition, for the fused self-attention module, the output fusion of the residual block in the auxiliary concept model is also introduced for processing. For the cross-attention module, the text embedding of the auxiliary concept text is also introduced for processing.

[0163] Furthermore, if Fig.17The figure shows the reconstruction of the Merge Self Attention module in the Merge U-Net Block, where the left side shows the base self-attention structure, that is, the basic architecture of the Self Attention module used in the U-Net network of the auxiliary concept model. The right side shows the modified Merge Self Attention module used in the main concept model, and the basic architecture of the module is the same as the Base self-attention. Because the present embodiment is a cross-model connection between two finetuned concept models directly without additional training, all network weight parameters in the Merge Self-Attention in the main concept model can reuse the parameter weights of the Self Attention module in the main concept model.

[0164] In actual use, through the switch connection, the generated features output by the ResNet module in the corresponding Block in the auxiliary concept model can be input into the Merge Self Attention of the main concept model. First, the main concept feature and the auxiliary concept feature are concat (concatenate), and then this new Feature Map replaces the input of the key feature K and value feature V in the original Self Attention. The input of the query feature Q still remains the feature of the main concept. After Q (main concept feature) and K (main concept feature + auxiliary concept feature) are Matmul (matrix multiplication) and Softmax (normalization), the feature correlation between the two features can be calculated, and then according to the feature correlation, it can be adaptively fused with V (main concept feature + auxiliary concept feature) to generate a new concatenated feature map Concat Feature Map. However, in order to ensure that the feature size in the entire network is the same, and because the main concept is on the left when Concat is performed, the left feature of the new Concat Feature Map is taken as the fused feature New Left Feature. However, in order to make the feature expression of the main concept stronger and more consistent, it is necessary to add the input main concept feature Feature of Q to the NewLeft Feature to generate a new main concept feature New Feature (new feature map), and then input it into the Cross Attention to be calculated next. Through this method of merging first, then calculating the relevance weight, and then adaptively fusing according to the relevance weight, the auxiliary concept can be adaptively integrated into the main concept generation process, thereby avoiding the problem of abrupt fusion and mutual influence, and finally generating a concept fusion image similar to the image of a tattooed man with the appearance of character A.

[0165] This embodiment constructs a personalized text image method for embedded concept fusion based on cross-model U-Net generated feature communication. This method is for two models that have embedded the required concepts through Finetune training and perfecting. Through the fast model fusion method in this solution, the concept generation of Finetuned in the two models is automatically fused, so as to achieve the purpose of concept collocation and generation between the two models. The image generation method provided in this embodiment can directly act on the trained model without other training, and can achieve pluggable and coordinated use between models, greatly improving the utilization rate of open source models in the AIGC community, and adding more gameplay and implementation of concept fusion generation. The image generation method provided in this embodiment realizes the generation feature exchange across two U-Net networks. This method directly uses the generated features processed in the U-Net backbone network in the two Stable Diffusion models to perform semantic adaptive fusion. In order to achieve adaptive collocation fusion between concepts, the Attention-based method is selected to fuse the two processed generated features into the feature stream in the backbone generation network U-Net. This method can prevent conflicts between concepts, and the model adaptively selects the degree of semantic fusion, which improves the degree of fusion and collocation between concepts.

[0166] The image generation method provided in this embodiment constructs a parallel information exchange relationship between two models, but in the specific generation process, it is innovatively divided into a main network and an auxiliary network, so that the conceptual information that has been Finetune embedded in the auxiliary network can be extracted and input into the main network for conceptual assistance, so that when the main network generates an image, it can generate a concept fusion result that the main network does not have but the auxiliary network Finetuned. Such a combination of one main and one auxiliary can make the system more convenient and flexible during use, and the same model can be used to try different mashup effects. The image generation method provided in this embodiment constructs a cross-model generation feature exchange process. In the generation process, the U-Net network model is used as the basis, and a generation feature exchange module is constructed in each Attention Block (attention module) in the U-Net network, so there are more than a dozen feature exchange line branches between the main network and the auxiliary network. The image generation method provided in this embodiment can select which line branches to use for communication during the generation process, so as to control the intensity of the concept fusion of the auxiliary network into the main network, so as to control the proportion of the auxiliary network Finetuned concept in the image finally generated by the main network.

[0167] The image generation method provided in this embodiment is aimed at two models that have already embedded the required concepts through Finetune training. Through the concept model fusion method in this embodiment, the concept generation of Finetuned in the two models is automatically fused, so as to achieve the purpose of concept matching and generation between the two models. The image generation method provided in this embodiment can directly act on the trained model without other training, and can achieve pluggable matching between models, greatly improving the utilization rate of open source models in the AIGC community, adding more gameplay and implementation of concept fusion generation, and avoiding the Finetune stage of the model, so there is no need for additional data preparation and model training. Therefore, this solution greatly reduces the time and cost of the project and improves efficiency on the basis of meeting the needs.

[0168] Furthermore, this embodiment constructs a generated feature communication method across two U-Net networks. This method directly uses the generated features processed in the U-Net backbone network in the two Stable Diffusion models to perform semantic adaptive fusion. In this embodiment, in order to achieve adaptive matching fusion between concepts, an Attention-based approach is selected to fuse the two processed generated features into a feature stream in the backbone generation network U-Net. The Attention-based mechanism can perform adaptive weight calculation between the two generated features of the main concept and the auxiliary concept, thereby adaptively fusing the model generated features according to the weights. This method can prevent conflicts between concepts, allow the model to adaptively select the degree of semantic fusion, improve the degree of fusion and matching between concepts, and avoid direct mutual influence between the two concepts during the generation process.

[0169] In this embodiment, a parallel information exchange relationship between two models is constructed, but in the specific generation process, it will be innovatively divided into a main network and an auxiliary network according to the distinction between the main concept and the auxiliary concept required, so that in the actual application process, the concept information that has been Finetune embedded in the auxiliary network can be extracted and input into the main network for conceptual assistance, so that when the main network generates an image, it can generate a concept fusion result that the main network does not have but the auxiliary network Finetuned. This combination of one main and one auxiliary can make the system more convenient and flexible during use, and different mix-and-match effects can be tried using the same model, providing more model generation graph gameplay and improving the utilization rate of community models.

[0170] The image generation method provided in this embodiment uses the U-Net network model as the basis to construct a generation feature exchange module in each Attention Block in the U-Net network. In these feature exchange modules, adaptive feature weighted fusion calculations are performed, so that adaptive fusion between the main concept and the auxiliary concept is achieved in these Attention Blocks. This fusion is performed in each Block, so each Block in the backbone network will be fused and exchanged once, and there are more than a dozen feature exchange line branches between the backbone network and the auxiliary network. Therefore, the image generation method provided in this embodiment can innovatively select which line branches to use for feature fusion and exchange during the generation process according to this network structure, so as to control the intensity of the concept carried by the auxiliary network to be integrated into the backbone network, thereby controlling the proportion of the auxiliary network Finetuned concept in the final image generated by the backbone network, so as to achieve a more controllable match between the main concept and the auxiliary concept in the final generated image.

[0171] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0172] Based on the same inventive concept, the embodiment of the present application also provides an image generation device for implementing the above-mentioned image generation method. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above-mentioned method, so the specific limitations in one or more image generation device embodiments provided below can refer to the limitations on the image generation method above, and will not be repeated here.

[0173] In an exemplary embodiment, Fig.18 As shown, an image generating device 1800 is provided, comprising: a text feature acquisition module 1802, a first feature extraction module 1804, a second feature extraction module 1806 and an information exchange feature processing module 1808, wherein:

[0174] A text feature acquisition module 1802, configured to acquire a first text feature of a first text and a second text feature of a second text, wherein the first text is used to describe a first image content feature, and the second text is used to describe a second image content feature;

[0175] The first feature extraction module 1804 is used to perform M-level first feature extraction on the first text feature in sequence to obtain first intermediate features outputted by each of the M levels, where M is an integer greater than or equal to 2;

[0176] The second feature extraction module 1806 is used to sequentially perform second feature extraction of M levels based on the second text feature to obtain information exchange features, wherein, in the second feature extraction of M levels, when the i-th level belongs to the level that triggers feature information exchange, the first intermediate feature obtained in the first feature extraction of the i-th level and the second intermediate feature obtained in the second feature extraction of the i-th level are feature fused to obtain a fused feature of the second feature extraction of the i-th level, an output feature of the i-th level is obtained based on the fused feature, and when i is a positive integer less than M, the second feature extraction of the next level is performed based on the output feature, and when i is equal to M, the information exchange feature is obtained based on the output feature;

[0177] The information exchange feature processing module 1808 is used to generate an image according to the information exchange feature, and the image content in the image has a first image content feature and a second image content feature.

[0178] In one embodiment, the second feature extraction module 1806 is also used to perform feature splicing on the first intermediate feature obtained in the first feature extraction of the i-th level and the second intermediate feature obtained in the second feature extraction of the i-th level in accordance with a feature splicing method to obtain a spliced ​​feature of the second feature extraction of the i-th level; perform attention feature extraction based on the spliced ​​feature and the second intermediate feature obtained in the second feature extraction of the i-th level to obtain an attention feature of the i-th level; determine, from the attention feature of the i-th level according to the feature splicing method, an adaptive fusion feature that is updated relative to the second intermediate feature; perform cross-attention feature extraction on the adaptive fusion feature and the second text feature to obtain an output feature of the i-th level.

[0179] In one embodiment, the second feature extraction module 1806 is also used to obtain key features and value features based on the splicing features, and obtain query features based on the second intermediate features obtained in the second feature extraction of the i-th level; determine the feature relevance based on the query features and the key features; and perform adaptive feature fusion on the value features according to the feature relevance to obtain the attention features of the i-th level.

[0180] In one embodiment, the second feature extraction module 1806 is also used to enhance the fusion of the adaptive fusion feature and the second intermediate feature obtained in the second feature extraction of the i-th level to obtain an enhanced adaptive fusion feature; and perform cross-attention feature extraction on the enhanced adaptive fusion feature and the second text feature to obtain the output feature of the i-th level.

[0181] In one embodiment, it also includes a feature fusion level determination module, which is used to determine the first feature type of the first image content feature and the second feature type of the second image content feature; based on the first feature type and the second feature type, determine the level that triggers the feature information exchange from M levels.

[0182] In one embodiment, the second feature extraction module 1806 is also used to perform second feature extraction of the first level among M levels based on the second text feature, and obtain the second intermediate feature in the second feature extraction of the first level and the second output feature of the first level; for each level starting from the second level among the M levels, perform second feature extraction of the level at which the level is located based on the second output feature of the previous level, and obtain the second intermediate feature in the second feature extraction of the level at which the level is located and the second output feature of the level at which the level is located, until the second output feature of the second feature extraction of the last level among the M levels is obtained, and obtain the information exchange feature based on the second output feature of the second feature extraction of the last level.

[0183] In one embodiment, the second feature extraction module 1806 is also used to, when the level at which the module is located does not belong to the level that triggers the exchange of feature information, perform a residual connection at the level at which the module is located based on the second output feature of the previous level to obtain a second intermediate feature in the second feature extraction at the level at which the module is located; extract the second self-attention feature at the level at which the module is located based on the second intermediate feature; perform cross-attention feature extraction based on the second self-attention feature and the second text feature to obtain the second output feature at the level at which the module is located.

[0184] In one embodiment, the second feature extraction module 1806 is also used to perform a residual connection of the first level among the M levels based on the second text feature to obtain a second intermediate feature in the second feature extraction of the first level; when the first level belongs to the level that triggers feature information exchange, the first intermediate feature obtained in the first feature extraction of the first level is fused with the second intermediate feature to obtain a fused feature of the second feature extraction of the first level; the second self-attention feature of the first level is extracted based on the fused feature; and cross-attention feature extraction is performed based on the second self-attention feature and the second text feature to obtain the second output feature of the first level.

[0185] In one embodiment, the second feature extraction module 1806 is also used to perform a residual connection of the first level among M levels based on the second text feature to obtain a second intermediate feature in the second feature extraction of the first level; when the first level does not belong to the level that triggers feature information exchange, the second intermediate feature is extracted to obtain the second self-attention feature of the first level; cross-attention feature extraction is performed based on the second self-attention feature and the second text feature to obtain the second output feature of the first level.

[0186] In one embodiment, the first feature extraction module 1804 is also used to extract the first feature of the first level among the M levels for the first text feature, and obtain the first intermediate feature and the first output feature of the first level; for each level starting from the second level among the M levels, the first feature of the level is extracted based on the first output feature of the previous level, and the first intermediate feature and the first output feature of the level are obtained, until the first intermediate feature of the last level among the M levels is obtained.

[0187] In one embodiment, the first feature extraction module 1804 is also used to perform a residual connection of the first level among M levels on the first text feature to obtain a first intermediate feature of the first level; perform attention feature extraction of the first level based on the first intermediate feature of the first level to obtain a first output feature of the first level.

[0188] In one embodiment, the first feature extraction module 1804 is also used to extract the first intermediate feature of the first level to obtain the first self-attention feature; perform cross-attention feature extraction based on the first self-attention feature and the first text feature to obtain the first output feature of the first level.

[0189] In one embodiment, the text feature acquisition module 1802 is further used to acquire a first text and a second text; the first text and the second text are respectively encoded by a text encoding network to obtain a first text feature of the first text and a second text feature of the second text.

[0190] In one embodiment, the first feature extraction module 1804 is also used to perform M-level first feature extraction on the first text feature in sequence through the first image generation model, and obtain the first intermediate features of each of the M levels from the first image generation model. The first image generation model includes M network layer structures, and each network layer structure in the first image generation model is used to realize the first feature extraction of the corresponding level; the second feature extraction module 1806 is also used to perform M-level second feature extraction on the second text feature in sequence through the second image generation model to obtain information exchange features. The second image generation model includes M network layer structures, and each network layer structure in the second image generation model is used to realize the second feature extraction of the corresponding level; the information exchange feature processing module 1808 is also used to decode the information exchange features through the decoding network in the second image generation model to obtain the image output by the second image generation model.

[0191] Each module in the above-mentioned image generation device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module above.

[0192] In an exemplary embodiment, a computer device is provided. The computer device may be a server or a terminal. The internal structure diagram thereof may be as follows: Fig.19 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data involved in the image generation method. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, an image generation method is implemented.

[0193] Those skilled in the art will understand that Fig.19The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0194] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.

[0195] In one embodiment, a computer-readable storage medium is provided, storing a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0196] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0197] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0198] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0199] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0200] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. An image generation method, characterized in that: The method comprises: Acquire a first text feature of a first text and a second text feature of a second text, wherein the first text is used to describe a first image content feature, and the second text is used to describe a second image content feature; Performing M-level first feature extraction on the first text feature in sequence to obtain first intermediate features outputted by each of the M levels, where M is an integer greater than or equal to 2; Based on the second text feature, M levels of second feature extraction are sequentially performed to obtain information exchange features, wherein, in the second feature extraction of the M levels, when the i-th level belongs to the level that triggers feature information exchange, the first intermediate feature obtained in the first feature extraction of the i-th level is fused with the second intermediate feature obtained in the second feature extraction of the i-th level to obtain a fused feature of the second feature extraction of the i-th level, an output feature of the i-th level is obtained based on the fused feature, and when i is a positive integer less than M, the second feature extraction of the next level is performed based on the output feature, and when i is equal to M, the information exchange feature is obtained based on the output feature; An image is generated according to the information exchange feature, and image content in the image has the first image content feature and the second image content feature.

2. The method according to claim 1, characterized in that The step of fusing the first intermediate feature obtained from the first feature extraction of the i-th level with the second intermediate feature obtained from the second feature extraction of the i-th level to obtain a fused feature of the second feature extraction of the i-th level, and obtaining the output feature of the i-th level according to the fused feature includes: According to the feature splicing method, the first intermediate feature obtained in the first feature extraction of the i-th level and the second intermediate feature obtained in the second feature extraction of the i-th level are spliced ​​to obtain the spliced ​​feature of the second feature extraction of the i-th level; Performing attention feature extraction based on the concatenated feature and the second intermediate feature obtained in the second feature extraction of the i-th level to obtain the attention feature of the i-th level; According to the feature concatenation method, determining an adaptive fusion feature updated relative to the second intermediate feature from the attention feature of the i-th level; Cross-attention feature extraction is performed on the adaptive fusion feature and the second text feature to obtain the output feature of the i-th level.

3. The method according to claim 2, characterized in that The step of extracting the attention feature based on the concatenated feature and the second intermediate feature obtained in the second feature extraction of the i-th level to obtain the attention feature of the i-th level includes: Obtaining a key feature and a value feature according to the concatenated feature, and obtaining a query feature according to the second intermediate feature obtained in the second feature extraction of the i-th level; determining feature relevance based on the query feature and the key feature; The value features are adaptively fused according to the feature relevance to obtain the attention features of the i-th level.

4. The method according to claim 2, characterized in that: The method further comprises: Enhance and fuse the adaptive fusion feature with the second intermediate feature obtained in the second feature extraction of the i-th level to obtain an enhanced adaptive fusion feature; The cross-attention feature extraction is performed on the adaptive fusion feature and the second text feature to obtain the output feature of the i-th level, including: Cross-attention feature extraction is performed on the enhanced adaptive fusion feature and the second text feature to obtain the output feature of the i-th level.

5. The method according to claim 1, characterized in that The method further comprises: Determining a first feature type of the first image content feature and a second feature type of the second image content feature; Based on the first feature type and the second feature type, the level for triggering the exchange of feature information is determined from the M levels.

6. The method according to claim 1, characterized in that The extracting the second features of M levels in sequence based on the second text features to obtain information exchange features includes: Extracting a second feature of a first level among the M levels based on the second text feature, obtaining a second intermediate feature in the second feature extraction of the first level and a second output feature of the first level; At each level starting from the second level among the M levels, the second feature extraction of the level is performed based on the second output feature of the previous level, and the second intermediate feature in the second feature extraction of the level and the second output feature of the level are obtained, until the second output feature of the second feature extraction of the last level among the M levels is obtained, and the information exchange feature is obtained based on the second output feature of the second feature extraction of the last level.

7. The method according to claim 6, characterized in that The step of extracting the second feature of the current level based on the second output feature of the previous level to obtain the second intermediate feature in the second feature extraction of the current level and the second output feature of the current level includes: When the level is not a level that triggers feature information exchange, a residual connection of the level is performed based on the second output feature of the previous level to obtain a second intermediate feature in the second feature extraction of the level; Extracting the second intermediate feature to obtain a second self-attention feature at the level; Cross-attention feature extraction is performed based on the second self-attention feature and the second text feature to obtain the second output feature of the level.

8. The method according to claim 6, characterized in that The step of extracting the second feature of the first level among the M levels based on the second text feature to obtain the second intermediate feature in the second feature extraction of the first level and the second output feature of the first level includes: Performing a residual connection of a first level among the M levels based on the second text feature to obtain a second intermediate feature in the second feature extraction of the first level; When the first level belongs to the level for triggering feature information exchange, a first intermediate feature obtained by extracting the first feature of the first level is fused with the second intermediate feature to obtain a fused feature extracted from the second feature of the first level; Extracting the fused features to obtain the second self-attention features of the first level; Cross-attention feature extraction is performed based on the second self-attention feature and the second text feature to obtain the second output feature of the first level.

9. The method according to claim 6, characterized in that The step of extracting the second feature of the first level among the M levels based on the second text feature to obtain the second intermediate feature in the second feature extraction of the first level and the second output feature of the first level includes: Performing a residual connection of a first level among the M levels based on the second text feature to obtain a second intermediate feature in the second feature extraction of the first level; When the first level does not belong to the level for triggering feature information exchange, extracting the second intermediate feature to obtain a second self-attention feature of the first level; Cross-attention feature extraction is performed based on the second self-attention feature and the second text feature to obtain the second output feature of the first level.

10. The method according to claim 1, characterized in that The extracting the first features of M levels in sequence on the first text feature to obtain the first intermediate features outputted by the M levels respectively includes: Extracting a first feature of a first level among the M levels from the first text feature to obtain a first intermediate feature and a first output feature of the first level; At each level starting from the second level among the M levels, the first feature of the level is extracted based on the first output feature of the previous level to obtain the first intermediate feature and the first output feature of the level, until the first intermediate feature of the last level among the M levels is obtained.

11. The method according to claim 10, characterized in that The step of extracting a first feature of a first level among the M levels from the first text feature to obtain a first intermediate feature and a first output feature of the first level includes: Performing a residual connection of a first level among the M levels on the first text feature to obtain a first intermediate feature of the first level; Attention features of the first level are extracted based on the first intermediate features of the first level to obtain first output features of the first level.

12. The method according to claim 11, characterized in that The step of extracting the attention feature of the first level based on the first intermediate feature of the first level to obtain the first output feature of the first level includes: Extracting a first intermediate feature of the first level to obtain a first self-attention feature; Cross-attention feature extraction is performed based on the first self-attention feature and the first text feature to obtain the first output feature of the first level.

13. The method according to claim 1, characterized in that The step of obtaining a first text feature of a first text and a second text feature of a second text includes: Get the first text and the second text; The first text and the second text are respectively encoded through a text encoding network to obtain a first text feature of the first text and a second text feature of the second text.

14. The method according to any one of claims 1 to 13, characterized in that: The extracting the first features of M levels in sequence on the first text feature to obtain the first intermediate features outputted by the M levels respectively includes: Through a first image generation model, sequentially extracting first features of M levels from the first text feature, and obtaining first intermediate features of the M levels from the first image generation model, wherein the first image generation model includes M network layer structures, and each network layer structure in the first image generation model is used to realize first feature extraction of its level; The extracting the second features of M levels in sequence based on the second text features to obtain information exchange features includes: By using a second image generation model, sequentially extracting second features of M levels based on the second text feature to obtain information exchange features, wherein the second image generation model includes M network layer structures, and each network layer structure in the second image generation model is used to extract the second features of the corresponding level; The step of generating an image according to the information exchange feature comprises: The information exchange features are decoded by a decoding network in the second image generation model to obtain an image output by the second image generation model.

15. An image generating device, characterized in that: The device comprises: A text feature acquisition module, used to acquire a first text feature of a first text and a second text feature of a second text, wherein the first text is used to describe a first image content feature, and the second text is used to describe a second image content feature; A first feature extraction module, used to perform M-level first feature extraction on the first text feature in sequence to obtain first intermediate features outputted by each of the M levels, where M is an integer greater than or equal to 2; A second feature extraction module is used to perform M levels of second feature extraction in sequence based on the second text feature to obtain information exchange features, wherein, in the second feature extraction of the M levels, when the i-th level belongs to the level that triggers feature information exchange, a first intermediate feature obtained in the first feature extraction of the i-th level is fused with a second intermediate feature obtained in the second feature extraction of the i-th level to obtain a fused feature of the second feature extraction of the i-th level, an output feature of the i-th level is obtained based on the fused feature, and when i is a positive integer less than M, a second feature extraction of the next level is performed based on the output feature, and when i is equal to M, the information exchange feature is obtained based on the output feature; The information exchange feature processing module is used to generate an image according to the information exchange feature, and the image content in the image has the first image content feature and the second image content feature.

16. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 14 are implemented.

17. A computer-readable storage medium having a computer program stored thereon, 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 14 are implemented.

18. A computer program product, comprising 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 14 are implemented.

Citation Information

Cited By

  • Image generation method and related device

    CN119027304A