Figure graph model training method and device

By constructing a training data set and combining the CLIP network and the VAE network to train the Vincentian graph model, the problem of the images generated by the Vincentian graph model not meeting expectations was solved and the quality of the generated images was improved.

CN118569320AActive Publication Date: 2024-08-30北京衔远有限公司

Patent Information

Application Number
CN202410731939.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-06
Publication Date
2024-08-30
Estimated Expiration
2044-06-06

AI Technical Summary

Technical Problem

The existing Vincentian graph model cannot stably understand the prompt words when generating images, resulting in abnormal generation results.

Method used

By obtaining the image data set, extracting the description of the person image, constructing a training data set, and constructing multiple LoRA branches for the U-Net network, combined with the text encoder, VAE network and denoising fine-tuning network in the CLIP network, training the Vincent graph model , enabling it to learn character images and image descriptions.

Benefits of technology

The quality of the generated images is improved, and the problem that the images generated by the Chinese image generation model in the prior art are not as expected is solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118569320A
    Figure CN118569320A
Patent Text Reader

Abstract

The invention provides a text graph model training method and device. The method comprises the following steps: acquiring an image data set, and extracting image description of each figure image in the image data set; constructing a first training data set by using each figure image and the image description thereof; segmenting each figure image to obtain a figure face image of each figure image, and constructing a second training data set by using the figure face image of each figure image and the image description; combining the first training data set and the second training data set according to a preset proportion to obtain a third training data set; a plurality of LoRA branches are constructed for the U-Net network to obtain a denoising fine tuning network, and a text encoder in the CLIP network, the VAE network and the denoising fine tuning network are utilized to construct a text graph model; and training the text graph model by using the third training data set, so that the text graph model learns the figure image and the image description. By adopting the technical means, the problem that images generated by a Chinese image generation model in the prior art are not expected is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of machine learning, and in particular to a method and device for training a text graph model. Background Art

[0002] The text-based graph model is a very popular large model at present. The text-based graph model can generate corresponding images based on the input description. However, in practice, it is found that the current text-based graph model cannot stably understand the prompt words, resulting in abnormal image generation results. Summary of the invention

[0003] In view of this, the embodiments of the present disclosure provide a method, device, electronic device and computer-readable storage medium for training a Chinese language graph model to solve the problem that the images generated by the Chinese language graph model in the prior art are not as expected.

[0004] In a first aspect of an embodiment of the present disclosure, a method for training a text-based graph model is provided, including: acquiring an image data set, extracting an image description of each character image in the image data set; constructing a first training data set using each character image and its image description; segmenting each character image to obtain a character facial image of each character image, and constructing a second training data set using the character facial image and the image description of each character image; combining the first training data set and the second training data set according to a preset ratio to obtain a third training data set; constructing multiple LoRA branches for a U-Net network to obtain a denoising fine-tuning network, and constructing a text-based graph model using a text encoder, a VAE network, and a denoising fine-tuning network in a CLIP network; and training the text-based graph model using the third training data set so that the text-based graph model learns the character images and image descriptions.

[0005] According to a second aspect of an embodiment of the present disclosure, a device for training a Wensheng graph model is provided, including: an acquisition module, configured to acquire an image data set, and extract an image description of each character image in the image data set; a first construction module, configured to construct a first training data set using each character image and its image description; a second construction module, configured to segment each character image to obtain a character facial image of each character image, and construct a second training data set using the character facial image and the image description of each character image; a third construction module, configured to combine the first training data set and the second training data set according to a preset ratio to obtain a third training data set; a modeling module, configured to construct multiple LoRA branches for a U-Net network, obtain a denoising fine-tuning network, and construct a Wensheng graph model using a text encoder, a VAE network, and a denoising fine-tuning network in a CLIP network; and a training module, configured to train the Wensheng graph model using the third training data set, so that the Wensheng graph model learns character images and image descriptions.

[0006] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.

[0007] According to a fourth aspect of the embodiments of the present disclosure, a computer-readable storage medium is provided, which stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.

