A facial image generation method and related device

By combining facial structural features and semantic features, and using the attention module to adjust the degree of attention, the problem of insufficient robustness in facial image generation in the existing technology is solved, the recognition accuracy and distinction are improved, and the image generation effect is enhanced.

CN118365509BActive Publication Date: 2024-09-27TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410794688.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-19
Publication Date
2024-09-27
Estimated Expiration
2044-06-19

AI Technical Summary

Technical Problem

When the existing technology generates facial images, its insufficient robustness leads to low recognition accuracy, and it lacks sufficient uniqueness, making it difficult to distinguish different entities.

Method used

By considering both facial structural features and facial semantic features, the attention module in the Vincentian graph model is used to dynamically adjust the degree of attention and generate target facial images, ensuring that facial semantics remain basically unchanged while improving discrimination.

Benefits of technology

While ensuring facial accuracy, it improves facial distinction, reduces redundant information interference, and enhances the effect of image generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118365509B
    Figure CN118365509B
Patent Text Reader

Abstract

The embodiment of the present application discloses a facial image generation method and related devices, which are applied to cloud technology, artificial intelligence, smart transportation, assisted driving, Internet of Things and other scenarios. Obtain a first adjustment text, an image to be adjusted and a first random noise. Perform feature extraction on the image to be adjusted to obtain facial semantic features and facial structural features of the face to be adjusted, and perform feature extraction on the first adjustment text to obtain first text features. According to the facial semantic features, facial structural features and first text features, adjustments are made through the attention module in the Vincent graph model to obtain the first attention weights of each position in the face to be adjusted. According to the first attention weight, the first random noise is denoised through the Vincent graph model to obtain a first target facial image. By simultaneously considering the facial structural features and the facial semantic features and integrating them into the Vincent graph model, not only the generation effect of the first target facial image is improved, but also the accuracy is ensured while improving the distinguishability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to a facial image generation method and related devices. Background Art

[0002] With the development of artificial intelligence technology, a target facial image that meets specific needs can be generated based on an image to be adjusted that includes the face to be adjusted, such as ensuring that the face to be adjusted remains unchanged and modifying the background, clothing, hairstyle, etc. of the image to be adjusted according to specific needs.

[0003] In the related art, specific requirements for the target facial image are generally described based on the first adjustment text, and then the features of the face to be adjusted in the image to be adjusted are extracted through image feature extraction models such as Contrastive Language-Image Pre-training (CLIP), and then the first adjustment text is understood in combination with the text-based graph model, so as to generate a target facial image that meets the specific requirements.

[0004] However, this method lacks robustness, resulting in low recognition accuracy, or lacks sufficient uniqueness, making it difficult to distinguish different entities. Summary of the invention

[0005] In order to solve the above technical problems, the present application provides a facial image generation method and related devices, which are used to improve the distinguishability while ensuring accuracy.

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

[0007] In one aspect, an embodiment of the present application provides a facial image generation method, the method comprising: acquiring an image to be adjusted, a first adjustment text, and a first random noise, the image to be adjusted comprising a face to be adjusted;

[0008] Performing feature extraction on the image to be adjusted to obtain facial semantic features of the face to be adjusted and facial structural features of the face to be adjusted, and performing feature extraction on the first adjustment text to obtain first text features;

[0009] According to the facial semantic features, the facial structural features and the first text features, an attention module in a text graph model is used to make adjustments to obtain a first attention weight for each position in the face to be adjusted;

[0010] According to the first attention weight, the first random noise is denoised by the text graph model to obtain a first target facial image, where the first target facial image is an image adjusted based on the first adjustment text on the basis of the face to be adjusted.

[0011] On the other hand, an embodiment of the present application provides a facial image generation device, the device comprising: an acquisition unit, a feature extraction unit, an adjustment unit, and a generation unit;

[0012] The acquisition unit is used to acquire the image to be adjusted, the first adjustment text and the first random noise, wherein the image to be adjusted includes the face to be adjusted;

[0013] The feature extraction unit is used to perform feature extraction on the image to be adjusted to obtain facial semantic features of the face to be adjusted and facial structural features of the face to be adjusted, and to perform feature extraction on the first adjustment text to obtain first text features;

[0014] The adjustment unit is used to adjust the facial semantic features, the facial structural features and the first text features through the attention module in the text graph model to obtain the first attention weight of each position in the face to be adjusted;

[0015] The generating unit is used to denoise the first random noise through the text graph model according to the first attention weight to obtain a first target facial image, where the first target facial image is an image adjusted based on the first adjustment text on the basis of the face to be adjusted.

[0016] On the other hand, an embodiment of the present application provides a computer device, the computer device comprising a processor and a memory:

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

[0018] The processor is configured to execute the method described in the above aspects according to the instructions in the computer program.

[0019] On the other hand, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method described in the above aspects.

[0020] On the other hand, an embodiment of the present application provides a computer program product or a computer program, which includes 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 the processor executes the computer instructions, so that the computer device executes the method described in the above aspects.

[0021] It can be seen from the above technical solution that a first adjustment text for describing a specific requirement is obtained, including an image to be adjusted of a face to be adjusted and a first random noise. Feature extraction is performed on the image to be adjusted to obtain facial semantic features and facial structural features of the face to be adjusted, and feature extraction is performed on the first adjustment text to obtain first text features. According to the facial semantic features, facial structural features and the first text features, adjustments are made through the attention module in the Vincent graph model, that is, the degree of attention paid by the Vincent graph model to different positions in the image to be adjusted is dynamically adjusted through the attention mechanism, and the first attention weights of each position in the face to be adjusted are obtained. According to the first attention weight, the first random noise is denoised through the Vincent graph model to obtain a first target facial image, so that the first target facial image is an image obtained by adjusting the face to be adjusted based on the first adjustment text, that is, while keeping the facial semantics of the face to be adjusted basically unchanged, the first target facial image meets the specific requirements described in the first adjustment text.

[0022] Therefore, by considering both facial structural features and facial semantic features, the accuracy of the face in the target face image is guaranteed while improving the distinctiveness of the face. Moreover, the facial structural features and facial semantic features are integrated into the viz-graph model through the attention mechanism, which increases the attention paid to the key information in the image to be adjusted, reduces the interference of redundant information, and better integrates feature information of different scales, thereby improving the generation effect of the target face image. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0024] Figure 1 A schematic diagram of generating a personalized image provided by an embodiment of the present application;

[0025] Figure 2 A schematic diagram of generating a multi-style image provided by an embodiment of the present application;

[0026] Figure 3 A schematic diagram of an alternative to portrait photography provided in an embodiment of the present application;

[0027] Figure 4 A schematic diagram of an application scenario of a facial image generation method provided in an embodiment of the present application;

[0028] Figure 5 A schematic diagram of a facial image generation method provided in an embodiment of the present application;

[0029] Figure 6 A schematic diagram of obtaining a sub-image provided in an embodiment of the present application;

[0030] Figure 7 A training diagram of a text graph model provided in an embodiment of the present application;

[0031] Figure 8 A training diagram of a text graph model provided in an embodiment of the present application;

[0032] Fig. 9 A training diagram of a text graph model provided in an embodiment of the present application;

[0033] Fig.10 A schematic diagram of an initial structural feature extraction model provided in an embodiment of the present application;

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

[0035] Fig.12 A schematic diagram of an application scenario of a facial image generation method provided in an embodiment of the present application;

[0036] Fig.13 A schematic diagram of the structure of a facial image generating device provided in an embodiment of the present application;

[0037] Fig.14 A schematic diagram of the structure of a server provided in an embodiment of the present application;

[0038] Fig.15 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION

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

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

[0041] In the related art, the Wensheng graph model is generally used to learn the embedding of facial features based on a pre-trained model. It is generally divided into two categories, which are explained below.

[0042] The first category, such as PhotoVerse (a model for tuning-free image customization using text-to-image diffusion models, Tuning-Free Image Customization with Text-to-Image Diffusion Models), FastComposer (a model for tuning-free multi-subject image generation with localized attention, Tuning-Free Multi-Subject Image Generation with Localized Attention) and other models, use the CLIP model to extract the facial structure features of the face to be adjusted in order to achieve the embedding of facial features.

[0043] The second category, such as InstantID (a model with zero-shot identity-preserving generation in seconds), extracts facial semantic features of the face to be adjusted, namely, facial identity (ID) features, to achieve embedding of facial features.

[0044] In other words, in the related art, only facial semantic features or facial structural features are used separately. Among them, facial structural features usually refer to the geometric features of the face, which can be obtained based on the distance and ratio between facial points, such as the "three parts and five eyes" and "four highs and three lows" of the face. These structural features provide basic shape and contour information of the face. Facial semantic features are usually used to uniquely identify the features of the corresponding entity. Facial semantic features are highly unique and robust, and can accurately identify the same entity under different lighting, angles and expressions.

[0045] However, considering facial semantic features alone may result in insufficient robustness to lighting, angle, expression changes, and occlusion, which may affect recognition accuracy. Considering facial structural features alone may make it difficult to accurately distinguish different individuals due to lack of sufficient uniqueness.

[0046] That is to say, in the related art, using facial semantic features or facial structural features alone cannot improve the distinguishability while ensuring accuracy.

[0047] Based on this, the present application provides a facial image generation method and related devices, which ensure that the generated first target facial image meets the specific requirements of the first adjustment text description while keeping the facial semantics of the face to be adjusted basically unchanged by considering the facial structural features and facial semantic features at the same time, that is, while ensuring the accuracy of the face, improve the distinctiveness of the face. Moreover, the facial structural features and facial semantic features are integrated into the text graph model through the attention mechanism, which improves the attention to the key information in the image to be adjusted, reduces the interference of redundant information, and better integrates feature information of different scales, thereby improving the generation effect of the first target facial image.

[0048] The facial image generation method provided in this application can be applied to various fields, including but not limited to cloud technology, artificial intelligence, smart transportation, assisted driving, the Internet of Things, etc. The following three scenarios are used as examples for explanation.

[0049] Scenario 1: Personalized image generation.

[0050] After the user gives a facial image and a text description of personalized needs such as clothing and hairstyle, the facial image is used as the image to be adjusted, and the text description is used as the first adjustment text. According to the facial image generation method provided in the embodiment of the present application, a first target facial image is generated by adjusting the face to be adjusted based on the first adjustment text, that is, adjustments are made based on the facial image to generate an image that meets the user's personalized needs.

[0051] In addition, if the user is not satisfied with the currently generated first target facial image, he can modify the text description to modify his personalized needs, so as to generate the corresponding first target facial image again according to the new text description, such as generating images of the same person with different shapes, such as Figure 1 As shown. This enhances the personalization and diversification of image synthesis and meets the user's demand for personalized images.

[0052] Scene 2: Multi-style image generation.

[0053] In addition to generating realistic face images, given a facial image, you can also use text to describe the style of the image, such as anime style, etc. Figure 2 As shown, a first target facial image in the style of a famous painting can be generated based on the image to be adjusted given by the user and the first adjustment text, thereby providing users with more choices and satisfying their different preferences.

[0054] Scene three, replace portrait photography.

[0055] When the user finds during the photography process that the current model is not suitable, or that the size of the clothing is not suitable, causing shooting difficulties, etc., the user can provide a facial image of a suitable model and a text description of specific needs. The facial image of the model can be used as the image to be adjusted, and the text description can be used as the first adjustment text. According to the facial image generation method provided in the embodiment of the present application, a first target facial image is generated, that is, adjustments are made based on the facial image of the model to generate an image that meets the specific needs of the user.

[0056] Similarly, users can also adjust the text description to meet specific needs, such as Figure 3 As shown, different clothes are replaced for the same model to generate images that meet specific needs, which can replace portrait photography, save the time cost of shooting and making portrait photos, and reduce the difficulty of shooting.

[0057] It should be noted that the above application scenarios are only examples, and the facial image generation method provided in this embodiment can also be applied to other scenarios, such as movies, games, advertisements, etc., which are not limited here.

[0058] The facial image generation method provided in the present application can be applied to computer devices with facial image generation capabilities, such as terminal devices and servers.

[0059] Among them, the terminal devices can specifically be desktop computers, laptops, smart phones, tablets, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. The smart car-mounted devices can be car-mounted navigation terminals and car-mounted computers, etc. The portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc., but are not limited to these.

[0060] The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server or server cluster that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms. The terminal device and the server can be directly or indirectly connected through wired or wireless communication, which is not limited in this application.

[0061] To facilitate understanding of the facial image generation method provided in the embodiment of the present application, the following uses a server as an example in which the execution subject of the facial image generation method is an example to exemplarily introduce the application scenario of the facial image generation method.

