Target hair style generation method and device, readable storage medium and program product

By eliminating and processing the bangs image, and combining multi-branch model training with text prompts, the problem of scarce bangs generation samples was solved, achieving natural bangs generation and improving the hairstyle generation effect.

CN121639848APending Publication Date: 2026-03-10XIAMEN MEITUZHIJIA TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-19
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

Existing bangs generation technology relies on training with bangs pairing data, but in real-world scenarios, samples of the same person with or without bangs are scarce, resulting in unnaturally overly thick and unsatisfactory bangs and poor performance.

Method used

By removing bangs from images of various bangs styles, images without bangs are generated. Then, a multi-branch bangs generation model is used to extract hairstyle features and construct a hairstyle splicing image. The initial hairstyle generation model is trained with text prompts to generate the target bangs image.

Benefits of technology

The sample size was increased, enabling the conversion from no bangs to various bang styles. The generated bangs are natural, improving the hairstyle generation effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121639848A_ABST
    Figure CN121639848A_ABST
Patent Text Reader

Abstract

The invention relates to a target hair style generation method and device, a readable storage medium and a program product. The method comprises the following steps: performing bang elimination processing on first bang images of multiple bang styles to obtain a bang-free image; performing hair style feature processing on the no-bang image to obtain second bang images of multiple bang styles under the same identity; splicing the images without the bangs under the same identity and the second bang images of the multiple bang styles in pairs to obtain spliced images of the hair styles under the same identity; generating a first text prompt corresponding to the bang style; performing model training on the initial hair style generation model according to each hair style spliced image and the corresponding text prompt to obtain a hair style generation model for generating each bang style; and performing hair style feature processing on the to-be-processed image according to the second text prompt through the hair style generation model to obtain a target bang image corresponding to the second text prompt. By adopting the method, the generation effect of the bang hair style can be effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of artificial intelligence, in particular to a target hairstyle generation method and device, a readable storage medium and a program product. BACKGROUND

[0002] As an important part of hairstyle design, bangs directly affect the facial proportion, temperament style and overall aesthetic. In modern retouching aesthetics, bang generation technology not only meets the user's demand for hairstyle diversification, but also has wide application in the fields of film and television, advertising, virtual social interaction and metaverse application.

[0003] Currently, the bang generation technology is mainly based on the bang generation method of GAN (such as StyleGAN). This method usually adopts bang pairing data training + hidden space editing, so it is necessary to first collect a large amount of bang pairing data with / without bangs, and then use the hidden space mapping capability of StyleGAN to adjust the latent variables of the hair region to generate realistic bangs. However, in real scenarios, samples with / without bangs of the same person are scarce, and hidden space editing is difficult to adjust the bang style through natural language description, resulting in over-natural hair strands of the generated bangs, which makes the hairstyle generation effect poor. SUMMARY

[0004] Therefore, the present application provides a target hairstyle generation method and device, a readable storage medium and a program product, which can effectively improve the generation effect of bang hairstyle.

[0005] In one aspect, the present application provides a target hairstyle generation method, comprising:

[0006] Performing bang elimination processing on first bang images of multiple bang styles to obtain no-bang images;

[0007] Performing hairstyle feature processing on the no-bang images through a multi-branch bang generation model to obtain second bang images of multiple bang styles under the same identity;

[0008] Splicing the no-bang images and the second bang images of multiple bang styles under the same identity two by two to obtain each hairstyle splicing image under the same identity;

[0009] Based on each hairstyle splicing image, constructing a first text prompt for generating a corresponding bang style;

[0010] According to each hairstyle splicing image and the corresponding text prompt, performing model training on an initial hairstyle generation model to obtain a hairstyle generation model for generating each bang style;

[0011] In response to the hairstyle generation request, the hairstyle generation model is used to perform hairstyle feature processing on the to-be-processed image according to the second text prompt, to obtain a target fringe image corresponding to the second text prompt.

[0012] In one of the embodiments, the method further includes:

[0013] From the fringeless images, a fringeless image satisfying a quality condition is selected;

[0014] The hairstyle feature processing on the fringeless image by the multi-branch fringe generation model to obtain the second fringe images of the multiple fringe styles under the same identity includes:

[0015] The hairstyle feature processing on the fringeless image satisfying the quality condition by the multi-branch fringe generation model to obtain the second fringe images of the multiple fringe styles under the same identity includes:

[0016] The two-by-two splicing of the fringeless image and the second fringe images of the multiple fringe styles under the same identity to obtain the hairstyle splicing images under the same identity includes:

[0017] The two-by-two splicing of the fringeless image and the second fringe images of the multiple fringe styles under the same identity to obtain the hairstyle splicing images under the same identity.

[0018] In one of the embodiments, the hairstyle feature processing on the fringeless image satisfying the quality condition by the multi-branch fringe generation model to obtain the second fringe images of the multiple fringe styles under the same identity includes:

[0019] The hairstyle feature processing on the fringeless image satisfying the quality condition by the multi-branch fringe generation model to obtain the second fringe images of the multiple fringe styles under the same identity includes:

[0020] In one of the embodiments, the two-by-two splicing of the fringeless image and the second fringe images of the multiple fringe styles under the same identity to obtain the hairstyle splicing images under the same identity includes:

[0021] The two-by-two splicing of the fringeless image and the second fringe images of the multiple fringe styles under the same identity to obtain the hairstyle splicing images under the same identity.

