Image generation method and device based on generative artificial intelligence, equipment and storage medium

By using a separate facial feature extractor and feature alignment module in face image generation to optimize Face Embedding, the problem of insufficient similarity in face generation in the existing technology is solved, and higher quality and similar face generation is achieved. Effect.

CN118553000AActive Publication Date: 2024-08-27SHENZHEN AIMALL TECHNOLOGY CO LTD

Patent Information

Application Number
CN202410996709.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-24
Publication Date
2024-08-27
Estimated Expiration
2044-07-24

AI Technical Summary

Technical Problem

It is difficult to maintain a high degree of similarity in face image generation with existing technology, especially when there are obvious deviations in the generation results of different races and angles, making it difficult to ensure the similarity between the generated face and the real face.

Method used

A separate facial feature extractor is used to extract facial features, and the high semantic features are integrated into the diffusion space through the feature alignment module. The embedding is adjusted based on the face position information, and the Face Embedding embedding process is optimized to ensure the control of the face generation direction. .

Benefits of technology

It effectively improves the similarity of generated faces, maintains higher quality generated images, and reduces the interference caused by other information in the image, ensuring that the faces of the generated images are more similar to the input faces.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118553000A
    Figure CN118553000A
Patent Text Reader

Abstract

The invention provides an image generation method and device based on generative artificial intelligence, equipment and a storage medium, and the method comprises the steps: inputting a to-be-processed text prompt word, and obtaining a text feature through text coding according to the text prompt word; obtaining face image information, wherein the face image information comprises image coding and face feature extraction; prompting and inputting image features through a decoupled cross attention layer according to the image codes, and embedding the image features into a diffusion space through an image cross attention module; face features are extracted through an additional face feature extractor, and features containing high semantics are fused into a diffusion space through a feature alignment module to serve as important prompts of face generation; according to the method, the similarity of generated faces can be effectively improved while a high-quality generated graph is kept, a single face feature extractor is used for face feature extraction, face feature fusion is carried out in model sampling iteration, and therefore control over the generation direction of the faces is guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to technical fields such as deep learning, reinforcement learning and computer vision, and in particular to an image generation method, device, equipment and storage medium based on generative artificial intelligence. Background Art

[0002] Generative AI uses machine learning algorithms to generate highly complex outputs. It can help machines achieve autonomous creation and learning, providing humans with more intelligent and personalized experiences.

[0003] Image generation has always been a hot research topic, with generative AI demonstrating strong capabilities in areas such as image generation and video production. The current mainstream technology uses Stable Diffusion (a large diffusion generative image model) to generate text-generated images or image-generated images. This approach offers advantages in generating rich scenes and diverse species. However, it also presents challenges. For example, in portrait generation, large models struggle to achieve good results due to the high level of detail required to depict human figures. This is particularly true when it comes to facial similarity: generated faces often differ from real faces, making it difficult to guarantee that they are images of the same individual.

[0004] Publication number CN116049523B, titled "A System for Intelligently Generating Ancient Poetry Contextual Videos and Its Working Method," discloses the construction of an AI-powered system for intelligently generating ancient poetry contextual videos. This system automatically generates contextual videos corresponding to the content of ancient poetry texts, providing a large amount of video learning resources for teachers' teaching and students' self-study activities, reducing the difficulty of understanding. This provides a new approach to generating ancient poetry learning videos and promotes the intelligent generation of ancient poetry teaching resources. Among existing technologies, Stable Diffusion XL combined with IP Adapter can maintain a certain degree of facial similarity. IP Adapter trains a facial feature extraction module and distinguishes the text embedding of the prompt word from the face embedding of the face. A Cross-Attention module is added to UNet to introduce facial features, thereby achieving the goal of reshaping the fixed IP of the face.

[0005] In terms of technical implementation, some large models are usually used in conjunction with some large model components, such as IP Adapter, to separate image and text features, and use the features of facial images as input for visual cues to ensure that the same face is generated.

[0006] However, the faces generated by this method are often unstable, with obvious deviations in different races and angles. Generating AI face images with high facial similarity remains a major challenge. To this end, a generative artificial intelligence-based image generation method is proposed. Summary of the Invention