[0062] See also Figure 4, which is a schematic diagram of an application scenario of a facial image generation method provided by an embodiment of the present application. Figure 4 As shown, the application scenario includes a terminal device 410 and a server 420, and the terminal device 410 and the server 420 can communicate through a communication network. The communication network uses standard communication technology and / or protocols, usually the Internet, but can also be any network, including but not limited to Bluetooth, local area network (LAN), metropolitan area network (MAN), wide area network (WAN), mobile, dedicated network or any combination of virtual private networks). In some embodiments, customized or dedicated data communication technology can be used to replace or supplement the above data communication technology.

[0063] In the terminal device 410, a client for facial image generation is installed, and the user uses the facial image generation service by clicking on the client. Specifically, the user uploads an image through the terminal device or specifies an image from multiple images as the image to be adjusted, and then expresses his specific requirements for image generation through text or semantics, and uses it as the first adjustment text. The terminal device 410 sends the image to be adjusted and the first adjustment text to the server 420.

[0064] The server 420 is installed with an application for facial image generation, which is used to provide facial image generation services for the client. After obtaining the first adjustment text and the image to be adjusted, a first random noise is generated, and feature extraction is performed on the image to be adjusted to obtain facial semantic features and facial structural features of the face to be adjusted, and feature extraction is performed on the first adjustment text to obtain a first text feature.

[0065] Server 420 makes adjustments through the attention module in the text graph model according to the facial semantic features, facial structural features and the first text features, that is, dynamically adjusts the degree of attention paid by the text graph model to different positions in the face to be adjusted through the attention mechanism, and obtains the first attention weight of each position in the face to be adjusted.

[0066] Server 420 denoises the first random noise through a text graph model according to the first attention weight, such as performing a denoising operation, to obtain a first target facial image, so that the first target facial image is an image adjusted based on the first adjustment text on the basis of the face to be adjusted, so that the first target facial image meets the specific requirements described in the first adjustment text while keeping the facial semantics of the face to be adjusted basically unchanged.

[0067] Therefore, by considering both facial structural features and facial semantic features, the accuracy of the face in the target facial image is guaranteed while improving the distinctiveness of the face. Moreover, the facial structural features and facial semantic features are integrated into the Wensheng graph model through the attention mechanism, which increases the attention to key information in the image to be adjusted, reduces the interference of redundant information, and better integrates feature information of different scales, thereby improving the generation effect of the first target facial image.

[0068] The facial image generation method provided in the embodiment of the present application can be executed by a server. However, in other embodiments of the present application, the terminal device can also have similar functions as the server, so as to execute the facial image generation method provided in the embodiment of the present application, or the terminal device and the server can jointly execute the facial image generation method provided in the embodiment of the present application, and this embodiment does not limit this.

[0069] The following is a detailed introduction to a facial image generation method provided by the present application through a method embodiment.

[0070] See also Figure 5 , which is a flow chart of the facial image generation method provided by the embodiment of the present application. For the convenience of description, the following embodiment is still introduced by taking the execution subject of the facial image generation method as a server as an example. Figure 5 As shown, the facial image generation method includes S501-S504.

[0071] S501: Acquire an image to be adjusted, a first adjustment text, and a first random noise.

[0072] The image to be adjusted is an image including a face to be adjusted, and the face to be adjusted is a face that needs to be adjusted. It should be noted that the face can be a human face, or an animal, a robot, a virtual person, etc., and this application does not make specific limitations on this.

[0073] The first adjustment text is used to describe the image to be generated, that is, the text used to describe specific requirements, and can be obtained through text or voice, etc. This application does not make any specific limitations on this.

[0074] The first random noise is randomly generated noise, such as Gaussian noise, etc. The size of the noise can be consistent with the size of the image sample (such as the first image sample) used in the process of training the viz graph model, so as to generate the required target facial image by continuously denoising the first random noise.

[0075] It is understandable that in the specific implementation of the present application, it involves user-related data such as the image to be adjusted and the first adjustment text. When the above embodiments of the present application are applied to specific products or technologies, it is necessary to obtain the user's separate permission or consent, and the collection, use and processing of the relevant data need to comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0076] S502: extracting features from the image to be adjusted to obtain facial semantic features and facial structural features of the face to be adjusted, and extracting features from the first adjustment text to obtain first text features.

[0077] Facial semantic features are used to uniquely identify the corresponding entity. Facial semantic features are highly unique and robust, and can accurately identify the same entity under different lighting, angles, and expressions. Different faces have different facial semantic features, thus ensuring the distinguishability of entities.

[0078] Facial structural features usually refer to the geometric features of the face, which can be obtained based on the distance and ratio between facial points, such as the "three parts and five eyes" and "four high and three low" of the face. These structural features provide the basic shape and contour information of the face. Different faces may correspond to the same facial structural features.

[0079] The first text feature is a text feature for describing the first adjustment text.

[0080] The embodiments of the present application do not specifically limit the feature extraction method, and those skilled in the art can set it according to actual needs. For example, feature extraction is performed on the image to be adjusted through the trained additive angular margin loss for deep face recognition (ArcFace), and the facial semantic features of the face to be adjusted included in the image to be adjusted are obtained. Feature extraction is performed on the image to be adjusted through the trained variational autoencoder (VAE), and the facial structural features of the face to be adjusted included in the image to be adjusted are obtained. Feature extraction is performed on the first adjustment text through a pre-training method or model based on contrastive language-image pre-training (CLIP) to obtain the first text feature.

[0081] As a possible implementation method, the image to be adjusted can be cropped to obtain a sub-image that only includes the face to be adjusted, and feature extraction is performed based on the sub-image to obtain facial semantic features and facial structural features to remove the influence of irrelevant information such as the background in the image to be adjusted. Subsequently, feature extraction is only performed on the sub-image including the face to be adjusted, thereby improving the accuracy of facial semantic features and facial structural features.

[0082] Furthermore, a face detection model or other method may be used to detect a region including the face to be adjusted in the image to be adjusted, and the region may be cropped from the image to be adjusted to obtain a sub-image including the face to be adjusted. Figure 6 , which is a schematic diagram of obtaining a sub-image provided by an embodiment of the present application. The area including the face to be adjusted is determined by a face detection model, and the sub-image is obtained by a cropping operation.

[0083] From the above analysis, it can be seen that in the related art, using facial semantic features alone or facial structural features alone to generate images cannot ensure accuracy while improving differentiation. Based on this, in the embodiment of the present application, facial semantic features and facial structural features are used in combination, so as to ensure accuracy based on facial structural features while improving differentiation based on facial semantic features. The following is a detailed description.

[0084] S503: According to the facial semantic features, the facial structural features and the first text features, an adjustment is performed through the attention module in the text graph model to obtain a first attention weight for each position in the face to be adjusted.

[0085] The text-based graph model is an artificial intelligence technology that can convert descriptive text into corresponding images. It can generate models of corresponding images based on text, such as the Stable Diffusion Model (SD).

[0086] In the related art, the required image can be generated through a text-based graph model based only on the first text feature, but this method may require accurate description of the features of the face to be adjusted through text, which places high demands on the user, resulting in a poor user experience.

[0087] Based on this, the embodiment of the present application introduces features for describing the face to be adjusted, and simultaneously introduces facial semantic features and facial structural features, so that the Vincent graph model can learn the features of the face to be adjusted, and can improve the distinguishability based on facial semantic features while ensuring accuracy based on facial structural features. The following describes how the Vincent graph model learns facial semantic features and facial structural features.

[0088] The Wensheng graph model includes an attention module, through which an attention mechanism is introduced, that is, the ability of humans or machines to selectively focus on and process certain information while ignoring other information when processing information. Therefore, the features of the face to be adjusted are learned based on facial semantic features and facial structural features through the attention module, and different first attention weights are assigned to the features corresponding to different positions in the face to be identified. For example, the first attention weight corresponding to the position with key information (hereinafter referred to as the key position) is larger, so that the features of the face to be adjusted are learned more focused through the first attention weight, so as to more accurately capture and transmit this information to the image to be generated, that is, the first target facial image, and improve the generation effect of the generated first target facial image, such as the accuracy of the face to be adjusted, reduce artifacts and distortion, and enhance realism and naturalness.

[0089] Among them, the first attention weight is used to describe the degree of attention that the Vincent graph model pays to each position in the face to be adjusted based on the first text feature, or in other words, the first attention weight is used to describe the degree of attention that the Vincent graph model pays to the key positions in the facial semantic features and facial structural features, but this degree of attention is determined based on the first text feature. The key positions may refer to the facial contour, facial features, expressions, skin texture, gloss, hair and other positions that are more relevant to the image generation task. Through the attention mechanism in the attention module, more focus can be placed on these features.

[0090] Moreover, since redundant information such as the background and irrelevant details in the image to be adjusted may interfere with the judgment of the Wensheng graph model, the attention mechanism can reduce the weight of these redundant information, so that the Wensheng graph model can focus more on processing the features of key positions in the face to be adjusted, thereby improving the generation effect.

[0091] S504: De-noising the first random noise using a Vincent graph model according to the first attention weight to obtain a first target facial image.

[0092] Therefore, after obtaining the first attention weight, the features of the face to be adjusted can be learned more focusedly through the Wensheng graph model, such as guiding the Wensheng graph model to perform feature selection on facial semantic features, facial structural features and first text features based on the first attention weight, so as to denoise the first random noise in a targeted manner, so that the continuously denoised first random noise increasingly meets specific needs, and the first target facial image is obtained, thereby achieving more accurate capture and transmission of key information to the first target facial image.

[0093] Moreover, the first attention weight can be dynamically adjusted according to different faces to be adjusted included in different images to be adjusted. For different images to be adjusted, the attention module in the Vincent graph model can generate different first attention weights to adapt to different scenarios and needs. This dynamic adjustment capability makes the network more flexible and robust.

[0094] The generated first target facial image is an image obtained by adjusting the face to be adjusted based on the first adjustment text. In other words, no matter what the specific requirements corresponding to the first adjustment text are, the face included in the first target facial image will have a high degree of similarity with the face to be adjusted and meet the specific requirements required by the user, such as Figure 1 , Figure 2 or Figure 3 It should be noted that the first target facial image refers to an image that includes a face that is relatively similar to the face to be adjusted, rather than an image that only includes the face. Figure 3 shown.

[0095] It can be seen from the above technical solution that a first adjustment text for describing a specific requirement is obtained, including an image to be adjusted of a face to be adjusted and a first random noise. Feature extraction is performed on the image to be adjusted to obtain facial semantic features and facial structural features of the face to be adjusted, and feature extraction is performed on the first adjustment text to obtain first text features. According to the facial semantic features, facial structural features and the first text features, adjustments are made through the attention module in the Vincent graph model, that is, the degree of attention paid by the Vincent graph model to different positions in the image to be adjusted is dynamically adjusted through the attention mechanism, and the first attention weights of each position in the face to be adjusted are obtained. According to the first attention weight, the first random noise is denoised through the Vincent graph model to obtain a first target facial image, so that the first target facial image is an image obtained by adjusting the face to be adjusted based on the first adjustment text, that is, while keeping the facial semantics of the face to be adjusted basically unchanged, the first target facial image meets the specific requirements described in the first adjustment text.

[0096] Therefore, by considering both facial structural features and facial semantic features, the accuracy of the face in the target facial image is guaranteed while improving the distinctiveness of the face. Moreover, the facial structural features and facial semantic features are integrated into the Wensheng graph model through the attention mechanism, which increases the attention to key information in the image to be adjusted, reduces the interference of redundant information, and better integrates feature information of different scales, thereby improving the generation effect of the first target facial image.

[0097] As a possible implementation, although the first target facial image is generated based on the first adjustment text, the user may be dissatisfied with the effect of the first target facial image, such as when the user finds that the specific requirements described by the user are incorrect, or when the user wants to change the image style. Based on this, the embodiment of the present application supports re-entering the required specific requirements, such as entering the second adjustment text. It should be noted that the second adjustment text can be directly input or modified based on the first adjustment text. The present application does not make specific limitations on this, and those skilled in the art can set it according to actual needs.

[0098] After obtaining the second adjustment text for the image to be adjusted, feature extraction is performed on the second adjustment text to obtain second text features. The embodiment of the present application does not specifically limit the method of feature extraction for the second adjustment text. For example, the same method as feature extraction for the first adjustment text is used, such as using the same feature extraction model, and those skilled in the art can make settings according to actual needs.

