Portrait beauty cutout processing method and device, electronic device and storage medium
By inputting the person image to be predicted into the pre-trained neural network model, the foreground image of the person is predicted and synthesized with the background image, which solves the problem of large-area beautification processing and high labor costs, and achieves efficient beautification effects.
Patent Information
- Application Number
- CN202410161509.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-05
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2044-02-05
AI Technical Summary
Existing portrait beautification algorithms have difficulties in beautifying large areas of skin, and face detection and key point extraction methods in the field of live broadcasts have high labor costs.
By inputting the image of the person to be predicted into the pre-trained neural network model, the foreground image of the portrait is predicted, and the image and the background image are input into the cutout synthesis module to output interesting gameplay images of different styles to achieve large-area beautification processing. Reduce labor costs.
Face slimming operations and portrait beautification can be completed without key point extraction and skin probability detection, effectively handling large-area beautification processes and reducing labor costs.
Smart Images

Figure CN117953104B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a method and device for processing portrait beauty cutouts, an electronic device, and a storage medium. Background Art
[0002] In the related technology, the existing portrait beautification algorithm detects the skin probability and then uses Gaussian skin smoothing to achieve the beautification effect. This method is limited to beautifying certain areas and is difficult to handle for large areas of skin. In the live broadcast field, the portrait beautification algorithm detects the face and extracts the key points of the face, and then moves the position of the key points of the human body or matches the template in the later stage to achieve the face-slimming and beautification function. This method has a high labor cost for the later template configuration.
[0003] In summary, the technical problems existing in the relevant technologies need to be improved. Summary of the invention
[0004] The main purpose of the embodiments of the present application is to propose a method and device for processing portrait beauty cutouts, an electronic device and a storage medium, which can handle large-area beauty processes and reduce labor costs.
[0005] To achieve the above-mentioned purpose, an embodiment of the present application provides a method for processing portrait beauty cutout, the method comprising:
[0006] Obtain the image of the person to be predicted;
[0007] Inputting the image of the person to be predicted into a pre-trained neural network model to predict a portrait foreground image;
[0008] Get the background image;
[0009] The portrait foreground image and the background image are input into a cutout synthesis module, and interesting gameplay images of different styles are output.
[0010] In some embodiments, the training process of the neural network model includes:
[0011] Obtain the image of the person to be trained;
[0012] Training the neural network model using the image of the person to be trained;
[0013] The step of training the neural network model using the image of the person to be trained includes:
[0014] Encoding the image of the person to be trained to obtain a first detail feature and a first semantic feature;
[0015] Performing deep feature aggregation on the first semantic feature to obtain a first deep semantic feature;
[0016] Performing resolution processing and semantic processing simultaneously according to the first detail feature and the first depth semantic feature to obtain a first portrait mask, a first skin mask, a skin edge, and a skin rough mask;
[0017] Constrained supervised learning is performed according to the first portrait mask, the first skin mask, the skin edge and the rough skin mask to adjust the parameters of the neural network model.
[0018] In some embodiments, the neural network model includes a dual decoder;
[0019] The dual decoder comprises a first embedding module, a second embedding module and a third embedding module;
[0020] The step of simultaneously performing resolution processing and semantic processing according to the first detail feature and the first depth semantic feature to obtain a first portrait mask, a first skin mask, a skin edge, and a skin rough mask includes:
[0021] Inputting the first detail feature and the first deep semantic feature into the first embedding module to obtain a first embedding output;
[0022] Inputting the first embedding output and the first deep semantic feature into the second embedding module to obtain a second embedding output;
[0023] Upsampling the second embedding output to obtain the rough skin mask;
[0024] The first embedding output and the second embedding output are input into the third embedding module to obtain the first portrait mask, the first skin mask and the skin edge.
[0025] In some embodiments, performing constrained supervised learning according to the first portrait mask, the first skin mask, the skin edge and the rough skin mask includes:
[0026] performing first constrained supervised learning according to the first portrait mask;
[0027] performing second constrained supervised learning based on the first skin mask;
[0028] performing third constraint supervised learning according to the skin edge;
[0029] A fourth constraint supervised learning is performed based on the rough skin mask.
[0030] In some embodiments, inputting the first detail feature and the first deep semantic feature into the first embedding module to obtain a first embedding output includes:
[0031] Performing interpolation upsampling on the first depth semantic feature to obtain a second depth semantic feature;
[0032] The first detail feature and the second deep semantic feature are input into the first embedding module to obtain a first embedding output.
[0033] In some embodiments, inputting the first embedding output and the second embedding output into the third embedding module to obtain the first portrait mask, the first skin mask and the skin edge includes:
[0034] Performing interpolation upsampling on the second embedding output;
[0035] The second embedding output after interpolation and upsampling and the first embedding output are input into the third embedding module to obtain the first portrait mask, the first skin mask and the skin edge.
[0036] In some embodiments, the step of inputting the image of the person to be predicted into a pre-trained neural network model to predict a portrait foreground image includes:
[0037] Performing semantic processing on the image of the person to be predicted to obtain semantic information;
[0038] Performing resolution processing on the image of the person to be predicted according to the semantic information to obtain a second portrait mask and a second skin mask;
[0039] performing skin optimization on the image of the person to be predicted according to the second skin mask;
[0040] Human body synthesis is performed according to the skin optimization result and the second portrait mask to obtain a portrait foreground image.
[0041] To achieve the above-mentioned purpose, another aspect of the embodiment of the present application provides a processing device for portrait beauty cutout, the device comprising:
[0042] The first module is used to obtain the image of the person to be predicted;
[0043] The second module is used to input the image of the person to be predicted into a pre-trained neural network model to predict a portrait foreground image;
[0044] The third module is used to obtain the background image;
[0045] The fourth module is used to input the portrait foreground image and the background image into a cutout synthesis module, and output interesting gameplay images of different styles.
[0046] To achieve the above object, another aspect of an embodiment of the present application provides an electronic device, including:
[0047] at least one processor;
[0048] at least one memory for storing at least one program;
[0049] When the at least one program is executed by the at least one processor, the at least one processor implements the above method.
[0050] To achieve the above objective, another aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program implements the above method when executed by a processor.
[0051] The embodiments of the present application include at least the following beneficial effects: The present application provides a method and device for processing portrait beautification cutouts, an electronic device and a storage medium, which predicts a portrait foreground image by inputting a person image to be predicted into a pre-trained neural network model, and then inputs the portrait foreground image and the background image into a cutout synthesis module to output interesting gameplay images of different styles, thereby completing the face-slimming operation without performing key point extraction, and completing portrait beautification without performing skin probability detection, thereby effectively processing large-area beautification processes and reducing labor costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 It is a flowchart of a method for processing portrait beauty cutout provided by an embodiment of the present application;
[0053] Figure 2 It is a structural schematic diagram of a neural network model provided in an embodiment of the present application;
[0054] Figure 3 It is a flow chart of training a neural network model provided in an embodiment of the present application;
[0055] Figure 4 yes Figure 3 Flow chart of step S330 in FIG.
[0056] Figure 5 yes Figure 3 Flow chart of step S340 in FIG.
[0057] Figure 6 yes Figure 4 Flow chart of step S410 in FIG.
[0058] Figure 7 yes Figure 4 Flowchart of step S440 in FIG.
[0059] Figure 8 is a prediction flow chart of a portrait foreground image provided by an embodiment of the present application;
[0060] Fig. 9 It is a structural schematic diagram of a processing device for portrait beauty cutout provided in an embodiment of the present application;
[0061] Fig.10 It is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0062] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the embodiments of the present application. They are only examples of devices and methods consistent with some aspects of the embodiments of the present application as detailed in the attached claims.
[0063] It is understood that the terms "first", "second", etc. used in this application can be used to describe various concepts in this article, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another concept. For example, without departing from the scope of the embodiment of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" and "if" as used herein can be interpreted as "at the time of" or "when" or "in response to determination".
[0064] The terms "at least one", "multiple", "each", "any", etc. used in this application, at least one includes one, two or more, multiple includes two or more, each refers to each of the corresponding multiple, and any refers to any one of the multiple.
[0065] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0066] Before describing the embodiments of the present application in detail, some nouns and terms involved in the embodiments of the present application are first described. The nouns and terms involved in the embodiments of the present application are subject to the following explanations.
[0067] Encoder: In a neural network, the input image resolution can be expressed as H×W, and the role of the encoder is to use convolution to extract the features of the input image. As the neural network goes deeper, the resolution of the features gradually decreases, but the semantic information contained in the features gradually becomes richer.
[0068] DF: Detail Feature in English and detail feature in Chinese. In the present invention, it refers to the 1 / 4 resolution feature obtained by the encoder.
[0069] SF: Semantic Feature in English and in Chinese. In the present invention, it refers to the output feature of the encoder.
[0070] DSF: Deep Semantic Feature in English and deep semantic feature in Chinese. In the present invention, it refers to the output of SF after being processed by the deep feature aggregation module.
[0071] In the related technologies, the existing technologies are no longer satisfied with conventional sharing of video content, but are more interested in innovative and interesting styles. For example, in mobile phone ringtones, users are eager to customize the ringtone video content to show the other party better beauty and fun. Aiming at similar needs, AI technology provides a solution.
[0072] The existing portrait beautification methods mainly detect the skin probability and then achieve the beautification effect through Gaussian skin smoothing. This method is limited to beautification of certain areas and is difficult to beautify a large area of skin. In the field of live broadcasting, portrait beautification methods are mostly reflected in face detection and face key point extraction, and then the face thinning and beautification function is achieved through the later stage of human key point position shifting or template matching. This method has the labor cost of later template configuration.
[0073] In view of this, a method and device for processing portrait beautification cutouts, an electronic device and a storage medium are provided in the embodiments of the present application. The scheme predicts a portrait foreground image by inputting the image of the person to be predicted into a pre-trained neural network model, and then inputs the portrait foreground image and the background image into a cutout synthesis module to output interesting gameplay images of different styles. Therefore, the face-slimming operation can be completed without key point extraction, and the portrait beautification can be completed without skin probability detection. Therefore, the large-area beautification process can be effectively processed, reducing labor costs.
[0074] The processing method of portrait beauty cutout provided in the embodiment of the present application relates to the field of image processing technology. The processing method of portrait beauty cutout provided in the embodiment of the present application can be applied to a terminal, can also be applied to a server, and can also be software running in a terminal or a server. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, and a car terminal, etc., but is not limited to this; the server side can be configured as an independent physical server, or it can be configured as a server cluster or a distributed system composed of multiple physical servers, and can also be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The server can also be a node server in a blockchain network; the software can be an application that implements the processing method of portrait beauty cutout, etc., but is not limited to the above forms.
[0075] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0076] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on data related to user identity or characteristics such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first, and the collection, use, and processing of these data will comply with relevant laws, regulations, and standards. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the user's separate permission or consent, the necessary user-related data for the normal operation of the embodiment of the present application will be obtained.
[0077] Figure 1 is an optional flowchart of a method for processing portrait beauty cutout provided in an embodiment of the present application. Figure 1 The method may include but is not limited to steps S110 to S140:
[0078] Step S110, obtaining an image of a person to be predicted;
[0079] Step S120, inputting the image of the person to be predicted into the pre-trained neural network model to predict a portrait foreground image;
[0080] Step S130, obtaining a background image;
[0081] Step S140: input the portrait foreground image and the background image into a cutout synthesis module, and output interesting gameplay images of different styles.
[0082] In steps S110 to S140 shown in the embodiment of the present application, the image of the person to be predicted is input into a pre-trained neural network model to predict a portrait foreground image, and then the portrait foreground image and the background image are input into a cutout synthesis module to output interesting gameplay images of different styles. Therefore, the face slimming operation can be completed without key point extraction, and the portrait beautification operation can be completed without skin probability detection, thereby effectively handling large-area beautification processes and reducing labor costs.
[0083] In some embodiments, Figure 2 As shown, the neural network model of the present application includes a dual decoder, which includes a first embedding module, a second embedding module and a third embedding module. It can be understood that the first embedding module takes the deep semantic features DSF and the detail features DF as input, and then performs feature fusion based on the deep semantic features DSF and the detail features DF to effectively improve the semantic perception ability of the detail features DF. The second embedding module takes the output of the first embedding module as input to perform feature fusion, thereby effectively supplementing the detail content of the semantic branch. The third embedding module takes the output of the second embedding module and the output of the first embedding module as input to further enhance the model's aggregation ability for key skin areas.
[0084] It is understandable that the training process of the neural network model of the present application can be to obtain the image of the person to be trained and then train the neural network model with the image of the person to be trained. Figure 3 As shown, the process of training the neural network model through the image of the person to be trained includes but is not limited to steps S310 to S340:
[0085] Step S310, encoding the person image to be trained to obtain a first detail feature and a first semantic feature;
[0086] Step S320: performing deep feature aggregation on the first semantic feature to obtain a first deep semantic feature;
[0087] Step S330: performing resolution processing and semantic processing simultaneously according to the first detail feature and the first depth semantic feature to obtain a first portrait mask, a first skin mask, a skin edge, and a skin rough mask;
[0088] Step S340: performing constrained supervised learning according to the first portrait mask, the first skin mask, the skin edge and the rough skin mask to adjust the parameters of the neural network model.
[0089] In the embodiment of the present application, the image resolution of the character image is H*W, and the first detail feature refers to the detail feature in the feature map corresponding to the resolution of 1 / 4H*1 / 4W after the input image is downsampled by the encoder. The first semantic feature is the semantic information in the high semantic feature map corresponding to the resolution of 1 / 16H*1 / 16W after the encoder is encoded. Figure 2 After processing by the medium-depth feature aggregation module, the deep semantic feature DSF can be obtained as the first deep semantic feature. It can be understood that the deep feature aggregation module does not downsample the input features, but uses a combination of deep convolution and large convolution full aggregation to extract global semantic features. Specifically, in the convolutional network, the information output by the encoder is called deep semantic features, but due to the limitations of convolution, the receptive field of the deep features is not as large as ideal. Therefore, in this embodiment, the deep semantic features are further input into the convolution layer based on the large convolution kernel to enhance the global perception ability of the features, so as to expand the receptive field of the features while maintaining certain learnable parameters.
[0090] In some embodiments, Figure 4 As shown, step S330 includes but is not limited to steps S410 to S440:
[0091] Step S410: input the first detail feature and the first deep semantic feature into a first embedding module to obtain a first embedding output;
[0092] Step S420: input the first embedding output and the first deep semantic feature into a second embedding module to obtain a second embedding output;
[0093] Step S430, upsampling the second embedding output to obtain a rough skin mask;
[0094] Step S440: input the first embedding output and the second embedding output into a third embedding module to obtain a first portrait mask, a first skin mask, and a skin edge.
[0095] It can be understood that the resolution processing branch involves the application process of the first embedding module and the third embedding module, which is used to output the portrait code (mask), skin code (mask) and skin edge. The semantic processing branch designs the application process of the second embedding module, which is used to output the rough skin code (mask). Specifically, the resolution processing branch is used to predict the portrait prediction information, and the semantic processing branch is used to predict the human skin area. The information of the resolution processing branch will be injected into the semantic processing branch to enhance the semantic capture ability of the global area and improve the recognition ability of the skin area. The stage output of the semantic processing branch will be fed back to the resolution processing branch to improve the aggregation ability of the portrait information.
[0096] In some embodiments, Figure 2 The neural network model shown in FIG. 1 also has first constraint supervision, human constraint supervision, third constraint supervision and fourth constraint supervision. Based on this structural feature, as shown in FIG. Figure 5 As shown, the processing process of step S340 includes but is not limited to steps S510 to S540:
[0097] Step S510, performing first constrained supervised learning according to the first portrait mask;
[0098] Step S520, performing second constrained supervised learning according to the first skin mask;
[0099] Step S530, performing third constraint supervised learning according to the skin edge;
[0100] Step S540: Perform fourth constrained supervised learning based on the rough skin mask.
[0101] In some embodiments, Figure 6 As shown, step S410 includes but is not limited to steps S610 to S620:
[0102] Step S610: performing interpolation upsampling on the first depth semantic feature to obtain a second depth semantic feature;
[0103] Step S620: input the first detail feature and the second deep semantic feature into a first embedding module to obtain a first embedding output.
[0104] In some embodiments, Figure 7 As shown, step S440 includes but is not limited to steps S710 to S720:
[0105] Step S710, performing interpolation upsampling on the second embedding output;
[0106] Step S720: Input the second embedding output after interpolation and upsampling and the first embedding output into a third embedding module to obtain a first portrait mask, a first skin mask and a skin edge.
[0107] It is understandable that Figure 2 Taking the neural network model structure shown as an example, during the training process, this embodiment involves an encoding process, a resolution processing branch, and a semantic processing branch. Specifically, the encoding process extracts the 1 / 4 resolution feature DF in the input image of the person to be trained as the first detail feature, and extracts the output semantic feature DSF of the depth aggregation module as the first depth semantic feature.
[0108] In the resolution processing branch, the first detail feature is first input into the first embedding module together with the first deep semantic feature. Since the resolution of the first deep semantic feature is lower than that of the first detail feature, the first deep semantic feature is interpolated and upsampled before feature fusion to obtain a 1 / 4 resolution feature. Then the output of the first embedding module and the output of the second embedding module are used as the input of the third embedding module. Since the output feature resolution of the second embedding module is lower than that of the first embedding module, the former is first interpolated and upsampled. Subsequently, the feature is further interpolated and upsampled to obtain a mask with the same resolution as the input image, including a portrait mask, a skin mask and a skin edge. These masks are input into the first constraint supervision, the second constraint supervision and the third constraint supervision in turn. Among them, the input of the first constrained supervision is the portrait mask mask output by the model and the corresponding portrait mask mask supervision signal, and their resolutions are both H×W. The input of the second constrained supervision is the skin mask mask output by the model and the corresponding skin mask maks supervision signal, and their resolutions are both H×W. The input signals of the fourth constrained supervision are the same, but the resolution is H / 2×W / 2. The third constrained supervision is the skin edge mask mask output by the model and the corresponding skin edge mask mask supervision signal, which can be obtained by edge detection on the skin mask supervision signal.
[0109] In the semantic processing branch, the input feature is the first deep semantic feature, which will serve as the input of the first embedding module and the second embedding module. The second embedding module first interpolates and upsamples the first deep semantic feature to obtain a 1 / 4 output feature. Then, the second embedding module receives the output from the first embedding module and performs feature fusion with the upsampled first deep semantic feature. Finally, the output of the second feature module is used as the input of the third embedding module and further upsampled to obtain a 1 / 2 resolution feature as a rough skin mask, which is further input into the fourth constraint supervision.
[0110] In some embodiments, after the training of the neural network model is completed, the image of the person to be predicted is input into the pre-trained neural network model to predict the portrait foreground image. Figure 8As shown, the prediction process of the neural network model includes but is not limited to steps S810 to S720:
[0111] Step S810, performing semantic processing on the image of the person to be predicted to obtain semantic information;
[0112] Step S820: performing resolution processing on the image of the person to be predicted according to the semantic information to obtain a second portrait mask and a second skin mask;
[0113] Step S830, performing skin optimization on the image of the person to be predicted according to the second skin mask;
[0114] Step S840: synthesize the human body according to the skin optimization result and the second portrait mask to obtain a portrait foreground image.
[0115] It can be understood that in the prediction process of the neural network model of this embodiment, the output of the second embedding module of the semantic processing branch is directly used as the input of the third embedding module, and no upsampling operation is performed. The resolution processing branch directly predicts the portrait mask and the skin mask, and inputs the skin mask into the skin optimization management module to obtain the skin optimized information, and the skin optimized information and the portrait mask are input into the human body synthesis module together to obtain the skin optimized portrait foreground image. Then the portrait foreground image and different background images are input into the cutout synthesis module together to generate various interesting gameplay images, so as to meet the user's personalized ringtone video needs. In this embodiment, the cutout synthesis module makes various changes to the portrait foreground in the portrait area and the skin area, such as skin tone and gloss improvement, and the portrait clothing color is updated, the body shape is optimized, etc. The background image can be a dynamic image or a static image. The fusion process of the portrait foreground image and the background image can be processed by Poisson fusion, image synthesis algorithm, etc., and the specific process can be selected in combination with the actual situation.
[0116] See also Fig. 9 The embodiment of the present application also provides a processing device for portrait beauty cutout, the device comprising:
[0117] The first module 910 is used to obtain a person image to be predicted;
[0118] The second module 920 is used to input the image of the person to be predicted into the pre-trained neural network model to predict a portrait foreground image;
[0119] The third module 930 is used to obtain a background image;
[0120] The fourth module 940 is used to input the portrait foreground image and the background image into the cutout synthesis module, and output interesting gameplay images of different styles.
[0121] It can be understood that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0122] The embodiment of the present application further provides an electronic device, which can be any intelligent terminal including a tablet computer, a car computer, etc. Specifically, the electronic device includes:
[0123] at least one processor;
[0124] at least one memory for storing at least one program;
[0125] When the at least one program is executed by the at least one processor, the at least one processor implements Figure 1 The processing method for portrait beauty cutout is shown.
[0126] It can be understood that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0127] See also Fig.10 , Fig.10 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:
[0128] The processor 1010 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0129] The memory 1020 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1020 can store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program codes are stored in the memory 1020 and are called by the processor 1010 to execute the embodiments of this application. Figure 1 The processing method of portrait beauty cutout shown;
[0130] Input / output interface 1030, used to implement information input and output;
[0131] The communication interface 1040 is used to realize the communication interaction between the device and other devices. The communication can be realized through a wired manner (such as USB, network cable, etc.) or a wireless manner (such as mobile network, WIFI, Bluetooth, etc.);
[0132] Bus 1050 , which transmits information between various components of the device (e.g., processor 1010 , memory 1020 , input / output interface 1030 , and communication interface 1040 );
[0133] The processor 1010 , the memory 1020 , the input / output interface 1030 , and the communication interface 1040 are connected to each other in communication within the device via a bus 1050 .
[0134] The present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above Figure 1 The processing method for portrait beauty cutout is shown.
[0135] It can be understood that the contents of the above method embodiments are all applicable to the present storage medium embodiments, the functions specifically implemented by the present storage medium embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0136] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0137] The embodiments of the present application provide Figure 1The processing method and device, electronic device and storage medium of portrait beauty cutout shown in the figure input the image to be predicted into the pre-trained neural network model to predict the portrait foreground image, and then input the portrait foreground image and background image into the cutout synthesis module to output interesting gameplay images of different styles, so that the face-thinning operation can be completed without key point extraction, and the portrait beauty can be completed without skin probability detection, thereby effectively processing the large-area beauty process and reducing labor costs. Further, in the first embedding module of this embodiment, due to the global feature injection of the feature DSF and the shallow feature of the encoder, not only the detail feature of the feature can be maintained, but also the global perception ability of the output feature can be further enhanced; in the second embedding module, since the output feature of the first embedding module can effectively make up for the loss of detail information after the encoder is down-sampled, the perception of the target position information by the semantic branch can be enhanced; in the third embedding module, due to the influence of the fourth constraint supervision, there is stronger skin semantic information, so the information injection of the second embedding module can greatly solve the problem of the lack of semantic perception ability of the output feature of the first embedding module. It can be seen that, through the effective synthesis of the three embedding modules in this embodiment, the entire module not only has the ability to semantically perceive the target but also preserves the detailed features of the target, thereby enabling the model to segment the portrait more accurately and reduce the interference of noise on target perception.
[0138] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0139] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0140] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0141] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0142] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0143] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0144] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0145] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0146] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0147] 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 application, 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, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0148] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. A method for processing portrait beauty cutout, characterized in that: The method comprises: Obtain the image of the person to be predicted; Inputting the image of the person to be predicted into a pre-trained neural network model to predict a portrait foreground image; Get the background image; Inputting the portrait foreground image and the background image into a cutout synthesis module, and outputting interesting gameplay images of different styles; The training process of the neural network model includes: Obtain the image of the person to be trained; Training the neural network model using the image of the person to be trained; The step of training the neural network model using the image of the person to be trained includes: Encoding the image of the person to be trained to obtain a first detail feature and a first semantic feature; Performing deep feature aggregation on the first semantic feature to obtain a first deep semantic feature; Performing resolution processing and semantic processing simultaneously according to the first detail feature and the first depth semantic feature to obtain a first portrait mask, a first skin mask, a skin edge, and a skin rough mask; Performing constrained supervised learning according to the first portrait mask, the first skin mask, the skin edge and the skin rough mask to adjust parameters of the neural network model; The neural network model includes a dual decoder; The dual decoder comprises a first embedding module, a second embedding module and a third embedding module; The step of simultaneously performing resolution processing and semantic processing according to the first detail feature and the first depth semantic feature to obtain a first portrait mask, a first skin mask, a skin edge, and a skin rough mask includes: Inputting the first detail feature and the first deep semantic feature into the first embedding module to obtain a first embedding output; Inputting the first embedding output and the first deep semantic feature into the second embedding module to obtain a second embedding output; Upsampling the second embedding output to obtain the rough skin mask; The first embedding output and the second embedding output are input into the third embedding module to obtain the first portrait mask, the first skin mask and the skin edge.
2. The method according to claim 1, characterized in that The performing constrained supervised learning according to the first portrait mask, the first skin mask, the skin edge and the rough skin mask includes: performing first constrained supervised learning according to the first portrait mask; performing second constrained supervised learning based on the first skin mask; performing third constraint supervised learning according to the skin edge; A fourth constraint supervised learning is performed based on the rough skin mask.
3. The method according to claim 1, characterized in that The step of inputting the first detail feature and the first deep semantic feature into the first embedding module to obtain a first embedding output includes: Performing interpolation upsampling on the first depth semantic feature to obtain a second depth semantic feature; The first detail feature and the second deep semantic feature are input into the first embedding module to obtain a first embedding output.
4. The method according to claim 1, characterized in that: The step of inputting the first embedding output and the second embedding output into the third embedding module to obtain the first portrait mask, the first skin mask and the skin edge comprises: Performing interpolation upsampling on the second embedding output; The second embedding output after interpolation and upsampling and the first embedding output are input into the third embedding module to obtain the first portrait mask, the first skin mask and the skin edge.
5. The method according to claim 1, characterized in that The step of inputting the image of the person to be predicted into a pre-trained neural network model to predict a portrait foreground image includes: Performing semantic processing on the image of the person to be predicted to obtain semantic information; Performing resolution processing on the image of the person to be predicted according to the semantic information to obtain a second portrait mask and a second skin mask; performing skin optimization on the image of the person to be predicted according to the second skin mask; Human body synthesis is performed according to the skin optimization result and the second portrait mask to obtain a portrait foreground image.
6. A processing device for portrait beauty cutout, characterized in that: The device comprises: The first module is used to obtain the image of the person to be predicted; The second module is used to input the image of the person to be predicted into a pre-trained neural network model to predict a portrait foreground image; The third module is used to obtain the background image; The fourth module is used to input the portrait foreground image and the background image into a cutout synthesis module, and output interesting gameplay images of different styles; The training process of the neural network model includes: Obtain the image of the person to be trained; Training the neural network model using the image of the person to be trained; The step of training the neural network model using the image of the person to be trained includes: Encoding the image of the person to be trained to obtain a first detail feature and a first semantic feature; Performing deep feature aggregation on the first semantic feature to obtain a first deep semantic feature; Performing resolution processing and semantic processing simultaneously according to the first detail feature and the first depth semantic feature to obtain a first portrait mask, a first skin mask, a skin edge, and a skin rough mask; Performing constrained supervised learning according to the first portrait mask, the first skin mask, the skin edge and the skin rough mask to adjust parameters of the neural network model; The neural network model includes a dual decoder; The dual decoder comprises a first embedding module, a second embedding module and a third embedding module; The step of simultaneously performing resolution processing and semantic processing according to the first detail feature and the first depth semantic feature to obtain a first portrait mask, a first skin mask, a skin edge, and a skin rough mask includes: Inputting the first detail feature and the first deep semantic feature into the first embedding module to obtain a first embedding output; Inputting the first embedding output and the first deep semantic feature into the second embedding module to obtain a second embedding output; Upsampling the second embedding output to obtain the rough skin mask; The first embedding output and the second embedding output are input into the third embedding module to obtain the first portrait mask, the first skin mask and the skin edge.
7. An electronic device, characterized in that: include: at least one processor; at least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor implements the method according to any one of claims 1 to 5.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Portrait stick figure area self-adaptive color matching method and system for industrial manufacturing
CN113763498A
Cartoon head portrait generation method and device based on portrait, equipment and medium
CN114638746A