[0007] In view of this, the present invention provides an image generation method, apparatus, device, and storage medium based on generative artificial intelligence. The present invention makes corresponding optimizations and improvements based on generative technology, effectively improving the similarity of generated faces while maintaining a high-quality generated image. It focuses on optimizing the Face Embedding in Stable Diffusion XL, extracting facial features using a separate facial feature extractor, and fusing facial features during model sampling iterations, thereby ensuring control over the generation direction of faces, solving or alleviating technical problems existing in the prior art, and providing at least a beneficial option.

[0008] The technical solution of the embodiment of the present invention is achieved as follows: In a first aspect, the present invention provides an image generation method based on generative artificial intelligence, comprising the following steps: Input a text prompt word to be processed, and obtain text features by encoding the text prompt word; Acquiring facial image information, wherein the facial image information includes image coding and facial feature extraction; According to the image encoding, the image feature prompt input is input through the decoupled cross attention layer, and is embedded into the diffusion space through the image cross attention module; according to the face feature extraction, the face region is encoded separately to obtain the face feature; Acquire a human face and head control image, wherein the human face and head control image includes facial position information of no less than five key points; Constructing a control network model, inputting the facial position information of the key points into the control network model, and combining the facial feature embedding of the feature alignment module to adjust and align the facial features and the facial position information of the key points and embed them into the diffusion space through the residual method; The diffusion space denoises the random noise several times according to the prompt information, inputs the facial image information and text features into the diffusion space for post-processing, and obtains an information feature matrix; The information feature matrix is ​​subjected to image redrawing through the feature decoder structure to obtain a generated image.

[0009] Further preferably, the step of inputting image feature prompts through a decoupled cross-attention layer according to the image encoding comprises: Encoding the input facial image information, removing the last two linear layers used for encoding classification tasks, to extract the image features; The projection network of the linear layer plus the normalization layer projects the image into a feature sequence of length N, so that the dimension of the image feature is consistent with the dimension of the text feature; Decoupled Cross Attention Layer: Image features and text features are decoupled through the cross attention layer.

[0010] Further preferably, the cross attention layer includes a cross attention embedding module, and the calculation expression of the cross attention embedding module is: ; in, are the query, key, and value matrices of the text cross-attention operation, is the key and value matrix of the image cross attention; is a controllable parameter; represents text cross attention, Cross attention for images.

[0011] Further preferably, the diffusion space denoises the random noise several times according to the prompt information, and inputs the facial image information and text features into the diffusion space for post-processing to obtain an information feature matrix, including: Forward process: generating intermediate data by adding the random noise to the facial image information, text information, and facial feature information, wherein the intermediate data is a Markov chain, wherein the random noise is added to the intermediate data at each step; Inverse process: Diffusion space learning recovers intermediate data from the random noise data; Loss function: Train the model and recover intermediate data by adding loss function; The denoising method specifically includes the following steps: Initialize random noise: Sample an initial random noise image from a diffuse spatial distribution ; Stepwise Denoising: Models Using the Inverse Process Gradually denoise and generate intermediate data; Generate the final image: The last step is to generate the denoised image .

[0012] Further preferably, the text features of the input text prompt words to be processed specifically include: Text encoding: The CLIP model encodes text prompt words and generates text feature vectors; Feature Embedding: The text feature vector is embedded into the diffusion space through a separate cross-attention layer.

[0013] Further preferably, the facial features and the facial position information of the key points are adjusted and aligned and embedded into the diffusion space in a residual manner. The calculation expression is: ; in, is the UNet module, x is random noise, Represents the frozen weights of the UNet model, and Z represents the weighted or Zero convolution calculation, It controls the weight value of the network model.

[0014] Further preferably, the image encoding includes performing edge detection on the image, and the edge detection includes gradient calculation, edge extraction and gradient amplitude calculation.

[0015] A second aspect: A device for generating an image based on generative artificial intelligence, applied to a method for generating an image based on generative artificial intelligence, comprising: An input module, configured to input the text prompt words to be processed and obtain text features through text encoding according to the text prompt words; A facial image acquisition module is used to acquire the facial image information, wherein the facial image information includes image coding and facial feature extraction; An image encoder for encoding image feature hints input through a decoupled crisscross attention layer according to the image, and embedding into a diffusion space through an image crisscross attention module; A facial feature extractor, configured to extract facial features by encoding the facial region separately according to the facial feature extraction; A face and head control image input module is used to provide the face and head control image including face position information of no less than five key points, and to specify the image area where the face is generated when generating the face and head control image; Constructing a control network module, for inputting the facial position information of the key points into the control network model, and combining the embedding of facial features by the feature alignment module to align the facial features and the facial position information of the key points and embed them into the diffusion space through residuals; An information feature matrix module is used to perform denoising on random noise in the diffusion space several times according to prompt information, input facial image information and text features into the diffusion space for post-processing, and obtain an information feature matrix; The image generation module redraws the information feature matrix through the feature decoder structure to obtain a generated image.