[0022] In one embodiment, the second bangs image indicating the bangs style indicated by the first text prompt is a tag image; the step of training the initial hairstyle generation model based on each of the hairstyle splicing images and the corresponding text prompts to obtain a hairstyle generation model for generating each of the bangs styles includes:

[0023] Obtain the mask image and noise image corresponding to each of the stitched hairstyle images;

[0024] The image encoder of the initial hairstyle generation model extracts visual features from each of the stitched hairstyle images, the mask image, and the noisy image, and the text encoder of the initial hairstyle generation model extracts text features from the text prompt;

[0025] The text features and the visual features are fused together by the fusion layer of the initial hairstyle generation model to obtain the fused features;

[0026] The fused features are processed by the generative network of the initial hairstyle generation model to generate an image, resulting in a third image of the bangs style indicated by the first text prompt.

[0027] The loss value is determined based on the third bangs image and the label image;

[0028] The parameters of the initial hairstyle generation model are updated based on the loss value to obtain a hairstyle generation model for generating each of the aforementioned bangs styles.

[0029] In one embodiment, the method further includes:

[0030] After obtaining the target bangs image, face enhancement is performed on the target bangs image to obtain a face enhancement image, and bangs segmentation is performed on the target bangs image to obtain a first bangs mask image;

[0031] The image to be processed is segmented by notch to obtain a second notch mask image;

[0032] Based on the first bangs mask image, the second bangs mask image, and the face enhancement image, spatial logic operations are performed to obtain the enhanced target bangs image.

[0033] In one embodiment, the step of segmenting the target bangs image to obtain a first bangs mask image includes:

[0034] Face point detection is performed on the target bangs image to obtain a first face feature map;

[0035] The target bangs image is segmented to obtain a first hair mask image;

[0036] A first bangs mask image is generated based on the first hair mask image and the first face feature map;

[0037] The step of performing notch segmentation on the image to be processed to obtain the second notch mask image includes:

[0038] Face point detection is performed on the image to be processed to obtain a second face feature map;

[0039] The image to be processed is segmented by hair to obtain a second hair mask image;

[0040] A second bangs mask image is generated based on the second hair mask image and the second face feature map.

[0041] On the one hand, this application also provides a target hair growth device, including:

[0042] The elimination unit is used to perform bangs elimination processing on the first bangs image of various bangs styles to obtain a bangs-free image;

[0043] The processing unit is used to perform hairstyle feature processing on the bangs-free image through a multi-branch bangs generation model to obtain second bangs images with multiple bangs styles under the same identity;

[0044] The splicing unit is used to splice the image without bangs and the second bangs images of various bangs styles under the same identity in pairs to obtain spliced ​​images of various hairstyles under the same identity.

[0045] A construction unit is used to construct a first text prompt for generating the corresponding bangs style based on each of the hairstyle splicing images;

[0046] The training unit is used to train the initial hairstyle generation model based on the stitched images of each hairstyle and the corresponding text prompts, so as to obtain a hairstyle generation model for generating each of the bangs styles;

[0047] The generation unit is used to respond to a hairstyle generation request by performing hairstyle feature processing on the image to be processed based on the second text prompt through the hairstyle generation model, thereby obtaining a target bangs image corresponding to the second text prompt.

[0048] In one embodiment, the device further includes:

[0049] The selection unit is used to select images without bangs that meet the quality requirements from the images without bangs.

[0050] The processing unit is also used to perform hairstyle feature processing on the no-bangs image that meets the quality conditions through a multi-branch bangs generation model to obtain second bangs images of multiple bangs styles under the same identity;

[0051] The splicing unit is also used to splice the images without bangs that meet the quality conditions under the same identity and the second bangs images of various bangs styles in pairs to obtain spliced ​​images of various hairstyles under the same identity.

[0052] In one embodiment, the processing unit is further configured to extract the morphological features and hair detail features of each of the bangs styles from the bangless images that meet the quality conditions using a multi-branch bangs generation model, and generate bangs images based on the morphological features and hair detail features of each of the bangs styles to obtain second bangs images of multiple bangs styles under the same identity.

[0053] In one embodiment, the splicing unit is further configured to splice the no-bangs images that meet the quality conditions under the same identity with the second bangs images of the multiple bangs styles in pairs, and to splice the second bangs images of the multiple bangs styles under the same identity in pairs to obtain spliced ​​images of various hairstyles under the same identity.

[0054] In one embodiment, the second image of the bangs style indicated by the first text prompt is a tag image;

[0055] The training unit is further configured to acquire mask images and noise images corresponding to each of the hairstyle splicing images; extract visual features from each of the hairstyle splicing images, the mask images, and the noise images using the image encoder of the initial hairstyle generation model, and extract text features from the text prompts using the text encoder of the initial hairstyle generation model; fuse the text features and the visual features using the fusion layer of the initial hairstyle generation model to obtain fused features; perform image generation processing on the fused features using the generator network of the initial hairstyle generation model to obtain a third bangs image of the bangs style indicated by the first text prompt; determine a loss value based on the third bangs image and the label image; and update the parameters of the initial hairstyle generation model based on the loss value to obtain a hairstyle generation model for generating each of the bangs styles.

[0056] In one embodiment, the device further includes:

[0057] An enhancement unit is used to perform face enhancement on the target bangs image after obtaining the target bangs image to obtain a face-enhanced image;

[0058] A segmentation unit is used to segment the target bangs image to obtain a first bangs mask image; and to segment the image to be processed to obtain a second bangs mask image.

