Image generation method and device, and text graph model training method and device

By using multiple reference pictures with common attributes for training in the Vincentian diagram model, the picture attribute guidance parameters are obtained, which solves the problem of requiring a large number of picture training in the existing technology, and improves the application convenience and calculation efficiency of the Vincentian diagram model.

CN118629051BActive Publication Date: 2024-10-25TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411100958.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-12
Publication Date
2024-10-25
Estimated Expiration
2044-08-12

AI Technical Summary

Technical Problem

Existing Vincentian graph technology requires collecting a large number of images for model training, which results in high consumption of computing resources and inconvenient application.

Method used

By obtaining the latent space vector of the guidance text and initial noise information, using the trained Vincentian graph model for denoising and decoding, and combining multiple reference pictures with common attributes for training, the picture attribute guidance parameters are obtained, which reduces the time required for model training. Number of images and computing resources.

Benefits of technology

It greatly reduces the application time of Vincentian diagram technology, makes the application of Vincentian diagram model more convenient, and avoids the need for large amounts of image collection and high computing resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118629051B_ABST
    Figure CN118629051B_ABST
Patent Text Reader

Abstract

The embodiments of the present application disclose a method and device for generating an image, and a method and device for training a Vincent graph model. The method includes: obtaining a guide text for guiding the generation of an image, and a latent space vector for characterizing the initial noise information corresponding to the image to be generated; performing semantic extraction on the guide text to obtain a text semantic vector; inputting the text semantic vector and the latent space vector into a trained Vincent graph model, wherein the trained Vincent graph model includes image attribute guidance parameters obtained by training the pre-trained Vincent graph model with multiple reference images having common attributes; receiving a target image output by the trained Vincent graph model, wherein the target image is obtained by denoising the latent space vector according to the text semantic vector and the image attribute guidance parameters, and decoding the denoised latent space vector. The embodiments of the present application can make the application of the Vincent graph model more convenient.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and specifically to a method and device for generating an image, and a method and device for training a text-based graph model. Background Art

[0002] Text-to-Image Generation technology refers to an artificial intelligence technology that uses a deep learning model to convert text descriptions into corresponding images. This deep learning model is generally called a text-to-image generation model. Text-to-image generation technology combines the capabilities of natural language processing and computer vision, allowing users to generate images that match the description by inputting descriptive text.

[0003] In related technologies, the Wensheng graph model still needs to collect a large number of pictures for model training, which means that the application of Wensheng graph technology still consumes a lot of computing resources and is time-consuming, which in turn leads to the lack of convenience in the application of Wensheng graph technology. Summary of the invention

[0004] To solve the above technical problems, the embodiments of the present application provide a method and device for generating images, a method and device for training a text graph model, an electronic device, a computer-readable storage medium, and a computer program product. The embodiments of the present application do not require the collection of a large number of images for model training, which can greatly reduce the time consumption of applying text graph technology, making the application of text graph technology more convenient.

[0005] One aspect of an embodiment of the present application provides a method for generating an image, the method comprising: obtaining a guide text for guiding the generation of an image, and a latent space vector for representing initial noise information corresponding to the image to be generated; performing semantic extraction on the guide text to obtain a text semantic vector; inputting the text semantic vector and the latent space vector into a trained Vincent graph model, the trained Vincent graph model comprising image attribute guidance parameters, the image attribute guidance parameters being obtained by training the pre-trained Vincent graph model with multiple reference images having common attributes; receiving a target image output by the trained Vincent graph model, the target image being obtained by denoising the latent space vector according to the text semantic vector and the image attribute guidance parameters, and decoding the denoised latent space vector.

[0006] In another exemplary embodiment, the trained Wensheng graph model and the pre-trained Wensheng graph model both include a denoising network and a decoding network; the denoising network includes a plurality of denoising sub-blocks connected in sequence, each denoising sub-block includes a sampling network layer, a self-attention network layer, a cross-attention network layer and an attribute cross-attention network layer connected in sequence; the attribute cross-attention network layer contains the image attribute guidance parameters; the text semantic vector and the latent space vector are input into the trained Wensheng graph model, including: inputting the latent space vector into the sampling network layer in the first denoising sub-block, and inputting the text semantic vector into the cross-attention network sub-layer in each denoising sub-block respectively.

[0007] In another exemplary embodiment, the pre-trained Wensheng graph model is trained through the following steps to obtain the trained Wensheng graph model: obtaining a sample semantic vector corresponding to a guide text sample and a plurality of reference images with common attributes; extracting a common attribute feature vector between the plurality of reference images with common attributes; inputting the latent space vector into a sampling network layer in the first denoising sub-block, inputting the sample semantic vector into the cross-attention sub-network layer in each denoising sub-block respectively, and inputting the common attribute feature vector into the attribute cross-attention network layer in each denoising sub-block; denoising the latent space vector in the pre-trained Wensheng graph model, decoding the denoised latent space vector, and outputting a training generated image so that the attribute cross-attention network layer in each denoising sub-block obtains the image attribute guidance parameter, thereby obtaining the trained Wensheng graph model.

[0008] In one aspect of an embodiment of the present application, a method for training a Wensheng graph model is provided. The Wensheng graph model before training includes a picture attribute extraction network, a denoising network and a decoding network. The method includes: obtaining a sample semantic vector corresponding to a guide text sample and a plurality of reference pictures with common attributes; extracting a common attribute feature vector between the plurality of reference pictures with common attributes through the picture attribute extraction network; inputting a latent space vector for representing initial noise information corresponding to a to-be-generated picture, the sample semantic vector and the common attribute feature vector into the denoising network; denoising the latent space vector in the denoising network according to the sample semantic vector and the common attribute feature vector to obtain a denoised latent space vector, decoding the denoised latent space vector through the decoding network, and outputting a training generated picture, so that the denoising network obtains picture attribute guidance parameters corresponding to the common attribute, and obtains a trained Wensheng graph model.

[0009] In another exemplary embodiment, the denoising network includes a plurality of denoising sub-blocks connected in sequence, each denoising sub-block includes a sampling network layer, a self-attention network layer, a cross-attention network layer and an attribute cross-attention network layer connected in sequence; the latent space vector used to characterize the initial noise information corresponding to the image to be generated, the sample semantic vector and the common attribute feature vector are input into the denoising network, including: inputting the latent space vector into the sampling network layer in the first denoising sub-block, and inputting the sample semantic vector into the cross-attention network layer in each denoising sub-block respectively, and inputting the common attribute feature vector into the attribute cross-attention network layer in each denoising sub-block.

[0010] In another exemplary embodiment, the attribute cross-attention network layer includes an attribute cross-attention sublayer and a self-attention network sublayer connected in sequence; the following steps are performed in the attribute cross-attention sublayer in each denoising sub-block: the output signal of the cross-attention network layer is used as a sentence vector, and a key vector and a value vector are extracted from the common attribute feature vector; and cross-attention calculation is performed based on the sentence vector, the key vector and the value vector.

[0011] In another exemplary embodiment, the pre-trained Wensheng graph model also includes a picture attribute extraction network, which includes connecting a plurality of attribute extraction sub-blocks in sequence; extracting common attribute feature vectors between the plurality of reference pictures with common attributes, including: selecting a reference picture as a base picture from the plurality of reference pictures with common attributes, and using other reference pictures as conditional pictures; inputting the base picture into the first attribute extraction sub-block, and inputting a conditional picture into each attribute extraction sub-block respectively, so as to obtain the common attribute feature vector output by the picture attribute extraction network.

[0012] In another exemplary embodiment, the method further includes: generating a corresponding number of sequentially connected attribute extraction sub-blocks according to the number of the conditional pictures, so as to obtain the picture attribute extraction network.

[0013] In another exemplary embodiment, the image attribute extraction network also includes multiple feature encoding networks, and each attribute extraction sub-block is connected to at least one feature encoding network; the feature encoding network is used to perform feature encoding processing on the input basic image or conditional image, and output the obtained feature vector to the connected attribute extraction sub-block.

[0014] In another exemplary embodiment, each attribute extraction sub-block includes a feature mapping network layer, a first self-attention network layer, and a second self-attention network layer connected in sequence; the feature encoding network for inputting the basic image is connected to the feature mapping network layer in the first attribute extraction sub-block; and the feature encoding network for inputting the conditional image is connected to the second self-attention network layer in the attribute extraction sub-block.