[0016] A third aspect: A computer device comprising: processor; a memory for storing executable instructions; Wherein, the processor is used to read the executable instructions from the memory and execute the executable instructions to implement the image generation method based on generative artificial intelligence.

[0017] A fourth aspect: A computer-readable storage medium storing a computer program, which, when executed by a processor, enables the processor to implement the image generation method based on generative artificial intelligence.

[0018] The embodiment of the present invention adopts the above technical solution, which has the following advantages: First, based on the technical route of Stable Diffusion XL, this invention extracts facial features through an additional facial feature extractor and fuses the highly semantic features into the diffusion space through a feature alignment module, which serves as an important hint for face generation. While maintaining a high quality of generated images, the similarity of generated faces can be effectively improved. We focus on optimizing the face embedding in Stable Diffusion XL, using a separate face feature extractor for facial feature extraction and performing facial feature fusion during model sampling iterations to ensure control over the generation direction of faces.

[0019] Second, the facial encoding features are extracted separately and aligned with the input. Due to the improvement, the diffusion process has high-semantic facial information prompts, which makes it possible to better prompt and compare facial information during multiple rounds of sampling and denoising. Therefore, in the diffusion direction, there is a clearer control direction for the generation of facial prompts, and the face of the generated image is more similar to the input face.

[0020] Third, this invention performs separate feature encoding on facial region images and then embeds them into the latent space (diffusion space) through feature alignment. This operation can greatly maintain the generated similarity of the face. Compared with the IP Adapter component that only uses Clip Encode to encode the image, this operation not only reduces the interference caused by other image information but also allows for flexible prompt input with the decoupled and separated text features.

[0021] The above summary is for illustrative purposes only and is not intended to be limiting in any way. In addition to the illustrative aspects, embodiments and features described above, further aspects, embodiments and features of the present invention will be readily apparent by reference to the accompanying drawings and the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0023] Figure 1 A flowchart of the image generation method based on generative artificial intelligence of the present invention; Figure 2 Schematic diagram of the structure of the image generation device based on generative artificial intelligence of the present invention; Figure 3 This is a schematic diagram of the computer device structure of embodiment 4 of the present invention.

[0024] In the figure, 10 is a computer device; 1002 is a processor; 1004 is a memory; and 1006 is a transmission device. DETAILED DESCRIPTION

[0025] Hereinafter, only certain exemplary embodiments are briefly described. As will be appreciated by those skilled in the art, the described embodiments may be modified in various ways without departing from the spirit or scope of the present invention. Therefore, the drawings and description are to be considered as illustrative in nature and not restrictive.

[0026] Explanation of key terms and technical abbreviations (the English abbreviations appearing below provide the corresponding English full names and Chinese translations, or detailed explanations of Chinese professional terms): Stable Diffusion: a large diffusion-generated image model. Stable Diffusion XL: An improved version based on Stable Diffusion; IP Adapter: Image prompt adapter, a plug-in that can be used with large image models; Text Embedding: text feature information; Face Embedding: facial feature information; UNet: A network model with an encoder-decoder structure that plays a role in diffusion (denoising) in large models. Cross-Attention: Cross-attention structure; Clip: data (text, image) encoder; ControlNet: Module that accepts conditional inputs that guide the image generation process.

[0027] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0028] Example 1 A method for image generation based on generative artificial intelligence, such as Figure 1 As shown, the following steps are included: Input a text prompt word to be processed, and obtain text features by encoding the text prompt word; Acquiring facial image information, wherein the facial image information includes image coding and facial feature extraction; According to the image encoding, the image feature prompt input is input through the decoupled cross attention layer, and is embedded into the diffusion space through the image cross attention module; according to the face feature extraction, the face region is encoded separately to obtain the face feature; Acquire a human face and head control image, wherein the human face and head control image includes facial position information of no less than five key points; Constructing a control network model, inputting the facial position information of the key points into the control network model, and combining the facial feature embedding of the feature alignment module to adjust and align the facial features and the facial position information of the key points and embed them into the diffusion space through the residual method; The diffusion space denoises the random noise several times according to the prompt information, inputs the facial image information and text features into the diffusion space for post-processing, and obtains an information feature matrix; The information feature matrix is ​​subjected to image redrawing through the feature decoder structure to obtain a generated image.