[0059] The processing unit is used to perform spatial logic operations based on the first bangs mask image, the second bangs mask image, and the face enhancement image to obtain an enhanced target bangs image.

[0060] In one embodiment, the segmentation unit is further configured to perform face point detection on the target bangs image to obtain a first face feature map; perform hair segmentation on the target bangs image to obtain a first hair mask image; and generate a first bangs mask image based on the first hair mask image and the first face feature map.

[0061] The segmentation unit is further configured to perform face point detection on the image to be processed to obtain a second face feature map; perform hair segmentation on the image to be processed to obtain a second hair mask image; and generate a second bangs mask image based on the second hair mask image and the second face feature map.

[0062] On the one hand, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the target hairstyle generation method.

[0063] On the one hand, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the target hairstyle generation method.

[0064] On the one hand, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the target hairstyle generation method.

[0065] The aforementioned target hairstyle generation method, apparatus, computer equipment, computer-readable storage medium, and computer program product perform bangs removal processing on first bangs images with multiple bangs styles. Then, through a multi-branch bangs generation model, they process the hairstyle features of the resulting bangs-free images. This allows for the generation of second bangs images with multiple bangs styles under the same identity. In other words, under the same identity, there are both bangs-free images and images with multiple bangs styles, effectively enriching the sample size and solving the problem of sample scarcity. Furthermore, the bangs-free images and second bangs images with multiple bangs styles under the same identity are paired and stitched together to obtain stitched images of various hairstyles under the same identity. Based on these stitched images, a system is constructed... The first text prompt is used to generate the corresponding bangs style. Based on the stitched images of each hairstyle and the corresponding text prompt, the initial hairstyle generation model is trained. After training, the hairstyle generation model is used to process the hairstyle features of the image to be processed according to the second text prompt. It can not only generate bangs from no bangs according to actual needs, but also switch from one bangs style to other bangs styles, enriching the generation methods of bangs hairstyles and improving the user experience. Moreover, during the bangs generation process, the hairstyle generation model can effectively adjust the bangs style through text prompts. In addition, the rich samples used in the training process make the generated bangs hair strands transition naturally, effectively improving the hairstyle generation effect. Attached Figure Description

[0066] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0067] Figure 1 This is an application environment diagram of the target hairstyle generation method in one embodiment;

[0068] Figure 2 This is a flowchart illustrating a target hairstyle generation method in one embodiment;

[0069] Figure 3 This is a schematic diagram illustrating the process of removing bangs from a bangs image in one embodiment to obtain a bangs-free image.

[0070] Figure 4 This is a schematic diagram showing a composite image of a hairstyle with and without bangs in one embodiment;

[0071] Figure 5 This is a schematic diagram illustrating the image with bangs generated from an image without bangs in one embodiment.

[0072] Figure 6 This is a schematic diagram of the bangs generation model in one embodiment;

[0073] Figure 7 This is a schematic diagram of the inference process in one embodiment;

[0074] Figure 8 This is a schematic diagram of the inference process in another embodiment;

[0075] Figure 9 This is a structural block diagram of a target hairstyle generation device in one embodiment;

[0076] Figure 10 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0077] To make the objectives, technical solutions, and beneficial effects of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0078] The target hairstyle generation method provided in this application embodiment can be applied to, for example... Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104, or it can be located in the cloud or on another network server.

[0079] Server 104 can perform bangs removal processing on first bangs images with multiple bangs styles to obtain bangs-free images; it can then perform hairstyle feature processing on the bangs-free images using a multi-branch bangs generation model to obtain second bangs images with multiple bangs styles under the same identity; it can then stitch the bangs-free images under the same identity and the second bangs images with multiple bangs styles in pairs to obtain stitched images of each hairstyle under the same identity; it can then construct a first text prompt for generating the corresponding bangs style based on each hairstyle stitched image; it can then train the initial hairstyle generation model based on each hairstyle stitched image and the corresponding text prompt to obtain a hairstyle generation model for generating each bangs style; this hairstyle generation model can be deployed on server 104 or on terminal 102. If deployed on server 104, terminal 102 can send a hairstyle generation request for bangs to the server when it needs to generate bangs. The hairstyle generation model of server 104 will then perform hairstyle feature processing on the image to be processed based on the second text prompt (such as generating French bangs) to obtain the target bangs image corresponding to the second text prompt.

[0080] The terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle systems, and projection devices. Portable wearable devices can include smartwatches, smart bracelets, and head-mounted displays. Head-mounted displays can be virtual reality (VR) devices, augmented reality (AR) devices, and smart glasses. The server 104 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.

[0081] In one exemplary embodiment, such as Figure 2 As shown, a method for generating a target hairstyle is provided, which can be applied to... Figure 1 Taking the server in the example, the explanation includes the following steps 202 to 212. Wherein:

[0082] Step 202: Perform bangs removal processing on the first bangs images of various bangs styles to obtain bangs-free images.

[0083] The various bangs styles can include blunt bangs, French bangs, side-cut bangs, Japanese wet bangs, and wispy bangs, among others. Correspondingly, the first image for each of these bangs styles can be an image of blunt bangs, French bangs, side-cut bangs, Japanese wet bangs, or wispy bangs, etc. It should be noted that the aforementioned bangs images refer to images of a person including bangs, which can be head images, upper body images, or full-body images.

