Image processing method and device, electronic equipment and storage medium
Patent Information
- Application Number
- CN202210743834.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-27
- Publication Date
- 2026-10-23
- Estimated Expiration
- 2042-06-27
AI Technical Summary
[0017] The image processing method, apparatus, electronic device, and storage medium provided in this embodiment segment the image to be processed to obtain a hairstyle segmentation map, which represents the hairstyle of a person in the image to be processed. Image style transfer is then performed on the hairstyle segmentation map to obtain a target style transfer map, which has different texture features from the hairstyle segmentation map. Based on a pre-trained image classification model, the target style transfer map is processed to obtain a target hairstyle material, wherein the target hairstyle material is the hairstyle material corresponding to the hairstyle of the person in the image to be processed. The image classification model is trained based on multiple style transfer maps corresponding to the hairstyle material. Because the image to be processed, representing the user's real hairstyle, is first segmented and stylized to obtain the target style transfer map corresponding to the hairstyle, and then processed based on the image classification model pre-trained using multiple style transfer maps, the influence of texture features in the hairstyle on the classification results can be reduced. This results in a higher matching degree between the obtained target discovery material and the person in the image to be processed, improving the accuracy of hairstyle recognition and hairstyle material matching.
Smart Images

Figure CN117372726B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of image processing technology, and in particular to an image processing method, apparatus, electronic device, and storage medium. Background Technology
[0002] Hairstyle classification is a research hotspot in facial attribute classification, especially in the application scenario of stylized virtual avatar generation (commonly known as face sculpting). Since the hair area occupies most of the image and is the most conspicuous, the similarity between the virtual avatar and the user's real avatar can be greatly improved when the virtual hairstyle is correctly matched with the user's real hairstyle.
[0003] In existing technologies, in order to determine hairstyle materials that match a user's real hairstyle, feature recognition and classification are usually performed based on the user's headshot image to determine the matching hairstyle material. However, existing technologies have problems such as low accuracy in hairstyle recognition and hairstyle material matching. Summary of the Invention
[0004] This disclosure provides an image processing method, apparatus, electronic device, and storage medium to overcome the problems of low accuracy in hairstyle recognition and hairstyle material matching in the prior art.
[0005] In a first aspect, embodiments of this disclosure provide an image processing method, including:
[0006] Image segmentation is performed on the image to be processed to obtain a hairstyle segmentation map, which represents the hairstyle of the person in the image to be processed. Image style transfer is performed on the hairstyle segmentation map to obtain a target style transfer map, which has different texture features from the hairstyle segmentation map. Based on a pre-trained image classification model, the target style transfer map is processed to obtain a target hairstyle material, wherein the target hairstyle material is the hairstyle material corresponding to the hairstyle of the person in the image to be processed, and the image classification model is trained based on multiple style transfer maps corresponding to the hairstyle material.
[0007] In a second aspect, embodiments of this disclosure provide an image processing apparatus, comprising:
[0008] The segmentation module is used to segment the image to be processed to obtain a hairstyle segmentation map, which represents the hairstyle of the person in the image to be processed.
[0009] The style transfer module is used to perform image style transfer on the hairstyle segmentation map to obtain a target style transfer map, wherein the target style transfer map has different texture features from the hairstyle segmentation map;
[0010] The classification module is used to process the target style transfer map based on a pre-trained image classification model to obtain target hairstyle material, wherein the target hairstyle material is the hairstyle material corresponding to the hairstyle of the person in the image to be processed, and the image classification model is trained based on multiple style transfer maps corresponding to the hairstyle material.
[0011] Thirdly, embodiments of this disclosure provide an electronic device, including:
[0012] A processor, and a memory communicatively connected to the processor;
[0013] The memory stores computer-executed instructions;
[0014] The processor executes computer execution instructions stored in the memory to implement the image processing method described in the first aspect and various possible designs of the first aspect.
[0015] Fourthly, embodiments of this disclosure provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the image processing method described in the first aspect and various possible designs of the first aspect.
[0016] Fifthly, embodiments of this disclosure provide a computer program product, including a computer program that, when executed by a processor, implements the image processing method as described in the first aspect and various possible designs of the first aspect.
[0017] The image processing method, apparatus, electronic device, and storage medium provided in this embodiment segment the image to be processed to obtain a hairstyle segmentation map, which represents the hairstyle of a person in the image to be processed. Image style transfer is then performed on the hairstyle segmentation map to obtain a target style transfer map, which has different texture features from the hairstyle segmentation map. Based on a pre-trained image classification model, the target style transfer map is processed to obtain a target hairstyle material, wherein the target hairstyle material is the hairstyle material corresponding to the hairstyle of the person in the image to be processed. The image classification model is trained based on multiple style transfer maps corresponding to the hairstyle material. Because the image to be processed, representing the user's real hairstyle, is first segmented and stylized to obtain the target style transfer map corresponding to the hairstyle, and then processed based on the image classification model pre-trained using multiple style transfer maps, the influence of texture features in the hairstyle on the classification results can be reduced. This results in a higher matching degree between the obtained target discovery material and the person in the image to be processed, improving the accuracy of hairstyle recognition and hairstyle material matching. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 This is a schematic diagram illustrating an application scenario of the image processing method provided in this embodiment of the disclosure;
[0020] Figure 2 Flowchart of the image processing method provided in the embodiments of this disclosure Figure 1 ;
[0021] Figure 3 This is a schematic diagram illustrating a process for obtaining a hairstyle segmentation diagram according to an embodiment of the present disclosure;
[0022] Figure 4 This is a schematic diagram illustrating a process for obtaining target hairstyle material based on an image classification model, as provided in an embodiment of the present disclosure.
[0023] Figure 5 Flowchart of the steps for training an image classification model;
[0024] Figure 6 A schematic diagram illustrating a training image classification model provided in an embodiment of this disclosure;
[0025] Figure 7 Flowchart of the image processing method provided in the embodiments of this disclosure Figure 2 ;
[0026] Figure 8 A schematic diagram illustrating a sample style transfer map obtained through a combined model, as provided in an embodiment of this disclosure;
[0027] Figure 9 A flowchart illustrating one implementation of step S210;
[0028] Figure 10 A flowchart illustrating another implementation of step S210;
[0029] Figure 11 This is a structural block diagram of an image processing apparatus provided in an embodiment of the present disclosure;
[0030] Figure 12 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure;
[0031] Figure 13 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation
[0032] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. Based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.
[0033] The application scenarios of the embodiments of this disclosure are explained below:
[0034] The image processing method provided in this disclosure can be applied to virtual avatar generation (commonly known as face creation). More specifically, it can be applied to the scenario of character hairstyle recognition and hairstyle material matching in the virtual avatar generation process. Figure 1 This is a schematic diagram illustrating an application scenario of the image processing method provided in this disclosure embodiment, such as... Figure 1 As shown, the method provided in this disclosure can be applied to a server or terminal device. Taking a terminal device as an example, specifically, a terminal device is such as a smartphone. After a user takes a picture of their head with their smartphone, the terminal device runs the corresponding application (APP) and uses the image processing method provided in this disclosure to identify and classify the user's hairstyle in the head image. From multiple candidate hairstyle materials, a target hairstyle material (hairstyle texture) that matches the real user hairstyle in the head image is obtained. Then, based on the hairstyle material, the generation of the user's virtual image is realized (not shown in the figure).
[0035] In existing technologies, to determine hairstyle materials that match a user's real hairstyle, a pre-trained classification model is typically used to perform feature recognition and classification on the user's portrait image to determine the matching hairstyle material. However, unlike object recognition and classification in general large scenes (such as vehicle and human body recognition and classification in images) and facial recognition and classification based on facial features, in the scenario of recognizing and classifying a user's hairstyle, the texture of a user's real hairstyle is very rich, and there are no clear boundaries between different hairstyle categories. Therefore, the annotation of training samples used to train the model is very difficult and the accuracy is low, meaning that the cost of obtaining effective training samples is high. This, in turn, leads to low classification accuracy of the trained hairstyle classification model. When using this hairstyle classification model to recognize and classify hairstyles in images, it results in problems such as low accuracy in hairstyle recognition and matching of hairstyle materials.
[0036] This disclosure provides an image processing method to solve the above-mentioned problems.
[0037] refer to Figure 2 , Figure 2 Flowchart of the image processing method provided in the embodiments of this disclosure Figure 1 The method of this embodiment can be applied to terminal devices or servers. In this embodiment, a terminal device is used as an example for description. The principle is similar when executed on the server side, and will not be described again. The image processing method provided in this disclosure includes:
[0038] Step S101: Perform image segmentation on the image to be processed to obtain a hairstyle segmentation map, which represents the hairstyle of the person in the image to be processed.
[0039] For example, the image processing method provided in this embodiment can be implemented by an application running on a terminal device. The image to be processed can be a picture containing a person's head, such as a selfie taken by a user through the terminal device. After loading the image to be processed, the application performs image processing on it, identifies the hair area of the person, and segments it to obtain an image containing only the person's hairstyle, i.e., a hairstyle segmentation image. For example, the hairstyle referred to in this embodiment refers to hair with a specific or non-specific style. The hairstyle is expressed by the combination of different pixels in the image to be processed and the hairstyle segmentation image.
[0040] Figure 3 This is a schematic diagram illustrating a process for obtaining a hairstyle segmentation diagram according to an embodiment of the present disclosure, such as... Figure 3 As shown, after recognizing the image to be processed, the hair region of the person in the image to be processed (shown as region A in the figure) is segmented and extracted to generate a hairstyle segmentation map. For example, the effective pixels in the hairstyle segmentation map only include the pixels corresponding to the person's hairstyle, and the remaining pixel positions are empty. They can be represented by 0 or a dilution matrix, thereby reducing the amount of data in the hairstyle segmentation map and improving the speed of subsequent processing steps based on the hairstyle segmentation map.
[0041] The methods for recognizing and segmenting the images to be processed are existing technologies, such as using pre-trained image recognition and segmentation models, which will not be elaborated here.
[0042] In one possible implementation, before performing image segmentation on the image to be processed, the following is also included:
[0043] Step S1001: Load the image to be processed and detect whether there is a person's hairstyle in the image to be processed.
[0044] Step S1002: If the image to be processed includes a person's hairstyle, then perform image segmentation on the image to be processed to obtain a hairstyle segmentation image.
[0045] For example, in the application scenario of virtual avatar generation, the image recognition and segmentation step of the image to be processed in this embodiment is automatically completed based on the model. Therefore, even if the image to be processed does not contain a person's hairstyle, a "segmented hairstyle image" will be obtained corresponding to the object in the image that is closest to a person's hairstyle. Subsequent processing steps are then performed based on this "segmented hairstyle image." Since this "segmented hairstyle image" has no valid information (no person's hairstyle), performing subsequent processing steps is meaningless and wastes computing resources. Especially when the improved solution in this embodiment is executed on the server side, a large number of meaningless requests will seriously consume computing resources, causing high server load and instability. However, by first detecting whether a person's hairstyle exists in the image to be processed (e.g., the confidence of the identified hairstyle is greater than the confidence threshold), and after determining that the image to be processed contains a person's hairstyle, the subsequent segmentation process is performed, thereby reducing the invalid calculation process and improving the utilization of computing resources.
[0046] Step S102: Perform image style transfer on the hairstyle segmentation map to obtain the target style transfer map, which has different texture features from the hairstyle segmentation map.
[0047] For example, after obtaining the hairstyle segmentation map, which represents a realistic human hairstyle, image style transfer can be performed based on the hairstyle segmentation map to obtain the corresponding target style transfer map. Specifically, for example, converting the input image from a realistic image style to an output image in an oil painting style, or to an output image in a comic book style, is image style transfer, and the corresponding output image obtained after image style transfer is the style transfer map. In this embodiment, the hairstyle segmentation map representing a realistic human hairstyle is used as the input image for style transfer, and the corresponding output image is the target style transfer map. The essence of image style transfer is to add, subtract, or transform image textures in the image; therefore, the target style transfer map and the hairstyle segmentation map have different texture features. The specific implementation of image style transfer can be achieved through a pre-trained image style transfer model, and the specific implementation steps are described in detail.
[0048] Step S103: Based on the pre-trained image classification model, process the target style transfer map to obtain the target hairstyle material, wherein the target hairstyle material is the hairstyle material corresponding to the hairstyle of the person in the image to be processed, and the image classification model is trained based on multiple style transfer maps corresponding to the hairstyle material.
[0049] For example, since the hairstyle segmentation map used to generate the target style transfer map can represent the hairstyle of a person in the image to be processed, the target style transfer map can also represent the features of the hairstyle of a person in the image to be processed to a certain extent. After obtaining the target style transfer map, it can be classified based on a pre-trained image classification model to determine the hairstyle material that matches the hairstyle represented by the target style transfer map, i.e., the target hairstyle material. The image classification model is trained based on multiple style transfer maps corresponding to the hairstyle material; that is, the image classification model uses various style transfer maps and their corresponding hairstyle material labels as labeled training samples for model training. Therefore, the image classification model can classify the style transfer map to determine the corresponding hairstyle material.
[0050] Figure 4 This is a schematic diagram illustrating a process for obtaining target hairstyle material based on an image classification model, as provided in an embodiment of this disclosure. Figure 4 As shown in steps S101-S102, after image segmentation of the image to be processed, a hairstyle segmentation map is obtained. Then, image style transfer is performed based on the hairstyle segmentation map to obtain a target style transfer map. Next, the target style transfer map is used as the input image to a pre-trained image classifier. The image classifier outputs a type identifier. Based on this type identifier, the target hairstyle material matching the target style transfer map is determined from multiple preset hairstyle materials, thereby achieving the mapping of the hairstyle value of the person in the image to be processed to the target hairstyle material. Optionally, in subsequent steps, the terminal device can display the target hairstyle material and combine it with other facial materials (such as face shape materials, eye materials, mouth materials), thereby generating a virtual image corresponding to the user's facial image displayed in the image to be processed.
[0051] For example, for the image classification model, before step S103, it needs to be trained on a variety of preset hairstyle materials so that it can classify the input style transfer map into one of the aforementioned preset hairstyle materials. The preset hairstyle materials can be hairstyle textures with specific image styles, used to represent character hairstyles, pre-installed in the application or on the server corresponding to the application. More specifically, for example, the preset hairstyle materials are in a cartoon image style; the categories of character hairstyles corresponding to the preset hairstyle materials are, for example: long center part, short hair, fluffy long hair, pompadour, buzz cut, medium-length straight hair, medium-length straight hair with bangs, long curly hair, long curly hair with bangs, short hair, long straight hair, long straight hair with bangs, bob, bob with bangs, medium-length curly hair, medium-length curly hair with bangs, single ponytail, single ponytail with bangs, double ponytails, double ponytails with bangs, etc.
[0052] In scenarios involving hairstyle recognition and matching, the complex texture features within the hair region corresponding to a hairstyle often lead to inaccurate classification results when directly classifying based on real head images due to the difficulty in training the model. This embodiment, however, uses a target style transfer map corresponding to the hairstyle segmentation map for classification. Image classification models for style transfer maps are easier to train, resulting in better classification accuracy. This leads to a more accurate match between the final target hairstyle material and the actual hairstyle, enhancing the realism of the generated virtual character.
[0053] For example, Figure 5 A flowchart of the steps for training an image classification model, as follows: Figure 5 As shown, the steps for training an image classification model include:
[0054] Step S10: Obtain a variety of preset hairstyle materials.
[0055] Step S11: Perform image style transfer on each preset hairstyle material to obtain multiple sample style transfer maps corresponding to each preset hairstyle material. The sample style transfer maps and the corresponding hairstyle materials have different texture features.
[0056] Step S12: Based on the multiple sample style transfer maps corresponding to each preset hairstyle material, train the preset neural network model to obtain an image classification model. The image classification model is used to determine the hairstyle material corresponding to the style transfer map.
[0057] Figure 6 This is a schematic diagram of a training image classification model provided in an embodiment of the present disclosure, as shown below. Figure 6 As shown,
[0058] For example, the target application provides five hairstyle images: Hairstyle Image 01, Hairstyle Image 02, Hairstyle Image 03, Hairstyle Image 04, and Hairstyle Image 05. Using a pre-trained image style transfer model, hairstyle images 01, 02, 03, and 04 are processed sequentially with varying style transfer parameters. More specifically, as shown in the figure, each hairstyle image corresponds to 10 style parameters, meaning 10 image style transfers are performed on each image image. Afterward, a corresponding sample group is generated for each hairstyle image, shown as sample group A, sample group B, sample group C, and sample group D in the figure. Each sample group includes 10 sample style transfer maps. Within each sample group, the sample style transfer maps and their corresponding images have similar contours but different texture features. Then, based on the correspondence between the sample style transfer maps and the hairstyle images, classification labels are formed for the sample style transfer maps (labeling the sample style transfer maps within each sample). A pre-set neural network model is trained based on the unlabeled sample style transfer maps until the neural network model converges, thus obtaining an image classification model.
[0059] In this embodiment, style transfer is performed on several preset hairstyle materials to generate sample style transfer maps with different texture features. Model training is then performed based on these sample style transfer maps. During training, because the texture features of the sample style transfer maps are different, the model learns the common features among them, namely the contour features of the hairstyle materials, and classifies the hairstyle materials based on these contour features. This allows the resulting image classification model to reduce the influence of the texture features of the style transfer maps, while using contour features as a high-weight factor to classify the style transfer maps to the corresponding hairstyle materials. Furthermore, since sample style transfer maps can be quickly obtained based on the style transfer model, a large number of training samples can be obtained at low cost to train the image classification model, thereby improving the training speed and classification accuracy of the image classification model.
[0060] In this embodiment, image segmentation is performed on the image to be processed to obtain a hairstyle segmentation map, which represents the hairstyle of the person in the image to be processed. Image style transfer is then performed on the hairstyle segmentation map to obtain a target style transfer map, which has different texture features from the hairstyle segmentation map. Based on a pre-trained image classification model, the target style transfer map is processed to obtain a target hairstyle material, where the target hairstyle material is the hairstyle material corresponding to the hairstyle of the person in the image to be processed. The image classification model is trained based on multiple style transfer maps corresponding to the hairstyle material. Since the image to be processed, which represents the user's real hairstyle, is first segmented and stylized to obtain the target style transfer map corresponding to the hairstyle, and then the target style transfer map is processed based on the image classification model pre-trained using multiple style transfer maps, the influence of texture features in the hairstyle on the classification results can be reduced. This results in a higher matching degree between the obtained target discovery material and the person in the image to be processed, improving the accuracy of hairstyle recognition and hairstyle material matching.
[0061] refer to Figure 7 , Figure 7 Flowchart of the image processing method provided in the embodiments of this disclosure Figure 2 This embodiment is in Figure 2 Based on the illustrated embodiment, steps S102 and S103 are further refined, and a detailed process for training the image classification model is added. This image processing method includes:
[0062] Step S201: Obtain the preset hairstyle material, which is a texture representing the character's hairstyle.
[0063] Step S202: Obtain at least two preset image style transfer models, each of which implements image style transfer for one image style;
[0064] Step S203: Iterate through at least two combinations of image style transfer models to generate at least two combined models, wherein the combined model includes at least two ordered connected image style transfer models, and the combined model is used to perform multiple iterative image style transfer on the input hairstyle material based on at least two ordered connected image style transfer models;
[0065] Step S204: Based on each combination model, process the current preset hairstyle material to obtain multiple sample style transfer maps corresponding to the preset hairstyle material.
[0066] Step S205: If the current preset hairstyle material is the last preset hairstyle material, then proceed to step S206; otherwise, return to step S203.
[0067] Step S206: Based on the multiple sample style transfer maps corresponding to each preset hairstyle material, train the preset neural network model to obtain an image classification model. The image classification model is used to determine the hairstyle material corresponding to the style transfer map.
[0068] For example, steps S201-S205 are steps for training an image classification model, wherein steps S201 and S205 have already been performed. Figure 2 The embodiments shown are described in detail here and will not be repeated. The following is a detailed description of steps S202-S204:
[0069] For example, at least two preset image style transfer models are obtained. These preset model types include style transfer model A, style transfer model B, and style transfer model C. Style transfer model A is used to convert the input image into a cartoon-style output image; style transfer model B is used to convert the input image into an optimized style output image; and style transfer model C is used to convert the input image into a black and white photograph style output image. Based on this, various combinations of style transfer models A, B, and C can be obtained. In the above case, based on style transfer models A, B, and C, there are a total of 12 different permutations and combinations (abbreviated as: AB, AC, BC, BA, CA, CB, ABC, ACB, BAC, CAB, BCA, CBA). For example, Figure 8 This is a schematic diagram illustrating how a sample style transfer map is obtained through a combined model, as provided in an embodiment of this disclosure. Figure 8 As shown, combined model 01 includes style transfer model A and style transfer model B; combined model 02 includes style transfer model B and style transfer model C; combined model 03 includes style transfer model A, style transfer model B, and style transfer model C. Inputting hairstyle materials into combined model 01, combined model 02, and combined model 03 respectively yields three corresponding sample style transfer maps, namely sample style transfer map a, sample style transfer map b, and sample style transfer map c.
[0070] Combining two or more style transfer models can generate more types of sample style transfer maps (with different texture features). Based on the multiple combined models obtained through traversal, sample style transfer maps corresponding to hairstyle materials are generated sequentially, which can effectively increase the number of sample style transfer maps generated for each type of hairstyle material. Then, model training is performed based on a large number of sample style transfer maps with different texture features, which can improve the model training effect.
[0071] Step S207: Perform image segmentation on the image to be processed to obtain a hairstyle segmentation image.
[0072] Step S208: Based on the hairstyle segmentation map, perform N image style transfers to obtain the corresponding N frame target style transfer maps, where N is an integer greater than 1.
[0073] Step S209: Based on the image classification model, classify each target style transfer map separately to obtain the classification result corresponding to each target style transfer map.
[0074] Step S210: Based on the classification results corresponding to each target style transfer map, determine the target hairstyle material.
[0075] For example, in this embodiment, after obtaining the hairstyle segmentation map corresponding to the image to be processed, the hairstyle segmentation map is subjected to multiple image style transfers based on different style transfer parameters, thereby generating N frames of style transfer maps with different styles (texture features). In practical applications, when performing image style transfer on the hairstyle segmentation map, it is necessary to set style transfer parameters so that the hairstyle segmentation map generates a target style transfer map with a specific image style, such as comic style or black and white photo style. However, due to the diversity of the images to be processed, it is uncertain which style transfer parameters to set for different hairstyle segmentation maps so that the generated target style transfer map can be accurately classified by the image classification model. Therefore, in this embodiment, the hairstyle segmentation map is subjected to multiple image style transfers based on different style transfer parameters to generate multiple frames of style transfer maps. Then, the multiple frames of style transfer maps are evaluated, and one or more of the best style transfer maps are selected and input into the image classification model to obtain the corresponding classification results. This allows the target hairstyle material corresponding to the classification results to be determined, thereby improving the matching degree between the target hairstyle material and the person's hairstyle.
[0076] In one possible implementation, the classification result includes a category identifier for characterizing the hairstyle material, and a classification evaluation value corresponding to the category identifier, wherein the classification evaluation value characterizes the confidence level of the category identifier;
[0077] For example, such as Figure 9 As shown, the specific implementation steps of step S210 include:
[0078] Step S2101: Obtain the category identifiers corresponding to each target style transfer map, and the classification evaluation values corresponding to each category identifier.
[0079] Step S2102: Obtain the target category identifier based on the classification evaluation value corresponding to each category identifier, wherein the target category identifier is the category identifier whose classification evaluation value is greater than the evaluation value threshold.
[0080] Step S2103: Determine the corresponding target hairstyle material based on the target category identifier.
[0081] For example, when processing a target style transfer map using an image classification model, the output classification result includes a category identifier and a corresponding classification evaluation value. For instance, the classification result might be {C1, 0.6}, where C1 is the category identifier, indicating a preset hairstyle image, such as a short female hairstyle image; 0.6 is the classification evaluation value. For example, the classification evaluation value ranges from (0,1). The closer the evaluation value is to the upper limit of 1, the more similar the hairstyle represented by the target style transfer map is to the hairstyle image C1, or the higher the probability that the hairstyle and hairstyle image C1 belong to the same category. The specific implementation of the classification evaluation is determined by the processing logic of the image classification model, and will not be elaborated here.
[0082] In another possible implementation, N is greater than 2, and the classification result includes a category identifier to characterize the hairstyle material. For example, such as... Figure 10 As shown, the specific implementation steps of step S209 include:
[0083] Step S2104: Accumulate and count the same category identifiers to obtain the target category identifier.
[0084] In one possible implementation, the target category is identified by the cumulative count exceeding a cumulative threshold, or... In another possible implementation, the target category is identified by the category with the highest cumulative count.
[0085] After processing each frame of the target style transfer map, the image classification model generates a corresponding category label (i.e., classification result). Then, labels with the same category are accumulated, and the target category label is determined based on the cumulative statistical result. Specifically, for example, after performing style transfer on a hairstyle segmentation map based on the image style transfer model, six target style transfer maps are generated: Style Transfer Map A, Style Transfer Map B, Style Transfer Map C, Style Transfer Map D, Style Transfer Map E, and Style Transfer Map F. These maps are then input into the image classification model for processing to obtain corresponding category labels. The category labels for Style Transfer Maps A, B, and C are T1; those for Style Transfer Maps D and E are T2; and those for Style Transfer Map F are T3. Based on the accumulated number of category labels, in one implementation, the category label T1 with the largest accumulated number is determined as the target category label. In another implementation, category identifiers T1 and T2 with an accumulated quantity greater than 2 (accumulation threshold) are identified as target category identifiers.
[0086] Step S2105: Determine the corresponding target hairstyle material based on the target category identifier.
[0087] Then, based on the target category identifier determined in the above steps, and the mapping relationship between the preset category identifier and the preset hairstyle material, the target hairstyle material can be determined, which will not be elaborated further.
[0088] Due to the diversity and uncertainty of the images to be processed, the target style transfer map obtained after image style transfer has a certain degree of randomness, which may lead to the problem of the image classification model classifying the target style transfer map incorrectly. In this embodiment, the hairstyle segmentation map is subjected to multiple image style transfers, and the resulting multi-frame target style transfer maps are sequentially input into the image classification model for processing. The processing results are evaluated to obtain the optimal classification result (target hairstyle material), thereby improving the matching degree between the obtained target hairstyle material and the hairstyle of the person in the image to be processed.
[0089] Optionally, after step S210, the method further includes: if there are more than two target hairstyle materials, displaying all target hairstyle materials, and in response to the user instruction, determining the personalized hairstyle material corresponding to the user instruction.
[0090] For example, if there are more than two target hairstyle images, they can be displayed through the interface of an application running on the terminal device. If a user input command is received, such as a selection command, the system responds and, based on the command, selects a hairstyle element from the multiple target images that matches the user's preferences—a personalized hairstyle image. In subsequent steps, a virtual avatar is generated based on this personalized hairstyle image, thus satisfying the user's individual preferences.
[0091] In this embodiment, the implementation of step S207 is the same as that in this disclosure. Figure 2 The implementation of step S101 in the illustrated embodiment is the same, and will not be described in detail here.
[0092] Corresponding to the image processing method in the above embodiments, Figure 11 This is a structural block diagram of an image processing apparatus provided according to an embodiment of the present disclosure. For ease of explanation, only the parts relevant to the embodiments of the present disclosure are shown.
[0093] Reference Figure 11 Image processing device 3, comprising:
[0094] The segmentation module 31 is used to segment the image to be processed to obtain a hairstyle segmentation map, which represents the hairstyle of the person in the image to be processed.
[0095] Style transfer module 32 is used to perform image style transfer on the hairstyle segmentation image to obtain a target style transfer image, which has different texture features from the hairstyle segmentation image.
[0096] The classification module 33 is used to process the target style transfer map based on the pre-trained image classification model to obtain the target hairstyle material. The target hairstyle material is the hairstyle material corresponding to the hairstyle of the person in the image to be processed. The image classification model is trained based on multiple style transfer maps corresponding to the hairstyle material.
[0097] In one embodiment of this disclosure, the style transfer module 32 is specifically used to: perform N image style transfers based on the hairstyle segmentation map to obtain N corresponding target style transfer maps, where N is an integer greater than 1; the classification module 33 is specifically used to: classify each target style transfer map based on an image classification model to obtain the classification result corresponding to each target style transfer map; and determine the target hairstyle material based on the classification result corresponding to each target style transfer map.
[0098] In one embodiment of this disclosure, the classification result includes a category identifier for characterizing the hairstyle material and a classification evaluation value corresponding to the category identifier, wherein the classification evaluation value characterizes the confidence level of the category identifier; when determining the target hairstyle material based on the classification results corresponding to each target style transfer map, the classification module 33 is specifically used to: obtain the category identifier corresponding to each target style transfer map and the classification evaluation value corresponding to each category identifier; obtain the target category identifier according to the classification evaluation value corresponding to each category identifier, wherein the target category identifier is a category identifier whose classification evaluation value is greater than the evaluation value threshold; and determine the corresponding target hairstyle material according to the target category identifier.
[0099] In one embodiment of this disclosure, N is greater than 2, and the classification result includes a category identifier used to characterize the hairstyle material;
[0100] When determining the target hairstyle material based on the classification results corresponding to each target style transfer map, the classification module 33 is specifically used to: obtain the category identifier corresponding to each target style transfer map; accumulate and count the same category identifiers to obtain the target category identifier, where the target category identifier is the category identifier with the most accumulated counts or the one with the most accumulated counts; and determine the corresponding target hairstyle material based on the target category identifier.
[0101] In one embodiment of this disclosure, if the number of target hairstyle materials is greater than two, each target hairstyle material is displayed, and in response to a user instruction, the personalized hairstyle material corresponding to the user instruction is determined.
[0102] In one embodiment of this disclosure, before processing the target style transfer map based on a pre-trained image classification model to obtain the target hairstyle material, the classification module 33 is further configured to: acquire preset hairstyle materials, wherein the hairstyle materials are textures representing a person's hairstyle; perform image style transfer on each preset hairstyle material to obtain multiple sample style transfer maps corresponding to each preset hairstyle material, wherein the sample style transfer maps and the corresponding hairstyle materials have different texture features; and train a preset neural network model based on the multiple sample style transfer maps corresponding to each preset hairstyle material to obtain an image classification model, wherein the image classification model is used to determine the hairstyle material corresponding to the style transfer map.
[0103] In one embodiment of this disclosure, when the classification module 33 performs image style transfer on each preset hairstyle material to obtain multiple sample style transfer maps corresponding to each preset hairstyle material, it is specifically used to: for each preset hairstyle material, perform the following steps: obtain at least two preset image style transfer models, wherein the image style transfer models implement image style transfer of one image style; traverse the combination of at least two image style transfer models to generate at least two combined models, wherein the combined models include at least two ordered connected image style transfer models, and the combined models are used to perform multiple iterative image style transfers on the input hairstyle material based on at least two ordered connected image style transfer models; and process the preset hairstyle material based on each combined model to obtain multiple sample style transfer maps corresponding to the preset hairstyle material.
[0104] In one embodiment of this disclosure, the segmentation module 31 is specifically used to: load the image to be processed and detect whether there is a person's hairstyle in the image to be processed; if the image to be processed includes a person's hairstyle, then perform image segmentation on the image to be processed to obtain a hairstyle segmentation map.
[0105] The segmentation module 31, segmentation migration module 32, and classification module 33 are connected in sequence. The image processing device 3 provided in this embodiment can execute the technical solution of the above method embodiment, and its implementation principle and technical effect are similar, so it will not be described again here.
[0106] Figure 12 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure, such as... Figure 12 As shown, the electronic device 4 includes:
[0107] Processor 41, and memory 42 communicatively connected to processor 41;
[0108] Memory 42 stores instructions executed by the computer;
[0109] The processor 41 executes computer execution instructions stored in the memory 42 to achieve, for example, Figures 2-10The image processing method in the illustrated embodiment.
[0110] Optionally, the processor 41 and the memory 42 are connected via a bus 43.
[0111] For relevant instructions, please refer to the corresponding text. Figures 2-10 The relevant descriptions and effects of the steps in the corresponding embodiments are understood, and will not be elaborated on here.
[0112] refer to Figure 13 The diagram illustrates a structural schematic of an electronic device 900 suitable for implementing embodiments of the present disclosure. The electronic device 900 can be a terminal device or a server. The terminal device can include, but is not limited to, mobile terminals such as mobile phones, laptops, digital radio receivers, personal digital assistants (PDAs), portable Android devices (PADs), portable media players (PMPs), and in-vehicle terminals (e.g., in-vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. Figure 13 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0113] like Figure 13 As shown, the electronic device 900 may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage device 908 into a random access memory (RAM) 903. The RAM 903 also stores various programs and data required for the operation of the electronic device 900. The processing unit 901, ROM 902, and RAM 903 are interconnected via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0114] Typically, the following devices can be connected to I / O interface 905: input devices 906 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 907 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 908 including, for example, magnetic tapes, hard disks, etc.; and communication devices 909. Communication device 909 allows electronic device 900 to communicate wirelessly or wiredly with other devices to exchange data. AlthoughFigure 13 An electronic device 900 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0115] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 909, or installed from a storage device 908, or installed from a ROM 902. When the computer program is executed by a processing device 901, it performs the functions defined in the methods of embodiments of this disclosure.
[0116] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0117] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0118] The aforementioned computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to perform the methods shown in the above embodiments.
[0119] Computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0120] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0121] The units described in the embodiments of this disclosure can be implemented in software or in hardware. The name of a unit does not necessarily limit the unit itself; for example, the first acquisition unit can also be described as "a unit that acquires at least two Internet Protocol addresses".
[0122] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0123] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0124] In a first aspect, according to one or more embodiments of the present disclosure, an image processing method is provided, comprising:
[0125] Image segmentation is performed on the image to be processed to obtain a hairstyle segmentation map, which represents the hairstyle of the person in the image to be processed. Image style transfer is performed on the hairstyle segmentation map to obtain a target style transfer map, which has different texture features from the hairstyle segmentation map. Based on a pre-trained image classification model, the target style transfer map is processed to obtain a target hairstyle material, wherein the target hairstyle material is the hairstyle material corresponding to the hairstyle of the person in the image to be processed, and the image classification model is trained based on multiple style transfer maps corresponding to the hairstyle material.
[0126] According to one or more embodiments of this disclosure, the step of performing image style transfer on the hairstyle segmentation map to obtain a target style transfer map includes: performing N image style transfers based on the hairstyle segmentation map to obtain N corresponding target style transfer maps, where N is an integer greater than 1; the step of processing the target style transfer maps based on a pre-trained image classification model to obtain target hairstyle material includes: classifying each target style transfer map based on the image classification model to obtain a classification result corresponding to each target style transfer map; and determining the target hairstyle material based on the classification result corresponding to each target style transfer map.
[0127] According to one or more embodiments of this disclosure, the classification result includes a category identifier for characterizing hairstyle material and a classification evaluation value corresponding to the category identifier, wherein the classification evaluation value characterizes the confidence level of the category identifier; determining the target hairstyle material based on the classification result corresponding to each target style transfer map includes: obtaining a category identifier corresponding to each target style transfer map and a classification evaluation value corresponding to each category identifier; obtaining a target category identifier based on the classification evaluation value corresponding to each category identifier, wherein the target category identifier is a category identifier whose classification evaluation value is greater than an evaluation value threshold; and determining the corresponding target hairstyle material based on the target category identifier.
[0128] According to one or more embodiments of this disclosure, N is greater than 2, and the classification result includes a category identifier for characterizing the hairstyle material; determining the target hairstyle material based on the classification result corresponding to each of the target style transfer maps includes: obtaining the category identifier corresponding to each of the target style transfer maps; accumulating and statistically analyzing the same category identifiers to obtain a target category identifier, wherein the target category identifier is the category identifier with the largest accumulated number or a greater accumulated number than an accumulated threshold; and determining the corresponding target hairstyle material based on the target category identifier.
[0129] According to one or more embodiments of this disclosure, if the number of target hairstyle materials is greater than two, each of the target hairstyle materials is displayed, and in response to a user instruction, a personalized hairstyle material corresponding to the user instruction is determined.
[0130] According to one or more embodiments of this disclosure, before processing the target style transfer map based on the pre-trained image classification model to obtain the target hairstyle material, the method further includes: acquiring preset hairstyle materials, wherein the hairstyle materials are textures representing a person's hairstyle; performing image style transfer on each of the preset hairstyle materials to obtain multiple sample style transfer maps corresponding to each preset hairstyle material, wherein the sample style transfer maps have different texture features from the corresponding hairstyle materials; and training a preset neural network model based on the multiple sample style transfer maps corresponding to each preset hairstyle material to obtain the image classification model, wherein the image classification model is used to determine the hairstyle material corresponding to the style transfer map.
[0131] According to one or more embodiments of this disclosure, the step of performing image style transfer on each of the preset hairstyle materials to obtain multiple sample style transfer maps corresponding to each preset hairstyle material includes: for each preset hairstyle material, performing the following steps: obtaining at least two preset image style transfer models, wherein the image style transfer models implement image style transfer of one image style; traversing the combination of the at least two image style transfer models to generate at least two combined models, wherein the combined models include at least two ordered connected image style transfer models, and the combined models are used to perform multiple iterative image style transfers on the input hairstyle material based on the at least two ordered connected image style transfer models; and processing the preset hairstyle material based on each of the combined models to obtain multiple sample style transfer maps corresponding to the preset hairstyle material.
[0132] According to one or more embodiments of this disclosure, the step of performing image segmentation on the image to be processed to obtain a hairstyle segmentation map includes: loading the image to be processed and detecting whether the person's hairstyle exists in the image to be processed; if the image to be processed includes the person's hairstyle, then performing image segmentation on the image to be processed to obtain the hairstyle segmentation map.
[0133] Secondly, according to one or more embodiments of the present disclosure, an image processing apparatus is provided, comprising:
[0134] The segmentation module is used to segment the image to be processed to obtain a hairstyle segmentation map, which represents the hairstyle of the person in the image to be processed.
[0135] The style transfer module is used to perform image style transfer on the hairstyle segmentation image to obtain a target style transfer image, wherein the target style transfer image has different texture features from the hairstyle segmentation image.
[0136] The classification module is used to process the target style transfer map based on a pre-trained image classification model to obtain target hairstyle material, wherein the target hairstyle material is the hairstyle material corresponding to the hairstyle of the person in the image to be processed, and the image classification model is trained based on multiple style transfer maps corresponding to the hairstyle material;
[0137] According to one or more embodiments of this disclosure, the style transfer module is specifically used for: performing N image style transfers based on the hairstyle segmentation map to obtain N corresponding target style transfer maps, where N is an integer greater than 1; the classification module is specifically used for: classifying each of the target style transfer maps based on the image classification model to obtain a classification result corresponding to each target style transfer map; and determining the target hairstyle material based on the classification result corresponding to each target style transfer map.
[0138] According to one or more embodiments of this disclosure, the classification result includes a category identifier for characterizing the hairstyle material, and a classification evaluation value corresponding to the category identifier, wherein the classification evaluation value characterizes the confidence level of the category identifier; when the classification module 33 determines the target hairstyle material based on the classification result corresponding to each target style transfer map, it is specifically configured to: obtain the category identifier corresponding to each target style transfer map, and the classification evaluation value corresponding to each category identifier; obtain the target category identifier according to the classification evaluation value corresponding to each category identifier, wherein the target category identifier is a category identifier whose classification evaluation value is greater than the evaluation value threshold; and determine the corresponding target hairstyle material according to the target category identifier.
[0139] According to one or more embodiments of this disclosure, N is greater than 2, and the classification result includes a category identifier for characterizing the hairstyle material; when the classification module determines the target hairstyle material based on the classification result corresponding to each target style transfer map, it is specifically used to: obtain the category identifier corresponding to each target style transfer map; accumulate and count the same category identifiers to obtain a target category identifier, wherein the target category identifier is the category identifier with the largest accumulation number or the largest accumulation number; and determine the corresponding target hairstyle material according to the target category identifier.
[0140] According to one or more embodiments of this disclosure, if the number of target hairstyle materials is greater than two, each of the target hairstyle materials is displayed, and in response to a user instruction, a personalized hairstyle material corresponding to the user instruction is determined.
[0141] According to one or more embodiments of this disclosure, before the target style transfer map is processed by the pre-trained image classification model to obtain the target hairstyle material, the classification module is further configured to: acquire preset hairstyle materials, wherein the hairstyle materials are textures representing a person's hairstyle; perform image style transfer on each of the preset hairstyle materials to obtain multiple sample style transfer maps corresponding to each preset hairstyle material, wherein the sample style transfer maps have different texture features from the corresponding hairstyle materials; and train a preset neural network model based on the multiple sample style transfer maps corresponding to each preset hairstyle material to obtain the image classification model, wherein the image classification model is used to determine the hairstyle material corresponding to the style transfer map.
[0142] According to one or more embodiments of this disclosure, when the classification module performs image style transfer on each of the preset hairstyle materials to obtain multiple sample style transfer maps corresponding to each preset hairstyle material, it is specifically used to: for each preset hairstyle material, perform the following steps: obtain at least two preset image style transfer models, wherein the image style transfer models implement image style transfer of one image style; traverse the combination of the at least two image style transfer models to generate at least two combined models, wherein the combined models include at least two ordered connected image style transfer models, and the combined models are used to perform multiple iterative image style transfers on the input hairstyle material based on the at least two ordered connected image style transfer models; and process the preset hairstyle material based on each of the combined models to obtain multiple sample style transfer maps corresponding to the preset hairstyle material.
[0143] According to one or more embodiments of this disclosure, the segmentation module is specifically configured to: load the image to be processed and detect whether the hairstyle of the person exists in the image to be processed; if the image to be processed includes the hairstyle of the person, then perform image segmentation on the image to be processed to obtain the hairstyle segmentation map.
[0144] Thirdly, according to one or more embodiments of the present disclosure, an electronic device is provided, including: a processor, and a memory communicatively connected to the processor;
[0145] The memory stores computer-executed instructions;
[0146] The processor executes computer execution instructions stored in the memory to implement the image processing method described in the first aspect and various possible designs of the first aspect.
[0147] Fourthly, according to one or more embodiments of the present disclosure, a computer-readable storage medium is provided, wherein computer-executable instructions are stored therein, which, when executed by a processor, implement the image processing method described in the first aspect and various possible designs of the first aspect.
[0148] Fifthly, embodiments of this disclosure provide a computer program product, including a computer program that, when executed by a processor, implements the image processing method as described in the first aspect and various possible designs of the first aspect.
[0149] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.
[0150] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0151] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.
Claims
1. An image processing method, characterized in that, include: Image segmentation is performed on the image to be processed to obtain a hairstyle segmentation map, which represents the hairstyle of the person in the image to be processed. Image style transfer is performed on the hairstyle segmentation image to obtain a target style transfer image, which has different texture features from the hairstyle segmentation image. Based on a pre-trained image classification model, the target style transfer map is processed to obtain target hairstyle material, wherein the target hairstyle material is the hairstyle material corresponding to the hairstyle of the person in the image to be processed, and the image classification model is trained based on multiple style transfer maps corresponding to the hairstyle material.
2. The method according to claim 1, characterized in that, The step of performing image style transfer on the hairstyle segmentation map to obtain the target style transfer map includes: Based on the hairstyle segmentation map, N image style transfers are performed to obtain the corresponding N frame target style transfer maps, where N is an integer greater than 1; The pre-trained image classification model processes the target style transfer map to obtain target hairstyle material, including: Based on the image classification model, each of the target style transfer maps is classified to obtain the classification result corresponding to each target style transfer map. Based on the classification results corresponding to each of the target style transfer maps, the target hairstyle materials are determined.
3. The method according to claim 2, characterized in that, The classification results include category identifiers for characterizing hairstyle materials, and classification evaluation values corresponding to the category identifiers, wherein the classification evaluation values characterize the confidence level of the category identifiers; Based on the classification results corresponding to each of the target style transfer maps, target hairstyle materials are determined, including: Obtain the category identifier corresponding to each of the target style transfer maps, and the classification evaluation value corresponding to each of the category identifiers; Based on the classification evaluation value corresponding to each category identifier, a target category identifier is obtained, wherein the target category identifier is a category identifier whose classification evaluation value is greater than the evaluation value threshold; Based on the target category identifier, determine the corresponding target hairstyle material.
4. The method according to claim 2, characterized in that, If N is greater than 2, the classification result includes a category identifier used to characterize the hairstyle material; The process of determining target hairstyle materials based on the classification results corresponding to each of the target style transfer maps includes: Obtain the category identifier corresponding to each of the target style transfer maps; The same category identifiers are accumulated and counted to obtain the target category identifier, which is the category identifier whose accumulated number is greater than the accumulated threshold, or the category identifier with the largest accumulated number; Based on the target category identifier, determine the corresponding target hairstyle material.
5. The method according to claim 2, characterized in that, If there are more than two target hairstyle materials, each target hairstyle material is displayed, and in response to the user command, the personalized hairstyle material corresponding to the user command is determined.
6. The method according to claim 1, characterized in that, Before processing the target style transfer map to obtain the target hairstyle material using the pre-trained image classification model, the method further includes: Obtain preset hairstyle materials, wherein the hairstyle materials are textures representing a character's hairstyle; Image style transfer is performed on each of the preset hairstyle materials to obtain multiple sample style transfer maps corresponding to each preset hairstyle material. The sample style transfer maps have different texture features from the corresponding hairstyle materials. Based on the multiple sample style transfer maps corresponding to each preset hairstyle material, a preset neural network model is trained to obtain the image classification model, which is used to determine the hairstyle material corresponding to the style transfer map.
7. The method according to claim 6, characterized in that, The step of performing image style transfer on each of the preset hairstyle materials to obtain multiple sample style transfer maps corresponding to each preset hairstyle material includes: For each of the preset hairstyle materials, perform the following steps: Obtain at least two preset image style transfer models, wherein the image style transfer models implement image style transfer of one image style; By traversing the combination of the at least two image style transfer models, at least two combined models are generated, wherein the combined model includes at least two ordered connected image style transfer models, and the combined model is used to perform multiple iterative image style transfer on the input hairstyle material based on the at least two ordered connected image style transfer models; Based on each of the aforementioned combination models, the preset hairstyle materials are processed to obtain multiple sample style transfer maps corresponding to the preset hairstyle materials.
8. The method according to any one of claims 1-6, characterized in that, The step of image segmentation of the image to be processed to obtain a hairstyle segmentation map includes: Load the image to be processed and detect whether the person's hairstyle exists in the image to be processed; If the image to be processed includes the person's hairstyle, then the image to be processed is segmented to obtain the hairstyle segmentation image.
9. An image processing apparatus, characterized in that, include: The segmentation module is used to segment the image to be processed to obtain a hairstyle segmentation map, which represents the hairstyle of the person in the image to be processed. The style transfer module is used to perform image style transfer on the hairstyle segmentation map to obtain a target style transfer map, wherein the target style transfer map has different texture features from the hairstyle segmentation map; The classification module is used to process the target style transfer map based on a pre-trained image classification model to obtain target hairstyle material, wherein the target hairstyle material is the hairstyle material corresponding to the hairstyle of the person in the image to be processed, and the image classification model is trained based on multiple style transfer maps corresponding to the hairstyle material.
10. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the method as described in any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, implement the image processing method as described in any one of claims 1 to 8.
12. A computer program product comprising a computer program that, when executed by a processor, implements the image processing method of any one of claims 1 to 8.
Citation Information
Patent Citations
Method and device for adjusting hair style in image, storage medium and electronic equipment
CN114493998A