[0015] In another exemplary embodiment, the following steps are performed in the second self-attention network layer in each attribute extraction sub-block: the output signal of the first self-attention network layer is used as a sentence vector, and a key vector and a value vector are extracted from the feature vector corresponding to the input conditional image; and self-attention calculation is performed based on the sentence vector, the key vector and the value vector.

[0016] In another exemplary embodiment, the feature mapping network layer contained in the attribute extraction sub-block has the same network structure as the sampling network layer in the denoising sub-block, the first self-attention network layer contained in the attribute extraction sub-block has the same network structure as the self-attention network layer in the denoising sub-block, and the second self-attention network layer contained in the attribute extraction sub-block has the same network structure as the self-attention network sublayer in the denoising sub-block.

[0017] In another aspect of an embodiment of the present application, a picture generation device is provided, the device comprising: an acquisition module, configured to acquire a guide text for guiding the generation of a picture, and a latent space vector for representing initial noise information corresponding to the picture to be generated; an extraction module, configured to perform semantic extraction on the guide text to obtain a text semantic vector; an input module, configured to input the text semantic vector and the latent space vector into a trained Vincent graph model, the trained Vincent graph model comprising picture attribute guidance parameters, the picture attribute guidance parameters being obtained by training the pre-trained Vincent graph model with a plurality of reference pictures having common attributes; a receiving module, configured to receive a target picture output by the trained Vincent graph model; wherein the target picture is obtained by denoising the latent space vector according to the text semantic vector and the picture attribute guidance parameters, and decoding the denoised latent space vector.

[0018] In another aspect of an embodiment of the present application, a device for training a text graph model is provided. The text graph model before training includes a picture attribute extraction network, a denoising network and a decoding network. The device includes: a sample acquisition module, configured to obtain a sample semantic vector corresponding to a guide text sample, and a plurality of reference pictures with common attributes; an attribute extraction module, configured to extract a common attribute feature vector between the plurality of reference pictures with common attributes through the picture attribute extraction network; a denoising processing module, configured to input a latent space vector for representing initial noise information corresponding to a picture to be generated, the sample semantic vector and the common attribute feature vector into the denoising network, so as to denoise the latent space vector according to the sample semantic vector and the common attribute feature vector to obtain a denoised latent space vector; and a decoding processing module, configured to decode the denoised latent space vector through the decoding network to obtain a training generated picture.

[0019] Another aspect of an embodiment of the present application provides an electronic device, including: one or more processors; a memory for storing one or more computer programs, when the one or more computer programs are executed by the one or more processors, the electronic device implements the image generation method or the cultural graph model training method as described above.

[0020] Another aspect of an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor of an electronic device, the electronic device executes the image generation method or the text-based graph model training method as described above.

[0021] Another aspect of an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor of an electronic device, implements the above-mentioned image generation method or cultural graph model training method.

[0022] In the technical solution provided in the embodiment of the present application, the trained Vincent graph model contains the image attribute guidance parameters obtained by performing model training in advance based on multiple reference images with common attributes, so that the trained Vincent graph model performs denoising processing on the input latent space vector according to the input text semantic vector and the image attribute guidance parameters contained in itself, and the process of decoding the denoised latent space vector can be understood as the trained Vincent graph model generating images under the guidance of the common attributes between the guiding text and multiple reference images. Therefore, only multiple reference images with common attributes are needed to train the pre-trained Vincent graph model, so that the trained Vincent graph model can obtain the image attribute guidance parameters corresponding to the common attributes, without the need to collect a large number of images and consume a large amount of computing resources for model training, thereby making the application of the Vincent graph model more convenient.

[0023] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 It is a schematic diagram of the implementation environment involved in this application.

[0025] Figure 2 It is a schematic diagram of the overall structure of a cultural graph model shown in an exemplary embodiment of the present application.

[0026] Figure 3 It illustrates a schematic diagram of different model effects obtained by using multiple reference images with different common attributes to perform training on the raw image model.

[0027] Figure 4 A schematic diagram showing the reasoning process performed by the trained Wensheng graph model.

[0028] Figure 5 A schematic diagram of the structure of any denoising sub-block included in the denoising network is shown.

[0029] Figure 6 A schematic diagram of the structure of any attribute extraction sub-block included in the image attribute extraction network is shown.

[0030] Figure 7 It is a flowchart of a method for generating an image shown in an exemplary embodiment of the present application.

[0031] Figure 8 It is a flowchart of a method for training a text graph model shown in an exemplary embodiment of the present application.

[0032] Fig. 9 It is a block diagram of a picture generating device shown in an exemplary embodiment of the present application.

[0033] Fig.10 It is a block diagram of a Wensheng graph model training device shown as an exemplary embodiment of the present application.

[0034] Fig.11 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown. DETAILED DESCRIPTION

[0035] Here, exemplary embodiments will be described in detail, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are only examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.

[0036] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0037] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.

[0038] The term "multiple" as used in this application refers to two or more than two. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the related objects are in an "or" relationship.

[0039] The terms "first", "second", "third" and "fourth" etc. in the specification and claims of the present application and the drawings are used to distinguish different objects, rather than to describe a specific order. The terms "including" and "having" and any variations thereof 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 limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units inherent to these processes, methods, products or devices.

[0040] 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.

[0041] First see Figure 1 , Figure 1 1 is a schematic diagram of an implementation environment involved in the present application. The implementation environment includes a terminal 110 and a server 120, and the terminal 110 and the server 120 communicate with each other in a wired or wireless manner.

[0042] The terminal 110 is used to obtain a guide text, which is a text description of the content of the picture to be generated, and a device for obtaining a picture corresponding to the text description. In some exemplary application scenarios, the terminal 110 interacts with the user to obtain the guide text input by the user, and returns to the user the picture generated accordingly based on the guide text. For example, the terminal 110 is configured with a graphical user interface (GUI), and the user can interact with the terminal 110 through the graphical user interface. For example, the user triggers the graphical user interface to input the guide text, and the user can also obtain the generated picture from the graphical user interface. For another example, the terminal 110 can also be configured with a keyboard, a mouse and other devices to assist in realizing information interaction with the user. In other exemplary application scenarios, the terminal 110 can also receive the guide text sent by other devices and return the corresponding generated picture to other devices.

[0043] The server 120 is used to provide data services for information interaction between the terminal 110 and the user or other devices. Of course, in the case where the terminal 110 does not have a data service demand, the terminal 110 may not interact with the server 120. For example, in some exemplary embodiments, a text graph model is deployed in the server 120, and the terminal 110 transmits the guide text input by the user or other device to the server 120, so that the server 120 generates a picture according to the guide text through the text graph model, and returns the generated picture to the terminal 110, so that the user or other device can obtain the picture generated by the text graph model through the terminal 110. For example, in other exemplary embodiments, the text graph model is deployed in the terminal 110, and the terminal 110 directly uses the text graph model to generate a picture according to the guide text input by the user or other device, so the terminal 110 may not interact with the server 120.

[0044] It should be noted that the terminal 110 may be a smart phone, tablet computer, laptop computer, desktop computer, smart home appliance, vehicle-mounted terminal or other device, and the embodiments of the present application do not limit the specific manner in which the terminal 110 interacts with the user or other devices and the specific structure of the terminal 110. The server 120 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services, and the embodiments of the present application do not limit the specific structure of the server 120.

[0045] In order to solve the related problems caused by the current Wensheng graph technology still needing to collect a large number of pictures to perform model training, the embodiments of the present application propose a new Wensheng graph model structure, and correspondingly propose a technical solution for performing training on the new Wensheng graph model structure.

[0046] See also Figure 2 , Figure 2 FIG. 1 is a schematic diagram of the overall structure of a text graph model shown in an exemplary embodiment of the present application. Figure 2 As shown, the text graph model includes a text encoding network 210, a denoising network 220, a decoding network 230 and an image attribute extraction network 240.

[0047] It should be noted that the embodiments of the present application divide the Wensheng graph model into two states: a trained Wensheng graph model and a pre-trained Wensheng graph model. That is to say, the trained Wensheng graph model is obtained by training the pre-trained Wensheng graph model. Since the training of the Wensheng graph model needs to rely on the image attribute extraction network 240, the pre-trained Wensheng graph model includes the image attribute extraction network 240. The trained Wensheng graph model does not need to input a reference image in the reasoning application stage, but directly generates an image based on the guide text input by the user. Therefore, the trained Wensheng graph model may not have the image attribute extraction network 240.