[0084] The image without bangs can be the image after the bangs hairstyle features are removed from the first image with bangs, that is, the image after the bangs are removed.

[0085] In one embodiment, the server can utilize StyleGAN's image restoration capabilities to remove the bangs from first images of various bangs styles, obtaining bang-free images for each identity, such as... Figure 3 As shown.

[0086] Here, identity can be an identifier (ID) used to represent a person. Each first bangs image can contain one or more people. Regardless of whether there are one or more people in the first bangs image, one first bangs image corresponds to one no-bangs image. That is, if there is one first bangs image under an identity, then there is also one no-bangs image under that identity.

[0087] Step 204: Perform hairstyle feature processing on the image without bangs using a multi-branch bangs generation model to obtain second bangs images with multiple bangs styles under the same identity.

[0088] The multi-branch bangs generation model can be the bangs generation model with multiple bangs branch networks (or modules) proposed in this application, which can be used to generate bangs images of various styles. Each bangs branch network (or module) can adopt a dedicated Flux-LoRA generation module, using multiple image samples with thin bangs, French bangs, slanted bangs, Japanese wet bangs, and airy bangs to train the dedicated Flux-LoRA generation module, thereby generating images of thin bangs, French bangs, slanted bangs, Japanese wet bangs, and airy bangs from images without bangs.

[0089] The second bangs image can be an image with bangs generated from an image without bangs. Multiple second bangs images for the same person can be images of the same person with multiple bangs styles. For example, by obtaining an image of person a without bangs in step 202, and using a multi-branch bangs generation model to process the hairstyle features of the image of person a without bangs, a second bangs image with the bangs style of person a can be obtained.

[0090] For example, the multi-branch bangs generation model is a five-branch bangs generation model. The five bangs branch networks (or modules) can be used to locate the morphological features and hair details of thin bangs, French bangs, slanted bangs, Japanese wet bangs, and airy bangs, respectively, so as to generate second bangs images of these bangs styles.

[0091] In one embodiment, before step 204, the server may select images without bangs that meet the quality conditions from the images without bangs; therefore, step 204 may include: the server performing hairstyle feature processing on the images without bangs that meet the quality conditions through a multi-branch bangs generation model to obtain second bangs images with multiple bangs styles under the same identity.

[0092] For example, before generating the second bangs image, the server can select a high-quality bangs-free image from a generated bangs-free image. The multi-branch bangs generation model can then perform hairstyle feature processing on these high-quality bangs-free images to obtain high-quality bangs images with multiple bangs styles under the same identity.

[0093] In one embodiment, the server can extract the morphological features and hair detail features of each bangs style from the bangs-free images that meet the quality conditions through a multi-branch bangs generation model, and generate bangs images based on the morphological features and hair detail features of each bangs style to obtain a second bangs image with multiple bangs styles under the same identity.

[0094] Step 206: Combine the image without bangs under the same identity with the second image of multiple bangs styles in pairs to obtain the combined image of various hairstyles under the same identity.

[0095] Among these, pairwise splicing can involve splicing various images of the same person (including images without bangs and various images with bangs) in pairs. For example, splicing the image of person A with French bangs after the image without bangs results in a spliced ​​image of hairstyles. Figure 4 As shown, this hairstyle spliced ​​image can also be called a biplot. In the subsequent model training process, one image in this hairstyle spliced ​​image (such as the French bangs image) can be used as the reference image (i.e., the label image), and the other image (such as the image without bangs) can be used to generate a new French bangs image by performing hairstyle feature processing.

[0096] In one embodiment, the server can stitch together images of no bangs and multiple second-style bangs images under the same identity, or, after filtering out images of no bangs that meet quality criteria, it can stitch together images of no bangs and multiple second-style bangs images under the same identity to obtain stitched images of various hairstyles under the same identity. Figure 5 As shown.

[0097] In one embodiment, when the server filters out images without bangs that meet the quality criteria, it can stitch the images without bangs that meet the quality criteria under the same identity with second images of multiple bangs styles in pairs, and stitch the second images of multiple bangs styles under the same identity in pairs to obtain stitched images of various hairstyles under the same identity.

[0098] For example, the server stitches together images of person A without bangs with images of thin bangs, French bangs, slanted bangs, Japanese wet bangs, and airy bangs, resulting in stitched images of hairstyles with and without bangs. Furthermore, the server stitches together images of person A with thin bangs, French bangs, slanted bangs, Japanese wet bangs, and airy bangs, resulting in stitched images of hairstyles with different bang styles.

[0099] Step 208: Construct a first text prompt based on the spliced ​​images of each hairstyle to generate the corresponding bangs style.

[0100] The first text prompt can be a text prompt constructed based on spliced ​​images of different hairstyles, so that during the model training process, the initial hairstyle generation model can be instructed to generate bangs images of the corresponding bangs style according to the instructions.

[0101] For example, if the hairstyle splicing image is a person a with no bangs and a person a with French bangs, the first text prompt could be to generate a person a with French bangs, or to add French bangs to the person a with no bangs; if the hairstyle splicing image is a person a with French bangs and a person a with Japanese wet bangs, the first text prompt could be to change it to Japanese wet bangs, or to change the person a with French bangs to Japanese wet bangs.

[0102] Step 210: Train the initial hairstyle generation model based on the spliced ​​images of each hairstyle and the corresponding text prompts to obtain a hairstyle generation model for generating each bangs style.

[0103] The initial hairstyle generation model can be a hairstyle generation model obtained by introducing an in-context editing framework based on the Flux model structure, such as... Figure 6 As shown.

