Image generation method and related device

The feature alignment module in the image generation model maps the original features and editing features to generate target editing features, which solves the problem of unchanged generation effects during the image editing process and improves the rationality and fidelity of the image.

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

Patent Information

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

AI Technical Summary

Technical Problem

During the image editing process, the existing image editing technology causes the generated image to be unable to maintain the generation effect of non-edited words unchanged, resulting in a decrease in the rationality and fidelity of the image.

Method used

Through the feature alignment module in the image generation model, the original features and edited features are mapped into target edited features, reflecting the image feature distribution after secondary editing, and the target image is generated based on the target edited features.

Benefits of technology

The rationality and fidelity of the generated target image are improved, ensuring that the non-edited content generation effect remains unchanged. The generated target image can not only reflect the new edited content, but also retain the non-edited content of the original image.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118537447A
    Figure CN118537447A
Patent Text Reader

Abstract

The invention discloses an image generation method and a related device, which can be applied to scenes of image generation, artificial intelligence, cloud technology and the like, and if secondary editing is needed, after an original image is generated based on an original description text through an image generation model, an editing description text can be obtained in response to an editing operation on the original image. Acquiring original features of the original description text and editing features of the editing description text; and mapping the original features and the editing features into target editing features through a feature alignment module in the image generation model. And based on the target editing feature, performing image generation through an image generation model, and replacing the to-be-edited content of the original image with the target content to obtain a target image corresponding to the editing description text. The target image generated by the method provided by the invention not only can reflect the edited new content, but also can keep the non-edited content of the original image, the generation effect of the non-edited content is kept unchanged, and the generated target image has higher rationality and fidelity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computers, and in particular to an image generation method and related devices. Background Art

[0002] Text-generated image technology is a technology that automatically generates images based on descriptive text. With the continuous development of artificial intelligence technology, text-generated image technology has been widely used in games, animation, web design and other fields. It has the advantages of high efficiency and high degree of automation.

[0003] With the emergence of generative models based on diffusion models, significant progress has been made in the field of image generation. It is common to use the creative ability of generative models to obtain image inspiration and perform subsequent secondary editing. For example, given a first description text (such as a cat sitting on the floor), the first description text is generated by the generative model to obtain an image corresponding to the first description text. Given a second description text (the second description text is a text that modifies a part of the object in the first description text, such as a dog sitting on the floor), the random seed used in the last image generation is used to generate an image for the second description text through the generative model to obtain an image corresponding to the second description text.

[0004] However, this method uses the method of fixing text words, and all words except the editing words are fixed. However, since different editing words will produce slight differences in control signals during the generation process, the final generated image cannot maintain the unchanged generation effect of non-editing words. Summary of the invention

[0005] In order to solve the above technical problems, the present application provides an image generation method and related devices to keep the non-edited content generation effect unchanged and improve the rationality and fidelity of the generated target image.

[0006] The embodiments of the present application disclose the following technical solutions:

[0007] On the one hand, an embodiment of the present application provides an image generation method, the method comprising:

[0008] After an original image is generated based on the original description text by an image generation model, in response to an editing operation on the original image, an edit description text is acquired, wherein the edit description text is used to perform a secondary editing on the content to be edited of the original image;

[0009] Acquire original features of the original description text and edit features of the edited description text;

[0010] Mapping the original features and the edited features into target edited features through a feature alignment module in the image generation model, wherein the target edited features are used to reflect the feature distribution of the image after the secondary editing;

[0011] Based on the target editing features, image generation is performed through the image generation model, the content to be edited of the original image is replaced with the target content, and a target image corresponding to the editing description text is obtained.

[0012] On the one hand, an embodiment of the present application provides an image generating device, the device comprising a first acquiring unit, a second acquiring unit, a feature alignment unit and an image generating unit:

[0013] The first acquisition unit is used to acquire the edit description text in response to an edit operation on the original image after the original image is generated based on the original description text by the image generation model, wherein the edit description text is used to perform secondary editing on the content to be edited of the original image;

[0014] The second acquisition unit is used to acquire the original features of the original description text and the edited features of the edited description text;

[0015] The feature alignment unit is used to map the original features and the edited features into target edited features through a feature alignment module in the image generation model, wherein the target edited features are used to reflect the feature distribution of the image after the secondary editing;

[0016] The image generation unit is used to generate an image based on the target editing feature through the image generation model, replace the content to be edited in the original image with the target content, and obtain the target image corresponding to the editing description text.

[0017] In one aspect, an embodiment of the present application provides a computer device, the computer device comprising a processor and a memory:

[0018] The memory is used to store a computer program and transmit the computer program to the processor;

[0019] The processor is configured to execute the method described in any one of the preceding aspects according to instructions in the computer program.

[0020] On the one hand, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store a computer program, and when the computer program is executed by a processor, the processor executes the method described in any of the aforementioned aspects.

[0021] In one aspect, an embodiment of the present application provides a computer program product, including a computer program, which implements the method described in any of the aforementioned aspects when executed by a processor.

[0022] It can be seen from the above technical solution that after the original image is generated based on the original description text by the image generation model, if the original image needs to be edited for a second time, the editing operation can be triggered, and then in response to the editing operation on the original image, the editing description text is obtained, and the editing description text is used to perform a second editing on the content to be edited of the original image. Then the original features of the original description text and the editing features of the editing description text are obtained, and the original features and the editing features are mapped into target editing features through the feature alignment module in the image generation model. Since the target editing features are obtained based on the original features before editing and the editing features of the second editing, the target editing features not only contain the information of the new text (i.e., the editing description text), but also retain the key information in the original features, which can more comprehensively and accurately reflect the feature distribution of the image after the second editing, that is, the generated target editing features are conducive to image generation. In this way, based on the target editing features, image generation is performed through the image generation model, and the content to be edited of the original image is replaced with the target content. When the target image corresponding to the edit description text is obtained, the generated target image can not only reflect the new content after editing (i.e., the target content), but also retain the non-edited content of the original image, keeping the non-edited content generation effect unchanged, and the generated target image has higher rationality and fidelity. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technical members in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0024] Figure 1 An application scenario architecture diagram of an image generation method provided in an embodiment of the present application;

[0025] Figure 2 A flowchart of an image generation method provided in an embodiment of the present application;

[0026] Figure 3 A schematic diagram of the structure of a characteristic adapter provided in an embodiment of the present application;

[0027] Figure 4 A schematic diagram of the structure of another characteristic adapter provided in an embodiment of the present application;

[0028] Figure 5A structural schematic diagram of a characteristic adapter provided for related technology;

[0029] Figure 6 A structural schematic diagram of a diffusion model provided in an embodiment of the present application;

[0030] Figure 7 A schematic diagram of the structure of a denoising network provided in an embodiment of the present application;

[0031] Figure 8 A flowchart of a method for training an image generation model provided in an embodiment of the present application;

[0032] Fig. 9 A schematic diagram of a sample image provided in an embodiment of the present application;

[0033] Fig.10 A schematic diagram of a training process of an image generation model provided in an embodiment of the present application;

[0034] Fig.11 A schematic diagram of an application of an image generation model provided in an embodiment of the present application;

[0035] Fig.12 A structural diagram of an image generating device provided in an embodiment of the present application;

[0036] Fig.13 A structural diagram of a terminal provided in an embodiment of the present application;

[0037] Fig.14 A structural diagram of a server provided in an embodiment of the present application. DETAILED DESCRIPTION

[0038] The embodiments of the present application are described below in conjunction with the accompanying drawings.

[0039] With the emergence of generative models based on diffusion models, significant progress has been made in the field of image generation. It is common to use the creative ability of generative models to obtain image inspiration and perform subsequent secondary editing. The generative model of the diffusion model can be applied to text images. The application process of the generative model based on the diffusion model can be to input a description text, and the model performs a series of operations on a random noise image, and generates a predicted image related to the description text under the cross-attention of the description text. Secondary editing can be secondary editing of the image generated by the generative model. For example, given a first description text (such as a cat sitting on the floor), the first description text is generated by the generative model to obtain an image corresponding to the first description text. Given a second description text (the second description text is a text that modifies a part of the first description text, such as a dog sitting on the floor), the random seed used in the last image generation is used to generate an image for the second description text through the generative model to obtain an image corresponding to the second description text.

[0040] However, the text words in the description text input into the diffusion model in this way are relatively fixed. Except for the editing words, other words between the first description text and the second description text are fixed. However, due to the slight difference in control signals caused by different editing words during the generation process, the generated image cannot maintain the unchanged generation effect of non-editing words.

[0041] In order to solve the above technical problems, the embodiment of the present application provides an image generation method, so that the generated target image has higher rationality and fidelity. After the method provided by the embodiment of the present application generates the original image based on the original description text through the image generation model, when the original image needs to be edited again by editing the description text, the original features and the edit features are mapped into target editing features through the feature alignment module in the image generation model, so that the target editing features not only contain the information of the new text (i.e., the edited description text), but also retain the key information in the original features, and can more comprehensively and accurately reflect the feature distribution of the image after the second editing, that is, the generated target editing features are conducive to image generation. In this way, based on the target editing features, the image generation model is used to generate the image, and the content to be edited of the original image is replaced with the target content. When the target image corresponding to the edited description text is obtained, the generated target image can reflect the new content after editing (i.e., the target content, that is, the content corresponding to the edited word), and can retain the non-edited content of the original image (i.e., the content corresponding to the non-edited word in the edited description text), keep the non-edited content generation effect unchanged, and the generated target image has higher rationality and fidelity.