[0048] The text graph model provided in the embodiment of the present application is a variant of a diffusion model, and can also be called a latent diffusion model (Latent Diffusion Model, abbreviated as LDM). The text graph model generates a picture that conforms to the description content corresponding to the guide text based on the input guide text for guiding the generation of the picture. The process of generating a picture by the text graph model can be understood as the process of removing Gaussian noise from the latent space vector corresponding to the generated picture, and decoding the final latent space vector after noise removal into the pixel space, thereby obtaining the generated picture.

[0049] It is understandable that in the text graph model provided in the embodiment of the present application, the latent space vector refers to the variables that are not directly observed in the model, that is, the most basic features in the entire model processing flow. These variables are very important for explaining the observed data and the behavior of the model. For example, the latent space vector can characterize individual characteristics, behaviors, styles, and composition factors, which may affect the denoising process.

[0050] exist Figure 2 In the illustrated text-generated graph model, the text encoding network 210 is used to extract semantic feature vectors from the input guide text, thereby outputting text semantic vectors corresponding to the guide text. The guide text can be understood as a conceptual text sequence used to guide the model to generate images, such as Figure 2 The guide text shown is the conceptual text sequence of "mountains, trees, streams, blue sky, white clouds". Therefore, the process of the text encoding network 210 extracting the semantic feature vector corresponding to the guide text is the process of converting the conceptual text sequence into an embedding space that can be understood by the denoising network 220. Exemplarily, the text encoding network 210 can adopt the text encoding module in the Clip model (a deep learning model for understanding text and images, which can identify objects, scenes, actions and other elements in the image, and can also understand text related to the image, such as labels, descriptions, titles, etc.), or it can adopt the encoder module in other Transformer models (a deep learning model for natural language processing tasks, by introducing the self-attention mechanism, the model can weight and combine the information at different positions when processing sequence data, so as to better understand the structure and semantics of the sequence). This embodiment does not limit the specific network structure of the text encoding network 210.

[0051] The denoising network 220 can also be called the backbone network of the text graph model. The denoising network 220 includes two parts: an encoder (down sample) and a decoder (up sample). Each part contains multiple denoising sub-blocks (unetblock), and each denoising sub-block receives the text semantic features output by the text encoding network 210. The structure of each denoising sub-block is the same, consisting of a sampling network layer and an attention network layer, but the feature size dimension is different.

[0052] The denoising network 220 obtains the image attribute guidance parameters through model training, and then performs denoising on the input latent space vector according to the image attribute guidance parameters contained in itself and the input text semantic vector to obtain the denoised latent space vector. The denoising network 220 inputs the denoised latent space vector into the decoding network 230 to perform decoding processing, thereby obtaining the generated image. The decoding network 230 can be a network structure such as a variational autoencoder (VAE), which is not limited here.

[0053] The training process of the Wensheng graph model can be understood as the model denoising the latent space vector according to the input guide text and multiple reference pictures with common attributes, and decoding the denoised latent space vector to generate a picture that matches the text description corresponding to the guide text and has this common attribute. Through this training process, the denoising network 220 can have picture attribute guidance parameters related to this common attribute. Therefore, the trained Wensheng graph model can be understood as generating pictures under the guidance of the common attributes between the conceptual information described by the guide text and multiple reference pictures. Therefore, only multiple reference pictures with common attributes are needed to train the Wensheng graph model, so that the denoising network 220 can obtain the picture attribute guidance parameters corresponding to this common attribute, without collecting a large number of pictures and consuming a large amount of computing resources for model training, so that the application of the Wensheng graph model can be more convenient.

[0054] The image attribute extraction network 240 is used to extract common attribute feature vectors for multiple reference images with common attributes during the model training phase. The extracted common attribute feature vectors are input to each denoising sub-block in the denoising network 220, so that each denoising sub-block performs denoising processing on the latent space vector output by the upper network according to the input text semantic vector and the common attribute feature vector.

[0055] The image attribute extraction network 240 is composed of multiple attribute extraction sub-blocks and a feature coding network. The feature coding network is used to extract the feature vector of the reference image, and the extracted feature vector is input into the attribute extraction sub-block for calculation related to the image attribute, so that the obtained common attribute feature vector contains feature information related to the common attributes between multiple reference images. The number of attribute extraction sub-blocks can be adaptively expanded, for example, the number of attribute extraction sub-blocks is determined according to the number of reference images. The number of feature coding networks can be one or more. In the case of one feature coding network, the feature vectors of each reference image are extracted through the feature coding network. In the case of multiple feature coding networks, the feature vectors of each reference image are extracted through different feature coding networks. The feature coding network can also be a network structure such as a variational autoencoder (VAE), which is not limited here.

[0056] Figure 2 The illustrated image attribute extraction network 240 is constructed by connecting attribute extraction sub-blocks in series. A reference image is selected as a base image from multiple reference images with common attributes, for example Figure 2 The reference picture 1 shown, other reference pictures are used as conditional pictures, for example Figure 2In the reference images 2-4 shown, the number of attribute extraction sub-blocks is the same as the number of conditional images. The feature vector corresponding to the basic image will always be transmitted as the basic feature of the image attribute extraction network 240. Each time it passes through an attribute extraction sub-block, a feature vector corresponding to a conditional image will be input, and the common attributes with the basic features will be calculated in the attribute extraction sub-block, so that the feature vector of the conditional image and the common attributes in the basic features are integrated into the basic features. After calculations of multiple attribute extraction sub-blocks, it is equivalent to purifying the attribute information contained in multiple reference images, thereby obtaining the common attribute feature vectors between multiple reference images.

[0057] Of course, in some exemplary embodiments, the image attribute extraction network may also be composed of multiple attribute extraction sub-blocks connected in parallel, or multiple attribute extraction sub-blocks connected in series and in parallel, which is not limited here. However, no matter which method is used to construct the image attribute extraction network, the image attribute extraction network is used to extract common attribute feature vectors from multiple input reference images with common attributes.

[0058] Based on this Figure 2 The structure of the text graph model is schematically shown, and the training process of the text graph model and the process of using the trained text graph model to perform image generation are introduced respectively.

[0059] For the training of the Vincent graph model (using four reference pictures with watercolor style as training examples), firstly, a reference picture is randomly selected from the four reference pictures as the basic picture, such as reference picture 1, and after the feature vector is extracted by the feature encoding network, it is input into the first attribute extraction sub-block; a reference picture is randomly selected from other reference pictures except the basic picture as the conditional picture, such as reference picture 2, and after the feature vector is extracted by the feature encoding network, it is also input into the first attribute extraction sub-block; similarly, reference pictures 3 and 4 are respectively used as conditional pictures, and after the feature vector is extracted by the feature encoding network, they are respectively input into the second attribute extraction sub-block and the third attribute extraction sub-block. By performing relevant calculations of the picture attributes through each attribute extraction sub-block, the feature vector representing the common attributes between reference pictures 1-4, that is, the common attribute feature vector, can be obtained. The common attribute feature vector is input into each denoising sub-block respectively, and the text semantic vector obtained by extracting the text semantics of the guide text "mountains, trees, streams, blue sky, white clouds" is input into each denoising sub-block respectively, and the latent space vector representing the initial noise information corresponding to the image to be generated is also input into the first denoising sub-block, thereby sequentially passing through multiple denoising sub-blocks, performing denoising on the latent space vector according to the text semantic vector and the common attribute feature vector, and outputting the denoised latent space vector. The latent space vector can be obtained by initializing random noise according to a random seed. The denoised latent space vector can be understood as being obtained by denoising the initial noise under the guidance of the common attributes between the guide text and multiple reference images. By decoding the denoised latent space vector, the obtained image not only conforms to the text description corresponding to the guide text, but also has the common attributes between multiple reference images. As Figure 2 The generated image not only matches the guiding text "mountains, trees, streams, blue sky, white clouds", but is also in the style of watercolor paintings, which is a common attribute among the four reference images.

[0060] Through the above training, a trained Vincent graph model is obtained. In the trained Vincent graph model, each denoising sub-block contains network parameters related to the attributes of watercolor painting, which are collectively referred to as image attribute guidance parameters in the embodiments of the present application.

[0061] In the inference application stage of the trained Vincent graph model, since the trained Vincent graph model contains image attribute guidance parameters related to watercolor attributes, it is no longer necessary to input a reference image. Instead, the guidance text can be directly input. The trained Vincent graph model can accordingly output a watercolor-style image that matches the guidance text.