[0104] In each spliced ​​image, the second image of the bangs style indicated by the first text prompt is the label image.

[0105] In one embodiment, the server can acquire mask images and noise images corresponding to each hairstyle stitched image; extract visual features from each hairstyle stitched image, mask image, and noise image using the image encoder of the initial hairstyle generation model, and extract text features from the text prompt using the text encoder of the initial hairstyle generation model; fuse the text features and visual features through the fusion layer of the initial hairstyle generation model to obtain fused features; perform image generation processing on the fused features through the generative network of the initial hairstyle generation model to obtain a third bangs image of the bangs style indicated by the first text prompt; determine a loss value based on the third bangs image and the label image; update the parameters of the initial hairstyle generation model based on the loss value to obtain a hairstyle generation model used to generate each bangs style.

[0106] During the model training phase, the initial hairstyle generation model receives two input branches: an image branch and a text branch, such as... Figure 6 As shown, the input to the image branch is a joint input of "biplexed image-mask image-noise image", and the visual features are extracted by the image encoder; the input to the text branch is the first text prompt, and the text encoder extracts the text features (i.e., semantic features) from the first text prompt. The visual features and text features are fused in a multimodal manner, thereby enabling accurate editing based on context.

[0107] The biplotact image (i.e., a stitched image of hairstyles) provides visual context, the mask image defines the editing area, and the noisy image optimizes the generation path through flow matching technology. The three work together to form a hierarchical conditional control system. This multimodal joint coding mechanism not only preserves the stylistic consistency of the reference image but also allows for flexible adjustment of the editing target through text commands, significantly improving the controllable generation capability in complex scenes.

[0108] The generative network can be a DiT (Diffusion Transformer, a network architecture that combines diffusion models and Transformer architecture) model.

[0109] Step 212: In response to the hairstyle generation request, the hairstyle generation model performs hairstyle feature processing on the image to be processed based on the second text prompt to obtain the target bangs image corresponding to the second text prompt.

[0110] The hairstyle generation request can be a request to generate a target bangs style, and can carry a second text prompt and an image to be processed. The image to be processed can be the user's own photo or a virtual avatar, which can be an avatar used in virtual social networking and the metaverse.

[0111] The second text prompt can be a text prompt input based on actual needs, so that during the model inference process, the hairstyle generation model is instructed to generate the corresponding bangs image according to the instructions.

[0112] For example, if a user wants to adjust the hairstyle in an image to be processed, such as changing the hairstyle in their own photo or virtual avatar to French bangs, they can use image editing software or software with editing functions. They can enter prompt text and a photo or virtual avatar on the software dialog page, such as entering "change the hairstyle in this photo or virtual avatar to French bangs", thereby generating a hairstyle generation request for French bangs.

[0113] In one embodiment, after obtaining the target notch image, the server performs face enhancement on the target notch image to obtain a face enhancement image, and performs notch segmentation on the target notch image to obtain a first notch mask image; performs notch segmentation on the image to be processed to obtain a second notch mask image; and performs spatial logic operations based on the first notch mask image, the second notch mask image, and the face enhancement image to obtain an enhanced target notch image.

[0114] The first bangs mask image can be obtained in the following way: the server performs face point detection on the target bangs image to obtain the first face feature map; the target bangs image is segmented into hair to obtain the first hair mask image; and the first bangs mask image is generated based on the first hair mask image and the first face feature map.

[0115] The second bangs mask image can be obtained as follows: the server performs face point detection on the image to be processed to obtain a second face feature map; the server performs hair segmentation on the image to be processed to obtain a second hair mask image; and the server generates a second bangs mask image based on the second hair mask image and the second face feature map.

[0116] like Figure 7 As shown, the reasoning process of this application can be referred to Figure 7 It adopts a dual-path parallel processing architecture: the main path inputs the image to the notch generation model (e.g., ...). Figure 6 As shown, the target notch image is generated, and the auxiliary path is preprocessed by the notch segmentation module to obtain the initial notch mask image. This segmentation module consists of two cooperating sub-networks (such as...). Figure 8 As shown, the model includes a facial keypoint detection branch for accurately locating the forehead region and a hair segmentation branch for extracting the overall hair structure. The features of these two branches are fused to output a high-precision bangs mask image. The target bangs image is input to two post-processing units: a face enhancement module and another segmentation model. The face enhancement module can enhance hair texture using high-frequency detail recovery technology, while the other segmentation module generates a precise mask image for the target bangs. Finally, the face protection module performs spatial logic operations (such as intersection operation plus Gaussian blur) on the initial bangs mask image and the precise mask image. This calculates the area to be edited and combines it with the alpha fusion algorithm applied to the face enhancement image to obtain the final target bangs image, thus achieving: 1) a naturally transitioning bangs edge fusion.