[0042] It should be noted that the image generation method provided in the embodiments of the present application can be applied to various image generation scenarios, especially scenarios where the generated images need to be edited later, such as image design, advertising design and marketing, etc., which are not limited in the embodiments of the present application. In the image design scenario, for the painting software, the interactive object can generate creative images according to what they think in their mind and convert them into text, and perform secondary editing on the generated creative images through the method provided in the embodiments of the present application to meet their design needs. In the advertising design and marketing scenarios, advertising designers can use image generation and editing techniques to create attractive advertising images. When using editing techniques, secondary editing can be performed through the method provided in the embodiments of the present application to finally obtain attractive advertising images.

[0043] The image generation method provided in the embodiment of the present application can be executed by a computer device, which can be, for example, a server or a terminal. The server can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. The terminal includes but is not limited to a smart phone, a computer, an intelligent voice interaction device, a smart home appliance, a vehicle terminal, an aircraft, etc.

[0044] like Figure 1 As shown, Figure 1 An application scenario architecture diagram of an image generation method is shown, and the application scenario is introduced with the computer device being a server.

[0045] The application scenario may include a server 100 and a terminal 200. An image generation model may be deployed on the server 100, and the image generation model may have a feature alignment module. The server 100 may provide an image generation service for the terminal 200 based on the image generation model. The terminal 200 may be installed with an application having an image generation function, the terminal 200 may send an original description text to the server 100, and the server 100 may generate an original image based on the original description text sent by the terminal 200. The server 100 and the terminal 200 may be directly or indirectly connected via wired or wireless communication, and this application does not limit this. For example, the server 100 and the terminal 200 may be connected via a network, and the network may be a wired or wireless network.

[0046] After the server 100 generates the original image based on the original description text through the image generation model, the server 100 may obtain the edit description text sent by the terminal 200 in response to the edit operation of the interactive object on the original image, and the edit description text is used to perform secondary editing on the content to be edited of the original image. The edit operation may be an operation issued by the interactive object with the editing intention on the original image. The interactive object may be an object that interacts with the terminal 200 and needs to generate an image or perform secondary editing on the generated image, and the interactive object may be, for example, a user.

[0047] The server 100 can obtain the original features of the original description text and the edited features of the edited description text. Then, the server 100 can map the original features and the edited features into target edited features through the feature alignment module in the image generation model, and the target edited features are used to reflect the real feature distribution of the image after the secondary editing.

[0048] The server 100 generates an image through an image generation model based on the target editing feature, replaces the content to be edited of the original image with the target content, and obtains a target image corresponding to the editing description text. The content to be edited may be content waiting to be edited.

[0049] After the server 100 obtains the target image through the image generation model, the server 100 may return the target image to the terminal 200. The terminal 200 may display the target image so that the interactive object can view the target image.

[0050] The present application generates a target image through a target editing feature. Since the target editing feature is obtained based on the original feature before editing and the editing feature of the secondary editing, the target editing feature not only contains the information of the edit description text, but also retains the key information in the original feature, and can more comprehensively and accurately reflect the feature distribution of the image after the secondary editing. The target image generated by the target editing feature can not only reflect the new content after editing (i.e., the target content), but also retain the non-edited content of the original image, keeping the non-edited content generation effect unchanged, and the generated target image has higher rationality and fidelity.

[0051] It should be noted that the method provided in the embodiments of the present application may involve artificial intelligence technology. 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 the machines have the functions of perception, reasoning and decision-making.

[0052] Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level and software-level technologies. Basic artificial intelligence technologies generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, pre-trained model technology, operation / interaction systems, mechatronics, etc. Among them, pre-trained models are also called large models and basic models. After fine-tuning, they 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.

[0053] It is understandable that the image generation method provided in the embodiment of the present application may involve natural language processing. Natural language processing (NLP) is an important direction in the field of computer science and artificial intelligence. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field will involve natural language, that is, the language used by people in daily life, so it is closely related to the study of linguistics. Natural language processing technology generally includes technologies such as text processing, semantic understanding, machine translation, robot question and answer, knowledge graph, etc. The image generation model trained in the embodiment of the present application can be applied to the scene of image generation, and technologies such as text processing and semantic understanding can be used when training the image generation model.

[0054] When training the image generation model, machine learning can also be involved. Machine Learning (ML) is a multi-field interdisciplinary subject involving probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It specializes in 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 fields of artificial intelligence. Machine learning and deep learning generally include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and learning by teaching. In an embodiment of the present application, machine learning training can be used to obtain an image generation model.

[0055] It should be noted that in the specific implementation of this application, user information and other related data may be involved in the entire process. When the above embodiments of this application are applied to specific products or technologies, the user's separate consent or separate permission is required, and the collection, use and processing of relevant data need to comply with the relevant laws, regulations and standards of relevant countries and regions.

[0056] Next, the image generation method provided by the embodiment of the present application will be introduced by taking the computer device being a server as an example in conjunction with the accompanying drawings. Figure 2 , Figure 2 A flow chart of an image generation method is shown, the method comprising:

[0057] S201. After an original image is generated based on an original description text by an image generation model, an edit description text is obtained in response to an edit operation on the original image.

[0058] When it is necessary to generate an image based on text, the server can input the original description text into the image generation model so that the image generation model can generate the original image based on the original description text. The description text can be a text carrying description information used to generate an image. Based on the description text, the image generated for the first time using the image generation model can be the original image, and the description text used to generate the original image can be the original description text. After obtaining the original image, the server can also perform secondary editing on the original image if the interactive object needs it. For example, the original image initially generated by the image generation model does not fully meet the expectations of the interactive object. The interactive object wants to make certain adjustments or modifications to the original image to better meet the needs of the interactive object. The interactive object can request the server to perform secondary editing on the original image. Secondary editing can be a secondary generation edit of the image. For example, if a dog is riding a bicycle in the original image, secondary editing can turn the original image into the dog riding a motorcycle.

[0059] After the server generates the original image based on the original description text through the image generation model, if the interactive object needs to perform a secondary edit on the original image, an editing operation can be triggered. The editing operation can be an operation with editing intent issued by the interactive object, and the editing operation can be, for example, an operation such as inputting text or voice with editing intent. Then, in response to the editing operation on the original image, the server obtains the editing description text, and the editing description text is used to perform a secondary edit on the content to be edited of the original image. The content to be edited can be a part of the original image, or it can be attribute information such as the style, color, or clothes of a certain character of the image. The embodiment of the present application does not limit the type of content to be edited. The content to be edited can be reflected by the editing words in the editing description text, and the editing words can be words with different semantics expressed by the editing description text and the original description text.

[0060] For example, the interactive object wants to generate an image whose content is a cat sitting on the floor. The interactive object can input the original description text "a cat sitting on the floor". The server generates the corresponding original image based on "a cat sitting on the floor". After the original image is generated, if the interactive object needs to perform a secondary edit on the original image, the interactive object can trigger an edit operation on the original image. The edit operation can be, for example, a text input operation. At this time, the interactive object can input the text "a dog sitting on the floor". The text "a dog sitting on the floor" indicates how to perform a secondary edit on the original image, that is, replace the cat in the original image (i.e., the content to be edited) with a dog, thereby obtaining an image of "a dog sitting on the floor". Therefore, the text "a dog sitting on the floor" can be used as an edit description text. In response to the edit operation on the original image, the server obtains the edit description text "a dog sitting on the floor". "Dog" can be an edit word in the edit description text, and the dog in the original image can be the content to be edited.

[0061] The image generation model can be a model for converting a description text into an image, that is, the image generation model can be a trained text-to-image model. The embodiment of the present application does not limit the model structure of the image generation model. In a possible implementation, the image generation model can be a diffusion model (Stable Diffusion, SD) that has been trained. The image generation model can also be a stable expansion model (Stable Diffusion, SDXL). The image generation model can also be other models based on cross-attention control, which is not limited by the embodiment of the present application. Next, the image generation model is mainly explained as an example of a diffusion model. The diffusion model can be a generative model based on a diffusion process. In an embodiment of the present application, the diffusion model can be a model that generates a predicted image related to the description text based on the input description text, undergoes a series of operations on a random noise image, and generates a model of a predicted image related to the description text under the cross-attention of the description text.

[0062] In some scenarios, the image generation model can provide image generation services for the interactive object. In order to better serve the interactive object and ensure the diversity of generated images, after the interactive object inputs the original description text, the image generation model can generate multiple original images. When performing secondary editing, in order to better meet the needs of the interactive object during secondary editing, the interactive object can select one or more of the multiple original images for secondary editing. The selected original image that needs to be edited can be called the image to be edited, that is, the multiple original images include the image to be edited. In this case, after obtaining multiple original images, the multiple original images can be displayed to the interactive object so that the interactive object can determine whether secondary editing is required and select the original image that needs to be edited when secondary editing is required. At this time, in response to the editing operation on the original image, the way to obtain the editing description text can be that the server obtains multiple original images, and then obtains the image to be edited based on the selection operation of the interactive object on the image to be edited among the multiple original images. The image to be edited is the original image that needs to be edited selected by the interactive object. Afterwards, the server can obtain the editing description text input by the interactive object through the text input operation in response to the text input operation of the interactive object on the image to be edited. In the embodiment of the present application, the editing operation includes a selection operation on the image to be edited and a text input operation.