[0029] Specifically, the step of inputting image feature prompts through a decoupled cross-attention layer according to the image encoding includes: Encoding the input facial image information, removing the last two linear layers used for encoding classification tasks, to extract the image features; The projection network of the linear layer plus the normalization layer projects the image into a feature sequence of length N, so that the dimension of the image feature is consistent with the dimension of the text feature; Decoupled Cross Attention Layer: Image features and text features are decoupled through the cross attention layer.

[0030] The cross attention layer includes a cross attention embedding module, and the calculation expression of the cross attention embedding module is: ; in, are the query, key, and value matrices of the text cross-attention operation, is the key and value matrix of the image cross attention; is a controllable parameter; represents text cross attention, For image cross attention, controllable parameters are used To flexibly adjust the embedding feature value of each iteration.

[0031] In this embodiment, the facial features and facial position information are aligned and embedded into the diffusion space through the residual method. The calculation expression is: ; in, is the UNet module, x is random noise, Represents the frozen weights of the UNet model, and Z represents the weighted or Zero convolution calculation, It controls the weight value of the network model.

[0032] For text prompt words, the original route of Stable Diffusion XL encodes the text features through the Clip text encoder and embeds the text features through a separate cross-attention layer.

[0033] For facial images, the original single route is split into two. The first branch encodes the entire image using a lightweight IPAdapter, which is the image encoder module in the process. The image features obtained here are then used as prompt input through a decoupled cross-attention layer, separated from the text features, to flexibly adjust image condition constraints.

[0034] On the second branch of the face image, the face feature extractor is abbreviated here, which includes two modules: face detection and feature extraction. Through this module, the face area is separately encoded to obtain facial features with strong semantics.

[0035] In the face generation position control, an additional face head control image input is added. This image provides the position information of the five key points of the face and is used to specify the image area where the face is generated during generation.

[0036] The control network model uses the spatial information of key points as the input of the controllable module, and then combines it with the feature alignment module to embed facial features, adjust the facial features and align them with the UNet module (diffusion space), increase facial semantic hints, and control the effect of face generation.

[0037] The overall goal is to embed the facial feature values ​​combined with the spatial position information of the key points into the original UNet module through residual means.

[0038] The diffusion space denoises the random noise several times according to the prompt information, inputs the facial image information and text features into the diffusion space for post-processing, and obtains the information feature matrix, including: Forward process: generating intermediate data by adding the random noise to the facial image information, text information, and facial feature information, wherein the intermediate data is a Markov chain, wherein the random noise is added to the intermediate data at each step; Inverse process: Diffusion space learning recovers intermediate data from the random noise data; Loss function: Train the model and recover intermediate data by adding loss function; The denoising method specifically includes the following steps: Initialize random noise: Sample an initial random noise image from a diffuse spatial distribution ; Stepwise Denoising: Models Using the Inverse Process Gradually denoise and generate intermediate data; Generate the final image: The last step is to generate the denoised image Finally, the information feature matrix is ​​redrawn through the VEA (Variational AutoEncoder) feature decoder structure, and the operation result of the latent space is decoded into the actual picture dimension to obtain the generated image.

[0039] In the entire structure, the facial area image is individually feature encoded and then embedded into the latent space (diffusion space) through feature alignment. This operation can greatly maintain the similarity of face generation. Compared with the IPAdapter component that only uses Clip Encode to encode the image, it can not only reduce the interference caused by other image information, but also provide flexible prompt input with the decoupled and separated text features.

[0040] In this embodiment, the facial features and the facial position information of the key points are aligned and embedded into the diffusion space by means of residuals. The calculation expression is: ; in, is the UNet module, x is random noise, Represents the frozen weights of the UNet model, and Z represents the weighted or Zero convolution calculation, It controls the weight value of the network model.