[0099] According to the facial semantic features, facial structural features and the second text features, the attention module in the Wensheng graph model is adjusted to obtain the second attention weights of each position in the face to be adjusted. See S503 for details, which will not be repeated here. Among them, the second attention weight is used to describe the degree of attention of the Wensheng graph model to each position in the face to be adjusted based on the second text feature, or in other words, the second attention weight is used to describe the degree of attention of the Wensheng graph model to the key positions in the facial semantic features and facial structural features, but the degree of attention is determined based on the second text feature, and the first attention weight and the second attention weight may be the same or different.

[0100] Finally, according to the second attention weight, the acquired second random noise is denoised by the text graph model to obtain a second target facial image. See S504 for details, which will not be repeated here. Among them, the second target facial image is an image adjusted based on the face to be adjusted based on the second adjustment text. The second random noise is randomly generated noise, such as Gaussian noise, etc. The second random noise can be the same as the first random noise or different, and this application does not make specific limitations on this.

[0101] Therefore, in the process of generating multiple target facial images for the same image to be adjusted, only the adjustment text can be updated. The embodiment of the present application will automatically adjust the attention weight of the updated adjustment text through the attention module in the text graph model based on the updated adjustment text, thereby generating the corresponding target facial image, thereby making the target facial image generation process have better text editability and improving the user experience.

[0102] As a possible implementation method, although the facial semantic features and facial structural features for the face to be adjusted are introduced into the text graph module, if more of them are integrated into the text graph model, it may affect the learning of the text graph model for the input text to be adjusted, that is, the text graph model learns more facial semantic features and facial structural features, resulting in overfitting and failure to meet the specific needs of the text description to be adjusted; if less of them are integrated into the text graph model, the text graph model may not be able to fully learn the facial semantic features and facial structural features, resulting in underfitting.

[0103] Based on this, an embodiment of the present application provides a specific implementation method of S503, that is, according to facial semantic features, facial structural features and first text features, adjustments are made through the attention module in the text graph model to obtain the first attention weights of each position in the face to be adjusted.

[0104] The first attention weight obtained by adjusting the attention module is taken as an example for explanation. Specifically, after the facial semantic features, facial structural features and the first text features are input into the Wensheng graph model, the Wensheng graph model includes a first encoder and a first decoder, and the facial semantic features, facial structural features and the first text features are adjusted by the attention module in the first encoder, and the facial semantic features and the first text features are adjusted by the attention module in the first decoder, so as to obtain the first attention weights of each position in the face to be adjusted.

[0105] That is to say, while integrating the first text feature into each module in the Vincent graph model, the facial semantic feature is integrated into the attention module of the first encoder and the attention module in the first decoder, and the facial structure feature is integrated into the attention module of the first encoder. This ensures that the facial semantic features and facial structure features are fully learned without causing the Vincent graph model to learn the text to be adjusted, that is, the learning intensity of the face to be adjusted and the text to be adjusted is balanced, thereby avoiding overfitting or underfitting, improving the learning ability of the Vincent graph model, and ensuring the accuracy of the generated target facial image.

[0106] The embodiments of the present application do not specifically limit the process of adjusting the attention module to obtain the attention weight. It is understandable that the text graph model may include one or more attention modules. The following is an example of adjusting an attention module included in the text graph model to obtain a first attention weight. See A1-A7 for details.

[0107] A1: According to the first random noise, denoising is performed through the text graph model to obtain query features.

[0108] After the first random noise is input to the Wensheng graph model, the Wensheng graph model will continuously denoise the first random noise. For example, each denoising will obtain a query feature, so as to obtain the desired target facial image through continuous denoising. It can be understood that the denoising process is performed based on the first attention weight obtained each time.

[0109] Taking the example of a multi-layer network including multiple Transformer structures in the Wensheng graph model, the features output by each Transformer structure are the query features. In other words, the query feature represents the area or information point that needs to be paid attention to at present. For example, taking the Convolutional Networks for Biomedical Image Segmentation (U-Net) for biomedical image segmentation as an example, in the context of U-Net, the query feature may come from a certain stage of the decoder, representing a certain area of ​​the image or feature map currently being processed.

[0110] A2: According to the query features and facial semantic features, the attention module in the text graph model performs a cross-attention operation to obtain the first sub-attention weight.

[0111] Among them, the Cross-Attention operation is used to process the interaction between two different sequences (or feature maps) and obtain the correlation between them by cross-calculating attention. For example, in the U-Net model, it is usually used to fuse the high-level features of the encoder and the current features of the decoder to capture the dependency between them, thereby assisting the U-Net model in recovering spatial information.

[0112] The cross-attention operation can not only reduce the interference of redundant information by reducing the weight of non-critical areas, but also help find similar local areas between two different sequences and perform feature fusion based on them, so as to retain the details of the face to be adjusted in the generated target facial image while meeting the corresponding specific needs, thereby increasing the attention to key information. Moreover, the cross-attention operation can make the Wensheng graph model more flexible and robust, able to adapt to faces of different shapes, sizes, postures and lighting conditions, and improve the accuracy of the generated target facial image.

[0113] The first sub-attention weight is a weight value obtained based on the similarity between the query feature and the facial semantic feature, so that based on the first sub-attention weight, it is possible to clarify how to learn the facial semantic feature.

[0114] A3: According to the query feature and the first text feature, a cross-attention operation is performed through the attention module in the text graph model to obtain the second sub-attention weight.

[0115] The second sub-attention weight is a weight value obtained based on the similarity between the query feature and the first text feature, so that based on the second sub-attention weight, it is possible to clarify how to learn the first text feature.

[0116] A4: Get the cross attention weight according to the first sub-attention weight and the second sub-attention weight.

[0117] For example, the criss-cross attention weight can be expressed as formula (1):

[0118] Output1 = cross_attention_1(Q, F1) + cross_attention_2(Q, F2) (1)

[0119] Among them, Output1 represents the cross attention weight; Q represents the query feature; F1 represents the facial semantic feature; F2 represents the first text feature, and cross_attention represents the cross attention operation, which is used to measure the similarity between the query (Query) and a set of keys (Keys), and perform weighted summation of the values ​​(Values) based on these similarities.

[0120] In other words, in the related art, the input of the text graph model is only text. In order to introduce images, an attention module with a cross-attention function can be added on the basis of the existing attention module in the text graph model. Continuing with the U-Net model as an example, a cross-attention module is added to each cross-attention module included in the U-Net model, so as to realize the calculation of the cross-attention weight based on the newly added cross-attention module, that is, to realize the introduction of facial semantic features, so that the model can learn facial semantic features, such as adding a trainable key linear layer and value linear layer to process facial semantic features.

[0121] A5: According to the query features, the self-attention operation is performed through the attention module in the text graph model to obtain the third sub-attention weight.

[0122] The self-attention operation is mainly used to interact information between different positions in the same sequence (or feature map). By calculating the weight at each position, different positions are given different importance, thereby achieving modeling of each position. It is mainly used to capture the internal dependencies of the feature map and establish global interactions.

[0123] The self-attention operation allows the Vincent graph model to capture long-range dependencies in the image, thereby better integrating global features. The weight of key information is enhanced by calculating the correlation between pixels or features. As a result, more attention can be paid to key locations of the face, such as eyes, mouth, nose, etc., thereby improving the details and realism of these key locations. Moreover, the interference of redundant information can be reduced by reducing the weight of non-critical areas. This further makes the Vincent graph model more flexible and robust, and can adapt to faces of different shapes, sizes, postures and lighting conditions.

[0124] The third sub-attention weight is the weight value obtained based on the query feature.

[0125] A6: According to the query features and facial structure features, the attention module in the text graph model performs a cross-attention operation to obtain the fourth sub-attention weight.

[0126] The fourth sub-attention weight is a weight value obtained based on the similarity between the query feature and the facial structure feature, so that based on the fourth sub-attention weight, it is possible to clarify how to learn the facial structure feature.

[0127] A7: According to the third sub-attention weight and the fourth sub-attention weight, the self-attention weight is obtained.

[0128] For example, the self-attention weight can be expressed as formula (2):

[0129] Output2 = self_attention(Q) + cross_attention(Q, S) (2)

[0130] Among them, Output2 represents the self-attention weight; Q represents the query feature; S represents the facial structure feature, and self_attention represents the self-attention operation.

[0131] In other words, in the related art, the input of the text graph model is only text. In order to introduce images, an attention module with a cross-attention function can be added on the basis of the attention module with a self-attention function already in the text graph model. Continuing with the U-Net model as an example, a cross-attention module is added to each self-attention module included in the U-Net model, so that the calculation of the self-attention weight is realized based on the newly added cross-attention module, that is, the introduction of facial structural features is realized, so that the model can learn facial structural features, such as adding a trainable key linear layer and a value linear layer to process facial semantic features.

[0132] Therefore, by adding an attention module to calculate the cross-attention weight and self-attention weight, facial semantic features and facial structural features are introduced into the Wensheng graph model through cross-attention operations and self-attention operations, so that the Wensheng graph model can better learn the facial semantic features, facial structural features and text features used to describe specific needs of the face to be adjusted, thereby improving the accuracy of the generated target facial image.

[0133] The training process of the Wensheng graph model is explained below.

[0134] Method 1: directly use the trained basic text graph model and train the attention module separately.