[0063] The selection operation may be an operation with a selection intention, and the selection operation may be, for example, operations such as clicking, selecting a box, and staying for a preset time.

[0064] For example, the interactive object wants to generate an image whose content is a cat sitting on the floor. The interactive object can input the original description text "a cat sitting on the floor". The server generates ten corresponding original images based on "a cat sitting on the floor". After generating the original images, the server can display the ten original images. If the interactive object selects two images to be edited from the ten original images displayed on the terminal corresponding to the server by clicking, the server can obtain the two objects to be edited in response to the selection operation. If the interactive object needs to perform a secondary edit on the two images to be edited, replacing the cats in the two images to be edited with dogs, the interactive object can input "a dog sitting on the floor" through a text input operation, and the server responds to the text input operation of the interactive object for the two images to be edited, and obtains the edit description text "a dog sitting on the floor" entered by the interactive object through the text input operation.

[0065] In the above method, in the case where the original image is multiple original images, the server can obtain the edit description text through the selection operation and text input operation of the interactive object. The interactive object has a higher degree of freedom in the image generation process. By fully considering the edit description text obtained by the operation of the interactive object, the target image finally generated better meets the needs of the interactive object.

[0066] S202: Acquire original features of the original description text and edited features of the edited description text.

[0067] After the description text is input into the image generation model, in order to enable the image generation model to build a deep understanding of the description text and generate an image that conforms to the description text, the text features of the description text can be obtained. In the embodiment of the present application, considering that the non-edited content generation effect needs to be guaranteed to remain unchanged before and after the secondary editing, it is necessary to understand the key information of the edited description text and retain the key information of the original description text. In order to enable the image generation model to fully understand the key information of the description text before the secondary editing (i.e., the original description text) and the key information of the description text used for the secondary editing (i.e., the edited description text), the server can obtain the original features of the original description text and the editing features of the edited description text. The original features can be features that can characterize the meaning, emotion, or theme of the original description text, and the editing features can be features that can characterize the meaning, emotion, or theme of the edited description text. The information represented by the original features and the editing features is essential for generating an image that matches the description text.

[0068] It should be noted that the server can obtain the original features and edited features in a variety of ways. For example, the server can obtain the original features of the original description text and the edited features of the edited description text through a model layer with feature extraction function of the image generation model.

[0069] In some cases, among the information represented by the original features, some information is relatively important for generating an image that matches the description text, while other information is relatively less important. In order to make the original features fully represent each part of the information, an attention mechanism can be used when obtaining the original features. In this case, the image generation model used in the embodiment of the present application may include a feature adapter (Edit-adapting spatial transformer), and the feature adapter includes a feature alignment module and an attention mechanism layer, so that the server can perform a first attention operation on the image features of the noise image and the vector representation of the original description text through the attention mechanism layer to obtain the original features. The noise image can be an image carrying noise, and the vector representation can be a data form that can be understood and processed by a computer converted from text. The attention mechanism is a data processing method that allows a machine to learn to perceive the important and unimportant parts of the data, and the attention mechanism layer can be a neural network layer for executing the attention mechanism.

[0070] The above method uses the attention mechanism in the process of obtaining the original features. Through the introduction of the attention mechanism, the original features can better represent the important and unimportant parts of the original description text, thereby allowing the model to focus on the most relevant and important parts when processing the text. This means that the model can pay more attention to those keywords or phrases in the description text that are closely related to image generation, thereby improving the match between the generated image and the description text.

[0071] S203, mapping the original features and the edited features into target edited features through a feature alignment module in the image generation model.

[0072] In the related art, the process of generating an image using a description text by an image generation model is random. For example, the description text is "a cat sitting on a sofa". In the image generated by the image generation model using the description text, the cat can be a long-haired cat or a short-haired cat; the sofa can be red or black. When performing secondary editing, if the edited description text is "a dog sitting on a sofa", the edited word in the description text is "dog", and other words except the edited word are fixed. When performing secondary editing using "a dog sitting on a sofa", the edited word "dog" will produce a slight control signal difference, which may eventually lead to the sofa being red in the original image and black in the image after secondary editing. In order to generate a target image with higher rationality and fidelity, the embodiment of the present application can combine the original features and the edited features to jointly determine the text features required for the secondary editing during the secondary editing, so that the text features used for the secondary editing not only contain the key information of the edited description text, but also retain the key information of the original description text. Specifically, the server can map the original features and the edited features into the target editing features through the feature alignment module.

[0073] The feature alignment module can fuse the original features and the edited features, thereby mapping the two features into target editing features that can reflect the real feature distribution of the image after secondary editing. At the same time, the feature alignment module can also match the partial information represented by different features, so that the target editing features can be better obtained based on the original features and the edited features.

[0074] It is understandable that the structure of the image generation model in the embodiment of the present application is different from that in the related art. Compared with the image generation model provided by the related art, the embodiment of the present application adds a feature alignment module based on the original image generation model. The feature alignment module is a newly added model layer for learning the mapping of original features and edit features to target edit features, so that the original features and edit features can be mapped to target edit features through the feature alignment module. The target edit feature is used to generate a more reasonable feature distribution of the target image. While reflecting the change of the edit word, it avoids the difference in control signals caused by the change of the edit word. Secondary editing with the target edit feature can obtain a more reasonable target image.

[0075] S204: Based on the target editing features, an image generation model is used to generate an image, and the content to be edited of the original image is replaced with the target content to obtain a target image corresponding to the editing description text.

[0076] After obtaining the target editing feature, since the target editing feature is obtained based on the original feature before editing and the editing feature of the secondary editing, the target editing feature not only contains the information of the new text (i.e., the editing description text), but also retains the key information in the original feature, and can more comprehensively and accurately reflect the feature distribution of the image after the secondary editing. In this way, the server can generate an image based on the target editing feature through the image generation model, replace the content to be edited of the original image with the target content, and more accurately obtain the target image corresponding to the editing description text, so that the target image can reflect the new content after editing (i.e., the target content), and retain the non-editing content of the original image, keep the non-editing content generation effect unchanged, and have higher rationality and fidelity. Among them, the target content can be the content corresponding to the vocabulary of the edited description text that has changed relative to the original description text. For example, if the original description text is "the cat sits on the floor" and the edited description text is "the dog sits on the floor", the content corresponding to the vocabulary "dog" in the edited description text can be called the target content.

[0077] If the image generation model includes a feature adapter, and the feature adapter includes a feature alignment module and an attention mechanism layer, S204 may be implemented by the server performing a second attention operation on the target editing features and the vector representation of the original description text through the attention mechanism layer to obtain the target potential output features.

[0078] The server can then generate an image based on the target potential output features through an image generation model, replace the content to be edited in the original image with the target content, and obtain a target image corresponding to the edit description text.

[0079] The above method obtains the target image based on the target potential output feature. The target potential output feature is obtained through the second attention operation. The introduction of the attention mechanism allows the model to focus on the most relevant and important parts when processing text. The target potential output feature obtained in this way can better represent the important and unimportant parts of the target editing feature. When multiple input features can be aligned to the attention features required for the target task, in the text-to-image task, this means that the model can pay more attention to the keywords or phrases in the description text that are closely related to image generation, thereby improving the match between the generated image and the text description.

[0080] In the above technical solution, after the original image is generated based on the original description text by the image generation model, if the original image needs to be edited for a second time, the editing operation can be triggered, and then the editing description text is obtained in response to the editing operation on the original image, and the editing description text is used to perform a second editing on the content to be edited of the original image. Then the original features of the original description text and the editing features of the edit description text are obtained, and the original features and the editing features are mapped into target editing features through the feature alignment module in the image generation model. Since the target editing features are obtained based on the original features before editing and the editing features of the second editing, the target editing features not only contain the information of the new text (i.e., the editing description text), but also retain the key information in the original features, and can more comprehensively and accurately reflect the feature distribution of the image after the second editing, that is, the generated target editing features are conducive to image generation. In this way, based on the target editing features, image generation is performed through the image generation model, and the content to be edited of the original image is replaced with the target content. When the target image corresponding to the edit description text is obtained, the generated target image can not only reflect the new content after editing (i.e., the target content), but also retain the non-edited content of the original image, keeping the non-edited content generation effect unchanged, and the generated target image has higher rationality and fidelity.

[0081] exist Figure 2 In the corresponding embodiment, it is introduced that the image generation model may include a feature adapter, and the feature adapter includes a feature alignment module and an attention mechanism layer. The feature alignment module and the attention mechanism layer can be used to obtain target editing features for generating a more reasonable target image. The feature adapter including the feature alignment module and the attention mechanism layer is crucial for the implementation of secondary editing. Next, the structure of the feature adapter will be introduced. Figure 3 A schematic diagram of the structure of a characteristic adapter provided in an embodiment of the present application. Figure 3 In the above example, the image feature can be the image feature of the noise image randomly generated by the image generation model, which can be used as the attention mechanism layer to implement the attention mechanism Q, and the vector representation of the original description text can be used as the attention mechanism layer to implement the attention mechanism K and V. The image feature Q and the vector representation K of the original description text perform the first attention operation to obtain the original feature M t The editing feature M2 is obtained by editing the vector representation K2 of the description text t . Original feature M t and edit feature M2 t The target editing feature M3 is obtained through the feature alignment module t . Target Editing Feature M3 t Perform a second attention operation with the vector representation V of the original description text to obtain the target potential output feature (Output). Figure 3 In it, K and V are both vector representations of the original description text.