[0041] In this embodiment: the image encoding includes edge detection on the image, and the edge detection includes gradient calculation, edge extraction and gradient amplitude calculation, wherein the gradient calculation is to calculate the image gradient using the Sobel operator; For the gradient in the x direction of the image : ; For the gradient in the y direction : ; Gradient amplitude calculation: ; in, and At the pixel points The gradient strength in the x and y directions calculated at ; Edge extraction: Set the threshold to T and consider pixels with gradient magnitude greater than T as edges: ; Among them, Edge represents the image edge set; Edge contains all pixel points (x, y) that satisfy the condition G(x, y)>T, where G(x, y) is the gradient magnitude of the image at the pixel point (x, y).

[0042] After the facial image information and text features are input into the diffusion space, the diffusion space then denoises the random noise several times according to the prompt information to obtain the processed information feature matrix, including: Forward process: Generate intermediate data by adding random noise to facial image information, text information, and facial feature information. The intermediate data is a Markov chain, where random noise is added to the intermediate data at each step: ; Among them, X t represents the data at time step t, β t is a predefined random noise scheduling parameter that controls the amount of random noise added at each step, where N represents a Gaussian distribution; Inverse process: Diffusion space learning recovers intermediate data from random noise data: ; Among them, X t−1 represents the data at time step t−1, and are the mean and covariance of the model parameterization, learned by the neural network; P represents the inverse process formula, Represents a set of weight and bias parameters of a neural network; Loss function: Train the model and recover intermediate data by adding loss function; ; Among them, D KL represents the Kullback-Leibler divergence, which measures the difference between two distributions; is the true posterior distribution of the forward process.

[0043] Specifically: the denoising process includes the following steps: Initialize random noise: Sample an initial random noise image from a diffuse spatial distribution ; Stepwise Denoising: Models Using the Inverse Process Gradually denoise and generate intermediate data; Generate the final image: The last step is to generate the denoised image .

[0044] Example 2 Figure 2 A generative artificial intelligence-based image generation device is shown, which is applied to a generative artificial intelligence-based image generation method, including: An input module, configured to input the text prompt words to be processed and obtain text features through text encoding according to the text prompt words; A facial image acquisition module is used to acquire the facial image information, wherein the facial image information includes image coding and facial feature extraction; An image encoder for encoding image feature hints input through a decoupled crisscross attention layer according to the image, and embedding into a diffusion space through an image crisscross attention module; A facial feature extractor, configured to extract facial features by encoding the facial region separately according to the facial feature extraction; A face and head control image input module is used to provide the face and head control image including face position information of no less than five key points, and to specify the image area where the face is generated when generating the face and head control image; Constructing a control network module, for inputting the facial position information of the key points into the control network model, and combining the embedding of facial features by the feature alignment module to align the facial features and the facial position information of the key points and embed them into the diffusion space through residuals; An information feature matrix module is used to perform denoising on random noise in the diffusion space several times according to prompt information, input facial image information and text features into the diffusion space for post-processing, and obtain an information feature matrix; The image generation module redraws the information feature matrix through the feature decoder structure to obtain a generated image.

[0045] The foregoing Figure 1 The various variations and specific examples of the image generation method based on generative artificial intelligence in Example 1 are also applicable to the image generation device based on generative artificial intelligence in this embodiment. Through the above detailed description of the image generation method based on generative artificial intelligence, those skilled in the art can clearly understand the implementation method of the image generation device based on generative artificial intelligence in this embodiment, so for the sake of brevity of the specification, it will not be described in detail here.

[0046] Example 3 Based on Example 1, the facial coding features are extracted separately and aligned with the input. Since the improved method provides highly semantic facial information prompts in the diffusion process, it enables better prompts and comparisons of facial information during multiple rounds of sampling and denoising. Therefore, in the diffusion direction, there is a clearer control direction for the facial prompt generation process, and the face of the generated image is more similar to the input face.

[0047] Test sample input image: A.jpg; Test sample face head position image: B.jpg; Test sample prompt text: A 20-year-old girl in a kimono is standing under a cherry blossom tree with cherry blossoms scattered around her face, A ray of sunlight hit her face, realistic life style photography. As the number of iteration steps (twice for each image) increases, the face redrawing gradually approaches the real face and continuously fits the original input face image in details, which fully demonstrates the feasibility of the solution of the present invention.

[0048] Example 4 An embodiment of the present application provides a computer device, which includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by the processor to implement an image generation method based on generative artificial intelligence as provided in the above method embodiment.