[0062] It can be understood that the latent space vector representing the initial noise information corresponding to the image to be generated can be automatically obtained by the Wensheng graph model, for example, the latent space vector is automatically generated by the Wensheng graph model, or the latent space vector is pre-stored data, and the Wensheng graph model can read it accordingly, so there is no need for the user to input the latent space vector.

[0063] It can be obtained that the trained Wensheng graph model contains the image attribute guidance parameters obtained by performing model training based on multiple reference images with common attributes in advance, so that the trained Wensheng graph model performs denoising processing on the input latent space vector according to the input text semantic vector and the image attribute guidance parameters contained in itself, and the process of decoding the denoised latent space vector can be understood as the trained Wensheng graph model generating images under the guidance of the common attributes between the guiding text and multiple reference images. Therefore, only multiple reference images with common attributes are needed to train the Wensheng graph model, so that the trained Wensheng graph model can obtain the image attribute guidance parameters corresponding to the common attributes, without collecting a large number of images and consuming a large amount of computing resources for model training, thereby making the application of the Wensheng graph model more convenient.

[0064] See also Figure 3 , Figure 3 The figure shows the different model effects obtained by using multiple reference images with different common attributes to perform training on the model. Figure 3 In the table shown, the first four columns are four reference images with common attributes. It should be noted that in practical applications, the number of reference images is not limited. Each row of images in the fifth column is generated by the trained Wensheng graph model after the model training is performed using the four reference images in the same row. Figure 3 It can be seen that the first four reference pictures in the first row of the table are all in the stick figure style, and the pictures generated by the trained Vincent graph model are also in the stick figure style; the first four reference pictures in the second row of the table are all in the watercolor style, and the pictures generated by the trained Vincent graph model are also in the watercolor style. Figure 3 The content shown can illustrate that the embodiments of the present application can perform training of the Vincent graph model by using multiple reference images with common attributes, so that the trained Vincent graph model can generate images with this common attribute, and there is no need to collect a large number of images and consume a large amount of computing resources for model training, thereby making the application of the Vincent graph model more convenient.

[0065] The structure of the text graph model provided in the embodiment of the present application is introduced in more detail below.

[0066] See also Figure 4 , Figure 4The figure shows the schematic diagram of the reasoning process of the trained Wensheng graph model. Figure 4 As shown in FIG, in the trained Wensheng graph model, each denoising sub-block in the denoising network is composed of a sampling network layer, a self-attention network layer, a cross-attention network layer and an attribute cross-attention network layer connected in sequence.

[0067] The sampling network layer is used to perform feature sampling on the input feature vector, thereby realizing feature mapping. However, there is a certain difference between the sampling network layer located in the encoder part and the sampling network layer located in the decoder part. The sampling network layer located in the encoder part is used to perform downsampling processing on the input latent space vector, which means compressing the image into a low-resolution image, and the sampling network layer located in the decoder part is used to perform upsampling processing on the input latent space vector, which means decoding the low-resolution image back to a high-resolution image. It should be understood that the denoising network is used to perform denoising processing on the latent space vector that represents the initial noise information corresponding to the image to be generated, so the output signal of each network layer in the denoising network can be regarded as a latent space vector that has been denoised to a certain extent. The sampling network layer can use ResNet (a deep residual network) and the like, which is not restricted here.

[0068] The self-attention layer set between the sampling network layer and the cross-attention network layer can enhance the denoising ability of the denoising network on the latent space vector, thereby making the image content generated by the text-based graph model more refined, thereby improving the quality of image generation.

[0069] The cross-attention network layer is used to perform cross-attention calculations on the text semantic vector and the latent space vector output by the self-attention network layer. This can be understood as a process of denoising the latent space vector based on the guide text.

[0070] The attribute crisscross attention network layer is used to perform crisscross attention calculation on the latent space vector output by the crisscross attention network layer. Figure 4 The dotted content in , which indicates that during the training process of the Wensheng graph model, the common attribute feature vector extracted from multiple reference images with common attributes will be input into the attribute cross-attention network layer in each denoising sub-block, so as to perform cross-attention calculation on the output signal of the upper network and the common attribute feature vector in the attribute cross-attention network, so that each denoising sub-block obtains the image attribute guidance parameter. Therefore, in the trained Wensheng graph model, the attribute cross-attention network layer contains the image attribute guidance parameters corresponding to the common attributes between multiple reference images obtained in the training stage, and the image attribute guidance parameters will participate in the cross-attention calculation performed by the attribute cross-attention network layer, which can be understood as the process of denoising the latent space vector according to the common attribute.

[0071] It is easy to understand that by setting an attribute cross-attention network layer in each denoising sub-block, it is equivalent to setting an attribute concept guidance module in each denoising sub-block. In this attribute concept guidance module, cross-attention calculation is performed on the common attribute concepts extracted by training and the input latent space vector, so as to achieve the generation of the final target image based on the common attribute concept guidance.

[0072] Figure 5 The schematic diagram of the structure of any denoising sub-block contained in the denoising network is shown. Figure 5 As shown, the attribute cross-attention network layer contained in the denoising sub-block is composed of a cross-attention network sub-layer and a self-attention network sub-layer connected in sequence.

[0073] In the model training phase, the latent space vector output by the cross-attention network layer is used as the sentence vector (Query) in the cross-attention network sublayer, and the key vector (Key) and value vector (Value) are obtained after feature reconstruction of the common attribute feature vector, and then the cross-attention calculation is performed on the sentence vector, key vector and value vector, thereby realizing the generation guidance of the common attribute feature vector on the latent space vector. In addition, the latent space vector output by the cross-attention network sublayer is also input into the self-attention network sublayer to perform self-attention calculation, which can better integrate the features related to the common attributes in the latent space variables, thereby further improving the accuracy of image generation.

[0074] In the inference application stage of the trained text-based graph model, since the cross-attention network sublayer has obtained the image attribute guidance parameters corresponding to the common attributes between multiple reference images during the training stage, the final target image can be generated under the guidance of the guidance text and this common attribute.

[0075] Figure 6 The schematic diagram shows the structure of any attribute extraction sub-block contained in the image attribute extraction network. Figure 6 As shown, the attribute extraction sub-block includes a feature mapping network layer, a first self-attention network layer and a second self-attention network layer connected in sequence.

[0076] The feature mapping network layer is used to perform feature mapping on the input basic feature vector in a high semantic dimension. It can be understood that the basic feature vector refers to the feature vector output by the previous attribute extraction sub-block. If the current attribute extraction sub-block is the first attribute extraction sub-block, the basic feature vector is the feature vector extracted from the basic image through the feature encoding network.

[0077] The mapped feature vector is input into the first self-attention network layer as the sentence vector, key vector and value vector to perform self-attention calculation to achieve the fusion of its own semantics.

[0078] After the conditional image is extracted by the feature encoding network to obtain a feature vector, the feature vector is input into the feature mapping network layer for feature mapping on a high semantic dimension. The mapped feature vector is input into the second self-attention network layer as a key vector and a value vector, and the feature vector output by the first self-attention network layer is input into the second self-attention network layer as a sentence vector, so that self-attention calculation is performed on the sentence vector, the key vector, and the value vector in the second self-attention network layer. The process of outputting the feature vector from the second self-attention network layer is to purify the common attributes in the basic image and the conditional image and integrate the common attributes into the feature vector.

[0079] It is understandable that in order to make the image attribute extraction network compatible with the backbone network (i.e., denoising network) of the Wensheng graph model and not require additional training, the attribute extraction sub-block in the image attribute extraction network can be constructed based on the denoising sub-block in the denoising network. Specifically, the feature mapping network layer contained in the attribute extraction sub-block has the same network structure as the sampling network layer in the denoising sub-block, the first self-attention network layer contained in the attribute extraction sub-block has the same network structure as the self-attention network layer in the denoising sub-block, and the second self-attention network layer contained in the attribute extraction sub-block has the same network structure as the self-attention network sub-layer in the denoising sub-block.

[0080] Therefore, the image attribute extraction network can automatically expand the number of attribute extraction sub-blocks according to the number of reference images, and connect them in sequence, so as to calculate the common attributes between multiple reference images as a guide for attribute concepts in the image generation process. In each attribute extraction sub-block, there will also be multiple layers of network layers for feature extraction and fusion. Through this multi-layer mechanism, reference images can be input into the image attribute extraction network multiple times, so that the image attribute extraction network can extract the common attribute concepts contained in multiple reference images at a deeper level, further improving the accuracy of attribute concept extraction.