[0082] The attention mechanism layer of the feature adapter can allow two attention weight features to be input and output a target potential output feature that can meet the specific task. The attention mechanism layer can obtain the original feature through the first attention operation and obtain the target potential output feature through the second attention operation. Through different attention operations, the whole process can be more finely controlled, and finally a more reasonable target potential output feature can be obtained.

[0083] Figure 4 A schematic diagram of the structure of another characteristic adapter provided in an embodiment of the present application, in Figure 4 In the example, the vector representation and image features of the original description text are passed through a neural network layer to obtain the original features, and the vector representation and image features of the edited description text are passed through a neural network layer to obtain the edited features. The neural network layer used to generate the original features can be an attention mechanism layer, and the neural network layer used to generate the edited features can be a text encoder. The original features and the edited features are passed through a feature alignment model to obtain the target edited features. The target edited features and the vector representation of the original description text are used to obtain the target potential output features.

[0084] Figure 5 A structural diagram of a characteristic adapter provided for related technology, in Figure 5 In the above example, the noise image is processed through convolution kernel and dense projection to obtain image features. The description text is processed through dense projection to obtain the vector representation of the description text. The image features of the noise image and the vector representation of the description text are sequentially processed through matrix product function, normalization layer and activation function to obtain the features corresponding to the description text. Then, the features corresponding to the description text and the vector representation of the description text are processed through matrix product function and convolution kernel to obtain the output features.

[0085] exist Figure 5 In , the output features are generated by the features corresponding to the description text and the vector representation of the description text. The description text here is the description text input when the image needs to be generated. Each time an image is generated, it is based only on the currently input description text. Figure 5 The feature adapter shown is used in the secondary editing scenario, input to Figure 5 The description text of the feature adapter shown is only the editing features entered during the secondary editing. However, in the secondary editing scenario, the original features of the original description text are very important for maintaining the consistency of the non-editing content before and after the secondary editing. Therefore, in order to obtain a more reasonable secondary editing result, the embodiment of the present application adds the original features of the original description text to the feature adapter. Figure 5 The structure shown in the figure is modified to obtain a feature adapter with a new feature alignment module, such as Figure 4 As shown, so that in the secondary editing Figure 4The structure shown is replaced Figure 5 The structure shown in the figure can be used to combine the original features and the edited features to obtain the target edited features during the secondary editing through the newly added feature alignment module. The target edited features and the vector representation of the original description text are used for subsequent attention operations to obtain the target potential output features, thereby using Figure 4 Output target potential output feature replacement Figure 5 The editing features of the edit description text are taken into account in the secondary editing process, so that the new content (i.e., the target content) can be considered while retaining the non-edited content of the original image. It is more reasonable to drive the secondary editing through the original features and the editing features of the edit description text.

[0086] It should be noted that Figure 3 and Figure 4 This is only a schematic diagram of the structure of a feature adapter. In actual application, the number and connection relationship of feature adapters can be designed according to actual conditions. In order to make the target image obtained by secondary editing more reasonable, the image generation model can include N layers of feature adapters. Among them, the value of N can be set according to actual needs, and the embodiment of the present application does not limit this.

[0087] When the image generation model may include N layers of feature adapters, the process of mapping the original features and the edited features into the target edited features by the feature alignment module in the image generation model in S203 may be completed collaboratively by the N layers of feature adapters.

[0088] In this case, the server can generate the i-th new editing feature based on the i-th original feature of the acquired original description text and the i-th editing feature of the edited description text through the feature alignment module in the i-th layer feature adapter, where i is a positive integer less than or equal to N.

[0089] The server performs the first attention operation on the i-th new edit feature through the attention mechanism layer in the i-th feature adapter to obtain the i-th potential output feature.

[0090] When N layers of feature adapters work together, the i-th potential output feature is the input of the i+1th layer. The server inputs the i-th potential output feature to the i+1th layer feature adapter, and the i+1th original feature can be generated. Based on the i+1th original feature and the edit description text generated by the i+1th edit feature in the i+1th layer feature adapter, the i+1th new edit feature is generated by the feature alignment module in the i+1th layer feature adapter.

[0091] If i+1=N, that is, the i+1th new editing feature is generated by the last layer of feature adapter, then the i+1th new editing feature is determined as the target editing feature.

[0092] After determining the target editing features, the server can perform a second attention operation on the vector representation of the target editing features and the original description text through the attention mechanism layer in the i+1th feature adapter to obtain the target potential output features.

[0093] The above method obtains more reasonable target potential output features through the collaborative work of multiple layers of feature adapters, and a more reasonable target image can be obtained through the target potential output features.

[0094] In S201, it is introduced that the image generation model may be a model for image generation, and the image generation model may be, for example, a diffusion model that has been trained. The diffusion model may be a generative model based on a diffusion process, and the working principle of the diffusion model is to restore or generate data by adding random noise to the data and then performing a reverse denoising process.

[0095] Specifically, the diffusion model generates a noisy image in the latent space through a random seed. Then, a text encoder is used to convert the input description text into the conditions of the denoising process. Denoising is performed based on the conditions to obtain the latent representation of the generated image. The denoising process can be flexibly adjusted according to the description text and the initial image. Finally, the image is converted from the latent space back to the pixel space through the image decoder to generate an image corresponding to the description text. Among them, the random seed is used to generate random numbers, which are then used as random noise.

[0096] In order to obtain a more reasonable target image, the image generation model may select a trained diffusion model. The diffusion model uses random noise when generating an image. In order to make the target image obtained by secondary editing more reasonable, in S204, the server may use the random noise used to generate the original image to generate a noisy image through the trained diffusion model. Then, based on the target editing features, the noisy image is denoised through the trained diffusion model to obtain the target image.

[0097] In the above method, the random noise used to generate the original image is used to generate a noise image, and the subsequent denoising process is also based on the noise image for denoising. By processing the same noise image, the target image finally obtained is more reasonable.

[0098] Combination Figure 3 The characteristic adapter shown, Figure 6 A structural diagram of a diffusion model provided in an embodiment of the present application. Next, in combination with the secondary editing process, Figure 6 Explain. Figure 6In the above example, X is the initial image. The initial image X passes through the image encoder ε to obtain the image feature Z of the initial image. After that, the image feature Z of the initial image is denoised through the diffusion process to obtain the image feature Z of the noisy image. T It should be noted that in the process of reasoning based on the diffusion model, X = 0, and the image feature Z of the noise image can be generated based on the random seed. T The original description text and the edited description text are processed by the text editor τ to obtain the vector representation K of the original description text and the vector representation K2 of the edited description text. Figure 6 The diffusion model includes four feature adapters. Specifically, the four feature adapters constitute the denoising network of the diffusion model. The Z T-1 In the feature adapter, the image feature Z of the noisy image T The first attention operation can be performed on the vector representation K of the original description text through the attention mechanism layer to obtain the original features. The original features and the edited features can be used to obtain the target edited features based on the feature alignment module of the feature adapter. The second attention operation is performed on the target edited features and the vector representation of the original description text through the attention mechanism layer to obtain the target potential output features. The diffusion model can obtain Z based on the target potential output features. T-1 , Z T-1 After (T-1) rounds of denoising steps, Z' is obtained. Finally, Z' is decoded by the image decoder D and the target image Y is output.

[0099] In the diffusion process, the image feature Z of the random image is diffused T times to generate the image feature Z of the noise image T Correspondingly, in the denoising network of the diffusion model, the denoising network can be a U-Net denoising network, which performs the denoising process on the noisy image Z T Perform T-1 denoising predictions to obtain Z'.

[0100] The above-mentioned feature adapter can adopt a variety of different structures, and the specific structure of the feature adapter can be determined according to actual needs. In a possible implementation, the specific structure of the feature adapter can be seen in Table 1.

[0101] Table 1

[0102] Model layer name Output Dimensions Convolutional Layer Fusion layer 1 8xDx77 1×1 convolutional layer Fusion layer 2 8xDx77 1×1 convolutional layer

[0103] As shown in Table 1, the feature adapter can include two fusion layers, each with an output dimension of 8×D×77, and a 1×1 convolution layer. D is the structure of the original features corresponding to the original description text or the structure of the edited features corresponding to the edited description text in the denoising network. The dimensions of D are 4096, 4096, 1024, 1024, 256, 256, 64, 256, 256, 256, 1024, 1024, 1024, 4096, 4096, 4096. The first six dimensions of D, 4096, 4096, 1024, 1024, 256, 256, are the dimensions of the downsampling structure in the denoising network, the seventh dimension, 64, is the dimension of the intermediate structure, and the last nine dimensions, 256, 256, 256, 1024, 1024, 1024, 4096, 4096, 4096, are the dimensions of the upsampling structure in the denoising network.