[0135] See also Figure 7 , which is a training diagram of a text graph model provided in an embodiment of the present application. Figure 7 In the text graph model, the text graph model includes the basic text graph model ( Figure 7 The basic text graph model is a text graph model that has been trained, such as the Stable Diffusion (SD) model V1.5. In the embodiment of the present application, at least one attention module is added to the basic text graph model to obtain the text graph model. The training process of the text graph model is described below, and specifically see B1-B6.

[0136] B1: Acquire a first image sample including a face and a text sample for describing the first image sample.

[0137] Among them, the first image sample is an image sample including a face, and the face may be the same as the face to be adjusted or different from the face to be adjusted, and this application does not make any specific limitation on this.

[0138] The text sample is a text describing the first image sample, so as to train the text-to-image model to establish a conversion relationship between the text and the image.

[0139] B2: Perform feature extraction on the first image sample to obtain a facial semantic feature sample and a facial structure feature sample, and perform feature extraction on the text sample to obtain a text feature sample.

[0140] The facial semantic feature samples are facial semantic features of the first image samples, the facial structural feature samples are facial structural features of the first image samples, and the text feature samples are text features of the text samples.

[0141] B3: Add noise to the first image sample to obtain a noisy first image sample.

[0142] The noisy first image sample is an image sample to which noise is added based on the first image sample. The embodiment of the present application does not specifically limit the noise, and the noise may be Gaussian noise or the like.

[0143] B4: According to the facial semantic feature samples, facial structural feature samples and text feature samples, the initial attention module in the initial text graph model is adjusted to obtain the predicted attention weights of each position in the face included in the first image sample.

[0144] The predicted attention weight is used to describe the degree of attention that the text graph model pays to each position in the face included in the first image sample based on the text feature sample.

[0145] The initial text graph model is a text graph model that has not been trained yet, or in other words, compared with the text graph model, the generation effect of the initial text graph model is poor, that is, the model parameters of the initial text graph model have not been adjusted to a better level. The initial text graph model includes an initial attention module and a basic text graph model, wherein the initial attention module is an attention module that has not been trained yet, and the basic text graph model is a trained model. In other words, the parameters of the basic text graph model are fixed during the training process of the initial text graph model, and only the parameters of the initial attention module are adjusted, that is, the reason why the initial text graph model has not been trained yet is that it includes an initial attention module that has not been trained yet.

[0146] B5: According to the predicted attention weight, the noisy first image sample is denoised through the initial text graph model to obtain the predicted facial image.

[0147] After obtaining the predicted attention weights, the initial text graph model can be used to more focusedly learn the facial features included in the first image sample. For example, based on the predicted attention weights, the initial text graph model can be guided to perform feature selection on facial semantic feature samples, facial structural feature samples, and text feature samples, thereby denoising the noisy first image samples in a targeted manner, so that the continuously denoised noisy first image samples increasingly meet the specific requirements of the text sample description, that is, the denoised noisy first image samples increasingly resemble the first image samples, thereby obtaining a predicted facial image.

[0148] The predicted facial image is obtained based on the initial text-graph model and is adjusted on the basis of the face included in the first sample image so as to be more in line with the specific requirements of the text sample description.

[0149] B6: According to the difference between the predicted facial image and the first image sample, the parameters of the initial attention module are adjusted to obtain a Wensheng graph model including the attention module.

[0150] The training goal of the initial Vincent graph model is to make the predicted facial image generated by it more and more similar to the first image sample, that is, to reduce the difference between the predicted facial image and the first image sample, and adjust the parameters of the initial attention module to obtain the attention module. Thus, the Vincent graph model is obtained based on the attention module and the basic Vincent graph model, and the training is completed.

[0151] Based on this, after the text generation model is trained based on the method of B1-B6, the text generation model can be used based on the method of S501-S504.

[0152] Therefore, the trained basic Wensheng graph model is directly adopted, and the initial attention module is added on its basis. The trained attention module is obtained by training the initial attention module, such as adjusting the parameters of the initial attention module on the basis of freezing the basic Wensheng graph model, and then the Wensheng graph model is obtained based on the attention module and the basic Wensheng graph model. This reduces the training cost of the Wensheng graph model, increases the training speed of the Wensheng graph model, and can also improve the image generation effect.

[0153] Method 2: directly use the trained basic text graph model to jointly train the attention module, semantic feature extraction model and structural feature extraction model.

[0154] See also Figure 8 , which is a training diagram of a text graph model provided in an embodiment of the present application. Figure 8 In the text graph model, the text graph model includes the basic text graph model ( Figure 8 ), and at least one attention module.

[0155] Among them, the basic text graph model is the text graph model that has been trained, and the attention module, semantic feature extraction model and structural feature extraction model are jointly trained. The training process is described below, and see C1-C6 for details.

[0156] C1: Acquire a first image sample including a face and a text sample for describing the first image sample.

[0157] C2: Based on the first image sample, feature extraction is performed through the initial semantic feature extraction model to obtain a facial semantic feature sample. Based on the first image sample, feature extraction is performed through the initial structural feature extraction model to obtain a facial structural feature sample. Feature extraction is performed on the text sample to obtain a text feature sample.

[0158] The initial semantic feature extraction model is a semantic feature extraction model that has not yet been trained and is used to extract features from images to obtain corresponding semantic features.

[0159] The initial structural feature extraction model is a structural feature extraction model that has not yet been trained and is used to extract features from images to obtain corresponding structural features.

[0160] The embodiment of the present application does not specifically limit the method of extracting features from text samples, such as extracting features through the CLIP model to obtain text feature samples. As a possible implementation method, the model used for extracting features from text samples can be a trained model, thereby further reducing the difficulty of model training.

[0161] As a possible implementation method, although the facial semantic feature sample is used to uniquely identify the corresponding entity, it also carries some features related to the facial structural feature sample. Therefore, in order to enrich the information carried by the facial structural feature samples and the facial semantic feature samples, it is no longer necessary to obtain the facial semantic feature sample and the facial structural feature sample for the same image, that is, for the first image sample. Instead, based on the first image sample, feature extraction is performed through the initial semantic feature extraction model to obtain the facial semantic feature sample, and based on the second image sample, feature extraction is performed through the initial structural feature extraction model to obtain the facial structural feature sample.

[0162] The second image sample can be obtained based on the first image sample. The first image sample and the second image sample are different images describing the same face, or in other words, the facial semantic features of the first image sample and the facial semantic features of the second image sample are the same.

[0163] As a possible implementation method, multiple different image samples can be collected for the same face, so that one of them is used as the first image sample and the other is used as the second image sample, thereby improving the diversity of information carried by the facial structure feature samples, improving the learning ability of the Vincent graph model, and enhancing the robustness of the Vincent graph model.

[0164] In addition, compared with the method of generating the second image sample based on the first image sample through a diffusion model or other models, the method of collecting multiple image samples for the same face can avoid the diffusion model from generating more useless information, such as posture, light and shadow, etc., thereby improving the accuracy of the target facial image generated by the Wensheng graph model.

[0165] Furthermore, after obtaining the second image sample, the second image sample can be cropped to obtain a sub-image including only the face, and feature extraction is performed on the sub-image to obtain a facial structure feature sample to remove the influence of irrelevant information such as the background in the second image sample. Feature extraction is only performed on the sub-image including the face, thereby improving the accuracy of the facial structure feature sample.

[0166] C3: adding noise to the first image sample to obtain a noisy first image sample.

[0167] C4: Based on the facial semantic feature samples, facial structural feature samples and text feature samples, the initial attention module in the initial text graph model is adjusted to obtain the predicted attention weights of each position in the face included in the first image sample.

[0168] C5: According to the predicted attention weight, the noisy first image sample is denoised through the initial Wensheng graph model to obtain the predicted facial image.

[0169] C6: According to the difference between the predicted facial image and the first image sample, the parameters of the initial attention module, the parameters of the initial semantic feature extraction model and the parameters of the initial structural feature extraction model are adjusted, and the corresponding text graph model including the attention module, the semantic feature extraction model and the structural feature extraction model are obtained.

[0170] According to the difference between the predicted facial image and the first image sample, the parameters of the initial attention module are adjusted to obtain the attention module.

[0171] According to the difference between the predicted facial image and the first image sample, the parameters of the initial semantic feature extraction model are adjusted to obtain the semantic feature extraction model.

[0172] According to the difference between the predicted facial image and the first image sample, the parameters of the initial structural feature extraction model are adjusted to obtain the structural feature extraction model.

[0173] That is, based on the training direction of minimizing the difference between the predicted facial image and the first image sample, the parameters of the initial attention module, the parameters of the initial semantic feature extraction model, and the parameters of the initial structural feature extraction model are adjusted together, thereby obtaining the attention module, the semantic feature extraction model, and the structural feature extraction model, respectively. It can be understood that during the training process, the parameters of the basic text graph model are fixed, and only the attention module is trained. When the attention module training is completed, the trained initial text graph model can be obtained.

[0174] Therefore, in the process of training the initial attention module in the initial text graph model, the initial semantic feature extraction model and the initial structural feature extraction model are jointly trained, so that the attention module is obtained while obtaining the semantic feature extraction model and the structural feature extraction model, so that the semantic feature extraction model and the structural feature extraction model obtained by the joint training can not only perform feature extraction, but also make the facial semantic features and facial structural features obtained by the feature extraction in the same feature space as the first text feature, so that the text graph model is easier to understand the newly introduced facial semantic features and facial structural features, thereby improving the generation effect of the target facial image.

[0175] Based on this, through joint training, after the text graph model is trained, the semantic feature extraction model and the structural feature extraction model can also be obtained.

[0176] Therefore, according to the image to be adjusted, feature extraction can be performed through the semantic feature extraction model to obtain facial semantic features, and according to the image to be adjusted, feature extraction can be performed through the structural feature extraction model to obtain facial structural features. The facial structural features and the first text features are in the same feature space, and the facial semantic features and the first text features are in the same feature space.

[0177] That is to say, by jointly training the text graph model, the semantic feature extraction model, and the structural feature extraction model, the facial semantic features extracted by the semantic feature extraction model and the facial structural features extracted by the structural feature extraction model can be in the same feature space as the first text feature. Since the text graph model can understand the first text feature, it is easier for the text graph model to understand the facial semantic features and facial structural features in the same feature space as the first text feature, thereby improving the generation effect of the text graph model.

[0178] Method three is to directly use the trained basic text-graph model, the trained (i.e., pre-trained) basic semantic feature extraction model, and the trained (i.e., pre-trained) basic structural feature extraction model to jointly train the attention module, the semantic feature extraction model, and the structural feature extraction model.

[0179] See also Fig. 9 , which is a training diagram of a text graph model provided in an embodiment of the present application. Fig. 9 In the text graph model, the text graph model includes the basic text graph model ( Fig. 9 ), and at least one attention module.

[0180] Among them, the basic text graph model is a trained text graph model, the basic semantic feature extraction model is a trained semantic feature extraction model, the basic structural feature extraction model is a trained structural feature extraction model, and the attention module, semantic feature extraction model and structural feature extraction model are jointly trained. The training process is described below, see D1-D6 for details.

[0181] D1: Obtain a first image sample including a face and a text sample for describing the first image sample.

[0182] D2: Based on the first image sample, feature extraction is performed using a pre-trained basic semantic feature extraction model to obtain an initial facial semantic feature sample; based on the initial facial semantic feature sample, conversion is performed using an initial semantic feature extraction model to obtain a facial semantic feature sample. Based on the first image sample, feature extraction is performed using a pre-trained basic structural feature extraction model to obtain an initial facial structural feature sample; based on the initial facial structural feature sample, feature extraction is performed using an initial structural feature extraction model to obtain a facial structural feature sample. Feature extraction is performed on the text sample to obtain a text feature sample.

[0183] The basic semantic feature extraction model is a trained model for extracting semantic features from images, such as the ArcFace model, etc., and this application does not specifically limit this. However, the initial facial semantic feature sample obtained by extracting features from the first image sample based on the trained basic semantic feature extraction model may not be understood by the Wensheng graph model.

[0184] Based on this, the facial semantic feature samples that can be understood by the Wensheng graph model are converted through the initial semantic feature extraction model, so as to avoid the initial facial semantic feature samples that cannot be understood by the initial Wensheng graph model or the facial semantic feature samples are inappropriate in dimension and cannot be used. For example, the dimension of the initial facial semantic feature samples extracted by the ArcFace model is 512. After conversion through the initial semantic feature extraction model, the dimension of the facial semantic feature samples is 3072, which can also be converted into 4×768 sequence features.

[0185] The embodiment of the present application does not specifically limit the semantic feature extraction model, and it can be a multilayer perceptron (English: Multilayer Perceptron, MLP) and the like.

[0186] Similarly, the basic structural feature extraction model is a trained model for extracting structural features from an image, such as a VAE model, etc., and this application does not specifically limit this. However, the initial facial structural feature sample obtained by extracting features from the first image sample (or the second image sample) based on the trained basic structural feature extraction model may not be understood by the Wensheng graph model.

[0187] Based on this, the initial structural feature extraction model is used for conversion to obtain facial structural feature samples that can be understood by the Wensheng graph model, thereby avoiding the situation where the initial Wensheng graph model cannot understand the initial facial structural feature samples or the facial structural feature samples are inappropriate in dimension and cannot be used. For example, the dimension of the initial facial structural feature samples extracted by the VAE model is 16x16x4. After conversion by the initial structural feature extraction model, the dimension of the facial structural feature samples is 4x4x1024.

[0188] As a possible implementation, the initial structural feature extraction model includes a first initial submodule, a second initial submodule and a third initial submodule, each of which is used to extract facial structural features of different scales. Specifically, according to the initial facial structural feature samples, the first initial submodule is used to extract features to obtain first-scale facial structural feature samples; according to the first-scale facial structural feature samples, the second initial submodule is used to extract features to obtain second-scale facial structural feature samples; according to the second-scale facial structural feature samples, the third initial submodule is used to extract features to obtain third-scale facial structural feature samples.

[0189] Among them, the scales of the first-scale facial structure feature samples, the scales of the second-scale facial structure feature samples and the scales of the third-scale facial structure feature samples are different, and the facial structure feature samples include the first-scale facial structure feature samples, the second-scale facial structure feature samples and the third-scale facial structure feature samples.

[0190] See also Fig.10 , which is a schematic diagram of an initial structural feature extraction model provided in an embodiment of the present application. Fig.10 In the , the initial structural feature extraction model includes three initial submodules, wherein the first initial submodule includes a 3×3 convolution layer (Conv), the second initial submodule includes two 3×3 convolution layers, an activation function layer (Relu) and a 2×2 pooling layer (Pooling), and the third initial submodule includes two 3×3 convolution layers, an activation function layer and a 2×2 pooling layer. The dimensions of the first-scale facial structural feature samples extracted by the first initial submodule are 16×16×256, the dimensions of the second-scale facial structural feature samples extracted by the second initial submodule are 8×8×512, and the dimensions of the third-scale facial structural feature samples extracted by the third initial submodule are 4×4×1024.

[0191] Therefore, compared with single-scale facial structure feature samples, multi-scale facial structure feature samples can make the facial structure description of the facial structure more accurate, that is, make the feature extraction of the initial structure feature extraction model more accurate, thereby improving the accuracy of the image generated by the subsequent initial text image model.

[0192] D3: adding noise to the first image sample to obtain a noisy first image sample.

[0193] D4: According to the facial semantic feature samples, facial structural feature samples and text feature samples, the initial attention module in the initial text graph model is adjusted to obtain the predicted attention weights of each position in the face included in the first image sample.

[0194] The initial text graph model includes a first initial encoder and a first initial decoder, wherein at least three attention modules are added to the first initial encoder, and the three attention modules are used to provide cross-attention operations, thereby fusing the three-scale facial structure feature samples obtained by feature extraction through the three initial submodules, that is, the first-scale facial structure feature sample, the second-scale facial structure feature sample and the third-scale facial structure feature sample are respectively input into different attention modules included in the first initial encoder. In addition, the facial semantic feature samples and the text feature samples are input into the initial text graph model, and the predicted attention weights of each position in the first image sample are obtained by adjusting them through the attention modules in the initial text graph model.

[0195] Therefore, compared with only inserting them into one attention module, by inserting the multi-scale facial structure feature samples into different attention modules, the multi-scale facial structure features can be more fully integrated into the Vincent graph model, so that the Vincent graph model can fully learn the facial structure feature samples, thereby better learning and improving the generation effect of subsequent target facial images.

[0196] Furthermore, while the first-scale facial structure feature samples, the second-scale facial structure feature samples and the third-scale facial structure feature samples are respectively input into different attention modules included in the first initial encoder, the facial semantic feature samples can also be respectively input into the first initial encoder and the first initial decoder, and the text feature samples can be respectively input into the first initial encoder and the first initial decoder, so as to ensure that the facial semantic feature samples and the facial structure feature samples are fully learned while not affecting the learning of the text feature samples by the initial text graph model, that is, the learning intensity of the facial features and the text features is balanced, thereby avoiding overfitting or underfitting, improving the learning ability of the text graph model, and ensuring the accuracy of the generated target facial image.

[0197] D5: According to the predicted attention weights, the noisy first image sample is denoised through the initial text graph model to obtain the predicted facial image.

[0198] D6: According to the difference between the predicted facial image and the first image sample, the parameters of the initial attention module, the parameters of the initial semantic feature extraction model and the parameters of the initial structural feature extraction model are adjusted, and the text graph model including the attention module, the semantic feature extraction model and the structural feature extraction model are correspondingly obtained.

[0199] In addition, the first initial decoder included in the initial text graph model is trained to obtain a first decoder, and the first initial encoder included in the initial text graph model is trained to obtain a first encoder.

[0200] Therefore, compared with the aforementioned method 2, feature extraction is first performed based on the trained basic semantic feature extraction model and the trained basic structural feature extraction model. This can reduce the training difficulty of the semantic feature extraction model and the structural feature extraction model, and there is no need to collect multiple facial images. While reducing the training cost, it can also improve the generation effect of the target facial image.

[0201] Based on this, after jointly training to obtain the text image model, semantic feature extraction model and structural feature extraction model, feature extraction can be performed based on the image to be adjusted through the pre-trained basic semantic feature extraction model to obtain initial facial semantic features; based on the initial facial semantic features, feature extraction can be performed through the semantic feature extraction model to obtain facial semantic features.

[0202] According to the image to be adjusted, feature extraction is performed through a pre-trained basic structural feature extraction model to obtain initial facial structural features; according to the initial facial structural features, feature extraction is performed through a structural feature extraction model to obtain facial structural features.

[0203] As a possible implementation method, if the initial structural feature extraction model includes a first initial submodule, a second initial submodule and a third initial submodule, the trained structural feature extraction model includes a first submodule, a second submodule and a third submodule, that is, the first initial submodule is trained to obtain the first submodule, the second initial submodule is trained to obtain the second submodule, and the third initial submodule is trained to obtain the third submodule.

[0204] Based on this, feature extraction can be performed through the first submodule according to the initial facial structure features to obtain first-scale facial structure features, feature extraction can be performed through the second submodule according to the first-scale facial structure features to obtain second-scale facial structure features, and feature extraction can be performed through the third submodule according to the second-scale facial structure features to obtain third-scale facial structure features.

[0205] Among them, the scales of the first-scale facial structure features, the scales of the second-scale facial structure features and the scales of the third-scale facial structure features are different, and the facial structure features include the first-scale facial structure features, the second-scale facial structure features and the third-scale facial structure features.

[0206] Therefore, compared with single-scale facial structural features, multi-scale facial structural features can make the facial structural features describe the facial structure more accurately, that is, make the feature extraction of the structural feature extraction model more accurate, thereby improving the accuracy of image generation by the subsequent text graph model.

[0207] That is to say, by jointly training the text graph model, the semantic feature extraction model, and the structural feature extraction model, and performing joint training based on the semantic feature extraction model and the basic structural feature extraction model, the facial semantic features extracted by the semantic feature extraction model and the facial structural features extracted by the structural feature extraction model can be in the same feature space as the first text feature. Since the text graph model can understand the first text feature, it is also easier for the text graph model to understand the facial semantic features and facial structural features in the same feature space as the first text feature, thereby improving the generation effect of the text graph model.

[0208] As a possible implementation method, since the user may enter the adjustment text such as the first adjustment text or the second adjustment text casually, the text-generated graph model may have a deviation in understanding the adjustment text, resulting in poor generation of the target facial image.

[0209] Based on this, a text template may be preset, and the following description will be given taking the first adjustment text as an example.

[0210] After obtaining the initial adjustment text input by the user, the text template is obtained, and the first adjustment text is obtained according to the initial adjustment text and the text molding. Therefore, after modifying the initial adjustment text based on the text template, the first adjustment text obtained is easier to be understood by the text graph model.

[0211] Furthermore, a variety of text templates can be set to meet the needs of different situations, such as dialect requirements, scene requirements, etc.

[0212] After obtaining the initial adjustment text input by the user, a text template is obtained based on the current situation, and a first adjustment text is obtained based on the initial adjustment text and text molding. Therefore, after modifying the initial adjustment text based on the text template, the first adjustment text obtained is easier to be understood by the text graph model.

[0213] The facial image generation method provided in the embodiment of the present application may mainly involve artificial intelligence technology, wherein artificial intelligence is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that the machines have the functions of perception, reasoning and decision-making.

[0214] Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level and software-level technologies. Basic artificial intelligence technologies generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operating / interactive systems, mechatronics and other technologies. Artificial intelligence software technologies mainly include computer vision technology, speech processing technology, natural language processing technology, as well as machine learning / deep learning, autonomous driving, smart transportation and other major directions.

[0215] In the embodiments of the present application, the artificial intelligence technologies mainly involved include the above-mentioned computer vision technology, machine learning, etc. For example, in the embodiments of the present application, the models involved, such as the text graph model, semantic feature extraction model, and structural feature extraction model, can all be obtained through computer vision technology or machine learning training included in artificial intelligence technology.

[0216] Among them, Computer Vision (CV) is a science that studies how to make machines "see". To put it more specifically, it refers to using cameras and computers to replace human eyes to identify targets, detect and measure in real time, and perform other machine vision functions, and further perform image processing to make computer processing more suitable for human observation or transmission to instruments for detection. As a scientific discipline, computer vision studies related theories and technologies, and attempts to establish an artificial intelligence system that can obtain information from images or multidimensional data. Large model technology has brought important changes to the development of computer vision technology. Pre-trained models in the visual field such as the general visual deformer backbone network (swin-transformer), image classification network (Vision Transformer, ViT), diluted visual deformer (Vision Transformer, V-MOE), and masked autoencoder (MAE) can be quickly and widely applied to downstream specific tasks after fine tuning. Computer vision technology generally includes image processing, image recognition, image semantic understanding, image retrieval, optical character recognition (OCR), video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous positioning and map construction, as well as common biometric recognition technologies such as face recognition and fingerprint recognition.

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

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

[0219] In order to facilitate further understanding of the technical solution provided by the embodiment of the present application, the facial image generation method provided by the embodiment of the present application is taken as an example in which the execution subject is a server, and the facial image generation method is introduced as a whole.

[0220] The following is an explanation of the training process of the Wensheng graph model.

[0221] In this embodiment, a face dataset containing faces is used for training, but each group of image samples includes a first image sample and a second image sample collected based on the same face. The Vincent graph model is a SDv1.5 model.

[0222] See also Fig.11 , which is a schematic diagram of an application scenario of a facial image generation method provided by an embodiment of the present application. Fig.11 In the paper, the text-based graph model includes the U-Net model, the CLIP model (i.e., the text feature extraction model) and the VAE model.

[0223] The U-Net model includes a first encoder (UNet encoder), a first decoder (UNet decoder) and a jump connection module (middle block), and the first encoder and the second encoder each include four different submodules. An attention module with a cross-attention function is added to each text cross-attention module to learn facial semantic features, as shown in formula (1). An attention module with a cross-attention function is added to each self-attention module to learn facial structural features, as shown in formula (2).

[0224] The VAE model includes a second encoder and a second decoder. It uses a VAE encoder to compress the image into low-resolution latent features. Then the U-Net model uses the latent output by the decoder to decode the image through the VAE decoder.

[0225] The CLIP model consists of an image encoder and a text encoder, and the embedding is generated by comparing the cosine similarity. The text encoder part of the CLIP model is used in the SDv1.5 model, and the text features are integrated into each module of the U-Net model through cross attention.

[0226] In addition, the SDv1.5 model also includes modules such as time step encoding (not shown in the figure) to control noise in the generation process.

[0227] E1: Obtain a first image sample including a face and a text sample for describing the first image sample.

[0228] E2: Based on the first image sample, feature extraction is performed using a pre-trained basic semantic feature extraction model to obtain an initial facial semantic feature sample.

[0229] E3: According to the initial facial semantic feature sample, the facial semantic feature sample is converted through the initial semantic feature extraction model to obtain the facial semantic feature sample.

[0230] E4: Obtain a second image sample according to the first image sample.

[0231] E5: Based on the second image sample, feature extraction is performed using a pre-trained basic structure feature extraction model to obtain an initial facial structure feature sample.

[0232] E6: Based on the initial facial structure feature sample, feature extraction is performed through the initial structure feature extraction model to obtain the facial structure feature sample.

[0233] Among them, the initial structural feature extraction model may include a first initial submodule, a second initial submodule and a third initial submodule. According to the initial facial structural feature samples, the first initial submodule is used to perform feature extraction to obtain a first-scale facial structural feature sample; according to the first-scale facial structural feature samples, the second initial submodule is used to perform feature extraction to obtain a second-scale facial structural feature sample; according to the second-scale facial structural feature samples, the third initial submodule is used to perform feature extraction to obtain a third-scale facial structural feature sample.

[0234] E7: Extract features from text samples through a text feature extraction model to obtain text feature samples.

[0235] E8: Add noise to the first image sample to obtain a noisy first image sample.

[0236] E9: According to the facial semantic feature samples, facial structural feature samples and text feature samples, the initial attention module in the initial text graph model is adjusted to obtain the predicted attention weights of each position in the face included in the first image sample.

[0237] If multi-scale facial structure feature samples are extracted through the structural feature extraction model, the first-scale facial structure feature samples, the second-scale facial structure feature samples and the third-scale facial structure feature samples are respectively input into different attention modules included in the first initial encoder. For example, the first encoder included in the U-Net model has four sub-modules, and the three-scale facial structure features can be integrated into the first three sub-modules respectively.

[0238] The facial semantic feature samples are respectively input into the first initial encoder, the first initial decoder and the jump connection module, and the text feature samples are respectively input into the first initial encoder, the first initial decoder and the jump connection module (the figure only shows the text feature samples being input into the first initial encoder). The attention module in the initial text graph model is used to adjust the predicted attention weights of each position in the first image sample.

[0239] E10: According to the predicted attention weights, the noisy first image sample is denoised through the initial text graph model to generate a predicted facial image.

[0240] E11: According to the difference between the predicted facial image and the first image sample, the parameters of the initial attention module, the parameters of the initial semantic feature extraction model and the parameters of the initial structural feature extraction model are adjusted, and the text graph model including the attention module, the semantic feature extraction model and the structural feature extraction model are correspondingly obtained.

[0241] It should be noted that during the training process, only the newly added semantic feature extraction model, structural feature extraction model, and attention module in the text graph model are trained. The training uses the AdamW optimizer with a fixed learning rate of 1e-5.

[0242] In this way, the joint training of the text graph model, semantic feature extraction model and structural feature extraction model is achieved.

[0243] The following is an explanation of the usage process of the Wensheng graph model.

[0244] See also Fig.12 , which is a schematic diagram of an application scenario of a facial image generation method provided in an embodiment of the present application.

[0245] F1: Obtain the image to be adjusted, the first adjustment text and the first random noise.

[0246] F2: According to the image to be adjusted, feature extraction is performed through the basic semantic feature extraction model to obtain the initial facial semantic features.

[0247] F3: Based on the initial facial semantic features, feature extraction is performed through the semantic feature extraction model to obtain facial semantic features.

[0248] F4: Based on the image to be adjusted, feature extraction is performed through the basic structural feature extraction model to obtain the initial facial structural features.

[0249] F5: Based on the initial facial structure features, feature extraction is performed through the structural feature extraction model to obtain facial structure features.

[0250] F6: Extract features from the first adjusted text using a text feature extraction model to obtain first text features.

[0251] It should be noted that the embodiment of the present application does not specifically limit the order of acquiring the facial semantic features, the facial structural features, and the first text features, and those skilled in the art may set it according to actual needs.

[0252] F7: According to the facial semantic features, facial structural features and the first text features, adjustments are made through the attention module in the text graph model to obtain the first attention weights of each position in the face to be adjusted.

[0253] F8: According to the first attention weight, the first random noise is denoised through the Vincent graph model to obtain the first target facial image.

[0254] Therefore, the embodiment of the present application only needs one model training, and can realize personalized generation based on text given an arbitrary face in the test phase, which reduces the difficulty and cost of training, and can not only quickly generate high-quality personalized images, such as faces with high consistency, but also improve the efficiency of image generation and the user experience. In addition, the method also has relatively good text editability.

[0255] With respect to the facial image generation method described above, the present application also provides a corresponding facial image generation device, so that the facial image generation method can be applied and implemented in practice.

[0256] See also Fig.13 , which is a schematic diagram of the structure of a facial image generation device provided in an embodiment of the present application. Fig.13 As shown, the facial image generating device 1300 includes: an acquiring unit 1301, a feature extracting unit 1302, an adjusting unit 1303 and a generating unit 1304;

[0257] The acquisition unit 1301 is used to acquire an image to be adjusted, a first adjustment text and a first random noise, wherein the image to be adjusted includes a face to be adjusted;

[0258] The feature extraction unit 1302 is used to perform feature extraction on the image to be adjusted to obtain facial semantic features of the face to be adjusted and facial structural features of the face to be adjusted, and to perform feature extraction on the first adjustment text to obtain first text features;

[0259] The adjustment unit 1303 is used to adjust the facial semantic features, the facial structural features and the first text features through the attention module in the text graph model to obtain the first attention weight of each position in the face to be adjusted;

[0260] The generating unit 1304 is used to denoise the first random noise through the text graph model according to the first attention weight to obtain a first target facial image, where the first target facial image is an image adjusted based on the face to be adjusted based on the first adjustment text.

[0261] It can be seen from the above technical scheme that the facial image generation device provided by the embodiment of the present application includes an acquisition unit, a feature extraction unit, an adjustment unit and a generation unit. The acquisition unit acquires a first adjustment text for describing a specific requirement, an image to be adjusted including a face to be adjusted and a first random noise. The feature extraction unit extracts features of the image to be adjusted to obtain facial semantic features and facial structural features of the face to be adjusted, and extracts features of the first adjustment text to obtain first text features. The adjustment unit adjusts the attention module in the Vincent graph model according to the facial semantic features, facial structural features and the first text features, that is, the attention degree of the Vincent graph model to different positions in the image to be adjusted is dynamically adjusted through the attention mechanism, and the first attention weight of each position in the face to be adjusted is obtained. The generation unit denoises the first random noise through the Vincent graph model according to the first attention weight to obtain a first target facial image, so that the first target facial image is an image obtained by adjusting the face to be adjusted based on the first adjustment text, that is, while keeping the facial semantics of the face to be adjusted basically unchanged, the first target facial image meets the specific requirements described in the first adjustment text.

[0262] Therefore, by considering both facial structural features and facial semantic features, the accuracy of the face in the target face image is guaranteed while improving the distinctiveness of the face. Moreover, the facial structural features and facial semantic features are integrated into the viz-graph model through the attention mechanism, which increases the attention paid to the key information in the image to be adjusted, reduces the interference of redundant information, and better integrates feature information of different scales, thereby improving the generation effect of the target face image.

[0263] As a possible implementation, the acquisition unit 1301 is further configured to acquire a second adjustment text for the image to be adjusted, where the second adjustment text is different from the first adjustment text; and acquire a second random noise;

[0264] The feature extraction unit 1302 is further used to extract features from the second adjusted text to obtain second text features;

[0265] The adjustment unit 1303 is further configured to perform adjustment through an attention module in the text graph model according to the facial semantic feature, the facial structural feature and the second text feature to obtain a second attention weight for each position in the face to be adjusted;

[0266] The generating unit 1304 is further configured to denoise the second random noise through the text graph model according to the second attention weight to generate a second target facial image, wherein the second target facial image is an image adjusted based on the face to be adjusted and based on the second adjustment text.

[0267] As a possible implementation manner, the text graph model includes a first encoder and a first decoder, and the adjustment unit 1303 is specifically used to:

[0268] The facial semantic features, the facial structural features and the first text features are input into the Wensheng graph model, the facial semantic features, the facial structural features and the first text features are adjusted by the attention module in the first encoder, and the facial semantic features and the first text features are adjusted by the attention module in the first decoder to obtain the first attention weights of each position in the face to be adjusted.

[0269] As a possible implementation, the first attention weight includes a cross attention weight and a self-attention weight, and the adjustment unit 1303 is specifically used to:

[0270] De-noising the first random noise by using the document graph model to obtain a query feature;

[0271] According to the query feature and the facial semantic feature, performing a cross attention operation through an attention module in the text graph model to obtain a first sub-attention weight;

[0272] According to the query feature and the first text feature, performing a cross attention operation through an attention module in the text graph model to obtain a second sub-attention weight;

[0273] Obtaining a cross attention weight according to the first sub-attention weight and the second sub-attention weight;

[0274] According to the query feature, a self-attention operation is performed by the attention module in the text graph model to obtain a third sub-attention weight;

[0275] According to the query feature and the facial structure feature, performing a cross attention operation through the attention module in the viz graph model to obtain a fourth sub-attention weight;

[0276] The self-attention weight is obtained according to the third sub-attention weight and the fourth sub-attention weight.

[0277] As a possible implementation, the feature extraction unit 1302 is specifically configured to:

[0278] According to the image to be adjusted, feature extraction is performed by a semantic feature extraction model to obtain the facial semantic feature, wherein the facial semantic feature and the first text feature are in the same feature space, and the semantic feature extraction model is a model obtained by joint training with the text graph model;

[0279] According to the image to be adjusted, feature extraction is performed through a structural feature extraction model to obtain the facial structural feature, the facial structural feature and the first text feature are in the same feature space, and the structural feature extraction model is a model jointly trained with the text graph model.

[0280] As a possible implementation, the feature extraction unit 1302 is specifically configured to:

[0281] According to the image to be adjusted, feature extraction is performed using a pre-trained basic semantic feature extraction model to obtain initial facial semantic features;

[0282] According to the initial facial semantic features, feature extraction is performed by the semantic feature extraction model to obtain the facial semantic features;

[0283] According to the image to be adjusted, feature extraction is performed using a pre-trained basic structure feature extraction model to obtain initial facial structure features;

[0284] According to the initial facial structural features, feature extraction is performed using the structural feature extraction model to obtain the facial structural features.

[0285] As a possible implementation, the structural feature extraction model includes a first submodule, a second submodule and a third submodule, and the feature extraction unit 1302 is specifically used for:

[0286] According to the initial facial structure feature, extracting features through the first submodule to obtain a first-scale facial structure feature;

[0287] According to the first-scale facial structure feature, extracting features through the second submodule to obtain a second-scale facial structure feature;

[0288] According to the second-scale facial structure feature, feature extraction is performed by the third submodule to obtain a third-scale facial structure feature, the scale of the first-scale facial structure feature, the scale of the second-scale facial structure feature and the scale of the third-scale facial structure feature are different, and the facial structure feature includes the first-scale facial structure feature, the second-scale facial structure feature and the third-scale facial structure feature.

[0289] As a possible implementation manner, the device further includes a training unit, which is used to:

[0290] Acquire a first image sample including a face and a text sample for describing the first image sample;

[0291] Performing feature extraction on the first image sample to obtain a facial semantic feature sample and a facial structure feature sample, and performing feature extraction on the text sample to obtain a text feature sample;

[0292] adding noise to the first image sample to obtain a noisy first image sample;

[0293] According to the facial semantic feature samples, the facial structural feature samples and the text feature samples, an initial attention module in an initial text graph model is used to adjust the predicted attention weights of various positions in the face included in the first image sample;

[0294] De-noising the noisy first image sample using the initial viz-graph model according to the predicted attention weights to generate a predicted facial image;

[0295] According to the difference between the predicted facial image and the first image sample, the parameters of the initial attention module are adjusted to obtain a Wensheng graph model including the attention module.

[0296] As a possible implementation manner, the device further includes a training unit, which is used to:

[0297] According to the first image sample, feature extraction is performed by an initial semantic feature extraction model to obtain a facial semantic feature sample;

[0298] According to the first image sample, feature extraction is performed using an initial structural feature extraction model to obtain a facial structural feature sample;

[0299] According to the difference between the predicted facial image and the first image sample, the parameters of the initial attention module, the parameters of the initial semantic feature extraction model and the parameters of the initial structural feature extraction model are adjusted to obtain the text graph model including the attention module, the semantic feature extraction model and the structural feature extraction model accordingly.

[0300] As a possible implementation manner, the device further includes a training unit, which is used to:

[0301] Acquire a second image sample according to the first image sample, wherein the first image sample and the second image sample are different images describing the same face, and both the second image sample and the first image sample are acquired through acquisition;

[0302] According to the second image sample, feature extraction is performed using the initial structural feature extraction model to obtain the facial structural feature sample.

[0303] As a possible implementation manner, the device further includes a training unit, which is used to:

[0304] According to the first image sample, feature extraction is performed using a pre-trained basic semantic feature extraction model to obtain an initial facial semantic feature sample;

[0305] According to the initial facial semantic feature sample, converting it through the initial semantic feature extraction model to obtain the facial semantic feature sample;

[0306] According to the first image sample, feature extraction is performed using a pre-trained basic structure feature extraction model to obtain an initial facial structure feature sample;

[0307] According to the initial facial structure feature sample, feature extraction is performed through the initial structure feature extraction model to obtain the facial structure feature sample.

[0308] As a possible implementation, the initial structural feature extraction model includes a first initial submodule, a second initial submodule and a third initial submodule, and the device also includes a training unit for:

[0309] According to the initial facial structure feature sample, feature extraction is performed through the first initial submodule to obtain a first-scale facial structure feature sample;

[0310] According to the first-scale facial structure feature sample, extracting features through the second initial submodule to obtain a second-scale facial structure feature sample;

[0311] According to the second-scale facial structure feature samples, feature extraction is performed through the third initial submodule to obtain third-scale facial structure feature samples, the scale of the first-scale facial structure feature samples, the scale of the second-scale facial structure feature samples and the scale of the third-scale facial structure feature samples are different, and the facial structure feature samples include the first-scale facial structure feature samples, the second-scale facial structure feature samples and the third-scale facial structure feature samples.

[0312] As a possible implementation, the first initial encoder in the initial text graph model includes a plurality of attention modules, and the device further includes a training unit for:

[0313] The facial semantic feature samples and the text feature samples are input into the initial text graph model, the first-scale facial structure feature samples, the second-scale facial structure feature samples and the third-scale facial structure feature samples are respectively input into different attention modules included in the first initial encoder, and adjustments are made through the attention modules in the initial text graph model to obtain predicted attention weights of each position in the first image sample.

[0314] As a possible implementation manner, the initial text graph model includes the first initial encoder and the first initial decoder, and the device further includes a training unit, which is used to:

[0315] The facial semantic feature samples are respectively input into the first initial encoder and the first initial decoder, the text feature samples are respectively input into the first initial encoder and the first initial decoder, the first-scale facial structure feature samples, the second-scale facial structure feature samples and the third-scale facial structure feature samples are respectively input into different attention modules included in the first initial encoder, and the predicted attention weights of each position in the first image sample are obtained by adjusting through the attention module in the initial text graph model.

[0316] As a possible implementation, the feature extraction unit 1302 is specifically configured to:

[0317] Detecting the image to be adjusted to obtain a region including the face to be adjusted;

[0318] Cropping the region from the image to be adjusted to obtain a sub-image including the face to be adjusted;

[0319] Feature extraction is performed on the sub-image to obtain facial semantic features of the face to be adjusted and facial structural features of the face to be adjusted.

[0320] As a possible implementation manner, the obtaining unit 1301 is specifically configured to:

[0321] Get initial adjustment text and text template;

[0322] The first adjusted text is obtained according to the initial adjusted text and the text template.

[0323] The present application also provides a computer device, which may be a server or a terminal device. The following will introduce the computer device provided by the present application from the perspective of hardware entity. Fig.14 The following is a schematic diagram of the server structure. Fig.15 Shown is a schematic diagram of the structure of the terminal equipment.

[0324] See also Fig.14, which is a schematic diagram of a server structure provided in an embodiment of the present application. The server 1400 may have relatively large differences due to different configurations or performances, and may include one or more processors 1422, such as central processing units (CPU), memory 1432, one or more application programs 1442 or storage media 1430 (such as one or more mass storage devices) for data 1444. Among them, the memory 1432 and the storage medium 1430 may be temporary storage or permanent storage. The program stored in the storage medium 1430 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Furthermore, the processor 1422 may be configured to communicate with the storage medium 1430 and execute a series of instruction operations in the storage medium 1430 on the server 1400.

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

[0326] The steps performed by the server in the above embodiment can be based on the Fig.14 The server structure shown.

[0327] The processor 1422 is used to perform the following steps:

[0328] Acquire an image to be adjusted, a first adjustment text, and a first random noise, wherein the image to be adjusted includes a face to be adjusted;

[0329] Performing feature extraction on the image to be adjusted to obtain facial semantic features of the face to be adjusted and facial structural features of the face to be adjusted, and performing feature extraction on the first adjustment text to obtain first text features;

[0330] According to the facial semantic features, the facial structural features and the first text features, an attention module in a text graph model is used to make adjustments to obtain a first attention weight for each position in the face to be adjusted;

[0331] According to the first attention weight, the first random noise is denoised by the text graph model to obtain a first target facial image, where the first target facial image is an image adjusted based on the first adjustment text on the basis of the face to be adjusted.

[0332] Optionally, the processor 1422 may also execute the method steps of any specific implementation of the facial image generation method in the embodiments of the present application.

[0333] See also Fig.15 , which is a schematic diagram of the structure of a terminal device provided in an embodiment of the present application. Taking the terminal device as a smart phone as an example, Fig.15 The block diagram of the partial structure of the smart phone is shown, and the smart phone includes: a radio frequency (RF) circuit 1510, a memory 1520, an input unit 1530, a display unit 1540, a sensor 1550, an audio circuit 1560, a wireless fidelity (WiFi) module 1570, a processor 1580, and a power supply 1590. Those skilled in the art can understand that Fig.15 The structure of the smartphone shown in the figure does not constitute a limitation of the smartphone, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0334] Combine the following Fig.15 A detailed introduction to the various components of a smartphone:

[0335] The RF circuit 1510 may be used for receiving and sending signals during information transmission or calls. In particular, after receiving the downlink information from the base station, it is sent to the processor 1580 for processing; in addition, the designed uplink data is sent to the base station.

[0336] The memory 1520 may be used to store software programs and modules. The processor 1580 implements various functional applications and data processing of the smartphone by running the software programs and modules stored in the memory 1520 .

[0337] The input unit 1530 can be used to receive input digital or character information, and to generate key signal input related to the user settings and function control of the smartphone. Specifically, the input unit 1530 may include a touch panel 1531 and other input devices 1532. The touch panel 1531, also known as a touch screen, can collect user touch operations on or near it and drive the corresponding connection device according to a pre-set program. In addition to the touch panel 1531, the input unit 1530 may also include other input devices 1532. Specifically, other input devices 1532 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and the like.

[0338] The display unit 1540 may be used to display information input by the user or information provided to the user and various menus of the smartphone. The display unit 1540 may include a display panel 1541. Optionally, the display panel 1541 may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.

[0339] The smartphone may also include at least one sensor 1550, such as a light sensor, a motion sensor, and other sensors. As for other sensors that may be configured in the smartphone, such as a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., they will not be described in detail here.

[0340] The audio circuit 1560, the speaker 1561, and the microphone 1562 can provide an audio interface between the user and the smartphone. The audio circuit 1560 can transmit the received audio data to the speaker 1561 after converting the received audio data into an electrical signal, which is converted into a sound signal for output; on the other hand, the microphone 1562 converts the collected sound signal into an electrical signal, which is received by the audio circuit 1560 and converted into audio data, and then the audio data is output to the processor 1580 for processing, and then sent to another smartphone through the RF circuit 1510, or the audio data is output to the memory 1520 for further processing.