[0008] Compared with the prior art, the disclosed embodiment has the following beneficial effects: obtaining an image data set, extracting the image description of each character image in the image data set; constructing a first training data set using each character image and its image description; segmenting each character image to obtain the character facial image of each character image, and constructing a second training data set using the character facial image and image description of each character image; combining the first training data set and the second training data set in a preset ratio to obtain a third training data set; constructing multiple LoRA branches for the U-Net network to obtain a denoising fine-tuning network, and constructing a text-generated graph model using the text encoder, VAE network, and denoising fine-tuning network in the CLIP network; and training the text-generated graph model using the third training data set so that the text-generated graph model learns the character image and image description. The above technical means can solve the problem that the image generated by the Chinese text-generated graph model in the prior art is not as expected, thereby improving the quality of the generated image. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0010] Figure 1 It is a flowchart of a method for training a text graph model provided by an embodiment of the present disclosure;

[0011] Figure 2 It is a schematic diagram of a process of providing a method for generating a text graph according to an embodiment of the present disclosure;

[0012] Figure 3 It is a structural schematic diagram of a cultural graph model training device provided by an embodiment of the present disclosure;

[0013] Figure 4 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0014] In the following description, specific details such as specific system structures and technologies are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present disclosure. However, it should be clear to those skilled in the art that the present disclosure may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid unnecessary details that hinder the description of the present disclosure.

[0015] A method and device for training a text graph model according to an embodiment of the present disclosure will be described in detail below with reference to the accompanying drawings.

[0016] Figure 1 It is a flowchart of a method for training a text graph model provided by an embodiment of the present disclosure. Figure 1 The Wensheng graph model training method can be executed by a computer or a server, or by software on the computer or the server.

[0017] like Figure 1 As shown, the text graph model training method includes:

[0018] S101, obtaining an image data set, and extracting image descriptions of each person image in the image data set;

[0019] S102, constructing a first training data set using each person image and its image description;

[0020] S103, segmenting each person image to obtain a person's facial image of each person image, and constructing a second training data set using the person's facial image and image description of each person image;

[0021] S104, combining the first training data set and the second training data set according to a preset ratio to obtain a third training data set;

[0022] S105, construct multiple LoRA branches for the U-Net network, obtain a denoising fine-tuning network, and use the text encoder, VAE network and denoising fine-tuning network in the CLIP network to construct a text graph model;

[0023] S106, training the text-graph model using the third training data set, so that the text-graph model learns the person images and image descriptions.

[0024] Each person image in the image dataset is a full-body image of each person. The Multi-Human-Parsing, Semantatic Human Matting and other algorithms can be used to segment each person image to obtain the person's facial image. The person's facial image only contains the person's facial image. Use Image caption tools to extract image descriptions of each person image. For example, GPT (Generative Pre-trained Transformer) is an Imagecaption tool. The image description of the person image is a text description of the facial orientation, facial features and body features in the person image. Facial orientation is the angle of the face in the image, facial features are the distribution and size of the facial features, and body features are height, fatness, shoulder width, leg length and other features.

[0025] A first training data set and a second training data set are constructed based on the image data set. The first training data set contains person images and their image descriptions, the second training data set contains person facial images and image descriptions, and the first training data set and the second training data set are combined in a preset ratio to obtain a third training data set. Then, the third training data set contains multiple training images, each training image carries an image description, and each training image is a person image or a person facial image.

[0026] The CLIP (Contrastive Language-Image Pre-training) network includes a text encoder and an image encoder, a VAE network, i.e., a variational autoencoder (Variational Autoencoder), and a U-Net network, which is a network with a U-shaped symmetrical structure and is commonly used for semantic segmentation. The embodiment of the present application constructs multiple LoRA branches for the U-Net network to obtain a denoising fine-tuning network, and connects the text encoder and the VAE network in the CLIP network in parallel with the denoising fine-tuning network to obtain a Wensheng graph model. The Wensheng graph model is trained using the third training data set so that the Wensheng graph model learns character images and image descriptions. Then in the reasoning stage, the Wensheng graph model can generate corresponding character images based on the text about the image description input by the user.

[0027] According to the technical solution provided by the embodiment of the present application, an image data set is obtained, and the image description of each character image in the image data set is extracted; a first training data set is constructed using each character image and its image description; the character facial image of each character image is obtained by segmenting each character image, and the character facial image and image description of each character image are used to construct a second training data set; the first training data set and the second training data set are combined in a preset ratio to obtain a third training data set; multiple LoRA branches are constructed for the U-Net network to obtain a denoising fine-tuning network, and a text-generated graph model is constructed using the text encoder, VAE network and denoising fine-tuning network in the CLIP network; the text-generated graph model is trained using the third training data set, so that the text-generated graph model learns character images and image descriptions. The above technical means can solve the problem that the image generated by the Chinese character model in the prior art is not as expected, thereby improving the quality of the generated image.