[0104] The structure of the denoising network mainly includes upsampling structure, intermediate structure and downsampling structure. Figure 7 A schematic diagram of a denoising network structure provided in an embodiment of the present application, in Figure 7 In the figure, the black rectangle represents the feature adapter, and the rectangle filled with diagonal lines represents the residual. The downsampling structure in the denoising network consists of the feature adapter, residual and downsampling. Figure 7 In the denoising network, the downsampling structure includes six feature adapters. The upsampling structure in the denoising network consists of feature adapters, residuals, and upsampling. Figure 7 In , the upsampling structure includes nine feature adapters. The intermediate structure of the denoising network consists of feature adapters and residuals. Figure 7 In the example, the intermediate structure includes a feature adapter. That is, Figure 7 A total of 16 feature adapters are included in the denoising network shown.

[0105] If the dimension D of the feature adapter in the structure of the denoising network is 4096, the structure of the original feature is 8×4096×77, and the structure of the edited feature is 8×4096×77. The server concatenates the original feature and the edited feature to obtain a concatenated result, and the structure of the concatenated result is 8×4096×154 (e.g., 8×4096×154 in the first layer of the downsampling structure). The server inputs the concatenated result into the feature alignment module to obtain the target edited feature, and the structure of the target edited feature is 8×4096×77.

[0106] Specifically, in the first layer of the latent space of the image generation model, the original features and the edited features are merged through the feature adapter to obtain the target edited features, and then the next attention operation is performed, that is, the merged target edited features and the vector representation of the original description text are subjected to the second attention operation to obtain the potential output features. The potential output features can be used as the input of the feature adapter in the second layer of the latent space. When the potential output features of the first layer are forward calculated to generate the original features in the second layer of the latent space, the edited features generated by the edited description text in the second layer can be merged with the original features generated in the second layer to obtain the target edited features in the second layer, and then the next attention operation of the second layer is performed, and so on, until the target edited features output by the last layer are obtained through all layers, and then the next attention operation is performed on the target edited features output by the last layer to obtain the target potential output features.

[0107] The above-mentioned embodiment introduces the multi-layer structure of the feature adapter. In some implementations, the feature adapter can also be a multi-layer structure or other neural network forms, such as a fully connected layer. The embodiments of the present application are not limited to this.

[0108] It is understandable that the image generation model is the key to realizing secondary editing. In order to obtain an image generation model that can better adapt to the secondary editing scenario, the embodiment of the present application also provides a method for training the image generation model. The training method for the image generation model can be executed by a computer device. Next, the training method for the image generation model will be introduced in conjunction with the accompanying drawings, taking the computer device that executes the training method for the image generation model as a server as an example. Figure 8 , Figure 8 A flow chart of a method for training an image generation model is shown, the method comprising:

[0109] S801: Obtain training samples.

[0110] In order to be more suitable for secondary editing, the training samples may include multiple image and text samples, each of the multiple image and text samples includes a first sample text and a first sample image, as well as a second sample text and a second sample image, the first sample image is an image generated based on the first sample text, the second sample text is text that is secondary edited of the sample editing content of the first sample image, and the second sample image is an image generated based on the second sample text.

[0111] When training an image generation model, for each image sample, you can use Fig. 9 The sample image shown, Fig. 9 A schematic diagram of a sample image provided in an embodiment of the present application. Fig. 9The image on the left is the first sample image. The first sample text corresponding to the first sample image is "cat in the bed". Fig. 9 The image on the right is the second sample image, and the second sample text corresponding to the second sample image is "dog in the bed". The training samples include Fig. 9 Shown are the first sample image, the second sample image, “cat in the bed”, and “dog in the bed”.

[0112] S802: For each image-text sample, obtain a first sample feature of a first sample text in the image-text sample and a second sample feature of a second sample text in the image-text sample.

[0113] For each image and text sample, the server can obtain the first sample features of the first sample text and the second sample features of the second sample text in the image and text sample in a variety of different ways. In order to make the trained image generation model more suitable for the secondary editing scenario, the process of obtaining the first sample features is similar to the process of obtaining the original features, and the process of obtaining the second sample features is similar to the process of obtaining the edited features, which will not be repeated here.

[0114] In a possible implementation, the process of obtaining the first sample feature can be completed by the initial adapter. The server performs a first attention operation on the image feature of the sample noise image and the vector representation of the first sample text through the initial attention mechanism layer of the initial adapter to obtain the first sample feature.

[0115] In the above method, an attention mechanism is introduced in the training process of the image generation model, through which the model can learn the important and unimportant parts of the sample. Therefore, when training the model, the model can learn to focus on the most relevant and important parts, thereby improving the performance of the trained image generation model.

[0116] S803: Map the first sample features and the second sample features into target sample features through an initial alignment module in the initial network model.

[0117] The process of mapping the first sample features and the second sample features into the target sample features through the initial alignment module in the initial network model is similar to the process of mapping the original features and the edited features into the target edited features through the feature alignment module, and will not be repeated here.

[0118] S804: Based on the target sample features, an initial network model is used to generate an image, and the sample editing content of the first sample image is replaced with the target sample content to obtain a predicted editing image corresponding to the second sample text.

[0119] The server can generate an image through an initial network model based on the target sample features, replace the sample editing content of the first sample image with the target sample content, and obtain a predicted editing image corresponding to the second sample text.

[0120] Since the image generation model is obtained by training the initial network model, the initial network model has the same structure as the image generation model but different parameters. The image generation model includes a feature adapter, which includes a feature alignment module and an attention mechanism layer. Correspondingly, the initial network model includes an untrained feature adapter, which includes an initial alignment module and an initial attention mechanism layer.

[0121] In order to be more adaptable to the secondary editing scenario, the server can perform a second attention operation on the target sample features and the vector representation of the first sample text through the initial attention mechanism layer of the initial adapter to obtain the sample potential output features.

[0122] After obtaining the sample potential output features, the server can generate an image based on the sample potential output features through the initial network model, replace the sample editing content of the first sample image with the target sample content, and obtain a predicted editing image corresponding to the second sample text.

[0123] In the above method, the attention mechanism is also introduced to obtain the predicted edited image. The attention mechanism allows the model to better learn the important and unimportant parts of the target sample features. By introducing the attention mechanism, a higher performance image generation model can be obtained through training.

[0124] It should be noted that, in the actual training process, the number and connection relationship of the feature adapters in the initial network model can be designed according to the actual situation. In order to train an image generation model that can perform secondary editing more reasonably, the initial network model may include N layers of feature adapters. Among them, the value of N can be set according to actual needs, and the embodiment of the present application does not limit this.

[0125] When the feature adapter may include N layers of initial adapters, the process of mapping the first sample feature and the second sample feature into the target sample feature through the initial alignment module in the initial network model in S803 may be completed collaboratively by the N layers of initial adapters.

[0126] In this case, the server can generate the i-th new sample editing feature based on the i-th first sample feature of the acquired first sample text and the i-th second sample feature of the second sample text through the initial alignment module in the i-th layer initial adapter, where i is a positive integer less than or equal to N.

[0127] The server performs an attention operation on the edited features of the i-th new sample through the initial attention mechanism layer in the i-th initial adapter to obtain the potential output features of the i-th sample.

[0128] When N layers of initial adapters work together, the potential output feature of the i-th sample is the input of the i+1th layer. The server inputs the potential output feature of the i-th sample into the i+1th layer initial adapter, and the i+1th first sample feature can be generated. Based on the i+1th first sample feature and the i+1th second sample feature generated by the second sample text in the i+1th layer initial adapter, the i+1th new sample editing feature is generated through the initial alignment module in the i+1th layer initial adapter.

[0129] If i+1=N, that is, the i+1th new sample editing feature is generated by the last layer of initial adapter, then the i+1th new sample editing feature is determined as the target sample feature.

[0130] After determining the target sample features, the server can perform a second attention operation on the target sample features and the vector representation of the first sample text through the attention mechanism layer in the i+1th layer initial adapter to obtain the sample potential output features.

[0131] The above method obtains more reasonable sample potential output features through the collaborative work of multiple layers of initial adapters, and a more reasonable predicted edited image can be obtained through the sample potential output features, so as to train an image generation model with better performance and use the image generation model to better perform secondary editing.

[0132] S805 , training the initial network model based on the difference between the predicted edited image and the second sample image to obtain an image generation model, wherein the feature alignment module included in the image generation model is obtained by training based on the initial alignment module.

[0133] The server can train the initial network model by predicting the difference between the edited image and the second sample image, and train the initial network model into an image generation model. The initial alignment module in the initial network model can obtain a feature alignment module of the feature generation model through training.

[0134] It can be seen from the above technical solution that the present application obtains a graphic sample including a first sample text and a first sample image, as well as a second sample text and a second sample image, wherein the first sample image is an image generated based on the first sample text, the second sample text is a text that performs secondary editing on the sample editing content of the first sample image, and the second sample image is an image generated based on the second sample text. By introducing the training sample, the trained image generation model can be more suitable for the secondary editing scenario. When training the image generation model, the first sample features and the second sample features are mapped into target sample features through the initial alignment module in the initial network model. Since the target sample features are obtained based on the first sample features before editing and the second sample features of secondary editing, the target sample features not only contain the information of the second sample text, but also retain the key information in the first sample features. The image generation model obtained by training the initial network model based on the difference between the predicted edited image and the second sample image has stronger performance and can generate a more reasonable target image.