[0341] The processor 1580 is the control center of the smartphone, and uses various interfaces and lines to connect various parts of the entire smartphone, and executes various functions of the smartphone and processes data by running or executing software programs and / or modules stored in the memory 1520, and calling data stored in the memory 1520. Optionally, the processor 1580 may include one or more processing units.

[0342] The smart phone also includes a power supply 1590 (such as a battery) for supplying power to various components. Preferably, the power supply can be logically connected to the processor 1580 through a power management system, so that the power management system can manage charging, discharging, power consumption and other functions.

[0343] Although not shown, the smartphone may also include a camera, a Bluetooth module, etc., which will not be described in detail here.

[0344] In the embodiment of the present application, the memory 1520 included in the smart phone can store a computer program and transmit the computer program to the processor.

[0345] The processor 1580 included in the smart phone can execute the facial image generation method provided in the above embodiment according to the instructions in the computer program.

[0346] An embodiment of the present application also provides a computer-readable storage medium for storing a computer program, wherein the computer program is used to execute the facial image generation method provided in the above embodiment.

[0347] The embodiment of the present application also provides a computer program product or a computer program, which includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the facial image generation method provided in various optional implementations of the above aspects.

[0348] A person skilled in the art can understand that: all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the above program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the above storage medium can be at least one of the following media: read-only memory (English: Read-Only Memory, abbreviated: ROM), RAM, magnetic disk or optical disk, etc. Various media that can store computer programs.

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