[0117] In the above embodiments, bangs removal processing is performed on first bangs images with multiple bangs styles. A multi-branch bangs generation model is then used to process the hairstyle features of the resulting bangs-free images. This allows for the generation of second bangs images with multiple bangs styles under the same identity. In other words, under the same identity, both bangs-free images and images with multiple bangs styles are available, effectively enriching the sample size and solving the problem of sample scarcity. Furthermore, the bangs-free images and the second bangs images with multiple bangs styles under the same identity are paired and stitched together to obtain stitched images of various hairstyles under the same identity. Based on these stitched images, a first text extraction tool for generating the corresponding bangs style is constructed. As shown, the initial hairstyle generation model is trained based on the stitched images of each hairstyle and the corresponding text prompts. After training, the hairstyle generation model is used to process the hairstyle features of the image to be processed according to the second text prompts. It can not only generate bangs from no bangs according to actual needs, but also switch from one bangs style to other bangs styles, enriching the generation methods of bangs hairstyles and improving the user experience. Moreover, during the bangs generation process, the hairstyle generation model can effectively adjust the bangs style through text prompts. In addition, the rich samples used in the training process make the generated bangs hair strands transition naturally, effectively improving the hairstyle generation effect.

[0118] As an example, the solution proposed in this application will be further described below:

[0119] This application presents a context-editable method for generating character bangs. The following three parts will describe the method:

[0120] (1) Data preparation

[0121] Current open-source datasets for bangs generation have significant limitations. While the FFHQ dataset provides a large number of 1024×1024 high-resolution face images covering diverse age, skin color, and expression features, and the CelebA-HQ dataset contains 30,000 celebrity images labeled with 40 attributes, both lack crucial pairing data for different bangs under the same ID and pairing data for having or not having bangs (referred to as paired bangs data). This data deficiency severely restricts the performance of supervised learning-based bangs generation models.

[0122] To address this pain point, this application innovatively designs a complete bangs data construction scheme. Through multi-stage bangs elimination and different bangs generation LoRa models, it achieves the construction of a large-scale, high-quality paired bangs dataset. This application's scheme not only solves the problem of scarce paired bangs data, but its standardized process can also be extended to data preparation for other hairstyling tasks. Specifically, the paired bangs data construction of this application mainly includes the following steps:

[0123] S1, Construct face matching data for "with bangs / without bangs".

[0124] For five typical bangs styles (i.e., straight bangs, French bangs, airy bangs, Japanese wet bangs, and slanted bangs), we collected diverse facial data. Then, we used the image inpainting capabilities of StyleGAN to remove the bangs. Finally, we obtained a high-fidelity paired dataset of bangs and no bangs under the same ID through quality screening.

[0125] S2, Training LoRa for "No bangs / Any target bangs" bangs generation

[0126] This application proposes a multi-branch bangs generation model based on high-quality paired bangs data constructed using S1. Dedicated Flux-LoRA generation modules were trained for five typical bangs styles. Each module precisely locates the morphological features and hair details of a specific bangs style, achieving a controllable transformation from a base image without bangs to the target bangs style. Ultimately, the model can generate highly realistic and diverse bangs effects by cooperating with different LoRA modules based on the input image.

[0127] S3, Construct a dataset for editing bangs with multiple styles that can be converted between each other.

[0128] This application integrates the results of phases S1 and S2 to construct an end-to-end hairstyle conversion framework. This framework employs a two-stage "elimination-then-generation" processing flow: first, the basic face is restored using the bangs elimination model in S1; then, multiple Flux-LoRA generation modules trained in S2 are used to generate the specified bangs style. This modular design not only enables free conversion between arbitrary bangs styles but also automatically generates a large amount of bangs pairing data, including "initial bangs - target bangs" and "no bangs - target bangs". After rigorous visual quality screening, a dataset consisting of bangs pairing data supporting the conversion between multiple hairstyles is finally constructed, providing an important training benchmark for subsequent bangs editing tasks.

[0129] (2) Model structure design

[0130] This application introduces an in-context editing framework based on Flux. For example... Figure 6 As shown, during the model training phase, the model input has two branches: an image branch and a text branch. The image branch takes a combined input of a "bilinked image-mask image-noise image". After visual features are extracted by the image encoder, they are fused with the semantic features of the text encoder in a multimodal manner to achieve context-based accurate editing.

[0131] The bilinked image provides visual context, the mask image defines the editing area, and the noisy image optimizes the generation path through flow matching technology. The three work together to form a hierarchical conditional control system. This multimodal joint coding mechanism not only preserves the stylistic consistency of the reference image but also allows for flexible adjustment of the editing target through text commands, significantly improving the controllable generation capability in complex scenes.

[0132] (3) Reasoning process of the scheme

[0133] The reasoning process of this application can be found by referring to Figure 7 It adopts a dual-path parallel processing architecture: the main path inputs the image to the notch generation model (e.g., ...). Figure 6 As shown, the target notch image is generated, and the auxiliary path is preprocessed by the notch segmentation module to obtain the initial notch mask image. This segmentation module consists of two cooperating sub-networks (such as...). Figure 8 As shown, the model includes a facial landmark detection branch for accurately locating the forehead region and a hair segmentation branch for extracting the overall hair structure. The features of these two branches are fused to output a high-precision bangs mask image. The target bangs image is input to two post-processing units: a face enhancement module and another segmentation model. The face enhancement module can enhance hair texture using high-frequency detail recovery technology, while the other segmentation module generates the accurate mask image of the target bangs. Finally, the face protection module performs spatial logic operations (such as intersection operation plus Gaussian blur) on the initial bangs mask image and the accurate mask image. This calculates the area to be edited and combines it with the alpha fusion algorithm applied to the face enhancement image to obtain the final target bangs image. This achieves: 1) a naturally transitioning bangs edge fusion; and 2) protective preservation of facial features, ensuring that the output maintains hair-level details without compromising the original facial structure and clarity.

[0134] The solution proposed in this application can bring the following beneficial effects:

[0135] This application aims to solve the problems of hairstyle trial and error, digital image retouching, and virtual avatar customization, and to realize virtual try-on, one-click image retouching, and diverse hairstyle generation.

[0136] First, this application creatively designs a process for constructing bangs pairing data: the first stage uses StyleGAN image inpainting technology to achieve high-precision bangs removal, and the second stage trains a dedicated Flux-LoRA generation module to construct a large-scale "arbitrary hairstyle - target bangs" pairing dataset. The arbitrary hairstyle can be non-bangs or other bangs styles.

[0137] Secondly, an In-Context Editing framework is introduced, which, through the deep integration of the DiT model and flow matching technology, achieves efficient context editing capabilities requiring only minor parameter tuning. This framework has three major advantages:

[0138] 1) Supports multimodal input with image stitching and joint prompts;

[0139] 2) By using stream matching technology, the number of generation steps is compressed to 10-15 steps, improving efficiency by 3 times;

[0140] 3) A dual-channel guidance mechanism (text instructions + image reference) ensures generation stability. Experiments show that this application can accurately convert five typical bangs styles while maintaining hair-level detail, providing a reliable AI solution for the beauty industry, virtual character design, and other fields.

[0141] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0142] Based on the same inventive concept, this application also provides a target hairstyle generation apparatus for implementing the target hairstyle generation method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more target hairstyle generation apparatus embodiments provided below can be found in the limitations of the target hairstyle generation method described above, and will not be repeated here.

[0143] In one exemplary embodiment, such as Figure 9 As shown, a target hairstyle generation device is provided, including: an elimination unit 902, a processing unit 904, a splicing unit 906, a construction unit 908, a training unit 910, and a generation unit 912, wherein:

[0144] The elimination unit 902 is used to perform bangs elimination processing on the first bangs image of various bangs styles to obtain a bangs-free image;

[0145] Processing unit 904 is used to perform hairstyle feature processing on images without bangs through a multi-branch bangs generation model to obtain second bangs images with multiple bangs styles under the same identity;

[0146] The splicing unit 906 is used to splice two images of no bangs under the same identity and two images of bangs with multiple styles of bangs in pairs to obtain spliced ​​images of various hairstyles under the same identity.

[0147] Construction unit 908 is used to construct a first text prompt for generating the corresponding bangs style based on the spliced ​​images of each hairstyle;

[0148] Training unit 910 is used to train the initial hairstyle generation model based on the spliced ​​images of each hairstyle and the corresponding text prompts, so as to obtain a hairstyle generation model for generating each bangs style.

[0149] The generation unit 912 is used to respond to the hairstyle generation request, and through the hairstyle generation model, perform hairstyle feature processing on the image to be processed according to the second text prompt to obtain the target bangs image corresponding to the second text prompt.

[0150] In one embodiment, the device further includes:

[0151] The selection unit is used to select images without bangs that meet the quality requirements from the images without bangs.

[0152] The processing unit is also used to perform hairstyle feature processing on images without bangs that meet the quality conditions through a multi-branch bangs generation model to obtain second bangs images with multiple bangs styles under the same identity;

[0153] The splicing unit is also used to splice two no-bangs images and two second bangs images with multiple bangs styles that meet the quality conditions under the same identity, to obtain spliced ​​images of various hairstyles under the same identity.

[0154] In one embodiment, the processing unit is further configured to extract the morphological features and hair detail features of each bangs style from a bangs-free image that meets the quality conditions using a multi-branch bangs generation model, and generate bangs images based on the morphological features and hair detail features of each bangs style to obtain a second bangs image with multiple bangs styles under the same identity.

[0155] In one embodiment, the splicing unit is further configured to splice two no-bangs images that meet the quality conditions under the same identity with two second bangs images of multiple bangs styles, and to splice two second bangs images of multiple bangs styles under the same identity to obtain spliced ​​images of various hairstyles under the same identity.

[0156] In one embodiment, the second image of the bangs style indicated by the first text prompt is a label image;

[0157] The training unit is also used to acquire mask images and noise images corresponding to each hairstyle stitched image; extract visual features from each hairstyle stitched image, mask image and noise image through the image encoder of the initial hairstyle generation model, and extract text features from the text prompts through the text encoder of the initial hairstyle generation model; fuse text features and visual features through the fusion layer of the initial hairstyle generation model to obtain fused features; perform image generation processing on the fused features through the generative network of the initial hairstyle generation model to obtain the third bangs image of the bangs style indicated by the first text prompt; determine the loss value based on the third bangs image and the label image; update the parameters of the initial hairstyle generation model based on the loss value to obtain the hairstyle generation model used to generate each bangs style.

[0158] In one embodiment, the device further includes:

[0159] The enhancement unit is used to perform face enhancement on the target bangs image after obtaining the target bangs image to obtain a face-enhanced image;

[0160] The segmentation unit is used to segment the target bangs image to obtain a first bangs mask image; and to segment the image to be processed to obtain a second bangs mask image.

[0161] The processing unit is used to perform spatial logic operations based on the first notch mask image, the second notch mask image, and the face enhancement image to obtain the enhanced target notch image.

[0162] In one embodiment, the segmentation unit is further configured to perform face point detection on the target bangs image to obtain a first face feature map; perform hair segmentation on the target bangs image to obtain a first hair mask image; and generate a first bangs mask image based on the first hair mask image and the first face feature map.