[0135] From the above introduction, we can know that the image generation model can be a diffusion model. The training task of the diffusion model can be carried out through training examples. The training example can be a single image for training, and the main object in the image is the target. The purpose of diffusion model training is to train the main objects in the image into the diffusion model.

[0136] The training principle of the diffusion model can be: first, the initial image can be compressed through an image encoder (Variational Autoencoder, VAE) to convert the initial image from pixel space to latent space to capture the essential information of the initial image. The diffusion model then applies a diffusion process to the initial image in the latent space, that is, adding noise. Then, the input description text is converted into the conditions of the denoising process using a text encoder. Denoising is performed based on this condition to obtain the potential representation of the generated image. The denoising process can be flexibly adjusted according to the description text and the initial image. Finally, the image is converted back from the latent space to the pixel space through the image decoder to generate an image corresponding to the description text.

[0137] When the image generation model is a diffusion model that has completed training, based on the principle of the diffusion model, during the training process of S605, the server can determine the first loss according to the difference between the predicted edited image and the second sample image. The server can then use the true value noise to generate a sample noise image through the initial diffusion model. The server performs noise prediction on the sample noise image through the initial diffusion model based on the sample editing features to obtain sample prediction noise. The second loss is determined according to the difference between the true value noise and the sample prediction noise, and then the initial network model is trained based on the first loss and the second loss to obtain the image generation model.

[0138] The above method fully considers the characteristics of the diffusion model and determines the second loss according to the difference between the true value noise and the sample prediction noise. In the training process, not only the difference between the predicted edited image and the second sample image is considered, but also the difference between the true value noise and the sample prediction noise. By training the initial network model simultaneously with the first loss and the second loss, a more powerful image generation model can be obtained.

[0139] The server can generate sample noise images in a variety of ways. In order to better meet the training scenario of the diffusion model, the server can choose to generate a Gaussian noise image with a random seed, and the Gaussian noise can be used as the true value noise.

[0140] The image generation model can be trained using different training methods. To better meet the needs of secondary editing, the image generation model can be trained using a gradient descent training method. During the training process, the initial network model can be trained using training samples from different batches.

[0141] Input a batch of training samples into the initial network model, then calculate the loss, and then calculate the gradient between the losses. Completing the training of all data (such as training samples) in a batch through the gradient update initial alignment module is called completing a training round (completing an epoch). The training round can be set according to actual needs, for example, it can be 100 training rounds. The learning rate between different rounds can also be set according to actual needs. The learning rate can be the improvement rate of the model performance of the next round compared to the previous training round. In one possible implementation, the learning rate can be set to 1e-4. The relevant hyperparameters of training the initial network model can be adjusted according to the actual situation. The relevant hyperparameters can be the learning rate or the number of training times.

[0142] Before the first round of training, the server can use the parameters of the denoising network, image encoder and text encoder of the open source already trained diffusion model to initialize the parameters of the denoising network, image encoder and text encoder of the initial network model in the embodiment of the present application.

[0143] In the process of training the diffusion model, training is performed on the graphic samples including the first sample text and the first sample image, as well as the second sample text and the second sample image. The server inputs the first sample text and the first sample image into the diffusion model, and the server can generate a Gaussian noise distribution map (sample noise image) with a random seed (true value noise). After the first sample text is passed through the text encoder to obtain the first sample feature, the first sample feature and the sample noise image are used as inputs of the feature adapter. The noise is predicted by the denoising network. Similarly, the second sample text and the second sample image can also be processed by the above method.

[0144] When the first sample text and the second sample text reach the initial adapter in the data flow of the denoising network, for the initial adapter of the current layer, the initial adapter at this layer can generate the first sample feature of the first sample text. Specifically, the server can input the first sample text in the graphic sample into the text encoder, obtain the vector representation of the first sample text through the text encoder, use the vector representation of the first sample text as the input of the initial attention mechanism layer of the initial adapter, perform the first attention operation, and obtain the first sample feature. The initial adapter at this layer can also generate the second sample feature of the second sample text. The first sample feature and the second sample feature are input into the initial alignment module of the initial adapter at this layer, and the first sample feature and the second sample feature are mapped into the target sample feature through the initial alignment module, and the subsequent attention operation is continued along the data flow direction of the first sample text to complete the processing of this layer. For example, the second attention operation can be performed on the target sample feature and the vector representation of the first sample text through the initial attention mechanism layer of the initial adapter at this layer to obtain the sample potential output feature.

[0145] When the initial network model is an initial diffusion model, the initial network model may also include multiple layers of initial adapters. When encountering subsequent initial adapters of other layers, the sample potential output features of the previous layer are used as the input of the next layer, and the processing of the initial adapter described above is repeated.

[0146] If the initial network model can also include 16 initial adapters, for example, the denoising network in the initial network model is Figure 7 As shown in , the above process will be repeated 16 times. The initial network model predicts noise based on the potential output features of the samples output by the last layer, and finally outputs the sample prediction noise.

[0147] The server determines the second loss according to the difference between the true value noise and the sample prediction noise, and obtains the image generation model by training by minimizing the difference between the true value noise and the sample prediction noise.

[0148] In order to better illustrate the training process of the above image generation model, Fig.10 This is a schematic diagram of the training process of an image generation model. Fig.10The first sample text and the second sample text are used as inputs of the text encoder τ. The first sample image and the second sample image are converted to the latent space by the image encoder under the superposition of the noise image generated by the random seed. The circle with a plus sign in the figure indicates that the random seed generates the noise image. The noise added to generate the noise image can be the true value noise. The first sample text and the second sample text obtain the target sample feature through the four-layer feature adapter, and the predicted edited image is obtained through the target sample feature. The server determines the first loss according to the difference between the predicted edited image and the second sample image. The server performs noise prediction on the sample noise image through the initial diffusion model to obtain the sample prediction noise. The second loss is determined according to the difference between the true value noise and the sample prediction noise. The server can adjust the parameters of the initial network model by combining the first loss and the second loss, and finally obtain the trained image generation model.

[0149] The trained image generation model can be deployed on a server to provide image generation services and secondary editing services for interactive objects. Fig.11 A schematic diagram of an application of an image generation model provided in an embodiment of the present application, in Fig.11 In the example, the interactive object can input the original description text through an input interface, and the input interface can be provided by an application installed in a terminal used by the interactive object. The server calls the image generation model to generate images based on the original description text input by the interactive object to obtain multiple original images.

[0150] For example, the interactive object inputs the original description text "a cat on the sofa", and the image generation model generates multiple original images based on the original description text. The composition and the movements and expressions of the cats in different images may be different.

[0151] If there is an original image among the multiple original images that does not meet the requirements of the interactive object, the interactive object can request a secondary edit from the server. Specifically, if the interactive object is not satisfied with the original image, the interactive object can select the original image that needs to be secondary edited through the input interface and input the edit description text through the input interface. The server calls the image generation model to perform secondary editing based on the edit description text input by the interactive object. After the secondary editing, the server can return the target image obtained by the secondary editing to the terminal of the interactive object and display the target image on the terminal.

[0152] For example, the interactive object inputs the edit description text "a robot cat on the sofa", and the image generation model performs secondary editing on the original image based on the edit description text input by the interactive object to obtain the target image. In the secondary editing process, the image generation model generates the target image based on the target editing features obtained by mapping the original features and the edit features. The generated target image can reflect the edited "arobot cat" and retain the non-edited content "on the sofa" of the original image, keeping the non-edited content generation effect unchanged, and the generated target image has higher rationality and fidelity.

[0153] The image generation model trained by the training method provided by the present application can perform secondary editing of images more accurately. The image generation model is allowed to perform secondary editing on the first generated image, and modify or replace the part with poor generation effect.

[0154] The trained image generation model can be used for artificial intelligence generated content (AIGC) and AIGC image creation and generation. AIGC image creation and generation can include generating an image and performing secondary editing on the objects in the image.

[0155] It should be noted that, based on the implementation methods provided in the above aspects, this application can also be further combined to provide more implementation methods.

[0156] based on Figure 2 Corresponding to the image generation method provided in the embodiment, the embodiment of the present application also provides an image generation device 1200. Fig.12 As shown, the image generating device 1200 includes a first acquiring unit 1201, a second acquiring unit 1202, a feature alignment unit 1203 and an image generating unit 1204:

[0157] The first acquisition unit 1201 is used to acquire the edit description text in response to the edit operation on the original image after the original image is generated based on the original description text by the image generation model, wherein the edit description text is used to perform secondary editing on the content to be edited of the original image;

[0158] The second acquisition unit 1202 is used to acquire the original features of the original description text and the edited features of the edited description text;

[0159] The feature alignment unit 1203 is used to map the original features and the edited features into target edited features through a feature alignment module in the image generation model, and the target edited features are used to reflect the feature distribution of the image after the secondary editing;

[0160] The image generation unit 1204 is used to generate an image based on the target editing feature through the image generation model, replace the content to be edited in the original image with the target content, and obtain a target image corresponding to the editing description text.

[0161] In a possible implementation manner, there are multiple original images, and the multiple original images include the image to be edited, and the first acquisition unit is specifically used to:

[0162] Acquire a plurality of the original images;

[0163] Based on a selection operation of the image to be edited from the plurality of original images, acquiring the image to be edited;