[0350] It should be noted that each embodiment in this specification is described in a progressive manner, and the same and similar parts between the embodiments can refer to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiments. The device and system embodiments described above are merely schematic, in which the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative work.

[0351] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a technician familiar with the technical field within the technical scope disclosed in the present application should be included in the protection scope of the present application. Based on the implementation methods provided in the above aspects, the present application can also be further combined to provide more implementation methods. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A facial image generation method, characterized in that: The method comprises: Acquire an image to be adjusted, a first adjustment text, and a first random noise, wherein the image to be adjusted includes a face to be adjusted; the size of the first random noise is the same as the size of an image sample used in a process of training a Vincent graph model; Performing feature extraction on the image to be adjusted to obtain facial semantic features of the face to be adjusted and facial structural features of the face to be adjusted, and performing feature extraction on the first adjustment text to obtain first text features; According to the facial semantic features, the facial structural features and the first text features, an attention module in a text graph model is used to make adjustments to obtain a first attention weight for each position in the face to be adjusted; According to the first attention weight, denoising the first random noise by using the text graph model to obtain a first target facial image, where the first target facial image is an image obtained by adjusting the face to be adjusted based on the first adjustment text; The step of extracting features from the image to be adjusted to obtain facial semantic features of the face to be adjusted and facial structural features of the face to be adjusted includes: According to the image to be adjusted, feature extraction is performed using a pre-trained basic semantic feature extraction model to obtain initial facial semantic features; According to the initial facial semantic features, feature extraction is performed by the semantic feature extraction model to obtain the facial semantic features; the facial semantic features and the first text features are in the same feature space, and the semantic feature extraction model is a model obtained by joint training with the text graph model; According to the image to be adjusted, feature extraction is performed using a pre-trained basic structure feature extraction model to obtain initial facial structure features; According to the initial facial structural features, feature extraction is performed through the structural feature extraction model to obtain the facial structural features; the facial structural features and the first text features are in the same feature space, and the structural feature extraction model is a model obtained by joint training with the text graph model.

2. The method according to claim 1, characterized in that The method further comprises: Acquire a second adjustment text for the image to be adjusted, where the second adjustment text is different from the first adjustment text; Obtaining a second random noise; Performing feature extraction on the second adjusted text to obtain second text features; According to the facial semantic features, the facial structural features and the second text features, an attention module in the text graph model is used to make adjustments to obtain second attention weights for each position in the face to be adjusted; According to the second attention weight, the second random noise is denoised by the text graph model to generate a second target facial image, where the second target facial image is an image adjusted based on the face to be adjusted and based on the second adjustment text.

3. The method according to claim 1, characterized in that The Wensheng graph model includes a first encoder and a first decoder, and the adjustment is performed through an attention module in the Wensheng graph model according to the facial semantic features, the facial structural features and the first text features to obtain a first attention weight of each position in the face to be adjusted, including: The facial semantic features, the facial structural features and the first text features are input into the Wensheng graph model, the facial semantic features, the facial structural features and the first text features are adjusted by the attention module in the first encoder, and the facial semantic features and the first text features are adjusted by the attention module in the first decoder to obtain the first attention weights of each position in the face to be adjusted.

4. The method according to claim 1, characterized in that: The first attention weight includes a cross attention weight and a self-attention weight, and the first attention weight is obtained by adjusting the facial semantic features, the facial structural features and the first text features through the attention module in the text graph model, including: De-noising the first random noise by using the document graph model to obtain a query feature; According to the query feature and the facial semantic feature, performing a cross attention operation through an attention module in the text graph model to obtain a first sub-attention weight; According to the query feature and the first text feature, performing a cross attention operation through an attention module in the text graph model to obtain a second sub-attention weight; Obtaining a cross attention weight according to the first sub-attention weight and the second sub-attention weight; According to the query feature, a self-attention operation is performed by the attention module in the text graph model to obtain a third sub-attention weight; According to the query feature and the facial structure feature, performing a cross attention operation through the attention module in the viz graph model to obtain a fourth sub-attention weight; The self-attention weight is obtained according to the third sub-attention weight and the fourth sub-attention weight.

5. The method according to claim 1, characterized in that The structural feature extraction model includes a first submodule, a second submodule and a third submodule. The facial structural feature is extracted by the structural feature extraction model according to the initial facial structural feature to obtain the facial structural feature, including: According to the initial facial structure feature, extracting features through the first submodule to obtain a first-scale facial structure feature; According to the first-scale facial structure feature, extracting features through the second submodule to obtain a second-scale facial structure feature; According to the second-scale facial structure feature, feature extraction is performed by the third submodule to obtain a third-scale facial structure feature, the scale of the first-scale facial structure feature, the scale of the second-scale facial structure feature and the scale of the third-scale facial structure feature are different, and the facial structure feature includes the first-scale facial structure feature, the second-scale facial structure feature and the third-scale facial structure feature.

6. The method according to claim 1, characterized in that The text graph model is a model in which an attention module is added to the basic text graph model, and the method further includes: Acquire a first image sample including a face and a text sample for describing the first image sample; Performing feature extraction on the first image sample to obtain a facial semantic feature sample and a facial structure feature sample, and performing feature extraction on the text sample to obtain a text feature sample; adding noise to the first image sample to obtain a noisy first image sample; According to the facial semantic feature samples, the facial structural feature samples and the text feature samples, an initial attention module in an initial text graph model is used to adjust the predicted attention weights of various positions in the face included in the first image sample; De-noising the noisy first image sample using the initial viz-graph model according to the predicted attention weights to generate a predicted facial image; According to the difference between the predicted facial image and the first image sample, the parameters of the initial attention module are adjusted to obtain a Wensheng graph model including the attention module.

7. The method according to claim 6, characterized in that The step of extracting features from the first image sample to obtain a facial semantic feature sample and a facial structural feature sample includes: According to the first image sample, feature extraction is performed by an initial semantic feature extraction model to obtain a facial semantic feature sample; According to the first image sample, feature extraction is performed using an initial structural feature extraction model to obtain a facial structural feature sample; The adjusting the parameters of the initial attention module according to the difference between the predicted facial image and the first image sample to obtain a Wensheng graph model including the attention module comprises: According to the difference between the predicted facial image and the first image sample, the parameters of the initial attention module, the parameters of the initial semantic feature extraction model and the parameters of the initial structural feature extraction model are adjusted to obtain the text graph model including the attention module, the semantic feature extraction model and the structural feature extraction model accordingly.

8. The method according to claim 7, characterized in that The step of extracting features by using an initial structural feature extraction model according to the first image sample to obtain a facial structural feature sample includes: Acquire a second image sample according to the first image sample, wherein the first image sample and the second image sample are different images describing the same face, and both the second image sample and the first image sample are acquired through acquisition; According to the second image sample, feature extraction is performed using the initial structural feature extraction model to obtain the facial structural feature sample.

9. The method according to claim 7, characterized in that: The step of extracting features by using an initial semantic feature extraction model according to the first image sample to obtain a facial semantic feature sample includes: According to the first image sample, feature extraction is performed using a pre-trained basic semantic feature extraction model to obtain an initial facial semantic feature sample; According to the initial facial semantic feature sample, converting it through the initial semantic feature extraction model to obtain the facial semantic feature sample; The step of extracting features by using an initial structural feature extraction model according to the first image sample to obtain a facial structural feature sample includes: According to the first image sample, feature extraction is performed using a pre-trained basic structure feature extraction model to obtain an initial facial structure feature sample; According to the initial facial structure feature sample, feature extraction is performed through the initial structure feature extraction model to obtain the facial structure feature sample.