[0081] Based on the structure of the above-mentioned text graph model, the embodiment of the present application also proposes a method for generating an image. Figure 7 , Figure 7 is a flowchart of a method for generating an image according to an exemplary embodiment of the present application, which can be applied to Figure 1 The implementation environment shown, for example, can be specifically executed by the server 120, can also be specifically executed by the terminal 110, or can be jointly executed by the terminal 110 and the server 120. Of course, the method can also be applied to other implementation environments, and can be executed by a terminal or a server in other implementation environments, or can be jointly executed by a terminal and a server in other implementation environments, and this embodiment is not limited thereto.

[0082] like Figure 7As shown, in an exemplary embodiment, the picture generation method includes S710-S740, which are described in detail as follows:

[0083] S710, obtaining a guide text for guiding the generation of an image, and a latent space vector for representing initial noise information corresponding to the image to be generated.

[0084] First of all, it should be noted that the image generation method provided in this embodiment is proposed based on the trained Wensheng graph model. Therefore, the image generation method provided in this embodiment can also be understood as the reasoning application process of the trained Wensheng graph model.

[0085] The trained text-based graph model needs to perform denoising on the input latent space vector representing the initial noise information corresponding to the image to be generated based on the input guidance text used to guide the generation of the image and the image attribute guidance parameters contained in the model. Therefore, in the inference application process of the trained text-based graph model, it is necessary to obtain the corresponding guidance text and latent space vector. The latent space vector representing the initial noise information corresponding to the image to be generated can be generated by random initialization based on a seed.

[0086] S720, performing semantic extraction on the guide text to obtain a text semantic vector.

[0087] In this embodiment, semantic extraction can be performed on the guide text through a text encoding network to obtain a text semantic vector. The text encoding network can be a network structure contained in the trained text graph model itself, or a network structure other than the trained text graph model, which is not limited here.

[0088] S730, inputting the text semantic vector and the latent space vector into the trained text graph model, wherein the trained text graph model includes image attribute guidance parameters, and the image attribute guidance parameters are obtained by training the pre-trained text graph model with multiple reference images having common attributes.

[0089] The pre-trained Wensheng graph model does not have image attribute guidance parameters for guiding the generation of images. By training the pre-trained Wensheng graph model with multiple reference images with common attributes, the trained Wensheng graph model can obtain image attribute guidance parameters related to the common attributes.

[0090] In this embodiment, the text semantic vector and the latent space vector are input into the trained text graph model, so that the trained text graph model performs denoising on the latent space vector according to the text semantic vector and the image attribute guidance parameters, and decodes the denoised latent space vector to output the corresponding target image.

[0091] Exemplarily, the trained Wensheng graph model and the pre-trained Wensheng graph model both include a denoising network and a decoding network. In the trained Wensheng graph model, the denoising network is used to denoise the input latent space vector according to the input text semantic vector and the image attribute guidance parameters contained in it, and the decoding network is used to decode the denoised latent space vector output by the denoising network to obtain the generated target image. In the pre-trained Wensheng graph model, the denoising network is used to denoise the input latent space vector according to the input text semantic vector and the input common attribute feature vector, and the decoding network is used to decode the noisy latent space vector output by the denoising network to obtain the training generated image. Through this training process, the denoising network can obtain the image attribute guidance parameters, thereby obtaining the trained Wensheng graph model.

[0092] The denoising network includes a plurality of denoising sub-blocks connected in sequence, and each denoising sub-block includes a sampling network layer, a self-attention network layer, a cross-attention network layer, and an attribute cross-attention network layer connected in sequence. The attribute cross-attention network layer contains image attribute guidance parameters. Thus, the latent space vector is specifically input into the sampling network layer in the first denoising sub-block, and the text semantic vector is respectively input into the cross-attention network sub-layer in each denoising sub-block to perform denoising processing on the latent space vector in the denoising network.

[0093] Exemplarily, the attribute cross-attention network layer includes an attribute cross-attention sublayer and a self-attention network sublayer connected in sequence. In the attribute cross-attention sublayer, the output signal of the cross-attention network layer is used as a sentence vector, and the image attribute guidance parameters are reflected as parameters related to the key vector and the value vector. The cross-attention calculation is performed according to the sentence vector, the key vector and the value vector. The obtained output signal reflects the image attribute guidance parameters obtained in the training phase, and the latent space vector output by the cross-attention network is further denoised, thereby achieving guidance for image generation based on the common attributes of multiple reference images. The latent space variables output by the attribute cross-attention sublayer are also input into the self-attention network sublayer to perform self-attention calculations, so that the attribute concept-related representations that have been integrated into the latent space vector can be better integrated, and then act to generate more refined image content, which can improve the quality of the generated target image.

[0094] It should be understood that the denoising network mentioned in this embodiment is used to perform denoising processing on the latent space vector representing the initial noise information corresponding to the image to be generated. Therefore, the output signal of each network layer in the denoising network can be regarded as a latent space vector that has been denoised to a certain extent.

[0095] S740, receiving a target image output by the trained text-based graph model, where the target image is obtained by denoising the latent space vector according to the text semantic vector and the image attribute guidance parameter, and decoding the denoised latent space vector.

[0096] Since the target image is obtained by denoising the latent space vector according to the text semantic vector and the image attribute guidance parameters and decoding the denoised latent space vector, the target image output by the trained text-based graph model matches the guidance text and has the common attributes of multiple reference images input in the training phase.

[0097] It can be obtained that in the image generation method provided in this embodiment, the trained Wensheng graph model contains the image attribute guidance parameters obtained by performing model training in advance based on multiple reference images with common attributes, so that the trained Wensheng graph model performs denoising processing on the input latent space vector according to the input text semantic vector and the image attribute guidance parameters contained in itself, and the process of decoding the denoised latent space vector can be understood as the trained Wensheng graph model generating images under the guidance of the common attributes between the guiding text and multiple reference images. Therefore, only multiple reference images with common attributes are needed to train the Wensheng graph model before training, so that the trained Wensheng graph model can obtain the image attribute guidance parameters corresponding to the common attributes, without collecting a large number of images and consuming a large amount of computing resources for model training, thereby making the application of the Wensheng graph model more convenient.

[0098] Based on the structure of the text graph model provided above, the embodiment of the present application also proposes a text graph model training method. Figure 8 As shown, Figure 8 is a flowchart of a method for training a text graph model according to an exemplary embodiment of the present application, which can be applied to Figure 1 The implementation environment shown, for example, can be specifically executed by the server 120, can also be specifically executed by the terminal 110, or can be jointly executed by the terminal 110 and the server 120. Of course, the method can also be applied to other implementation environments, and can be executed by a terminal or a server in other implementation environments, or can be jointly executed by a terminal and a server in other implementation environments, and this embodiment is not limited thereto.

[0099] This embodiment performs training on a pre-trained Wensheng graph model to obtain a trained Wensheng graph model. The pre-trained Wensheng graph model includes a picture attribute extraction network, a denoising network, and a decoding network. The picture attribute extraction network is used to extract a common attribute feature vector for a plurality of reference pictures with a common attribute, and input the extracted common attribute feature vector into the denoising network, so that the denoising network in the trained Wensheng graph model obtains a picture attribute guide parameter corresponding to the common attribute.

[0100] like Figure 8 As shown, in an exemplary embodiment, the method for training a cultural graph model includes S810-S840, which are described in detail as follows:

[0101] S810, obtaining a sample semantic vector corresponding to the guide text sample and a plurality of reference images having common attributes.

[0102] In the process of training the pre-trained text-based graph model, it is necessary to input a guide text sample for guiding the generation of an image, and a plurality of reference images with common attributes, and obtain a text semantic vector corresponding to the guide text sample.

[0103] S820, extracting common attribute feature vectors between multiple reference images with common attributes through an image attribute extraction network.

[0104] The image attribute extraction network includes a plurality of attribute extraction sub-blocks connected in sequence, each of which is used to extract common attribute concept representations between images. Exemplarily, a plurality of attribute extraction sub-blocks connected in sequence can be generated according to the number of reference images to obtain the image attribute extraction network.

[0105] In this embodiment, a reference picture can be selected from multiple reference pictures with common attributes as a basic picture, and other reference pictures can be used as conditional pictures. The basic picture and the conditional picture can be respectively input into the picture attribute extraction network to obtain a common attribute feature vector output by the picture attribute extraction network.