[0163] The segmentation unit is also used to perform face point detection on the image to be processed to obtain a second face feature map; to perform hair segmentation on the image to be processed to obtain a second hair mask image; and to generate a second bangs mask image based on the second hair mask image and the second face feature map.

[0164] In the above embodiments, bangs removal processing is performed on first bangs images with multiple bangs styles. A multi-branch bangs generation model is then used to process the hairstyle features of the resulting bangs-free images. This allows for the generation of second bangs images with multiple bangs styles under the same identity. In other words, under the same identity, both bangs-free images and images with multiple bangs styles are available, effectively enriching the sample size and solving the problem of sample scarcity. Furthermore, the bangs-free images and the second bangs images with multiple bangs styles under the same identity are paired and stitched together to obtain stitched images of various hairstyles under the same identity. Based on these stitched images, a first text extraction tool for generating the corresponding bangs style is constructed. As shown, the initial hairstyle generation model is trained based on the stitched images of each hairstyle and the corresponding text prompts. After training, the hairstyle generation model is used to process the hairstyle features of the image to be processed according to the second text prompts. It can not only generate bangs from no bangs according to actual needs, but also switch from one bangs style to other bangs styles, enriching the generation methods of bangs hairstyles and improving the user experience. Moreover, during the bangs generation process, the hairstyle generation model can effectively adjust the bangs style through text prompts. In addition, the rich samples used in the training process make the generated bangs hair strands transition naturally, effectively improving the hairstyle generation effect.

[0165] Each module in the aforementioned target hairstyle generation device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.

[0166] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 10 As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores image data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When executed by the processor, the computer program implements a method for generating a target hairstyle.

[0167] In an exemplary embodiment, a computer device is provided, which may also be a terminal, including a processor, memory, input / output interface, communication interface, display unit, and input device. The processor, memory, and input / output interface are connected via a system bus, and the communication interface, display unit, and input device are connected to the system bus via the input / output interface. The processor of the computer device provides computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The input / output interface of the computer device is used for exchanging information between the processor and external devices. The communication interface of the computer device is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When the computer program is executed by the processor, it implements a method for generating a target hairstyle. The display unit of the computer device is used to form a visually visible image and may be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.

[0168] Those skilled in the art will understand that Figure 10 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0169] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the target hairstyle generation method described above.

[0170] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the target hairstyle generation method described above.

[0171] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps of the target hairstyle generation method described above.

[0172] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.

[0173] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0174] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0175] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A target hairstyle generation method characterized by, The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises:

2. The method of claim 1, wherein, The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises:

3. The method of claim 2, wherein, The method comprises: The method comprises:

4. The method of claim 2, wherein, The method comprises: The method comprises:

5. The method of claim 1, wherein, The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: The method comprises: obtain a mask image and a noise image corresponding to each of the hairstyle splicing images; extract visual features from each of the hairstyle splicing images, the mask image, and the noise image through an image encoder of an initial hairstyle generation model, and extract text features from the text prompt through a text encoder of the initial hairstyle generation model; fuse the text features and the visual features through a fusion layer of the initial hairstyle generation model to obtain fused features; perform image generation processing on the fused features through a generation network of the initial hairstyle generation model to obtain a third bang image of the bang style indicated by the first text prompt; determine a loss value based on the third bang image and the label image; update parameters of the initial hairstyle generation model based on the loss value to obtain a hairstyle generation model for generating each of the bang styles.

6. The method of claim 1, wherein, The method further includes: after obtaining the target bang image, performing face enhancement on the target bang image to obtain a face enhanced image, and performing bang segmentation on the target bang image to obtain a first bang mask image; performing bang segmentation on the to-be-processed image to obtain a second bang mask image; performing spatial logical operation based on the first bang mask image, the second bang mask image, and the face enhanced image to obtain an enhanced target bang image.

7. The method of claim 6, wherein, The method further includes: performing face point detection on the target bang image to obtain a first face feature map; performing hair segmentation on the target bang image to obtain a first hair mask image; generating the first bang mask image based on the first hair mask image and the first face feature map; The method further includes: performing face point detection on the to-be-processed image to obtain a second face feature map; performing hair segmentation on the to-be-processed image to obtain a second hair mask image; generating the second bang mask image based on the second hair mask image and the second face feature map.

8. A target hairstyle generating apparatus characterized by comprising: The apparatus includes: a removing unit configured to perform bang removing processing on first bang images of a plurality of bang styles to obtain no-bang images; a processing unit configured to perform hairstyle feature processing on the no-bang images through a multi-branch bang generation model to obtain second bang images of the plurality of bang styles under the same identity; a splicing unit configured to splice the no-bang images and the second bang images of the plurality of bang styles under the same identity two by two to obtain each of the hairstyle splicing images under the same identity; a constructing unit configured to construct first text prompts for generating corresponding bang styles based on each of the hairstyle splicing images; a training unit configured to perform model training on an initial hairstyle generation model according to each of the hairstyle splicing images and the corresponding text prompts to obtain a hairstyle generation model for generating each of the bang styles; a generating unit configured to perform hairstyle feature processing on a to-be-processed image according to a second text prompt through the hairstyle generation model to obtain a target bang image corresponding to the second text prompt in response to a hairstyle generation request.

9. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program, which when executed by a processor, implements the steps of the method of any one of claims 1 to 7.

10. A computer program product comprising a computer program, characterized in that, The computer program, which when executed by a processor, implements the steps of the method of any one of claims 1 to 7.