[0049] Figure 3The following is a schematic diagram of the hardware structure of a device for implementing an image generation method based on generative artificial intelligence provided by an embodiment of the present application. The device may participate in or include the apparatus or system provided by an embodiment of the present application. Figure 3 As shown, the computer device 10 may include one or more processors 1002 (the processor may include but is not limited to a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 1004 for storing data, and a transmission device 1006 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a power supply and / or a camera. It will be understood by those skilled in the art that Figure 3 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 3 More or fewer components than shown, or with Figure 3 Different configurations shown.

[0050] It should be noted that the one or more processors and / or other data processing circuits described above may generally be referred to herein as "data processing circuitry". The data processing circuitry may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuitry may be a single independent processing module, or may be incorporated in whole or in part into any of the other components of the computer device 10 (or mobile device). As described in the embodiments of the present application, the data processing circuitry serves as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).

[0051] The memory 1004 can be used to store software programs and modules of application software, such as a program instruction / data storage device corresponding to an image generation method based on generative artificial intelligence in an embodiment of the present application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory 1004, that is, implementing one of the above methods. The memory 1004 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 1004 may further include a memory remotely located relative to the processor, and these remote memories may be connected to the computer device 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0052] Transmission device 1006 is configured to receive or transmit data via a network. A specific example of the aforementioned network may include a wireless network provided by the communications provider of computer device 10. In one embodiment, transmission device 1006 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, transmission device 1006 may be a radio frequency (RF) module configured to communicate with the Internet wirelessly.

[0053] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer device 10 (or mobile device).

[0054] Example 5 An embodiment of the present application also provides a computer-readable storage medium, which can be set in a server to store at least one instruction or at least one program related to an image generation method based on generative artificial intelligence in a method embodiment. The at least one instruction or the at least one program is loaded and executed by the processor to implement the image generation method based on generative artificial intelligence provided by the above method embodiment.

[0055] Optionally, in this embodiment, the storage medium may be located in at least one of a plurality of network servers in a computer network. Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing program code, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.

[0056] Example 6 An embodiment of the present invention further provides a computer program product or computer program, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform a method for generating an image based on generative artificial intelligence provided in any of the aforementioned optional embodiments.

[0057] It should be noted that the order of the embodiments of the present application described above is for descriptive purposes only and does not represent the superiority or inferiority of the embodiments. The above description is of specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0058] The various embodiments in this application are described in a progressive manner. Similar portions between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the device, equipment, and storage medium embodiments are generally similar to the method embodiments, so their descriptions are relatively simple. For relevant portions, refer to the descriptions of the method embodiments.

[0059] Those skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware, or may be accomplished by a program to instruct the relevant hardware, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.

[0060] With the above-described preferred embodiments of the present invention as a guide, and with reference to the above description, relevant personnel are fully capable of making various changes and modifications without departing from the technical scope of this invention. The technical scope of this invention is not limited to the contents of the specification and must be determined according to the scope of the claims.

[0061] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various modifications and substitutions within the technical scope disclosed in the present invention, and such modifications and substitutions are intended to be within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be subject to the scope of protection of the claims.

Claims

1. A method for generating an image based on generative artificial intelligence, characterized in that: The following steps are involved: Input a text prompt word to be processed, and obtain text features by encoding the text prompt word; Acquiring facial image information, wherein the facial image information includes image coding and facial feature extraction; According to the image encoding, the image feature prompt is input through the decoupled cross attention layer, and embedded into the diffusion space through the image cross attention module; according to the face feature extraction, the face area is encoded separately to obtain the face feature; Acquire a face and head control image, wherein the face and head control image includes face position information of no less than five key points; Constructing a control network model, the control network model inputs the face position information of the key points, and combines the embedding of face features by the feature alignment module to adjust and align the face features and the face position information of the key points and embed them into the diffusion space through the residual method; The diffusion space denoises the random noise several times according to the prompt information, inputs the face image information and text features into the diffusion space for post-processing, and obtains an information feature matrix; The information feature matrix is ​​redrawn through a feature decoder structure to obtain a generated image.