[0106] Exemplarily, a corresponding number of attribute extraction sub-blocks connected in sequence can be generated according to the number of conditional images to obtain an image attribute extraction network. The base image and one of the images are input into the first attribute extraction sub-block to perform the extraction of common attribute concept representations. Each of the other attribute extraction sub-blocks will input a conditional image accordingly to perform the extraction of common attribute concept representations for the feature vector output by the previous attribute extraction sub-block and the currently input conditional image. Therefore, through this multi-layer mechanism, the common attribute concepts contained in multiple reference images can be extracted at a deeper level, thereby further improving the accuracy of attribute concept extraction.

[0107] Each attribute extraction sub-block includes a feature mapping network layer, a first self-attention network layer, and a second self-attention network layer connected in sequence. The feature mapping network layer is used to perform feature mapping on the input feature vector in a high semantic dimension.

[0108] Exemplarily, the image attribute extraction network also includes multiple feature encoding networks, which are used to extract feature vectors related to the image, and each attribute sub-block is connected to at least one feature encoding network. Therefore, this embodiment inputs the basic image into the feature encoding network layer connected to the first attribute extraction sub-block, and inputs each conditional image into the feature encoding network layer connected to different attribute extraction sub-blocks.

[0109] Exemplarily, the feature encoding network for inputting the base image is connected to the feature mapping network layer in the first attribute extraction sub-block, and the feature encoding network for inputting the conditional image is connected to the second self-attention network layer in the attribute extraction sub-block. It can also be understood that the feature vector corresponding to the conditional image participates in the calculation related to the extraction of the common attribute concept in the second self-attention network layer.

[0110] Exemplarily, in the attribute extraction sub-block, the feature mapping network layer is connected to a feature encoding network, and the second self-attention network layer is also connected to a feature encoding network. The two feature encoding networks can be the same network or different networks.

[0111] In the second self-attention network, the output signal of the first self-attention network layer is used as the sentence vector, and the key vector and value vector are extracted from the feature vector corresponding to the input conditional image, and self-attention calculation is performed based on the sentence vector, key vector and value vector, thereby realizing the extraction of common attribute concept representations between the input basic image and the conditional image.

[0112] This embodiment extracts common attribute feature vectors from multiple reference images with common attributes, and inputs the common attribute feature vectors into a denoising network as conceptual attribute guidance for generating images. This can make the extracted conceptual attribute guidance more accurate, thereby greatly improving the generation accuracy of the attribute concepts in the final generated image.

[0113] S830, inputting the latent space vector, the sample semantic vector and the common attribute feature vector used to characterize the initial noise information corresponding to the image to be generated into the denoising network.

[0114] The denoising network includes a plurality of denoising sub-blocks connected in sequence, and each denoising sub-block includes a sampling network layer, a self-attention network layer, a cross-attention network layer, and an attribute cross-attention network layer connected in sequence.

[0115] In this embodiment, the latent space vector is input into the sampling network layer in the first denoising sub-block, and the sample semantic vector is input into the cross-attention network layer in each denoising sub-block, and the common attribute feature vector is input into the attribute cross-attention network layer in each denoising sub-block. Thus, the attribute cross-attention network layer is equivalent to providing image generation guidance related to the attribute concept. By performing model training, the attribute cross-attention network layer can obtain image attribute guidance parameters related to the common attributes.

[0116] Exemplarily, the attribute cross-attention network layer includes an attribute cross-attention sublayer and a self-attention network sublayer connected in sequence. In the attribute cross-attention sublayer, the output signal of the cross-attention network layer is used as a sentence vector, and a key vector and a value vector are extracted from the input common attribute feature vector, so as to perform cross-attention calculation based on the sentence vector, the key vector and the value vector, thereby achieving guidance of image generation based on common attributes.

[0117] S840, according to the sample semantic vector and the common attribute feature vector, the latent space vector is denoised in the denoising network to obtain the denoised latent space vector, and the denoised latent space vector is decoded through the decoding network, and the training generated image is output, so that the denoising network obtains the image attribute guidance parameters corresponding to the common attributes, and the trained text graph model is obtained.

[0118] The denoising process performed by the denoising network can be understood as a process of guiding the generation of images based on the guide text sample and multiple reference images with common attributes. Therefore, in the training generated image obtained by decoding the denoised latent space vector output by the denoising network, it not only matches the text content described by the guide text, but also has the common attribute.

[0119] By executing the above training process, the denoising network can obtain the image attribute guidance parameters corresponding to the common attribute. Therefore, the solution of extracting and transferring guidance through concept attributes proposed in this embodiment can support the direct migration of any desired concept attributes under limited data, without the need for additional concept attribute embedding model training, thereby increasing the ease of use of the entire model and significantly reducing the cost of generating specified attribute concept images.

[0120] The image generation method and the text graph model training method proposed in the embodiment of the present application can be implemented in different application scenarios according to actual application requirements. For example, the application scenario of art poster creation, especially the continuation of the style of famous artists, personalized AI (Artificial Intelligence) image generation scenario, game production and peripheral production scenarios, etc., are not listed here one by one.

[0121] For example, if a user wants to create a new portrait based on the style of Van Gogh, the user only needs to collect a few paintings of Van Gogh, input them into the pre-trained Vincent graph model, and input the guide text of the image content that he wants to generate. The pre-trained Vincent graph model can automatically output a picture with a consistent style and the desired content based on the provided styles. In other words, when the pre-trained Vincent graph model is trained using several pre-collected Van Gogh paintings, the art picture that the user wants to create can be obtained, and the trained Vincent graph model can be obtained. If you want to continue to generate Van Gogh-style pictures later, you only need to input the corresponding guide text into the trained Vincent graph model, and the trained Vincent graph model can automatically generate Van Gogh-style pictures that match the picture content described by the guide text.

[0122] If the user wants to obtain an AI image of his own with a specific style, he only needs to input a few of his own selfies into the pre-trained Wenshengtu model, and input the guide text used to describe the style type of the image he wants to generate. The pre-trained Wenshengtu model can automatically extract the user's appearance attributes based on the user's selfies, and then when generating a personalized AI image, the extracted appearance attributes can be integrated into the generated image, thereby obtaining an AI image of the user with a specific style and a trained Wenshengtu model. Similarly, if you want to continue to generate your own AI image in the future, you don't need to pass in the user's selfies. You only need to input the corresponding guide text into the trained Wenshengtu model, and the trained Wenshengtu model can automatically generate the user's own AI image that matches the style type described by the guide text.

[0123] In the game production and peripheral production scenes, the original artist of the game character image can input several pictures of the same game character image into the pre-trained Wenshengtu model, and the pre-trained Wenshengtu model can automatically extract the attribute concept of the game character image, and combine the input guide text used to describe the game style or game scene to generate the game character image picture of the corresponding game style or game scene, and obtain the trained Wenshengtu model. Subsequently, you only need to input the guide text describing the desired game style or game scene into the trained Wenshengtu model, and the trained game style or game scene can automatically output the game character image picture of the corresponding game style or game scene.

[0124] It can be concluded that in the embodiment of the present application, during the model training phase, common attribute concepts are extracted from multiple images with common attributes, and then the extracted attribute concepts are merged with the text content described by the guide text, thereby automatically generating images that conform to both the guide text and the common attributes. The trained text graph model obtains the common attribute concepts extracted during the training phase, so it can be directly generated based on the input guide, and combined with the extracted common attribute concepts, to automatically generate images that conform to both the guide text and the common attributes. Therefore, the training phase of the text graph model does not require the collection of a large number of images for training, which increases the ease of use of the text graph model and greatly reduces the image generation cost of the specified attribute concept.

[0125] See also Fig. 9 , Fig. 9 is a block diagram of an image generation device shown in an exemplary embodiment of the present application. The image generation device includes:

[0126] An acquisition module 910 is configured to acquire a guide text for guiding the generation of an image, and a latent space vector for representing initial noise information corresponding to the image to be generated;

[0127] An extraction module 920 is configured to perform semantic extraction on the guide text to obtain a text semantic vector;

[0128] An input module 930 is configured to input the text semantic vector and the latent space vector into a trained text graph model, wherein the trained text graph model includes image attribute guidance parameters, and the image attribute guidance parameters are obtained by training the pre-trained text graph model with multiple reference images having common attributes;

[0129] The receiving module 940 is configured to receive a target image output by the trained text graph model; wherein the target image is obtained by denoising the latent space vector according to the text semantic vector and the image attribute guidance parameter, and decoding the denoised latent space vector.

