Hair style matching method and device, electronic equipment and readable storage medium
By extracting and matching virtual hairstyle features, the problem of virtual image not being similar to user hairstyles is solved, and the realism and mimicry of the virtual experience is improved.
Patent Information
- Application Number
- CN202411098281.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-12
- Publication Date
- 2024-12-13
AI Technical Summary
The existing technology cannot accurately match virtual hairstyles, resulting in the virtual image being different from the user's real hairstyles, affecting the realism and imitation of virtual social, conferences, fittings and gaming experiences.
By obtaining the face image of the target character, using the pre-trained feature extraction model to extract hairstyle features, and based on the model trained by multiple sample subsets, select matching virtual hairstyles from the virtual hairstyle library to improve the fine-grainedness and matching accuracy of hairstyle features. sex.
It achieves the accurate matching of virtual images with the user's real hairstyle, and improves the realism and imitation of virtual social, conference, fitting and gaming experience.
Smart Images

Figure CN119128198A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of artificial intelligence technology, and specifically relates to a hairstyle matching method, device, electronic device and readable storage medium. Background Art
[0002] In a virtual world, a user may need to generate his or her own avatar, and hairstyle is particularly important in the avatar, so a hairstyle matching operation needs to be performed. In the related art, a matching virtual hairstyle is usually selected for the user's avatar based on a pre-built hairstyle region library and the user's detected hairstyle region. However, since the straightness, texture, direction and other information of the user's hairstyle cannot be fully reflected in the hairstyle region, it will result in an inability to accurately match the virtual hairstyle. Summary of the invention
[0003] The purpose of the embodiments of the present application is to provide a hairstyle matching method, device, electronic device and readable storage medium to solve the problem in the related art that virtual hairstyles cannot be accurately matched.
[0004] In order to solve the above technical problems, this application is implemented as follows:
[0005] In a first aspect, a hairstyle matching method is provided, comprising:
[0006] Obtain the face image of the target person;
[0007] Extracting hairstyle features from the face image using a pre-trained feature extraction model to obtain the hairstyle features of the target person, wherein the feature extraction model is trained based on a plurality of first sample subsets, each of which contains a plurality of face images of the same sample person with the same hairstyle type;
[0008] According to the hairstyle feature, a virtual hairstyle is selected for the virtual image of the target person from a pre-established virtual hairstyle library.
[0009] In a second aspect, a hairstyle matching device is provided, comprising:
[0010] The first acquisition module is used to acquire the face image of the target person;
[0011] An extraction module, configured to extract hairstyle features from the face image using a pre-trained feature extraction model to obtain the hairstyle features of the target person, wherein the feature extraction model is trained based on a plurality of first sample subsets, each of which contains a plurality of face images of the same sample person with the same hairstyle type;
[0012] The selection module is used to select a virtual hairstyle for the virtual image of the target person from a pre-established virtual hairstyle library according to the hairstyle characteristics.
[0013] In a third aspect, an electronic device is provided, comprising a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method described in the first aspect.
[0014] In a fourth aspect, a readable storage medium is provided, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.
[0015] In a fifth aspect, a computer program product is provided, comprising computer instructions, which, when executed by a processor, implement the steps of the method described in the first aspect.
[0016] In an embodiment of the present application, after acquiring a facial image of a target person, a pre-trained feature extraction model can be used to extract hairstyle features from the facial image to obtain the hairstyle features of the target person, wherein the feature extraction model is trained based on multiple first sample subsets, each of which contains multiple facial images of the same sample person under the same hairstyle type, and according to the hairstyle features, a virtual hairstyle is selected for the virtual image of the target person from a pre-established virtual hairstyle library. Thus, the feature extraction model can be trained based on multiple facial images of the same sample person under the same hairstyle type contained in each first sample subset, thereby improving the effect of the model in extracting hairstyle features, obtaining fine-grained hairstyle features, and then the fine-grained hairstyle features can be comprehensively considered to select a virtual hairstyle for the corresponding virtual image, thereby achieving accurate matching of the virtual hairstyle. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 is a flow chart of a hairstyle matching method provided in an embodiment of the present application;
[0018] Figure 2A , Figure 2B , Figure 2C , Figure 2D and Figure 2E is one of the schematic diagrams of a face image in an embodiment of the present application;
[0019] Figure 3A , Figure 3B , Figure 3C , Figure 3D and Figure 3E is one of the schematic diagrams of a face image in an embodiment of the present application;
[0020] Figure 4is a schematic diagram of a hairstyle matching process in an embodiment of the present application;
[0021] Figure 5 is a schematic diagram of selecting a virtual hairstyle in an embodiment of the present application;
[0022] Figure 6 is a structural schematic diagram of a hairstyle matching device provided in an embodiment of the present application;
[0023] Figure 7 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0024] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0025] The terms "first", "second", etc. in the specification and claims of this application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of the same type, and the number of objects is not limited. For example, the first object can be one or more.
[0026] The embodiment of the present application provides a hairstyle matching method. Optionally, the applicable scenarios of the embodiment of the present application include but are not limited to the following scenarios:
[0027] (1) Social interaction: When users socialize on the Metaverse platform, they often hope that their virtual images can truly reflect their personality and style, which can help users establish a unique social identity in the virtual world. Therefore, matching the hairstyle that is most similar to one's own in the virtual hairstyle library can greatly increase the similarity between the virtual image and the user himself.
[0028] (2) Online meetings: With the popularity of remote work, more and more companies and teams are choosing to hold meetings in virtual spaces. In this case, a realistic virtual image can make online meetings more lively and interactive. Matching a hairstyle that is closest to your own in the virtual hairstyle library can greatly improve the realism of the virtual image.
[0029] (3) Virtual fitting: The retail and fashion industries can use this technology to allow customers to try on clothes or accessories in the metaverse. A virtual image that is similar to the real world, especially matching the hairstyle that is closest to your own in the virtual hairstyle library, can greatly improve the realism and satisfaction of the fitting experience.
[0030] (4) Games: In many role-playing games and virtual reality (VR) games, players usually spend a lot of time customizing the appearance of their characters, accurately mapping the player's real image to the game character, thereby greatly enhancing the player's immersion and sense of belonging. Matching the hairstyle that is most similar to one's own in the virtual hairstyle library can greatly improve the similarity between the game character and the player's real image.
[0031] The hairstyle matching method, device, electronic device and readable storage medium provided in the embodiments of the present application are described in detail below with reference to the accompanying drawings through specific embodiments and their application scenarios.
[0032] See also Figure 1 , Figure 1 is a flowchart of a hairstyle matching method provided in an embodiment of the present application, the method is applied to electronic devices such as Figure 1 As shown, the method comprises the following steps:
[0033] Step 11: Obtain the face image of the target person;
[0034] Step 12: extracting hairstyle features from the face image using a pre-trained feature extraction model to obtain the hairstyle features of the target person; wherein the feature extraction model is trained based on a plurality of first sample subsets, each of the first sample subsets contains a plurality of face images of the same sample person with the same hairstyle type, and the face images in each first sample subset correspond to a hairstyle type; that is, for the same sample person, a plurality of frontal face images with the same hairstyle type are obtained to form a first sample subset, and the face images in the first sample subset have the same hairstyle type;
[0035] Step 13: According to the hairstyle features, a virtual hairstyle is selected for the virtual image of the target person from a pre-established virtual hairstyle library.
[0036] In the embodiment of the present application, the target person may be selected as a user in the Metaverse social platform, a meeting member in an online meeting, a customer in a virtual fitting scene, a player in a virtual game, etc., without limitation.
[0037] The face image is specifically a real image containing a face.
[0038] The hairstyle features may be selected from, but not limited to, the straightness, texture, length, shape, bangs, direction of hair tail, hair color, etc. The hairstyle features may be represented in the form of a feature vector, such as a floating point vector with a certain length.
[0039] Optionally, the feature extraction model can be trained using a deep learning method or a machine learning method such as a support vector machine or a random forest. The specific training method can be an existing method and is not limited to this. In addition to using a pre-trained feature extraction model to extract hairstyle features, a variety of methods can be used to extract hairstyle features, such as using an existing image recognition method to directly extract hairstyle features from a face image.
[0040] Optionally, in order to accurately extract the hairstyle features, the face image may be preprocessed before the hairstyle features are extracted to highlight the hair area. The preprocessing method is, for example, to first use a facial segmentation algorithm to identify the hair area and the face area, then set each pixel in the face area to a random color, keep the hair area as it is, and set the grayscale values of all pixels in other areas except the hair area and the face area to 0, that is, set the other areas to all black, that is, RGB = [0,0,0], so as to highlight the hair area.
[0041] Optionally, after selecting a virtual hairstyle for the virtual image of the target person, subsequent rendering and other operations may be performed based on the virtual hairstyle to obtain a virtual image that is more similar to the target person.
[0042] The hairstyle matching method in the embodiment of the present application can, after acquiring the facial image of the target person, use a pre-trained feature extraction model to extract the hairstyle features of the facial image to obtain the hairstyle features of the target person, wherein the feature extraction model is trained based on multiple first sample subsets, each of which contains multiple facial images of the same sample person under the same hairstyle type, and according to the hairstyle features, a virtual hairstyle is selected for the virtual image of the target person from a pre-established virtual hairstyle library. Thus, the feature extraction model can be trained based on multiple facial images of the same sample person under the same hairstyle type contained in each first sample subset, thereby improving the effect of the model in extracting hairstyle features, obtaining fine-grained hairstyle features, and then the fine-grained hairstyle features can be comprehensively considered to select a virtual hairstyle for the corresponding virtual image, thereby achieving accurate matching of the virtual hairstyle.
[0043] Optionally, the training process of the feature extraction model may include:
[0044] Obtain a first training sample set including a plurality of first sample subsets; that is, the first training sample set includes a plurality of first sample subsets, each first sample subset includes a plurality of face images of the same sample person with the same hairstyle type, and each face image in the first sample subset corresponds to a hairstyle type;
[0045] Preprocessing the facial images in each first sample subset to highlight the hair area is performed to obtain multiple second sample subsets; for example, the preprocessing includes but is not limited to denoising, adjusting the image size, adjusting the image brightness, adjusting the pixel values of different areas in the image, etc.; it is worth noting that in order to avoid affecting the model training effect, the preprocessing cannot change the characteristics of the hairstyle in the corresponding facial image and the corresponding hairstyle type;
[0046] The feature extraction model is obtained by training according to the multiple second sample subsets.
[0047] In this way, since it is less difficult to obtain multiple facial images of the same person than to obtain multiple facial images of multiple persons, and it is convenient to obtain multiple facial images of the same person, a feature extraction model is obtained by training based on the training sample set, which can reduce the difficulty of sample data collection, reduce the workload of obtaining sample data, and improve the efficiency of extraction model training.
[0048] Optionally, the process of obtaining the training sample set containing multiple first sample subsets may include: first, collecting multiple facial images of each sample person under different camera positions, shooting angles and / or lighting conditions; then, classifying and storing the collected facial images based on the two dimensions of sample person and hairstyle type, and storing multiple facial images of the same sample person under the same hairstyle type in the sample subset corresponding to the same hairstyle identifier. That is, for the same sample person, while keeping the hairstyle unchanged, a plurality of facial images may be collected / obtained by slightly moving the camera position, changing the shooting angle of the sample person and / or changing the lighting conditions, etc., and these facial images have the same hairstyle type and correspond to one hairstyle identifier. If it is the same sample person, but the hairstyle is changed, the collected / obtained facial image corresponds to another hairstyle type or hairstyle identifier. For example, after collecting a type of sample data for a sample person with a single ponytail hairstyle, if the hairstyle of the sample person is changed to a double ponytail, another type of sample data may be collected with a double ponytail hairstyle. In this way, the required training sample data can be obtained with only a simple operation, thereby reducing the difficulty of sample data collection and the workload of obtaining sample data.
[0049] It should be pointed out that when obtaining the training sample set, it is necessary to collect the hairstyle data of multiple sample characters to form multiple categories of hairstyle data, that is, corresponding to multiple hairstyle types, so as to ensure the diversity of hairstyle types.
[0050] For example, for the first training sample set mentioned above, the multiple face images contained in a first sample subset can be as follows: FIG. 2A to FIG. 2E As shown in FIG. 1 , the characters in these face images have the same hairstyle type, but the shooting angles, lighting conditions, etc. are different; the multiple face images included in another first sample subset can be as follows FIG. 3A to FIG. 3E As shown in FIG. 1 , the characters in these face images have the same hairstyle type, but the shooting angles, lighting conditions, etc. are different. It should be noted that in order to protect implicit FIG. 2A to FIG. 2E as well as FIG. 3A to FIG. 3E The faces in the face images shown have mosaics added to them, but the actual face images used during model training may not have these mosaics.
[0051] Optionally, when the feature extraction model is obtained by training the multiple second sample subsets, the feature extraction model can be directly obtained by training the multiple second sample subsets, and the corresponding training method is, for example, supervised learning, machine learning, etc. In addition, the feature extraction model can also be obtained by indirectly training the multiple second sample subsets.
[0052] Optionally, when the feature extraction model is obtained by indirect training, the process of obtaining the feature extraction model by training according to the plurality of second sample subsets may include:
[0053] Taking the face image in each second sample subset as input and the hairstyle type corresponding to the face image in each second sample subset as output, model training is performed to obtain a hairstyle classification model; for example, the hairstyle classification model can be selected as a classification model in a deep learning model, and the specific training method can adopt an existing method, which is not limited to this;
[0054] The fully connected layer in the hairstyle classification model is removed to obtain the feature extraction model; the fully connected layer plays the role of a "classifier" and is used to perform classification according to the extracted hairstyle features; in this embodiment, the fully connected layer is removed from the trained hairstyle classification model, so that when the input of the obtained model is a face image, the output is the hairstyle features of the face image, that is, the feature extraction model can be obtained by removing the fully connected layer.
[0055] Optionally, the preprocessing of highlighting the hair region on the face images in each first sample subset may include: in each face image, maintaining the hair region as it is, setting the face region to a random color, and setting the grayscale values of pixels in other regions except the hair region and the face region to 0. That is, the face images in each second sample subset obtained after the preprocessing at least meet the following conditions: the hair region remains as it is, the face region is set to a random color, and the grayscale values of pixels in other regions except the hair region and the face region are set to 0. Since the preprocessing maintains the hair region in the face image as it is, the characteristics of the hairstyle in the face image and the corresponding hairstyle type will not be changed. The preprocessing process is, for example, as follows: first, for all the face images in the first sample subset, identify the key points of the face and perform face alignment. For example, when performing face alignment, geometric scaling, translation and other operations can be used to place the eye positions in each face image at the same coordinates; then use the facial segmentation algorithm to identify the hair area and face area in the face image, and set each pixel in the face area to a random color, keep the hair area as it is, and set the grayscale values of all pixels in other areas except the hair area and the face area to 0, that is, set the other areas to all black, that is, RGB = [0,0,0], so as to highlight the hair area. The above setting of each pixel in the face area to a random color allows the model to clearly learn the position of the hair relative to the face, as well as the hairstyle information of the bangs.
[0056] In this way, with the help of the preprocessing operation, when using each second sample subset for model training, the model can focus on the hair area, thereby improving the trained model's recognition ability of the hair area and improving the accuracy of the trained model.
[0057] In the embodiment of the present application, considering that different hairstyles have different characteristics and different hairstyles correspond to different types, a matching hairstyle can be selected by classifying the hairstyle characteristics. The process of selecting a virtual hairstyle for the virtual image of the target person from a pre-established virtual hairstyle library according to the hairstyle characteristics may include:
[0058] Obtaining a hairstyle type corresponding to the hairstyle feature;
[0059] Based on the correspondence between the hairstyle identifier and the hairstyle type stored in the virtual hairstyle library, the virtual hairstyle is selected from a storage space identified by the hairstyle identifier corresponding to the hairstyle type.
[0060] It should be noted that the pre-established virtual hairstyle library may store virtual hairstyles designed according to business scenarios and corresponding hairstyle types / hairstyle identifiers. Thus, after obtaining the hairstyle type corresponding to the hairstyle feature, the virtual hairstyle can be selected for the virtual image of the target person by using the correspondence between the hairstyle identifier and the hairstyle type stored in the virtual hairstyle library, thereby improving the selection efficiency.
[0061] Optionally, different hairstyle features may correspond to different hairstyle types, that is, different hairstyle types may be divided according to the hairstyle features. The division of hairstyle types may be determined according to actual needs, for example, including but limited to crew cut, 3:7 split hairstyle, double ponytail hairstyle, etc.
[0062] In an optional implementation, the hairstyle feature can be input into a pre-trained feature classification model for processing to obtain the hairstyle type corresponding to the hairstyle feature. For example, the feature classification model can be trained using a deep learning method or a machine learning method such as a support vector machine or a random forest. The specific training method can be an existing method and is not limited to this.
[0063] Optionally, the feature classification model can be obtained by following the steps:
[0064] Acquire a second training sample set; wherein the second training sample set includes a plurality of third sample subsets, each of which includes a plurality of face images obtained based on a virtual hairstyle; and each face image in the third sample subset corresponds to a hairstyle type;
[0065] Preprocessing the face images in each third sample subset respectively to obtain a plurality of fourth sample subsets; for example, the preprocessing includes but is not limited to denoising, adjusting the image size, adjusting the image brightness, adjusting the pixel values of different areas in the image, etc.; it is worth noting that in order to avoid affecting the model training effect, the preprocessing cannot change the characteristics of the hairstyle in the corresponding face image and the corresponding hairstyle type;
[0066] Performing hairstyle feature analysis on the face images in each fourth sample subset respectively to obtain the hairstyle features of the face images in each fourth sample subset; for example, the feature extraction model trained in the above embodiment may be used to extract the hairstyle features; the hairstyle features are, for example, floating-point vectors with a certain length;
[0067] The hairstyle features of the facial images in each fourth sample subset are taken as input and the hairstyle types corresponding to the facial images in each fourth sample subset are taken as output to perform model training to obtain the feature classification model; for example, the feature classification model can be trained using deep learning methods or machine learning methods such as support vector machines and random forests. The specific training method can adopt existing methods and is not limited to this.
[0068] It should be pointed out that the multiple facial images obtained based on a virtual hairstyle can be selected as a small number of typical real-life images, and the virtual hairstyle can be selected as a virtual hairstyle in a pre-established virtual hairstyle library. Assuming that there are only two virtual hairstyles in the virtual hairstyle library constructed for men, one of which is a buzz cut and the other is a 3:7 split hair. At this time, 20 frontal photos of men with a buzz cut and 3:7 split hair can be collected and constructed into a training sample set. In this way, only a small number of real-life images are needed to train the required feature classification model. Furthermore, after adjusting the virtual hairstyle library, there is no need to adjust the existing feature extraction model. It is only necessary to re-collect the corresponding small amount of real hairstyle data according to the adjustment of the virtual hairstyle library and retrain the feature classification model, thereby reducing the workload.
[0069] Optionally, in order to improve the accuracy of the training model, after preprocessing the face images in each third sample subset, the face images in each fourth sample subset obtained may at least satisfy the following: the hair region remains in its original state, the face region is set to a random color, and the grayscale values of pixels in other regions except the hair region and the face region are set to 0. Since the preprocessing keeps the hair region in the face image in its original state, the characteristics of the hairstyle in the face image and the corresponding hairstyle type will not be changed. The preprocessing process is, for example, as follows: first, for all face images in the third sample subset, identify face key points and perform face alignment. For example, when performing face alignment, geometric scaling, translation and other operations can be used to place the eye positions in each face image at the same coordinate; then use a facial segmentation algorithm to identify the hair area and face area in the face image, set each pixel in the face area to a random color, keep the hair area as it is, and set the grayscale values of all pixels in other areas except the hair area and the face area to 0, that is, set the other areas to all black, that is, RGB = [0,0,0], so as to highlight the hair area.
[0070] In this way, with the help of preprocessing operations, when using the face images in each fourth sample subset for model training, the model can focus on the hair area, thereby improving the trained model's recognition ability of the hair area and improving the accuracy of the trained model.
[0071] In an optional embodiment, Figure 4 and Figure 5 As shown, the hairstyle matching process in this application may include the following steps:
[0072] S1: Input the user image / photo into the hairstyle matching system; in order to protect the implicit, the face in the user image is added with mosaics, but the actual image may not have these mosaics;
[0073] S2: The hairstyle matching system processes the input user image; for example Figure 5 As shown, the processing process may include: S21: pre-processing the user image so that the hair area in the processed image remains original, each pixel in the face area is set to a random color, and other areas are set to be completely black; S22: using a pre-trained feature extraction model to extract hairstyle features from the processed image to obtain hairstyle features, and the hairstyle features are, for example, floating-point vectors of a certain length; S23: using a pre-trained feature classification model to process the hairstyle features to obtain a hairstyle classification result, i.e., a hairstyle type; S24: according to the hairstyle type, selecting a matching virtual hairstyle from a pre-established virtual hairstyle library, and obtaining an identification ID of the virtual hairstyle;
[0074] S3: Based on the identification ID of the virtual hairstyle, the corresponding resource data, namely the virtual hairstyle, is called, and subsequent rendering and other operations are performed based on the virtual hairstyle to obtain a virtual image that is more similar to the user.
[0075] It should be noted that the hairstyle matching method provided in the embodiment of the present application can be executed by a hairstyle matching device or a control module in the hairstyle matching device for executing the hairstyle matching method. In the embodiment of the present application, the hairstyle matching device executing the hairstyle matching method is taken as an example to illustrate the hairstyle matching device provided in the embodiment of the present application.
[0076] See also Figure 6 , Figure 6 is a schematic diagram of a hairstyle matching device provided in an embodiment of the present application, and the device is applied to electronic devices such as Figure 6 As shown, the hairstyle matching device 60 includes:
[0077] A first acquisition module 61 is used to acquire a face image of a target person;
[0078] An extraction module 62 is used to extract hairstyle features from the face image using a pre-trained feature extraction model to obtain the hairstyle features of the target person, wherein the feature extraction model is trained based on a plurality of first sample subsets, each of which contains a plurality of face images of the same sample person with the same hairstyle type;
[0079] The selection module 63 is used to select a virtual hairstyle for the virtual image of the target person from a pre-established virtual hairstyle library according to the hairstyle characteristics.
[0080] Optionally, the hairstyle matching device 60 further includes:
[0081] A second acquisition module, used to acquire a first training sample set including the plurality of first sample subsets;
[0082] A first preprocessing module, configured to perform preprocessing on each of the face images in the first sample subsets to highlight the hair area, to obtain a plurality of second sample subsets;
[0083] The first training module is used to obtain the feature extraction model through training according to the multiple second sample subsets.
[0084] Optionally, the first training module is specifically used to: take each facial image in the second sample subset as input and take the hairstyle type corresponding to each facial image in the second sample subset as output, perform model training, and obtain a hairstyle classification model; remove the fully connected layer in the hairstyle classification model to obtain the feature extraction model.
[0085] Optionally, the first preprocessing module is specifically used to: in each face image, maintain the hair area as it is, set the face area to a random color, and set the grayscale values of pixels in other areas except the hair area and the face area to 0.
[0086] Optionally, the second acquisition module is specifically used to: collect multiple facial images of each sample person under different camera positions, shooting angles and / or lighting conditions; classify and store the collected facial images based on two dimensions: sample person and hairstyle type, and store multiple facial images of the same sample person with the same hairstyle type in a sample subset corresponding to the same hairstyle identifier.
[0087] Optionally, the selection module 63 is specifically used to: obtain the hairstyle type corresponding to the hairstyle feature; and select the virtual hairstyle from a storage space identified by a hairstyle identifier corresponding to the hairstyle type.
[0088] The hairstyle matching device 60 of the embodiment of the present application can achieve the above Figure 1 The various processes of the method embodiment shown can achieve the same technical effect, and will not be described again here to avoid repetition.
[0089] Optional, such as Figure 7As shown, the embodiment of the present application also provides an electronic device 70, including a processor 71, a memory 72, and a program or instruction stored in the memory 72 and executable on the processor 71. When the program or instruction is executed by the processor 71, each process of the above-mentioned hairstyle matching method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0090] The embodiment of the present application also provides a computer program product, including computer instructions. When the computer instructions are executed by a processor, the various processes of the above-mentioned hairstyle matching method embodiment can be implemented and the same technical effect can be achieved. To avoid repetition, they are not described here.
[0091] The embodiment of the present application further provides a readable storage medium on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned hairstyle matching method embodiment can be implemented and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0092] Computer readable media include permanent and non-permanent, removable and non-removable media, and can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0093] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0094] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0095] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a service classification device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0096] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A hairstyle matching method, It is characterized in that include: Get the face image of the target person; Extracting hairstyle features from the face image using a pre-trained feature extraction model to obtain the hairstyle features of the target person, wherein the feature extraction model is trained based on a plurality of first sample subsets, each of which contains a plurality of face images of the same sample person with the same hairstyle type; According to the hairstyle feature, a virtual hairstyle is selected for the virtual image of the target person from a pre-established virtual hairstyle library.
2. The method according to claim 1, It is characterized in that The training process of the feature extraction model includes: Acquire a first training sample set including the plurality of first sample subsets; Preprocessing each of the facial images in the first sample subsets to highlight the hair area to obtain multiple second sample subsets; The feature extraction model is obtained by training according to the multiple second sample subsets.
3. The method according to claim 2, It is characterized in that The step of obtaining the feature extraction model by training the plurality of second sample subsets comprises: Taking each face image in the second sample subset as input and taking each hairstyle type corresponding to the face image in the second sample subset as output, performing model training to obtain a hairstyle classification model; The fully connected layer in the hairstyle classification model is removed to obtain the feature extraction model.
4. The method according to claim 2, It is characterized in that The preprocessing of highlighting the hair area of each face image in the first sample subset comprises: In each face image, the hair region is kept as it is, the face region is set to a random color, and the grayscale values of pixels in other regions except the hair region and the face region are set to 0.
5. The method according to claim 2, It is characterized in that The obtaining of a first training sample set including the plurality of first sample subsets comprises: Collect multiple facial images of each sample person under different camera positions, shooting angles and / or lighting conditions; The collected face images are classified and stored based on the two dimensions of sample person and hairstyle type, and multiple face images of the same sample person with the same hairstyle type are stored in a sample subset corresponding to the same hairstyle identifier.
6. The method according to claim 1, It is characterized in that The step of selecting a virtual hairstyle for the virtual image of the target person from a pre-established virtual hairstyle library according to the hairstyle feature comprises: Obtaining a hairstyle type corresponding to the hairstyle feature; Based on the correspondence between the hairstyle identifier and the hairstyle type stored in the virtual hairstyle library, the virtual hairstyle is selected from a storage space identified by the hairstyle identifier corresponding to the hairstyle type.
7. A hairstyle matching device, It is characterized in that include: The first acquisition module is used to acquire the face image of the target person; An extraction module, configured to extract hairstyle features from the face image using a pre-trained feature extraction model to obtain the hairstyle features of the target person, wherein the feature extraction model is trained based on a plurality of first sample subsets, each of which contains a plurality of face images of the same sample person with the same hairstyle type; The selection module is used to select a virtual hairstyle for the virtual image of the target person from a pre-established virtual hairstyle library according to the hairstyle characteristics.
8. An electronic device, It is characterized in that The method comprises a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method according to any one of claims 1 to 6.
9. A readable storage medium, It is characterized in that The readable storage medium stores a program or instruction, and when the program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, It is characterized in that The method comprises computer instructions, which, when executed by a processor, implement the steps of the method according to any one of claims 1 to 6.