[0164] In response to a text input operation for the image to be edited, the edit description text input by the text input operation is acquired, wherein the edit operation includes the selection operation and the text input operation.

[0165] In a possible implementation, the image generation model includes a feature adapter, the feature adapter includes the feature alignment module and the attention mechanism layer, and the second acquisition unit is specifically used to:

[0166] Performing a first attention operation on the image features of the noise image and the vector representation of the original description text through the attention mechanism layer to obtain the original features;

[0167] The image generation unit is specifically used for:

[0168] Performing a second attention operation on the target editing feature and the vector representation of the original description text through the attention mechanism layer to obtain a target potential output feature;

[0169] Based on the target potential output features, the image generation model is used to generate an image, and the content to be edited of the original image is replaced with the target content to obtain a target image corresponding to the editing description text.

[0170] In a possible implementation, the image generation model includes N layers of feature adapters, and the feature alignment unit is specifically used to:

[0171] Based on the i-th original feature of the original description text and the i-th edit feature of the edit description text, a feature alignment module in an i-th layer feature adapter is used to generate an i-th new edit feature, where i is a positive integer less than or equal to N;

[0172] Performing an attention operation on the i-th new edited feature through the attention mechanism layer in the i-th layer feature adapter to obtain an i-th potential output feature;

[0173] When the i-th potential output feature is input into the i+1-th layer feature adapter to generate the i+1-th original feature, based on the i+1-th original feature and the i+1-th edit feature generated by the edit description text in the i+1-th layer feature adapter, a feature alignment module in the i+1-th layer feature adapter is used to generate the i+1-th new edit feature;

[0174] If i+1=N, the i+1th new editing feature is determined as the target editing feature;

[0175] The step of performing a second attention operation on the target editing feature and the vector representation of the original description text through the attention mechanism layer to obtain a target potential output feature includes:

[0176] Through the attention mechanism layer in the i+1th layer feature adapter, a second attention operation is performed on the vector representation of the target editing feature and the original description text to obtain the target potential output feature.

[0177] In a possible implementation, the image generation model is a diffusion model that has completed training, and the image generation unit is specifically used to:

[0178] Generate a noise image through the trained diffusion model using the random noise used to generate the original image;

[0179] Based on the target editing features, the noise image is denoised by using the trained diffusion model to obtain the target image.

[0180] In a possible implementation, the device further includes a model training unit, and the model training unit is specifically used to:

[0181] Acquire a training sample, wherein the training sample includes a plurality of image-text samples, each of the plurality of image-text samples includes a first sample text and a first sample image, and a second sample text and a second sample image, wherein the first sample image is an image generated based on the first sample text, the second sample text is a text that performs secondary editing on sample edited content of the first sample image, and the second sample image is an image generated based on the second sample text;

[0182] For each of the image-text samples, obtaining a first sample feature of the first sample text in the image-text sample and a second sample feature of the second sample text in the image-text sample;

[0183] Mapping the first sample feature and the second sample feature into a target sample feature through an initial alignment module in an initial network model;

[0184] Based on the target sample features, the initial network model is used to generate an image, and the sample edited content of the first sample image is replaced with the target sample content to obtain a predicted edited image corresponding to the second sample text;

[0185] The initial network model is trained based on the difference between the predicted edited image and the second sample image to obtain the image generation model, and the feature alignment module included in the image generation model is trained based on the initial alignment module.

[0186] In a possible implementation, the initial network model includes an initial adapter, the initial adapter includes the initial alignment module and the initial attention mechanism layer, and the model training unit is specifically used for:

[0187] Performing a first attention operation on the image features of the sample noise image and the vector representation of the first sample text through the initial attention mechanism layer to obtain the first sample features;

[0188] The step of generating an image based on the target sample feature by using the initial network model, replacing the sample edit content of the first sample image with the target sample content, and obtaining a predicted edit image corresponding to the second sample text includes:

[0189] Performing a second attention operation on the target sample feature and the vector representation of the first sample text through the initial attention mechanism layer to obtain a sample potential output feature;

[0190] Based on the potential output features of the sample, image generation is performed through the initial network model, and the sample editing content of the first sample image is replaced with the target sample content to obtain a predicted editing image corresponding to the second sample text.

[0191] In a possible implementation, the initial network model includes N layers of initial adapters, and the model training unit is specifically used for:

[0192] Based on the acquired i-th first sample feature of the first sample text and the i-th second sample feature of the second sample text, an i-th new sample editing feature is generated by an initial alignment module in an i-th layer initial adapter, where i is a positive integer less than or equal to N;

[0193] Performing an attention operation on the edited features of the i-th new sample through the initial attention mechanism layer in the i-th initial adapter to obtain a potential output feature of the i-th sample;

[0194] When the i+1th sample potential output feature is input into the i+1th layer initial adapter to generate the i+1th first sample feature, based on the i+1th first sample feature and the i+1th second sample feature generated by the second sample text in the i+1th layer initial adapter, an i+1th new sample editing feature is generated through an initial alignment module in the i+1th layer initial adapter;

[0195] If i+1=N, the i+1th new sample editing feature is determined as the target sample feature;

[0196] A second attention operation is performed on the target sample features and the vector representation of the first sample text through the attention mechanism layer in the i+1th layer initial adapter to obtain the sample potential output features.

[0197] In a possible implementation, the image generation model is a diffusion model that has completed training, the initial network model is an initial diffusion model, and the model training unit is specifically used to:

[0198] determining a first loss based on a difference between the predicted edited image and the second sample image;

[0199] Using true value noise, a sample noise image is generated through the initial diffusion model;

[0200] Based on the sample editing feature, performing noise prediction on the sample noise image through the initial diffusion model to obtain sample prediction noise;

[0201] Determine a second loss according to the difference between the true value noise and the sample prediction noise;

[0202] The initial network model is trained based on the first loss and the second loss to obtain the image generation model.

[0203] It can be seen from the above device that after the original image is generated based on the original description text by the image generation model, if the original image needs to be edited for a second time, the editing operation can be triggered, and then in response to the editing operation on the original image, the editing description text is obtained, and the editing description text is used to perform a second editing on the content to be edited of the original image. Then the original features of the original description text and the editing features of the editing description text are obtained, and the original features and the editing features are mapped into target editing features through the feature alignment module in the image generation model. Since the target editing features are obtained based on the original features before editing and the editing features of the second editing, the target editing features not only contain the information of the new text (i.e., the editing description text), but also retain the key information in the original features, and can more comprehensively and accurately reflect the feature distribution of the image after the second editing, that is, the generated target editing features are conducive to image generation. In this way, based on the target editing features, image generation is performed through the image generation model, and the content to be edited of the original image is replaced with the target content. When the target image corresponding to the edit description text is obtained, the generated target image can not only reflect the new content after editing (i.e., the target content), but also retain the non-edited content of the original image, keeping the non-edited content generation effect unchanged, and the generated target image has higher rationality and fidelity.

[0204] The embodiment of the present application also provides a computer device, which can execute the image generation method. The computer device can be a terminal, Fig.13 The structure diagram of a terminal provided by an embodiment of the present application is shown. Fig.13 In the example, the terminal is a smartphone:

[0205] refer to Fig.13 The smartphone includes: a radio frequency (RF) circuit 1310, a memory 1320, an input unit 1330, a display unit 1340, a sensor 1350, an audio circuit 1360, a wireless fidelity (WiFi) module 1370, a processor 1380, and a power supply 1390. The input unit 1330 may include a touch panel 1331 and other input devices 1332, the display unit 1340 may include a display panel 1341, and the audio circuit 1360 may include a speaker 1361 and a microphone 1362. It is understood that Fig.13 The structure of the smartphone shown in the figure does not constitute a limitation of the smartphone, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0206] The memory 1320 can be used to store software programs and modules. The processor 1380 executes various functional applications and data processing of the smartphone by running the software programs and modules stored in the memory 1320. The memory 1320 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the smartphone (such as audio data, a phone book, etc.), etc. In addition, the memory 1320 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0207] The processor 1380 is the control center of the smartphone, which uses various interfaces and lines to connect various parts of the entire smartphone, and executes various functions of the smartphone and processes data by running or executing software programs and / or modules stored in the memory 1320, and calling data stored in the memory 1320. Optionally, the processor 1380 may include one or more processing units; preferably, the processor 1380 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, interactive object interface and application programs, etc., and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 1380.

[0208] In this embodiment, the processor 1380 in the smart phone can execute the image generation method provided in each embodiment of the present application.

[0209] The computer device provided in the embodiment of the present application may also be a server. Fig.14 As shown, Fig.14 The structural diagram of the server 1400 provided in the embodiment of the present application, the server 1400 may have relatively large differences due to different configurations or performances, and may include one or more processors, such as a central processing unit (CPU) 1422, and a memory 1432, one or more storage media 1430 (such as one or more mass storage devices) storing application programs 1442 or data 1444. Among them, the memory 1432 and the storage medium 1430 can be short-term storage or permanent storage. The program stored in the storage medium 1430 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Furthermore, the central processing unit 1422 can be configured to communicate with the storage medium 1430 and execute a series of instruction operations in the storage medium 1430 on the server 1400.

[0210] The server 1400 may also include one or more power supplies 1426, one or more wired or wireless network interfaces 1450, one or more input and output interfaces 1458, and / or one or more operating systems 1441, such as Windows Server 2003. TM , Mac OS X TM , Unix TM ,Linux TM , FreeBSD TM etc.

