Hair style replacement method and device and storage medium
By building a machine learning model for pupil recognition and face feature marking, analyzing the hair style material library data, recommending and fine-tuning the hairstyle, solving the problem of cumbersome user operations, achieving fast and convenient hairstyle replacement, and improving the user experience.
Patent Information
- Application Number
- CN202411072315.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-06
- Publication Date
- 2024-12-27
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing online hairstyle replacement methods are complicated for users to operate, making it difficult to quickly identify the hairstyle that suits them, resulting in the hairstyle not meeting the user's expectations and affecting the experience.
By obtaining sample images, building a machine learning model for pupil recognition, marking face features, analyzing hair style material library data, recommending hairstyles with high matching degrees, and adaptive adjustments according to user fine-tuning instructions, and finally saving the processed image.
It realizes that users can change their hairstyles with one click, reduces trial and error costs, and improves the efficiency and user experience of hairstyle selection.
Smart Images

Figure CN119206842A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a hairstyle changing method, device and storage medium. Background Art
[0002] As living standards improve, people are more eager to pursue beauty. Today, the most important process in the hairdressing industry is to let users choose the hairstyle they want based on photos or videos of hair models. However, it is difficult for users to identify the hairstyle that suits them based on photos or videos alone. This results in the situation that the hairstyle does not meet the user's expectations at the end of the styling, affecting the user experience.
[0003] Among the existing online hairstyle changing methods, most are done by adding pictures. Users need to prepare a hairstyle picture first and then manually adjust it to the appropriate position. The user operation is cumbersome and the waiting time is long, resulting in a poor user experience. Summary of the invention
[0004] The purpose of the present invention is to solve the above-mentioned problem and to design a hairstyle changing method, device and storage medium.
[0005] A first aspect of the present invention provides a hairstyle changing method, comprising: obtaining a sample image, constructing a machine learning model for pupil recognition, determining whether there is a pupil, outputting an image containing the pupil, and obtaining a target image;
[0006] Acquire the target image, and perform facial feature marking of the initial facial contour and facial features contours on the facial image area in the target image;
[0007] Analyze the facial feature markers, obtain hairstyle library data, calculate the matching degree, and recommend hairstyles with high matching degree to the user;
[0008] The recommended hairstyles with high matching degree are transmitted to the front-end page for display, and the user selects the hairstyle and hair color according to the displayed results;
[0009] A face model is obtained, the hairstyle and hair color selected by the user are integrated into the face image, adaptive adjustments are made according to the user's fine-tuning instructions, and the processed image is finally saved.
[0010] Optionally, in a first implementation of the first aspect of the present invention, the acquiring includes a sample image, constructing a machine learning model for pupil recognition, determining whether there is a pupil, outputting an image containing the pupil, and obtaining a target image, comprises:
[0011] Obtain sample images of people in different environments, lighting conditions, and pupil states to create a training data set;
[0012] The sample images in the training data set are input into the trained machine learning model, and the model outputs the recognition result to determine whether there is a pupil in the image;
[0013] If the pupil exists, the image is further processed to extract and output a target image containing only the pupil to obtain a target image; if the pupil does not exist, corresponding prompt information is output.
[0014] Optionally, in a second implementation of the first aspect of the present invention, the acquiring the target image and performing facial feature marking of an initial facial contour and facial features contours on a facial image region in the target image includes:
[0015] Acquire a target image including the pupil;
[0016] Performing an initial facial contour on the face image in the target image, using a series of boundary points to outline the overall shape of the face to form a closed polygon covering the entire area from the forehead to the chin;
[0017] Performing feature marking of facial features of the face image in the target image, including eye feature marking, nose feature marking, mouth feature marking, and eyebrow feature marking;
[0018] The eye feature mark is to mark the outline of the eye including the corner of the eye and the pupil position;
[0019] The nose feature mark is a mark of key points of the nose bridge and nose tip, describing the shape and position of the nose;
[0020] The mouth feature mark is to mark the outer contour and inner contour of the mouth;
[0021] The eyebrow feature marks are marks that depict the shape and position of the eyebrows.
[0022] Optionally, in a third implementation of the first aspect of the present invention, analyzing according to the facial feature markers, acquiring hairstyle library data, calculating a matching degree, and recommending a hairstyle with a high matching degree to the user includes:
[0023] According to the facial feature labeling result, the hairstyle material data in the hairstyle material library is obtained;
[0024] Calculate the matching degree between the hairstyle material and the facial features, taking into account the face shape, forehead width, chin shape, and hair quality dimensional features, and use a weighted algorithm to comprehensively evaluate and derive the matching value, and sort them from high to low according to the matching degree;
[0025] Recommend hairstyles with high matching degree to users.
[0026] Optionally, in a fourth implementation of the first aspect of the present invention, obtaining a face model, integrating the hairstyle and hair color selected by the user into the face image, making adaptive adjustments according to a user fine-tuning instruction, and finally saving the processed image, includes:
[0027] Obtain a face model, receive the hairstyle, hair color and fine-tuning instructions selected by the user, and merge the selected hairstyle and hair color into the original face image;
[0028] In the process of fitting the hairstyle model to the human face shape, an iterative algorithm is used to fine-tune the feature points of the hairstyle model along the normal direction of the human face contour until the fitting effect is achieved;
[0029] Supports users to fine-tune the selected hairstyle by moving and scaling it;
[0030] After the user completes the hairstyle selection and fine-tuning, the final image can be saved to the local terminal by clicking the Save command. The export of multiple image formats is supported.
[0031] A second aspect of the present invention provides a hairstyle changing device, comprising: a pupil recognition module, for acquiring a sample image, constructing a machine learning model for pupil recognition, determining whether there is a pupil, outputting an image containing the pupil, and obtaining a target image;
[0032] A feature marking module is used to obtain the target image and perform facial feature marking of the initial facial contour and facial features contour on the facial image area in the target image;
[0033] A hairstyle matching module is used to analyze the facial feature markers, obtain hairstyle library data, calculate the matching degree, and recommend hairstyles with high matching degree to the user;
[0034] The recommendation display module is used to transmit the recommended hairstyles with high matching degree to the front-end page for display, and the user selects the hairstyle and hair color according to the displayed results;
[0035] The fusion output module is used to obtain the face model, fuse the hairstyle and hair color selected by the user into the face image, make adaptive adjustments according to the user's fine-tuning instructions, and finally save the processed image.
[0036] Optionally, in the first implementation of the second aspect of the present invention, the fusion output module includes an acquisition submodule, a fitting submodule, a fine-tuning submodule, and a derivation submodule, wherein;
[0037] The acquisition submodule is used to acquire a face model, receive a hairstyle, hair color and fine-tuning instructions selected by a user, and fuse the selected hairstyle and hair color into the original face image;
[0038] The fitting submodule is used to use an iterative algorithm to fine-tune the feature points of the hairstyle model along the normal direction of the face contour in the process of fitting the hairstyle model to the face shape until the fitting effect is achieved;
[0039] The fine-tuning submodule is used to support the user to perform fine-tuning operations such as moving and scaling the selected hairstyle;
[0040] The export submodule is used for saving the final image to the local terminal by clicking the save command after the user completes the hairstyle selection and fine-tuning, and supports the export of multiple image formats.
[0041] A third aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-readable instructions, which, when executed on a computer, enable the computer to execute the various steps of the hairstyle changing method described above.
[0042] Beneficial effect: In the technical solution of the present invention, by acquiring a sample image, constructing a machine learning model for pupil recognition, determining whether there is a pupil, outputting an image containing the pupil, and obtaining a target image; acquiring the target image, and marking the initial facial contour and facial features of the facial image area in the target image; analyzing according to the facial feature marking, acquiring the hairstyle library data, calculating the matching degree, and recommending a hairstyle with a high matching degree to the user; transmitting the recommended hairstyle with a high matching degree to the front-end page for display, and the user selects a hairstyle and hair color according to the display result; acquiring a face model, integrating the hairstyle and hair color selected by the user into the face image, and performing adaptive adjustments according to the user's fine-tuning instructions, and finally saving the processed image. The present invention can realize a one-click hairstyle change after the user takes a photo, achieving an image effect that satisfies the user, and when a hairstyle design is required, the hairstyle effect can be simulated by software, thereby reducing the trial and error cost of the user going to the barber shop. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 A first flow chart of a method for changing a hairstyle provided by an embodiment of the present invention;
[0044] Figure 2 A schematic diagram of the structure of a hairstyle changing device provided in an embodiment of the present invention;
[0045] Figure 3 Another structural schematic diagram of a hairstyle changing device provided by an embodiment of the present invention; DETAILED DESCRIPTION
[0046] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" or "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0047] For ease of understanding, the specific process of the embodiment of the present invention is described below. Figure 1 The first embodiment of the hairstyle changing method in the embodiment of the present invention includes:
[0048] Step 101: obtain a sample image, build a machine learning model to perform pupil recognition, determine whether there is a pupil, output an image containing the pupil, and obtain a target image.
[0049] Specifically, sample images of people in different environments, lighting conditions and pupil states are obtained to make a training data set; the sample images in the training data set are input into a trained machine learning model, and the model outputs a recognition result to determine whether there is a pupil in the image; if there is a pupil, the image is further processed to extract and output a target image containing only the pupil to obtain a target image; if there is no pupil, a corresponding prompt message is output.
[0050] Step 102: Acquire a target image, and perform facial feature marking of an initial facial contour and facial features contours on a facial image region in the target image.
[0051] Specifically, a target image including pupils is obtained; an initial facial contour is performed on the face image in the target image, and a series of boundary points are used to outline the overall shape of the face to form a closed polygon covering the entire area from the forehead to the chin;
[0052] The facial image in the target image is marked with feature markers of the facial features, including eye feature markers, nose feature markers, mouth feature markers, and eyebrow feature markers; the eye feature markers are used to mark the contours of the eyes, including the corners of the eyes and the positions of the pupils; the nose feature markers are used to mark the key points of the nose bridge and the nose tip, describing the shape and position of the nose; the mouth feature markers are used to mark the outer and inner contours of the mouth; the eyebrow feature markers are used to mark the shape and position of the eyebrows.
[0053] Step 103: Analyze the facial feature markers, obtain the hairstyle library data, calculate the matching degree, and recommend a hairstyle with a high matching degree to the user.
[0054] Specifically, based on the facial feature marking results, the hairstyle material data in the hairstyle material library is obtained; the matching degree between the hairstyle material and the facial features is calculated, taking into account the face shape, forehead width, chin shape, and hair quality dimension features, and the matching degree value is obtained through a comprehensive evaluation through a weighted algorithm, and is sorted from high to low according to the matching degree; and hairstyles with high matching degrees are recommended to users.
[0055] Step 104: The recommended hairstyles with high matching degree are transmitted to the front-end page for display, and the user selects the hairstyle and hair color according to the displayed results.
[0056] Specifically, hairstyles with a high degree of matching will be sent to the front-end page safely and quickly through efficient data transmission protocols (such as HTTP protocol). The hairstyles are intuitively displayed in front of the user in the form of grid layout, carousel or card. When browsing these carefully recommended hairstyles, users can intuitively see the style, length, layering and other details of each hairstyle, and can even use the dynamic effects achieved by front-end technology to get a more immersive experience. In addition, the front-end page will clearly mark the name and brief style description of each hairstyle to help users quickly understand and find their favorite hairstyle. Users can easily click or touch the corresponding button on the screen according to their preferences and actual needs to select the hairstyle they are most satisfied with.
[0057] Step 105: Acquire the face model, integrate the hairstyle and hair color selected by the user into the face image, make adaptive adjustments according to the user's fine-tuning instructions, and finally save the processed image.
[0058] Specifically, the facial model is obtained, the hairstyle, hair color and fine-tuning instructions selected by the user are received, and the selected hairstyle and hair color are integrated into the original facial image; in the process of fitting the hairstyle model to the facial shape, an iterative algorithm is used to fine-tune the feature points of the hairstyle model along the normal direction of the facial contour until the fitting effect is achieved; the user is supported to perform fine-tuning operations such as moving and scaling the selected hairstyle; after the user completes the hairstyle selection and fine-tuning, the final image can be saved to the local terminal by clicking the save instruction, and the export of multiple image formats is supported.
[0059] The above describes the hairstyle changing method in the embodiment of the present invention. The following describes the hairstyle changing device in the embodiment of the present invention. Figure 2 In one embodiment of the present invention, a hairstyle changing device includes:
[0060] The pupil recognition module is used to obtain sample images, build a machine learning model for pupil recognition, determine whether there is a pupil, output an image containing the pupil, and obtain a target image;
[0061] A feature marking module is used to obtain a target image and mark the initial facial contour and facial features of the facial image area in the target image;
[0062] The hairstyle matching module is used to analyze facial feature markers, obtain hairstyle library data, calculate the matching degree, and recommend hairstyles with high matching degree to users;
[0063] The recommendation display module is used to transmit the recommended hairstyles with high matching degree to the front-end page for display, and the user selects the hairstyle and hair color according to the displayed results;
[0064] The fusion output module is used to obtain the face model, fuse the hairstyle and hair color selected by the user into the face image, make adaptive adjustments according to the user's fine-tuning instructions, and finally save the processed image.
[0065] See also Figure 3 Another embodiment of the hairstyle changing device in the embodiment of the present invention includes:
[0066] The acquisition submodule is used to acquire the face model, receive the hairstyle, hair color and fine-tuning instructions selected by the user, and merge the selected hairstyle and hair color into the original face image;
[0067] The fitting submodule is used to use an iterative algorithm to fine-tune the feature points of the hairstyle model along the normal direction of the face contour in the process of fitting the hairstyle model to the face shape until the fitting effect is achieved;
[0068] The fine-tuning submodule is used to support the user to perform fine-tuning operations such as moving and scaling the selected hairstyle;
[0069] The export submodule is used for users to save the final image to the local terminal by clicking the save command after completing the hairstyle selection and fine-tuning. It supports exporting in multiple image formats.
[0070] The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. Instructions are stored in the computer-readable storage medium. When the instructions are executed on a computer, the computer executes the steps of the hairstyle changing method.
[0071] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described system, device, or unit can refer to the corresponding process in the aforementioned method embodiment and will not be repeated here.
[0072] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program codes.
[0073] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for changing a hairstyle, characterized in that: The hairstyle changing method comprises: Obtain sample images, build a machine learning model for pupil recognition, determine whether there is a pupil, output an image containing the pupil, and obtain a target image; Acquire the target image, and perform facial feature marking of the initial facial contour and facial features contours on the facial image area in the target image; Analyze the facial feature markers, obtain hairstyle library data, calculate the matching degree, and recommend hairstyles with high matching degree to the user; The recommended hairstyles with high matching degree are transmitted to the front-end page for display, and the user selects the hairstyle and hair color according to the displayed results; A face model is obtained, the hairstyle and hair color selected by the user are integrated into the face image, adaptive adjustments are made according to the user's fine-tuning instructions, and the processed image is finally saved.
2. A method for changing a hairstyle according to claim 1, characterized in that: The method of obtaining a sample image, building a machine learning model for pupil recognition, determining whether there is a pupil, outputting an image containing the pupil, and obtaining a target image includes: Obtain sample images of people in different environments, lighting conditions, and pupil states to create a training data set; The sample images in the training data set are input into the trained machine learning model, and the model outputs the recognition result to determine whether there is a pupil in the image; If the pupil exists, the image is further processed to extract and output a target image containing only the pupil to obtain a target image; if the pupil does not exist, corresponding prompt information is output.
3. A method for changing a hairstyle according to claim 1, characterized in that: The step of acquiring the target image and marking the initial facial contour and facial features of the facial image area in the target image includes: Acquire a target image including the pupil; Performing an initial facial contour on the face image in the target image, using a series of boundary points to outline the overall shape of the face to form a closed polygon covering the entire area from the forehead to the chin; Performing feature marking of facial features of the face image in the target image, including eye feature marking, nose feature marking, mouth feature marking, and eyebrow feature marking; The eye feature mark is to mark the outline of the eye including the corner of the eye and the pupil position; The nose feature mark is a mark of key points of the nose bridge and nose tip, describing the shape and position of the nose; The mouth feature mark is to mark the outer contour and inner contour of the mouth; The eyebrow feature marks are marks that depict the shape and position of the eyebrows.
4. A method for changing a hairstyle according to claim 1, characterized in that: The step of analyzing the facial feature markers, acquiring hairstyle library data, calculating the matching degree, and recommending a hairstyle with a high matching degree to the user includes: According to the facial feature labeling result, the hairstyle material data in the hairstyle material library is obtained; Calculate the matching degree between the hairstyle material and the facial features, taking into account the face shape, forehead width, chin shape, and hair quality dimensional features, and use a weighted algorithm to comprehensively evaluate and derive the matching value, and sort them from high to low according to the matching degree; Recommend hairstyles with high matching degree to users.
5. A method for changing a hairstyle according to claim 1, characterized in that: The acquiring of the face model, integrating the hairstyle and hair color selected by the user into the face image, making adaptive adjustments according to the user's fine-tuning instructions, and finally saving the processed image, includes: Obtain a face model, receive the hairstyle, hair color and fine-tuning instructions selected by the user, and merge the selected hairstyle and hair color into the original face image; In the process of fitting the hairstyle model to the human face shape, an iterative algorithm is used to fine-tune the feature points of the hairstyle model along the normal direction of the human face contour until the fitting effect is achieved; Supports users to fine-tune the selected hairstyle by moving and scaling it; After the user completes the hairstyle selection and fine-tuning, the final image can be saved to the local terminal by clicking the Save command. The export of multiple image formats is supported.
6. A hairstyle changing device, characterized in that: include: The pupil recognition module is used to obtain sample images, build a machine learning model for pupil recognition, determine whether there is a pupil, output an image containing the pupil, and obtain a target image; A feature marking module is used to obtain the target image and perform facial feature marking of the initial facial contour and facial features contour on the facial image area in the target image; A hairstyle matching module is used to analyze the facial feature markers, obtain hairstyle library data, calculate the matching degree, and recommend hairstyles with high matching degree to the user; The recommendation display module is used to transmit the recommended hairstyles with high matching degree to the front-end page for display, and the user selects the hairstyle and hair color according to the displayed results; The fusion output module is used to obtain the face model, fuse the hairstyle and hair color selected by the user into the face image, make adaptive adjustments according to the user's fine-tuning instructions, and finally save the processed image.
7. A hairstyle changing device according to claim 6, characterized in that: The fusion output module includes an acquisition submodule, a fitting submodule, a fine-tuning submodule, and a derivation submodule, wherein; The acquisition submodule is used to acquire a face model, receive a hairstyle, hair color and fine-tuning instructions selected by a user, and fuse the selected hairstyle and hair color into the original face image; The fitting submodule is used to use an iterative algorithm to fine-tune the feature points of the hairstyle model along the normal direction of the face contour in the process of fitting the hairstyle model to the face shape until the fitting effect is achieved; The fine-tuning submodule is used to support the user to perform fine-tuning operations such as moving and scaling the selected hairstyle; The export submodule is used for saving the final image to the local terminal by clicking the save command after the user completes the hairstyle selection and fine-tuning, and supports the export of multiple image formats.
8. A computer-readable storage medium having computer-readable instructions stored thereon, characterized in that: When the computer-readable instructions are executed by a processor, the steps of the hairstyle changing method as described in any one of claims 1 to 5 are implemented.