[0028] Furthermore, the third training data set is used to train the Vincent graph model so that the Vincent graph model learns character images and image descriptions, including: the third training data set contains multiple training images, each training image carries an image description, and each training image is a character image or a character facial image; each training image and the image description it carries are input into the Vincent graph model, and within the Vincent graph model: the image description carried by each training image is encoded by the text encoder in the CLIP network to obtain the text features corresponding to each training image; each training image is encoded by the VAE network to obtain the image features corresponding to each training image, wherein the VAE network The network encodes each training image by adding noise; the denoising fine-tuning network decodes the image features corresponding to each training image according to the text features corresponding to each training image to obtain the restored image corresponding to each training image, wherein the denoising fine-tuning network decodes the image features corresponding to each training image by predicting the noise added by the VAE network and removing the noise based on the predicted noise; the divergence function is used to calculate the prediction loss value between the noise added by the VAE network and the noise predicted by the denoising fine-tuning network on each training image; the model parameters of the Wensheng graph model are optimized according to the prediction loss value to complete the training of the Wensheng graph model.

[0029] Inside the Wensheng graph model: the text encoder encodes each image description to obtain the text features corresponding to each training image. The VAE network encodes each training image to obtain the image features corresponding to each training image. The denoising fine-tuning network decodes the image features of each training image according to the text features corresponding to each training image to obtain the restored image corresponding to each training image. It should be noted that the VAE network encodes each training image by adding noise, and the denoising fine-tuning network decodes the image features corresponding to each training image by predicting the noise added by the VAE network and removing the noise based on the predicted noise. The divergence function is used to calculate the prediction loss value between the noise added by the VAE network and the noise predicted by the denoising fine-tuning network on each training image. The divergence function can be the KL divergence (Kullback-Leibler Divergence). The model parameters of the Wensheng graph model are optimized according to the prediction loss value to complete the training of the Wensheng graph model.

[0030] Furthermore, the image features corresponding to each training image are decoded according to the text features corresponding to each training image through the denoising fine-tuning network to obtain the restored images corresponding to each training image, including: the denoising fine-tuning network includes a basic network, a cross-attention network and multiple LoRA branches; within the denoising fine-tuning network: the text features and image features corresponding to each training image are processed through the basic network; the text features and image features corresponding to each training image processed by the basic network are processed through the cross-attention network to obtain the cross-attention features corresponding to each training image; the cross-attention features corresponding to each training image are adjusted through multiple LoRA branches to obtain the restored images corresponding to each training image.

[0031] The basic network is the most basic network in the U-Net network, including: convolutional layer, pooling layer, downsampling layer, upsampling layer and other networks. In the application of the U-Net network, in order to improve the effect of the U-Net network, a cross-attention network is often added to the U-Net network. As a classic structure of the U-Net network, the U-Net network is used in the embodiment of the present application. Then the denoising fine-tuning network can be regarded as three parts, namely the basic network, the cross-attention network and multiple LoRA branches. Inside the denoising fine-tuning network: for each training image, the basic network processes the text features and image features. The cross-attention network processes the text features and image features processed by the basic network to obtain cross-attention features. Multiple LoRA branches adjust the cross-attention features corresponding to each training image to obtain the restored image corresponding to each training image. Because the image itself is a feature matrix, the cross-attention features adjusted by multiple LoRA branches can also be directly regarded as images.

[0032] Furthermore, the text features and image features corresponding to each training image processed by the basic network are processed through a cross-attention network to obtain cross-attention features corresponding to each training image, including: using the text features corresponding to each training image processed by the basic network as the query vector and value vector corresponding to each training image, using the image features corresponding to each training image processed by the basic network as the key vector corresponding to each training image, and processing the query vector, value vector and key vector corresponding to each training image through the cross-attention network to obtain cross-attention features corresponding to each training image.

[0033] The query vector is the Query vector, the key vector is the Key vector, and the value vector is the Value vector. The query vector, value vector, and key vector are input into the cross-attention network as a set of vectors, and the cross-attention features are output.