2. The method according to claim 1, characterized in that: The step of inputting image feature prompts through a decoupled cross-attention layer according to the image encoding comprises: Encode the input face image information, remove the last two linear layers used for encoding classification tasks, so as to extract the image features; The projection network of the linear layer plus the normalization layer projects the image into a feature sequence of length N, so that the dimension of the image feature is consistent with the dimension of the text feature; Decoupled Cross-Attention Layer: Image features and text features are decoupled through the cross-attention layer.

3. The method according to claim 2, characterized in that: The cross attention layer includes a cross attention embedding module, and the calculation expression of the cross attention embedding module is: ; in, are the query, key, and value matrices of the text cross-attention operation, respectively. is the key and value matrix of the image cross attention; is a controllable parameter; represents text cross attention, Cross attention for images.

4. The method according to claim 1, characterized in that: The diffusion space denoises the random noise several times according to the prompt information, inputs the face image information and text features into the diffusion space for post-processing, and obtains the information feature matrix, including: Forward process: generating intermediate data by adding the random noise to the facial image information, text information, and facial feature information, wherein the intermediate data is a Markov chain, wherein the random noise is added to the intermediate data at each step; Inverse process: Diffusion space learning recovers intermediate data from the random noise data; Loss function: Train the model and restore intermediate data by adding the loss function; The denoising specifically comprises the following steps: Initialize random noise: Sample an initial random noise image from a diffuse spatial distribution ; Stepwise denoising: Use the inverse process model to gradually denoise and generate intermediate data; Generate the final image: The last step is to generate the denoised image .

5. The method according to claim 1, characterized in that: The text features of the input text prompt words to be processed specifically include: Text encoding: The CLIP model encodes text prompt words and generates text feature vectors; Feature Embedding: The text feature vector is embedded into the diffusion space through a separate cross-attention layer.

6. The method according to claim 1, characterized in that: The calculation expression for adjusting and aligning the facial features and the facial position information of the key points and embedding them into the diffusion space through the residual method is: ; in, is the UNet module, x is random noise, Represents the frozen weights of the UNet model, and Z represents the weighted or Zero convolution calculation, It controls the weight value of the network model.

7. The method according to claim 1, characterized in that: The image encoding includes edge detection on the image, and the edge detection includes gradient calculation, edge extraction and gradient amplitude calculation.

8. An image generation device based on generative artificial intelligence, applied to the image generation method based on generative artificial intelligence according to any one of claims 1 to 7, characterized in that: include: An input module, used for inputting the text prompt words to be processed, and obtaining text features through text encoding according to the text prompt words; A facial image acquisition module is used to acquire the facial image information, wherein the facial image information includes image coding and facial feature extraction; An image encoder for inputting image feature prompts through a decoupled cross-attention layer according to the image encoding and embedding into a diffusion space through an image cross-attention module; A face feature extractor, used for extracting face features by encoding face regions separately to obtain face features; A face head control image input module is used to provide the face head control image including face position information of no less than five key points, and to specify the image area where the face is generated when generating; Constructing a control network module, which is used for the control network model to input the face position information of the key points, and combining the embedding of face features by the feature alignment module, adjusting and aligning the face features and the face position information of the key points and embedding them into the diffusion space through the residual method; An information feature matrix module is used to denoise the random noise of the diffusion space several times according to the prompt information, input the face image information and text features into the diffusion space for post-processing, and obtain an information feature matrix; The image generation module redraws the information feature matrix through a feature decoder structure to obtain a generated image.

9. A computer device, characterized in that: include: processor; A memory for storing executable instructions; Wherein, the processor is used to read the executable instructions from the memory and execute the executable instructions to implement the image generation method based on generative artificial intelligence as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor implements the image generation method based on generative artificial intelligence as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • A system and its working method for AI-powered intelligent generation of classical Chinese poetry contextual videos

    CN116049523B

  • Face key point prediction method and virtual digital human generation method and device

    CN115588224A

  • Generative AI face detection method based on facial expressions

    CN116469151A

  • Face image generation method and system and model training method

    CN117522697A

  • Facial expression recognition method and system for enhancing by embedding privilege information

    CN117612226A

Cited By

  • Multi-mode automatic classification method for building sketches based on DINOv2 and CLIP

    CN119339405A

  • Face multi-pose generation method and system, electronic equipment and storage medium

    CN120452046A

  • Face image reconstruction method based on ID preservation

    CN120580156A

  • Image generation model training method and device, image generation method and device, electronic equipment, storage medium and program product

    CN120599091A

  • System and method for image generation

    TWI922249B