[0211] In this embodiment, the central processor 1422 in the server 1400 can execute the image generation method provided in each embodiment of the present application.

[0212] According to one aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium is used to store a computer program, and the computer program is used to execute the image generation method described in each of the aforementioned embodiments.

[0213] According to one aspect of the present application, a computer program product is provided, the computer program product comprising a computer program, the computer program being stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the method provided in various optional implementations of the above-mentioned embodiments.

[0214] The descriptions of the processes or structures corresponding to the above-mentioned figures have different emphases. For parts that are not described in detail in a certain process or structure, please refer to the relevant descriptions of other processes or structures.

[0215] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein, for example. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

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

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

[0218] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0219] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a terminal, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store computer programs.

[0220] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.

[0221] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, ordinary technical members in the art should understand that they can still modify the technical solutions recorded in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. An image generation method, characterized in that: The method comprises: After an original image is generated based on the original description text by an image generation model, in response to an editing operation on the original image, an edit description text is acquired, wherein the edit description text is used to perform a secondary editing on the content to be edited of the original image; Acquire original features of the original description text and edit features of the edited description text; Mapping the original features and the edited features into target edited features through a feature alignment module in the image generation model, wherein the target edited features are used to reflect the feature distribution of the image after the secondary editing; Based on the target editing features, image generation is performed through the image generation model, the content to be edited of the original image is replaced with the target content, and a target image corresponding to the editing description text is obtained.

2. The method according to claim 1, characterized in that: The number of the original images is multiple, and the multiple original images include an image to be edited. In response to the editing operation on the original image, obtaining the editing description text includes: Acquire a plurality of the original images; Based on a selection operation of the image to be edited from the plurality of original images, acquiring the image to be edited; In response to a text input operation for the image to be edited, the edit description text input by the text input operation is acquired, wherein the edit operation includes the selection operation and the text input operation.

3. The method according to claim 1, characterized in that The image generation model includes a feature adapter, The feature adapter includes the feature alignment module and the attention mechanism layer, and the obtaining of the original features of the original description text includes: Performing a first attention operation on the image features of the noise image and the vector representation of the original description text through the attention mechanism layer to obtain the original features; The step of generating an image based on the target editing feature by using the image generation model, replacing the content to be edited of the original image with the target content, and obtaining a target image corresponding to the editing description text includes: Performing a second attention operation on the target editing feature and the vector representation of the original description text through the attention mechanism layer to obtain a target potential output feature; Based on the target potential output features, the image generation model is used to generate an image, and the content to be edited of the original image is replaced with the target content to obtain a target image corresponding to the editing description text.

4. The method according to claim 3, characterized in that The image generation model includes N layers of feature adapters, and mapping the original features and the edited features into target edited features through a feature alignment module in the image generation model includes: Based on the i-th original feature of the original description text and the i-th edit feature of the edit description text, a feature alignment module in an i-th layer feature adapter is used to generate an i-th new edit feature, where i is a positive integer less than or equal to N; Performing an attention operation on the i-th new edited feature through the attention mechanism layer in the i-th layer feature adapter to obtain an i-th potential output feature; When the i-th potential output feature is input into the i+1-th layer feature adapter to generate the i+1-th original feature, based on the i+1-th original feature and the i+1-th edit feature generated by the edit description text in the i+1-th layer feature adapter, a feature alignment module in the i+1-th layer feature adapter is used to generate the i+1-th new edit feature; If i+1=N, the i+1th new editing feature is determined as the target editing feature; The step of performing a second attention operation on the target editing feature and the vector representation of the original description text through the attention mechanism layer to obtain a target potential output feature includes: Through the attention mechanism layer in the i+1th layer feature adapter, a second attention operation is performed on the vector representation of the target editing feature and the original description text to obtain the target potential output feature.

5. The method according to claim 1, characterized in that The image generation model is a diffusion model that has completed training. The image generation model is used to generate an image based on the target editing feature, and the content to be edited of the original image is replaced with the target content to obtain a target image corresponding to the editing description text, including: Generate a noise image through the trained diffusion model using the random noise used to generate the original image; Based on the target editing features, the noise image is denoised by using the trained diffusion model to obtain the target image.

6. The method according to claim 1, characterized in that The method further comprises: Acquire a training sample, wherein the training sample includes a plurality of image and text samples, each of the plurality of image and text samples includes a first sample text and a first sample image, and a second sample text and a second sample image, wherein the first sample image is an image generated based on the first sample text, the second sample text is a text that performs secondary editing on the sample edited content of the first sample image, and the second sample image is an image generated based on the second sample text; For each of the image-text samples, obtaining a first sample feature of the first sample text in the image-text sample and a second sample feature of the second sample text in the image-text sample; Mapping the first sample feature and the second sample feature into target sample features through an initial alignment module in an initial network model; Based on the target sample features, the initial network model is used to generate an image, and the sample edited content of the first sample image is replaced with the target sample content to obtain a predicted edited image corresponding to the second sample text; The initial network model is trained based on the difference between the predicted edited image and the second sample image to obtain the image generation model, and the feature alignment module included in the image generation model is trained based on the initial alignment module.

7. The method according to claim 6, characterized in that The initial network model includes an initial adapter, and the initial adapter includes the initial alignment module and the initial attention mechanism layer. The step of obtaining the first sample feature of the first sample text includes: Performing a first attention operation on the image features of the sample noise image and the vector representation of the first sample text through the initial attention mechanism layer to obtain the first sample features; The step of generating an image based on the target sample feature by using the initial network model, replacing the sample edit content of the first sample image with the target sample content, and obtaining a predicted edit image corresponding to the second sample text includes: Performing a second attention operation on the target sample feature and the vector representation of the first sample text through the initial attention mechanism layer to obtain a sample potential output feature; Based on the potential output features of the sample, image generation is performed through the initial network model, and the sample editing content of the first sample image is replaced with the target sample content to obtain a predicted editing image corresponding to the second sample text.

8. The method according to claim 7, characterized in that The initial network model includes N layers of initial adapters, and mapping the first sample features and the second sample features into target sample features through an initial alignment module in the initial network model includes: Based on the acquired i-th first sample feature of the first sample text and the i-th second sample feature of the second sample text, an i-th new sample editing feature is generated by an initial alignment module in an i-th layer initial adapter, where i is a positive integer less than or equal to N; Performing an attention operation on the edited features of the i-th new sample through the initial attention mechanism layer in the i-th initial adapter to obtain a potential output feature of the i-th sample; When the i+1th sample potential output feature is input into the i+1th layer initial adapter to generate the i+1th first sample feature, based on the i+1th first sample feature and the i+1th second sample feature generated by the second sample text in the i+1th layer initial adapter, an i+1th new sample editing feature is generated through an initial alignment module in the i+1th layer initial adapter; If i+1=N, the i+1th new sample editing feature is determined as the target sample feature; The performing a second attention operation on the target sample feature and the vector representation of the first sample text through the initial attention mechanism layer to obtain a sample potential output feature includes: A second attention operation is performed on the target sample features and the vector representation of the first sample text through the attention mechanism layer in the i+1th layer initial adapter to obtain the sample potential output features.

9. The method according to claim 6, characterized in that The image generation model is a diffusion model that has completed training, the initial network model is an initial diffusion model, and the initial network model is trained based on the difference between the predicted edited image and the second sample image to obtain the image generation model, including: determining a first loss based on a difference between the predicted edited image and the second sample image; Using true value noise, a sample noise image is generated through the initial diffusion model; Based on the sample editing feature, performing noise prediction on the sample noise image through the initial diffusion model to obtain sample prediction noise; Determine a second loss according to the difference between the true value noise and the sample prediction noise; The initial network model is trained based on the first loss and the second loss to obtain the image generation model.

10. An image generating device, characterized in that: The device comprises a first acquisition unit, a second acquisition unit, a feature alignment unit and an image generation unit: The first acquisition unit is used to acquire the edit description text in response to an edit operation on the original image after the original image is generated based on the original description text by the image generation model, wherein the edit description text is used to perform secondary editing on the content to be edited of the original image; The second acquisition unit is used to acquire the original features of the original description text and the edited features of the edited description text; The feature alignment unit is used to map the original features and the edited features into target edited features through a feature alignment module in the image generation model, wherein the target edited features are used to reflect the feature distribution of the image after the secondary editing; The image generation unit is used to generate an image based on the target editing feature through the image generation model, replace the content to be edited in the original image with the target content, and obtain the target image corresponding to the editing description text.

11. A computer device, characterized in that: The computer device comprises a processor and a memory: The memory is used to store a computer program and transmit the computer program to the processor; The processor is configured to execute the method according to any one of claims 1 to 9 according to the instructions in the computer program.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store a computer program, which, when executed by a processor, causes the processor to perform the method according to any one of claims 1 to 9.

13. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.

Citation Information

Cited By

  • Image generation method and device, model training method and device, equipment and storage medium

    CN119540379A

  • Image generation method, model training method, device, equipment and storage medium

    CN119540379B

  • Image generation method and device, equipment and storage medium

    CN119810266A

  • Image Generation Method, Apparatus, Device, and Storage Medium

    CN119810266B

  • Text-driven garment template intelligent generation method

    CN120197247A