[0034] Furthermore, the cross-attention features corresponding to each training image are adjusted through multiple LoRA branches to obtain restored images corresponding to each training image, including: processing the cross-attention features corresponding to each training image through each LoRA branch to obtain adjusted features corresponding to each training image; adding the cross-attention features corresponding to each training image and multiple adjusted features to obtain restored images corresponding to each training image.

[0035] LoRA (Low-Rank Adaptation) is a low-rank adaptation technology for large language models (such as the GPT series) and other multimodal models (such as Stable Diffusion), which can be used as a branch to optimize the output of the original network. The embodiment of the present application uses multiple LoRA branches to process cross-attention features to obtain adjustment features, adds the cross-attention features and multiple adjustment features, and uses the result of the addition as the restored image.

[0036] Furthermore, the cross-attention features corresponding to each training image are adjusted through multiple LoRA branches to obtain a restored image corresponding to each training image, including: the denoising fine-tuning network includes three LoRA branches; the cross-attention features corresponding to each training image are processed through the first LoRA branch to obtain a first adjustment feature corresponding to each training image; the cross-attention features corresponding to each training image are processed through the second LoRA branch to obtain a second adjustment feature corresponding to each training image; the cross-attention features corresponding to each training image are processed through the third LoRA branch to obtain a third adjustment feature corresponding to each training image; the cross-attention features, the first adjustment features, the second adjustment features and the third adjustment features corresponding to each training image are added to obtain a restored image corresponding to each training image.

[0037] The embodiment of the present application uses three LoRA branches to optimize the cross-attention feature, and may also use two LoRA branches, four LoRA branches, or the like number of LoRA branches to optimize the cross-attention feature.

[0038] Furthermore, after using the divergence function to calculate the prediction loss value between the noise added by the VAE network and the noise predicted by the denoising fine-tuning network on each training image, the method also includes: judging the probability of each training image being true under the condition of the image description carried by the training image through a discriminator; judging the probability of the restored image corresponding to each training image being true under the condition of the image description carried by the training image through a discriminator; calculating the judgment loss value based on the probability corresponding to each training image and the probability corresponding to the restored image corresponding to each training image; optimizing the model parameters of the Vincent graph model based on the prediction loss value and the judgment loss value to complete the training of the Vincent graph model.

[0039] The embodiment of the present application optimizes the model parameters of the Generative Adversarial Network (the embodiment of the present application actually uses the Generative Adversarial Network as a generator) by using the discriminator in the adversarial network. The Generative Adversarial Network (GANs) includes a generator and a discriminator.

[0040] The probability that the discriminator judges that the training image x is real under the condition that it carries the image description y is recorded as D(x / y), and the probability that the discriminator judges that the restored image z corresponding to the training image x is real under the condition y is recorded as D(z / y). Then the judgment loss value LD can be calculated according to the following formula:

[0041] LD=-Ex[log(D(x / y))]-Ez[log(1-D(z / y))];

[0042] E is the expected value operator, log(D(x / y)) is the logarithm of D(x / y), Ex[log(D(x / y))] is used to calculate the average of the logarithm values ​​corresponding to all training images, log(1-D(z / y)) is the logarithm of D(z / y), and Ez[log(1-D(z / y))] is used to calculate the average of the logarithm values ​​corresponding to all restored images.

[0043] Figure 2 is a flow chart of a method for generating a text graph according to an embodiment of the present disclosure, such as Figure 2 As shown, the method includes:

[0044] S201, obtaining text and images input by a user;

[0045] S202, inputting text and images into the text-generated graph model, within the text-generated graph model;

[0046] S203, encoding the text through a text encoder in the CLIP network to obtain target text features;

[0047] S204, encoding the image through the VAE network to obtain target image features;

[0048] S205, decoding the target image features according to the target text features through the denoising fine-tuning network to obtain the target restored image.

[0049] In the embodiment of the present application, the image is actually adjusted according to the text input by the user. The image can also be a template in a database, and the image already in the database is adjusted according to the text input by the user to obtain an image that meets the user's requirements.

[0050] All the above-mentioned optional technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described one by one here.

[0051] The following are embodiments of the device disclosed herein, which can be used to execute the method embodiments disclosed herein. For details not disclosed in the device embodiments disclosed herein, please refer to the method embodiments disclosed herein.

[0052] Figure 3 Schematic diagram of the structure of a text graph model training device provided by the embodiment of the present disclosure. Figure 3 As shown, the text graph model training device includes:

[0053] The acquisition module 301 is configured to acquire an image data set and extract an image description of each person image in the image data set;

[0054] A first construction module 302 is configured to construct a first training data set using each person image and its image description;

[0055] The second construction module 303 is configured to segment each character image to obtain a character facial image of each character image, and construct a second training data set using the character facial image and image description of each character image;

[0056] The third construction module 304 is configured to combine the first training data set and the second training data set according to a preset ratio to obtain a third training data set;

[0057] A modeling module 305 is configured to construct multiple LoRA branches for the U-Net network, obtain a denoising fine-tuning network, and construct a text graph model using the text encoder, the VAE network, and the denoising fine-tuning network in the CLIP network;

[0058] The training module 306 is configured to train the text-graph model using the third training data set, so that the text-graph model learns character images and image descriptions.

[0059] According to the technical solution provided by the embodiment of the present application, an image data set is obtained, and the image description of each character image in the image data set is extracted; a first training data set is constructed using each character image and its image description; the character facial image of each character image is obtained by segmenting each character image, and the character facial image and image description of each character image are used to construct a second training data set; the first training data set and the second training data set are combined in a preset ratio to obtain a third training data set; multiple LoRA branches are constructed for the U-Net network to obtain a denoising fine-tuning network, and a text-generated graph model is constructed using the text encoder, VAE network and denoising fine-tuning network in the CLIP network; the text-generated graph model is trained using the third training data set, so that the text-generated graph model learns character images and image descriptions. The above technical means can solve the problem that the image generated by the Chinese character model in the prior art is not as expected, thereby improving the quality of the generated image.

[0060] In some embodiments, the training module 306 is further configured such that the third training data set includes multiple training images, each training image carries an image description, and each training image is a person image or a person face image; each training image and the image description it carries are input into the Vincent graph model, and inside the Vincent graph model: the image description carried by each training image is encoded by the text encoder in the CLIP network to obtain the text features corresponding to each training image; each training image is encoded by the VAE network to obtain the image features corresponding to each training image, wherein the VAE network is to add noise to the image description. Each training image is encoded; the image features corresponding to each training image are decoded by a denoising fine-tuning network according to the text features corresponding to each training image to obtain a restored image corresponding to each training image, wherein the denoising fine-tuning network decodes the image features corresponding to each training image by predicting the noise added by the VAE network and removing the noise based on the predicted noise; the divergence function is used to calculate the prediction loss value between the noise added by the VAE network on each training image and the noise predicted by the denoising fine-tuning network; the model parameters of the Wensheng graph model are optimized according to the prediction loss value to complete the training of the Wensheng graph model.

[0061] In some embodiments, the training module 306 is further configured as a denoising fine-tuning network including a basic network, a cross-attention network and multiple LoRA branches; within the denoising fine-tuning network: the text features and image features corresponding to each training image are processed through the basic network; the text features and image features corresponding to each training image processed by the basic network are processed through the cross-attention network to obtain the cross-attention features corresponding to each training image; the cross-attention features corresponding to each training image are adjusted through multiple LoRA branches to obtain the restored images corresponding to each training image.

[0062] In some embodiments, the training module 306 is further configured to use the text features corresponding to each training image processed by the basic network as the query vector and value vector corresponding to each training image, and use the image features corresponding to each training image processed by the basic network as the key vector corresponding to each training image, and process the query vector, value vector and key vector corresponding to each training image through the cross-attention network to obtain the cross-attention features corresponding to each training image.

[0063] In some embodiments, the training module 306 is also configured to process the cross-attention features corresponding to each training image through each LoRA branch to obtain an adjustment feature corresponding to each training image; add the cross-attention features corresponding to each training image and multiple adjustment features to obtain a restored image corresponding to each training image.

[0064] In some embodiments, the training module 306 is also configured as a denoising fine-tuning network comprising three LoRA branches; the cross-attention features corresponding to each training image are processed through the first LoRA branch to obtain the first adjustment features corresponding to each training image; the cross-attention features corresponding to each training image are processed through the second LoRA branch to obtain the second adjustment features corresponding to each training image; the cross-attention features corresponding to each training image are processed through the third LoRA branch to obtain the third adjustment features corresponding to each training image; the cross-attention features, the first adjustment features, the second adjustment features and the third adjustment features corresponding to each training image are added together to obtain the restored images corresponding to each training image.