[0130] In another exemplary embodiment, the trained Vincent graph model and the pre-trained Vincent graph model both include a denoising network and a decoding network;

[0131] The denoising network includes a plurality of denoising sub-blocks connected in sequence, each denoising sub-block includes a sampling network layer, a self-attention network layer, a cross-attention network layer and an attribute cross-attention network layer connected in sequence; the attribute cross-attention network layer contains the image attribute guidance parameters;

[0132] The input module 930 is further configured to: input the latent space vector to the sampling network layer in the first denoising sub-block, and input the text semantic vector to the cross-attention network sub-layer in each denoising sub-block respectively.

[0133] In another exemplary embodiment, the apparatus further includes a training module, and the training module is configured to train the pre-trained Wensheng graph model through the following steps to obtain a trained Wensheng graph model:

[0134] Obtain the sample semantic vector corresponding to the guide text sample and multiple reference images with common attributes;

[0135] Extracting common attribute feature vectors between multiple reference images with common attributes;

[0136] Input the latent space vector into the sampling network layer in the first denoising sub-block, input the sample semantic vector into the cross-attention sub-network layer in each denoising sub-block, and input the common attribute feature vector into the attribute cross-attention network layer in each denoising sub-block;

[0137] By denoising the latent space vector in the pre-trained Wensheng graph model and decoding the denoised latent space vector, the training generated image is output, so that the attribute cross-attention network layer in each denoising sub-block obtains the image attribute guidance parameter, and the trained Wensheng graph model is obtained.

[0138] Fig.10 : is a block diagram of a Wensheng graph model training device shown in an exemplary embodiment of the present application. The Wensheng graph model before training includes an image attribute extraction network, a denoising network and a decoding network. The Wensheng graph model training device includes:

[0139] The sample acquisition module 1010 is configured to acquire a sample semantic vector corresponding to a guide text sample and a plurality of reference images having common attributes;

[0140] The attribute extraction module 1020 is configured to extract common attribute feature vectors between multiple reference images having common attributes through an image attribute extraction network;

[0141] An information input module 1030 is configured to input a latent space vector, a sample semantic vector, and a common attribute feature vector for representing initial noise information corresponding to the image to be generated into a denoising network;

[0142] The model processing module 1040 is configured to perform denoising processing on the latent space vector in the denoising network according to the sample semantic vector and the common attribute feature vector to obtain the denoised latent space vector, and decode the denoised latent space vector through the decoding network, and output the training generated image so that the denoising network obtains the image attribute guidance parameters corresponding to the common attributes to obtain the trained text graph model; wherein the training generated image has the common attributes and matches the guidance text.

[0143] In another exemplary embodiment, the denoising network includes a plurality of denoising sub-blocks connected in sequence, each denoising sub-block includes a sampling network layer, a self-attention network layer, a cross-attention network layer, and an attribute cross-attention network layer connected in sequence; the information input module 1030 is further configured as follows:

[0144] The latent space vector, sample semantic vector and common attribute feature vector used to represent the initial noise information corresponding to the image to be generated are input into the denoising network, including:

[0145] The latent space vector is input into the sampling network layer in the first denoising sub-block, the sample semantic vector is input into the cross-attention network layer in each denoising sub-block, and the common attribute feature vector is input into the attribute cross-attention network layer in each denoising sub-block, so that the attribute cross-attention network layer in each denoising sub-block obtains the image attribute guidance parameter.

[0146] In another exemplary embodiment, the attribute cross-attention network layer includes an attribute cross-attention sublayer and a self-attention network sublayer connected in sequence; the attribute extraction module 1020 is further configured to perform the following steps in the attribute cross-attention sublayer in each denoising sub-block:

[0147] The output signal of the cross-attention network layer is used as the sentence vector, and the key vector and value vector are extracted from the common attribute feature vector;

[0148] Cross-attention calculation is performed based on sentence vector, key vector and value vector.

[0149] In another exemplary embodiment, the pre-trained text graph model further includes an image attribute extraction network, and the image attribute extraction network includes a plurality of attribute extraction sub-blocks connected in sequence; the attribute extraction module 1020 is further configured as follows:

[0150] Select a reference image from multiple reference images with common attributes as a base image, and use the other reference images as conditional images;

[0151] The base image is input into the first attribute extraction sub-block, and a conditional image is input into each attribute extraction sub-block respectively, so as to obtain the common attribute feature vector output by the image attribute extraction network.

[0152] In another exemplary embodiment, the attribute extraction module 1020 is further configured to: generate a corresponding number of sequentially connected attribute extraction sub-blocks according to the number of conditional pictures, so as to obtain a picture attribute extraction network.

[0153] In another exemplary embodiment, the image attribute extraction network also includes multiple feature encoding networks, and each attribute extraction sub-block is connected to at least one feature encoding network; the feature encoding network is used to perform feature encoding processing on the input basic image or conditional image, and output the obtained feature vector to the connected attribute extraction sub-block.

[0154] In another exemplary embodiment, each attribute extraction sub-block includes a feature mapping network layer, a first self-attention network layer, and a second self-attention network layer connected in sequence; the feature encoding network for inputting the basic image is connected to the feature mapping network layer in the first attribute extraction sub-block; and the feature encoding network for inputting the conditional image is connected to the second self-attention network layer in the attribute extraction sub-block.

[0155] In another exemplary embodiment, the attribute extraction module 1020 is further configured to perform the following steps in the second self-attention network layer in each attribute extraction sub-block:

[0156] The output signal of the first self-attention network layer is used as the sentence vector, and the key vector and value vector are extracted from the feature vector corresponding to the input conditional image;

[0157] Self-attention calculation is performed based on sentence vector, key vector and value vector.

[0158] In another exemplary embodiment, the feature mapping network layer contained in the attribute extraction sub-block has the same network structure as the sampling network layer in the denoising sub-block, the first self-attention network layer contained in the attribute extraction sub-block has the same network structure as the self-attention network layer in the denoising sub-block, and the second self-attention network layer contained in the attribute extraction sub-block has the same network structure as the self-attention network sub-layer in the denoising sub-block.

[0159] It should be noted that the device provided in the above embodiment and the method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs the operation has been described in detail in the method embodiment and will not be repeated here. In practical applications, the image generation device or the text graph model training device provided in the above embodiment can distribute the above functions to different functional modules as needed, that is, divide the internal structure of the device into different functional modules to complete all or part of the functions described above, and this is not limited here.

[0160] An embodiment of the present application also provides an electronic device, including: one or more processors; a memory for storing one or more computer programs, when the one or more computer programs are executed by the one or more processors, the electronic device implements the image generation method or the text graph model training method provided in the above-mentioned embodiments.

[0161] Fig.11 The structure diagram of the computer system of the electronic device suitable for implementing the embodiment of the present application is shown. It should be noted that the electronic device can be Figure 1 The terminal 110 or server 120 in the implementation environment shown may also be a terminal or server in other implementation environments, and is not limited here. It should also be noted that Fig.11 The computer system 1100 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0162] like Fig.11 As shown, the computer system 1100 includes a central processing unit (CPU) 1101, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 1102 or a computer program loaded from a storage part 1108 to a random access memory (RAM) 1103, such as executing the method described in the above embodiment. Various computer programs and data required for system operation are also stored in RAM 1103. CPU 1101, ROM 1102 and RAM 1103 are connected to each other via a bus 1104. An input / output (I / O) interface 1105 is also connected to the bus 1104.

[0163] The following components are connected to the I / O interface 1105: an input section 1106 including a keyboard, a mouse, etc.; an output section 1107 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1108 including a hard disk, etc.; and a communication section 1109 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 1109 performs communication processing via a network such as the Internet. A drive 1110 is also connected to the I / O interface 1105 as needed. A removable medium 1111, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1110 as needed so that a computer program read therefrom is installed into the storage section 1108 as needed.

[0164] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1109, and / or installed from the removable medium 1111. When the computer program is executed by the central processing unit (CPU) 1101, various functions defined in the system of the present application are executed.

[0165] It should be noted that the computer-readable medium shown in the embodiment of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. A more specific example of a computer-readable storage medium may include, but is not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. The computer program contained in the computer-readable medium may be transmitted with any suitable medium, including but not limited to: wireless, wired, etc., or any suitable combination thereof.

[0166] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0167] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.

[0168] Another aspect of the present application further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor of an electronic device, implements the above-described image generation method or text graph model training method. The computer-readable storage medium may be included in the electronic device described in the above embodiment, or may exist independently without being assembled into the electronic device.