10. The method according to claim 9, characterized in that The initial structural feature extraction model includes a first initial submodule, a second initial submodule and a third initial submodule. The initial structural feature extraction model is used to extract features according to the initial facial structural feature sample to obtain the facial structural feature sample, including: According to the initial facial structure feature sample, feature extraction is performed through the first initial submodule to obtain a first-scale facial structure feature sample; According to the first-scale facial structure feature sample, extracting features through the second initial submodule to obtain a second-scale facial structure feature sample; According to the second-scale facial structure feature samples, feature extraction is performed through the third initial submodule to obtain third-scale facial structure feature samples, the scale of the first-scale facial structure feature samples, the scale of the second-scale facial structure feature samples and the scale of the third-scale facial structure feature samples are different, and the facial structure feature samples include the first-scale facial structure feature samples, the second-scale facial structure feature samples and the third-scale facial structure feature samples.

11. The method according to claim 10, characterized in that The first initial encoder in the initial text graph model includes a plurality of attention modules, and the adjustment is performed through the initial attention modules in the initial text graph model according to the facial semantic feature samples, the facial structural feature samples, and the text feature samples to obtain the predicted attention weights of each position in the face included in the first image sample, including: The facial semantic feature samples and the text feature samples are input into the initial text graph model, the first-scale facial structure feature samples, the second-scale facial structure feature samples and the third-scale facial structure feature samples are respectively input into different attention modules included in the first initial encoder, and adjustments are made through the attention modules in the initial text graph model to obtain predicted attention weights of each position in the first image sample.

12. The method according to claim 11, characterized in that The initial text graph model includes the first initial encoder and the first initial decoder, the facial semantic feature sample and the text feature sample are input into the initial text graph model, the first scale facial structure feature sample, the second scale facial structure feature sample and the third scale facial structure feature sample are respectively input into different attention modules included in the first initial encoder, and the predicted attention weights of each position in the first image sample are obtained by adjusting through the attention modules in the initial text graph model, including: The facial semantic feature samples are respectively input into the first initial encoder and the first initial decoder, the text feature samples are respectively input into the first initial encoder and the first initial decoder, the first-scale facial structure feature samples, the second-scale facial structure feature samples and the third-scale facial structure feature samples are respectively input into different attention modules included in the first initial encoder, and the predicted attention weights of each position in the first image sample are obtained by adjusting through the attention module in the initial text graph model.

13. The method according to claim 1, characterized in that The step of extracting features from the image to be adjusted to obtain facial semantic features of the face to be adjusted and facial structural features of the face to be adjusted includes: Detecting the image to be adjusted to obtain a region including the face to be adjusted; Cropping the region from the image to be adjusted to obtain a sub-image including the face to be adjusted; Feature extraction is performed on the sub-image to obtain facial semantic features of the face to be adjusted and facial structural features of the face to be adjusted.

14. The method according to claim 1, characterized in that The first adjustment text is obtained, including: Get initial adjustment text and text template; The first adjusted text is obtained according to the initial adjusted text and the text template.

15. A facial image generating device, characterized in that: The device comprises: an acquisition unit, a feature extraction unit, an adjustment unit and a generation unit; The acquisition unit is used to acquire an image to be adjusted, a first adjustment text, and a first random noise, wherein the image to be adjusted includes a face to be adjusted; and the size of the first random noise is the same as the size of an image sample used in a process of training a Vincent graph model; The feature extraction unit is used to perform feature extraction on the image to be adjusted to obtain facial semantic features of the face to be adjusted and facial structural features of the face to be adjusted, and to perform feature extraction on the first adjustment text to obtain first text features; The adjustment unit is used to adjust the facial semantic features, the facial structural features and the first text features through the attention module in the text graph model to obtain the first attention weight of each position in the face to be adjusted; The generating unit is configured to denoise the first random noise by using the text graph model according to the first attention weight to obtain a first target facial image, where the first target facial image is an image obtained by adjusting the face to be adjusted based on the first adjustment text; The feature extraction unit is specifically used for: According to the image to be adjusted, feature extraction is performed by a semantic feature extraction model to obtain the facial semantic feature, wherein the facial semantic feature and the first text feature are in the same feature space, and the semantic feature extraction model is a model obtained by joint training with the text graph model; According to the image to be adjusted, feature extraction is performed by a structural feature extraction model to obtain the facial structural feature, wherein the facial structural feature and the first text feature are in the same feature space, and the structural feature extraction model is a model obtained by joint training with the text graph model; The feature extraction unit is specifically used for: According to the image to be adjusted, feature extraction is performed using a pre-trained basic semantic feature extraction model to obtain initial facial semantic features; According to the initial facial semantic features, feature extraction is performed by the semantic feature extraction model to obtain the facial semantic features; According to the image to be adjusted, feature extraction is performed using a pre-trained basic structure feature extraction model to obtain initial facial structure features; According to the initial facial structural features, feature extraction is performed using the structural feature extraction model to obtain the facial structural features.

16. The device according to claim 15, characterized in that The acquisition unit is further configured to acquire a second adjustment text for the image to be adjusted, where the second adjustment text is different from the first adjustment text; and acquire a second random noise; The feature extraction unit is further used to extract features from the second adjusted text to obtain second text features; The adjustment unit is further used to perform adjustment through the attention module in the text graph model according to the facial semantic features, the facial structural features and the second text features to obtain a second attention weight for each position in the face to be adjusted; The generating unit is further configured to denoise the second random noise through the text graph model according to the second attention weight to generate a second target facial image, wherein the second target facial image is an image adjusted based on the second adjustment text on the basis of the face to be adjusted.

17. The device according to claim 15, characterized in that The Wensheng graph model includes a first encoder and a first decoder, and the adjustment unit is specifically used to: The facial semantic features, the facial structural features and the first text features are input into the Wensheng graph model, the facial semantic features, the facial structural features and the first text features are adjusted by the attention module in the first encoder, and the facial semantic features and the first text features are adjusted by the attention module in the first decoder to obtain the first attention weights of each position in the face to be adjusted.

18. The device according to claim 15, characterized in that The first attention weight includes a cross attention weight and a self-attention weight, and the adjustment unit is specifically used to: De-noising the first random noise by using the document graph model to obtain a query feature; According to the query feature and the facial semantic feature, performing a cross attention operation through an attention module in the text graph model to obtain a first sub-attention weight; According to the query feature and the first text feature, performing a cross attention operation through an attention module in the text graph model to obtain a second sub-attention weight; Obtaining a cross attention weight according to the first sub-attention weight and the second sub-attention weight; According to the query feature, a self-attention operation is performed by the attention module in the text graph model to obtain a third sub-attention weight; According to the query feature and the facial structure feature, performing a cross attention operation through the attention module in the viz graph model to obtain a fourth sub-attention weight; The self-attention weight is obtained according to the third sub-attention weight and the fourth sub-attention weight.

19. The device according to claim 15, characterized in that The structural feature extraction model includes a first submodule, a second submodule and a third submodule, and the feature extraction unit is specifically used for: According to the initial facial structure feature, extracting features through the first submodule to obtain a first-scale facial structure feature; According to the first-scale facial structure feature, extracting features through the second submodule to obtain a second-scale facial structure feature; According to the second-scale facial structure feature, feature extraction is performed by the third submodule to obtain a third-scale facial structure feature, the scale of the first-scale facial structure feature, the scale of the second-scale facial structure feature and the scale of the third-scale facial structure feature are different, and the facial structure feature includes the first-scale facial structure feature, the second-scale facial structure feature and the third-scale facial structure feature.

20. The device according to claim 15, characterized in that The device also includes a training unit, which is used to: Acquire a first image sample including a face and a text sample for describing the first image sample; Performing feature extraction on the first image sample to obtain a facial semantic feature sample and a facial structure feature sample, and performing feature extraction on the text sample to obtain a text feature sample; adding noise to the first image sample to obtain a noisy first image sample; According to the facial semantic feature samples, the facial structural feature samples and the text feature samples, an initial attention module in an initial text graph model is used to adjust the predicted attention weights of various positions in the face included in the first image sample; De-noising the noisy first image sample using the initial viz-graph model according to the predicted attention weights to generate a predicted facial image; According to the difference between the predicted facial image and the first image sample, the parameters of the initial attention module are adjusted to obtain a Wensheng graph model including the attention module.

21. The device according to claim 20, characterized in that The device also includes a training unit, which is used to: According to the first image sample, feature extraction is performed by an initial semantic feature extraction model to obtain a facial semantic feature sample; According to the first image sample, feature extraction is performed using an initial structural feature extraction model to obtain a facial structural feature sample; According to the difference between the predicted facial image and the first image sample, the parameters of the initial attention module, the parameters of the initial semantic feature extraction model and the parameters of the initial structural feature extraction model are adjusted to obtain the text graph model including the attention module, the semantic feature extraction model and the structural feature extraction model accordingly.

22. The device according to claim 21, characterized in that The device also includes a training unit, which is used to: Acquire a second image sample according to the first image sample, wherein the first image sample and the second image sample are different images describing the same face, and both the second image sample and the first image sample are acquired through acquisition; According to the second image sample, feature extraction is performed using the initial structural feature extraction model to obtain the facial structural feature sample.

23. The device according to claim 21, characterized in that The device also includes a training unit, which is used to: According to the first image sample, feature extraction is performed using a pre-trained basic semantic feature extraction model to obtain an initial facial semantic feature sample; According to the initial facial semantic feature sample, converting it through the initial semantic feature extraction model to obtain the facial semantic feature sample; According to the first image sample, feature extraction is performed using a pre-trained basic structure feature extraction model to obtain an initial facial structure feature sample; According to the initial facial structure feature sample, feature extraction is performed through the initial structure feature extraction model to obtain the facial structure feature sample.

24. The device according to claim 23, characterized in that The initial structural feature extraction model includes a first initial submodule, a second initial submodule and a third initial submodule, and the device also includes a training unit for: According to the initial facial structure feature sample, feature extraction is performed through the first initial submodule to obtain a first-scale facial structure feature sample; According to the first-scale facial structure feature sample, extracting features through the second initial submodule to obtain a second-scale facial structure feature sample; According to the second-scale facial structure feature samples, feature extraction is performed through the third initial submodule to obtain third-scale facial structure feature samples, the scale of the first-scale facial structure feature samples, the scale of the second-scale facial structure feature samples and the scale of the third-scale facial structure feature samples are different, and the facial structure feature samples include the first-scale facial structure feature samples, the second-scale facial structure feature samples and the third-scale facial structure feature samples.

25. The device according to claim 24, characterized in that The first initial encoder in the initial text graph model includes a plurality of attention modules, and the apparatus further includes a training unit for: The facial semantic feature samples and the text feature samples are input into the initial text graph model, the first-scale facial structure feature samples, the second-scale facial structure feature samples and the third-scale facial structure feature samples are respectively input into different attention modules included in the first initial encoder, and adjustments are made through the attention modules in the initial text graph model to obtain predicted attention weights of each position in the first image sample.

26. The device according to claim 25, characterized in that The initial text graph model includes the first initial encoder and the first initial decoder, and the apparatus further includes a training unit for: The facial semantic feature samples are respectively input into the first initial encoder and the first initial decoder, the text feature samples are respectively input into the first initial encoder and the first initial decoder, the first-scale facial structure feature samples, the second-scale facial structure feature samples and the third-scale facial structure feature samples are respectively input into different attention modules included in the first initial encoder, and the predicted attention weights of each position in the first image sample are obtained by adjusting through the attention module in the initial text graph model.

27. The device according to claim 15, characterized in that The feature extraction unit is specifically used for: Detecting the image to be adjusted to obtain a region including the face to be adjusted; Cropping the region from the image to be adjusted to obtain a sub-image including the face to be adjusted; Feature extraction is performed on the sub-image to obtain facial semantic features of the face to be adjusted and facial structural features of the face to be adjusted.

28. The device according to claim 15, characterized in that The acquisition unit is specifically used for: Get initial adjustment text and text template; The first adjusted text is obtained according to the initial adjusted text and the text template.

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

30. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method according to any one of claims 1 to 14.

31. A computer program product comprising a computer program, characterized in that When the method is executed on a computer device, the computer device is enabled to execute the method according to any one of claims 1 to 14.