[0065] In some embodiments, the training module 306 is further configured to determine, through a discriminator, the probability that each training image is real under the condition of the image description carried by the training image; determine, through a discriminator, the probability that the restored image corresponding to each training image is real under the condition of the image description carried by the training image; calculate a judgment loss value based on the probability corresponding to each training image and the probability corresponding to the restored image corresponding to each training image; and optimize the model parameters of the Vincent graph model based on the predicted loss value and the judgment loss value to complete the training of the Vincent graph model.

[0066] In some embodiments, the training module 306 is also configured to obtain text and images input by the user; input the text and images into the text-graph model, and inside the text-graph model; encode the text through the text encoder in the CLIP network to obtain target text features; encode the image through the VAE network to obtain target image features; and decode the target image features according to the target text features through the denoising fine-tuning network to obtain the target restored image.

[0067] It should be understood that the sequence numbers of the steps in the above embodiments do not imply a sequence of execution. The execution sequence of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present disclosure.

[0068] Figure 4 FIG. 4 is a schematic diagram of an electronic device 4 provided in an embodiment of the present disclosure. Figure 4 As shown, the electronic device 4 of this embodiment includes: a processor 401, a memory 402, and a computer program 403 stored in the memory 402 and capable of running on the processor 401. When the processor 401 executes the computer program 403, the steps in the above-mentioned method embodiments are implemented. Alternatively, when the processor 401 executes the computer program 403, the functions of each module / unit in the above-mentioned device embodiments are implemented.

[0069] The electronic device 4 may be a desktop computer, a notebook, a PDA, a cloud server, or other electronic device. The electronic device 4 may include, but is not limited to, a processor 401 and a memory 402. Those skilled in the art will appreciate that Figure 4 The electronic device 4 is merely an example and does not limit the electronic device 4 , which may include more or fewer components than those shown in the figure, or different components.

[0070] The processor 401 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.

[0071] The memory 402 may be an internal storage unit of the electronic device 4, for example, a hard disk or memory of the electronic device 4. The memory 402 may also be an external storage device of the electronic device 4, for example, the electronic device 4 is equipped with a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. The memory 402 may also include both an internal storage unit of the electronic device 4 and an external storage device. The memory 402 is used to store computer programs and other programs and data required by the electronic device.

[0072] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the above-mentioned functional units and module divisions are used as examples for illustration. In practical applications, the above-mentioned functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. In the embodiment, each functional unit and module can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit, and the above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units.

[0073] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present disclosure implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the above-mentioned various method embodiment steps when executed by the processor. The computer program may include computer program code, and the computer program code may be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electric carrier signals and telecommunication signals.

[0074] The above embodiments are only used to illustrate the technical solutions of the present disclosure, rather than to limit them. Although the present disclosure has been described in detail with reference to the aforementioned embodiments, it should be understood by those skilled in the art that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure.

Claims

1. A method for training a text graph model, characterized in that: include: Acquire an image data set, and extract an image description of each person image in the image data set; Constructing a first training data set using each person image and its image description; Segmenting each person image to obtain a person face image of each person image, and constructing a second training data set using the person face image and image description of each person image; Combining the first training data set and the second training data set according to a preset ratio to obtain a third training data set; Construct multiple LoRA branches for the U-Net network to obtain a denoising fine-tuning network, and use the text encoder, VAE network and the denoising fine-tuning network in the CLIP network to construct a text graph model; The third training data set is used to train the text graph model, so that the text graph model learns character images and image descriptions.

2. The method according to claim 1, characterized in that: Using the third training data set to train the Wensheng graph model so that the Wensheng graph model learns character images and image descriptions includes: The third training data set includes a plurality of training images, each training image carries an image description, and each training image is a person image or a person face image; Each training image and its image description are input into the Wensheng graph model. Inside the Wensheng graph model: Encoding the image description carried by each training image through the text encoder in the CLIP network to obtain text features corresponding to each training image; Encoding each training image through the VAE network to obtain image features corresponding to each training image, wherein the VAE network encodes each training image by adding noise; The denoising fine-tuning network decodes the image features corresponding to each training image according to the text features corresponding to each training image, so as to obtain a restored image corresponding to each training image, wherein the denoising fine-tuning network decodes the image features corresponding to each training image by predicting the noise added by the VAE network and removing the noise based on the predicted noise; Calculate the prediction loss value between the noise added by the VAE network and the noise predicted by the denoising fine-tuning network on each training image using a divergence function; The model parameters of the Wensheng graph model are optimized according to the predicted loss value to complete the training of the Wensheng graph model.