[0169] Another aspect of the present application further provides a computer program product, which includes a computer program stored in a computer-readable storage medium. A processor of an electronic device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the electronic device executes the image generation method or the text image model training method provided in each of the above embodiments.

[0170] The above content is only a preferred exemplary embodiment of the present application and is not intended to limit the implementation scheme of the present application. A person skilled in the art can easily make corresponding changes or modifications based on the main concept and spirit of the present application. Therefore, the scope of protection of the present application shall be based on the scope of protection required by the claims.

[0171] It is understandable that in the specific implementation of this application, related data such as guide texts and reference pictures are involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.

Claims

1. A method for generating an image, characterized in that: The method comprises: Obtaining a guide text for guiding the generation of an image and a latent space vector for representing initial noise information corresponding to the image to be generated; Performing semantic extraction on the guide text to obtain a text semantic vector; Inputting the text semantic vector and the latent space vector into a trained Vincent graph model, wherein the trained Vincent graph model includes image attribute guidance parameters, and the image attribute guidance parameters are obtained by training the pre-trained Vincent graph model with multiple reference images having common attributes; A target image output by the trained text graph model is received, wherein the target image is obtained by denoising the latent space vector according to the text semantic vector and the image attribute guidance parameter, and decoding the denoised latent space vector.

2. The method according to claim 1, characterized in that The trained Vincent graph model and the pre-trained Vincent graph model both include a denoising network and a decoding network; The denoising network includes a plurality of denoising sub-blocks connected in sequence, each denoising sub-block includes a sampling network layer, a self-attention network layer, a cross-attention network layer and an attribute cross-attention network layer connected in sequence; The attribute cross attention network layer contains the image attribute guidance parameters; Inputting the text semantic vector and the latent space vector into the trained text graph model includes: The latent space vector is input into the sampling network layer in the first denoising sub-block, and the text semantic vector is input into the cross-attention network sub-layer in each denoising sub-block respectively.

3. The method according to claim 2, characterized in that The pre-trained Wensheng graph model is trained through the following steps to obtain the trained Wensheng graph model: Obtain the sample semantic vector corresponding to the guide text sample and multiple reference images with common attributes; Extracting common attribute feature vectors between the plurality of reference pictures having common attributes; Input the latent space vector into the sampling network layer in the first denoising sub-block, input the sample semantic vector into the cross-attention sub-network layer in each denoising sub-block, and input the common attribute feature vector into the attribute cross-attention network layer in each denoising sub-block; The trained Vincent graph model is obtained by denoising the latent space vector in the pre-trained Vincent graph model, decoding the denoised latent space vector, and outputting the training generated image so that the attribute cross-attention network layer in each denoised sub-block obtains the image attribute guidance parameter.

4. The method according to claim 3, characterized in that The attribute cross-attention network layer includes an attribute cross-attention sublayer and a self-attention network sublayer connected in sequence; The following steps are performed in the attribute cross-attention sublayer in each denoising sub-block: Using the output signal of the cross-attention network layer as a sentence vector, and extracting a key vector and a value vector from the common attribute feature vector; A cross attention calculation is performed based on the sentence vector, the key vector and the value vector.

5. The method according to claim 3, characterized in that: The pre-trained text graph model also includes a picture attribute extraction network, and the picture attribute extraction network includes a plurality of attribute extraction sub-blocks connected in sequence; Extracting common attribute feature vectors between the plurality of reference pictures having common attributes includes: Selecting a reference picture from the plurality of reference pictures having a common attribute as a base picture, and using the other reference pictures as conditional pictures; The basic image is input into the first attribute extraction sub-block, and a conditional image is input into each attribute extraction sub-block respectively, so as to obtain the common attribute feature vector output by the image attribute extraction network.

6. The method according to claim 5, characterized in that The method further comprises: According to the number of the conditional pictures, a corresponding number of sequentially connected attribute extraction sub-blocks are generated to obtain the picture attribute extraction network.

7. The method according to claim 5, characterized in that The image attribute extraction network also includes multiple feature encoding networks, and each attribute extraction sub-block is connected to at least one feature encoding network; the feature encoding network is used to perform feature encoding processing on the input basic image or conditional image, and output the obtained feature vector to the connected attribute extraction sub-block.

8. The method according to claim 7, characterized in that Each attribute extraction sub-block includes a feature mapping network layer, a first self-attention network layer and a second self-attention network layer connected in sequence; the feature encoding network for inputting the basic image is connected to the feature mapping network layer in the first attribute extraction sub-block; the feature encoding network for inputting the conditional image is connected to the second self-attention network layer in the attribute extraction sub-block.

9. The method according to claim 8, characterized in that The following steps are performed in the second self-attention network layer in each attribute extraction sub-block: The output signal of the first self-attention network layer is used as a sentence vector, and a key vector and a value vector are extracted from the feature vector corresponding to the input conditional image; A self-attention calculation is performed based on the sentence vector, the key vector, and the value vector.

10. A method for training a text graph model, characterized in that: The pre-trained text graph model includes a picture attribute extraction network, a denoising network and a decoding network, and the method includes: Obtain the sample semantic vector corresponding to the guide text sample and multiple reference images with common attributes; Extracting common attribute feature vectors between the plurality of reference images having common attributes through the image attribute extraction network; Inputting the latent space vector for representing the initial noise information corresponding to the image to be generated, the sample semantic vector and the common attribute feature vector into the denoising network; According to the sample semantic vector and the common attribute feature vector, the latent space vector is denoised in the denoising network to obtain a denoised latent space vector, and the denoised latent space vector is decoded by the decoding network to output a training generated image, so that the denoising network obtains image attribute guidance parameters corresponding to the common attributes to obtain a trained Wensheng graph model.

11. The method according to claim 10, characterized in that The denoising network includes a plurality of denoising sub-blocks connected in sequence, each denoising sub-block includes a sampling network layer, a self-attention network layer, a cross-attention network layer and an attribute cross-attention network layer connected in sequence; Inputting the latent space vector for representing the initial noise information corresponding to the to-be-generated picture, the sample semantic vector and the common attribute feature vector into the denoising network includes: The latent space vector is input into the sampling network layer in the first denoising sub-block, and the sample semantic vector is input into the cross-attention network layer in each denoising sub-block, and the common attribute feature vector is input into the attribute cross-attention network layer in each denoising sub-block.

12. A picture generating device, characterized in that: The device comprises: An acquisition module configured to acquire a guide text for guiding the generation of an image, and a latent space vector for representing initial noise information corresponding to the image to be generated; An extraction module, configured to perform semantic extraction on the guide text to obtain a text semantic vector; An input module configured to input the text semantic vector and the latent space vector into a trained Vincent graph model, wherein the trained Vincent graph model includes image attribute guidance parameters, and the image attribute guidance parameters are obtained by training the pre-trained Vincent graph model with multiple reference images having common attributes; A receiving module is configured to receive a target image output by the trained text graph model; wherein the target image is obtained by denoising the latent space vector according to the text semantic vector and the image attribute guidance parameter, and decoding the denoised latent space vector.

13. A device for training a text graph model, characterized in that: The pre-trained text graph model includes a picture attribute extraction network, a denoising network and a decoding network, and the device includes: A sample acquisition module, configured to acquire a sample semantic vector corresponding to a guide text sample and a plurality of reference images having common attributes; an attribute extraction module, configured to extract common attribute feature vectors between the plurality of reference images having common attributes through the image attribute extraction network; An information input module, configured to input a latent space vector for representing initial noise information corresponding to the image to be generated, the sample semantic vector and the common attribute feature vector into the denoising network; The model processing module is configured to perform denoising on the latent space vector in the denoising network according to the sample semantic vector and the common attribute feature vector to obtain a denoised latent space vector, and decode the denoised latent space vector through the decoding network, and output a training generated image so that the denoising network obtains image attribute guidance parameters corresponding to the common attribute to obtain a trained Wensheng graph model.

14. An electronic device, characterized in that: include: one or more processors; A memory for storing one or more computer programs, which, when executed by the one or more processors, enables the electronic device to implement the method as described in any one of claims 1-9 or 10-11.

15. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor of an electronic device, the electronic device is caused to execute the method described in any one of claims 1-9 or 10-11.

16. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor of an electronic device, the method as described in any one of claims 1-9 or 10-11 is implemented.

Citation Information

Cited By

  • Method and system for temporally consistent concept-guided video generation

    GB2704944A