3. The method according to claim 2, characterized in that: The denoising fine-tuning network decodes the image features corresponding to each training image according to the text features corresponding to each training image to obtain a restored image corresponding to each training image, including: The denoising fine-tuning network includes a base network, a cross-attention network and multiple LoRA branches; Inside the denoising fine-tuning network: Processing text features and image features corresponding to each training image through the basic network; Processing the text features and image features corresponding to each training image processed by the basic network through the cross attention network to obtain the cross attention features corresponding to each training image; The cross-attention features corresponding to each training image are adjusted through multiple LoRA branches to obtain the restored images corresponding to each training image.

4. The method according to claim 3, characterized in that: The text features and image features corresponding to each training image processed by the basic network are processed by the cross attention network to obtain the cross attention features corresponding to each training image, including: The text features corresponding to each training image processed by the basic network are used as the query vector and value vector corresponding to each training image, and the image features corresponding to each training image processed by the basic network are used as the key vector corresponding to each training image. The query vector, value vector and key vector corresponding to each training image are processed by the cross-attention network to obtain the cross-attention features corresponding to each training image.

5. The method according to claim 3, characterized in that: The cross-attention features corresponding to each training image are adjusted through multiple LoRA branches to obtain the restored images corresponding to each training image, including: The cross-attention features corresponding to each training image are processed through each LoRA branch to obtain the adjustment features corresponding to each training image; The cross-attention features and multiple adjustment features corresponding to each training image are added together to obtain the restored image corresponding to each training image.

6. The method according to claim 3, characterized in that: The cross-attention features corresponding to each training image are adjusted through multiple LoRA branches to obtain the restored images corresponding to each training image, including: The denoising fine-tuning network includes three LoRA branches; The cross-attention features corresponding to each training image are processed by the first LoRA branch to obtain the first adjustment features corresponding to each training image; The cross-attention features corresponding to each training image are processed by the second LoRA branch to obtain the second adjustment features corresponding to each training image; The cross-attention features corresponding to each training image are processed through the third LoRA branch to obtain the third adjustment features corresponding to each training image; The cross-attention feature, the first adjustment feature, the second adjustment feature and the third adjustment feature corresponding to each training image are added together to obtain a restored image corresponding to each training image.

7. The method according to claim 1, characterized in that: After calculating the prediction loss value between the noise added by the VAE network and the noise predicted by the denoising fine-tuning network on each training image using a divergence function, the method further includes: The discriminator determines the probability that each training image is real given the image description carried by the training image; The discriminator determines the probability that the restored image corresponding to each training image is true under the condition of the image description carried by the training image; The loss value is determined based on the probability corresponding to each training image and the probability corresponding to the restored image corresponding to each training image; The model parameters of the culture graph model are optimized according to the predicted loss value and the judged loss value to complete the training of the culture graph model.

8. A device for training a text graph model, characterized in that: include: An acquisition module is configured to acquire an image data set and extract an image description of each person image in the image data set; A first construction module is configured to construct a first training data set using each person image and its image description; A second construction module is configured to segment each character image to obtain a character facial image of each character image, and construct a second training data set using the character facial image and image description of each character image; A third construction module is configured to combine the first training data set and the second training data set according to a preset ratio to obtain a third training data set; A modeling module is configured to construct multiple LoRA branches for a U-Net network, obtain a denoising fine-tuning network, and construct a text graph model using a text encoder in a CLIP network, a VAE network, and the denoising fine-tuning network; The training module is configured to train the text-graph model using the third training data set so that the text-graph model learns character images and image descriptions.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Pentograph model training method and device, equipment and storage medium

    CN117173504A

  • Method and system for constructing image generation model

    CN117495993A

  • Image generation method, device and equipment and computer readable storage medium

    CN117541683A

  • Image generation method and device, equipment and storage medium

    CN117710530A

  • Neural network adjustment method and device, electronic equipment and readable storage medium

    CN117829228A

Cited By

  • Potential space human motion generation method based on diffusion model

    CN119169205A

  • Modal attribute-structure decoupling infrared and visible image fusion method

    CN121810509A