Virtual portrait generation method and device and storage medium
By displaying template parameter options, the target model parameters and theme parameters selected by the user are obtained, the virtual portrait generation model is called, and the target virtual portrait is generated and displayed, which solves the problems of distortion, unreality, singularity and excessive resource utilization of virtual portrait generation in the existing technology, and achieves the satisfaction of personalized needs and efficient utilization of resources.
Patent Information
- Application Number
- CN202311433535.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-31
- Publication Date
- 2025-05-02
AI Technical Summary
The virtual portraits generated in the prior art have problems such as distortion, innocence, singularity, and excessive data and computing resources, which cannot meet the personalized needs of users.
It provides a virtual portrait generation method. By displaying template parameter options, it obtains the target model parameters and theme parameters selected by the user, calls the virtual portrait generation model, generates and displays the target virtual portrait to match the user's personalized needs.
It improves the authenticity and diversity of virtual portraits, meets users' personalized needs, and reduces the use of data and computing resources.
Smart Images

Figure CN119919511A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of terminals, and in particular to a method, device and storage medium for generating a virtual portrait. Background Art
[0002] With the development of artificial intelligence technology, more and more fields have applied artificial intelligence technology. AI painting and AI virtual portrait generation technology are currently one of the hottest application areas of artificial intelligence technology.
[0003] In the related art, the generated images have problems of distortion and unreality, the generated images are single and cannot meet the personalized needs of users, and the generation of images requires a large amount of data and computing resources. Summary of the invention
[0004] In order to overcome the problems existing in the related art, the present disclosure provides a method, device and storage medium for generating a virtual portrait.
[0005] According to a first aspect of an embodiment of the present disclosure, a method for generating a virtual portrait is provided, comprising: in response to determining that an electronic device enables a virtual portrait generation function, displaying template parameter options, the template parameter options comprising model parameter options and subject parameter options, the subject parameter options being used to determine text prompt information, the text prompt information being used to prompt image subject information of a target virtual portrait to be generated, and the model parameter options being used to describe image attribute information of the target virtual portrait to be generated; obtaining target model parameters and target subject parameters selected by a user based on the template parameter options; based on the target model parameters and the target subject parameters, calling a virtual portrait generation model, wherein different virtual portrait generation models correspond to different template parameter options; based on the target model, generating and displaying a target virtual portrait, the target virtual portrait matching the target model parameters and the target subject parameters.
[0006] In one embodiment, the virtual portrait generation model is pre-trained in the following manner: obtaining a portrait sample set selected by a user; preprocessing the portrait sample set to obtain a portrait training set; determining a label data set corresponding to the portrait samples in the portrait training set, wherein the label data set includes text prompt information corresponding to the portrait samples; and training the virtual portrait generation model based on the label data set and the portrait training set.
[0007] In one embodiment, obtaining the portrait sample set selected by the user includes: providing an image selection path in response to detecting that the user triggers an operation to select the portrait sample set; obtaining the portrait selected by the user based on the image selection path to obtain the portrait sample set.
[0008] In one implementation, preprocessing the portrait sample set to obtain a portrait training set includes: screening portrait samples including a target portrait in the portrait sample set to obtain a first portrait sample set; and obtaining a portrait training set based on the first portrait sample set.
[0009] In one embodiment, at least one of the following methods is used to screen portrait samples including a target portrait in the portrait sample set to obtain a first portrait sample set: perform face recognition on the portrait samples in the portrait sample set to obtain a target portrait; delete portrait samples of other portraits different from the target portrait; delete portrait samples including the target portrait and other portraits; retain portrait samples including at least faces and bodies; retain portrait samples whose body morphology meets morphological conditions, and delete portrait samples whose body morphology does not meet morphological conditions; retain portrait samples whose ratio between faces and bodies meets the ratio condition, and delete portrait samples whose ratio between faces and bodies does not meet the ratio condition; retain portrait samples whose contrast between portraits and backgrounds meets the contrast condition, and delete portrait samples whose contrast between portraits and backgrounds does not meet the contrast condition; in response to the number of portrait samples being lower than a preset number, prompt the user to reselect portrait samples to obtain portrait samples whose number of images meets the preset number.
[0010] In one implementation, obtaining a portrait training set based on the first portrait sample set includes: screening portrait samples that meet image quality requirements in the first portrait sample set to obtain a second portrait sample set; and obtaining a portrait training set based on the second portrait sample set.
[0011] In one embodiment, at least one of the following methods is used to screen portrait samples that meet image quality conditions in the first portrait sample set: retain first portrait samples whose image resolution is greater than a resolution threshold, and delete first portrait samples whose image resolution is less than or equal to the resolution threshold; retain first portrait samples whose posture of a set part of the human body meets a preset posture, and delete first portrait samples whose posture of the set part of the human body does not meet the preset posture; retain first portrait samples whose facial morphology meets facial morphology conditions, and delete first portrait samples whose facial morphology does not meet facial morphology conditions; arrange the first portrait samples that meet the conditions in the first portrait sample set from large to small according to resolution, and select first portrait samples whose number of images meets the preset number.
[0012] In one embodiment, obtaining a portrait training set based on the second portrait sample set includes: performing image segmentation on the portrait samples in the second portrait sample set according to face, upper body and body above the knees, respectively, to obtain a third portrait sample set; performing background removal on the face images and half-body images in the second portrait sample set, to obtain a fourth portrait sample set; performing resolution compression on the portrait samples in the second portrait sample set, the third portrait sample set and the fourth portrait sample set whose resolution is higher than a resolution threshold, to obtain portrait samples with a preset resolution; and distinguishing between face sample images and body sample images of the portrait samples with the preset resolution and storing them separately, to obtain a portrait training set.
[0013] In one embodiment, determining the label data set corresponding to the portrait samples in the portrait training set includes: generating an initial text description of the portrait samples in the portrait training set based on a multimodal visual language model; screening out preset text included in the initial text description, and the portrait samples corresponding to the preset text, to obtain the label data set corresponding to the portrait samples in the portrait training set.
[0014] In one embodiment, the training of a virtual portrait generation model based on the labeled data set and the portrait training set includes: calling a first pre-trained model, and training a second pre-trained model based on the labeled data set and the portrait training set; based on the first pre-trained model and the second pre-trained model, repeatedly training each portrait in the portrait training set based on the labeled data set for a preset number of times to obtain a virtual portrait generation model; wherein the number of repeated training times for the face sample images is N times the number of repeated training times for the body sample images, and N is a positive integer greater than or equal to 2.
[0015] In one embodiment, the theme parameter options include a default theme parameter option and a custom theme parameter option, the default theme parameter option is text prompt information that has been generated and displayed, and the custom theme parameter option includes multiple theme options for generating text prompt information for user selection; the target theme parameter is determined in the following manner: in response to not detecting that the user selects the custom theme parameter option, the text prompt information that has been generated and displayed is used as the target theme parameter; or in response to the user selecting the custom theme parameter option, the text prompt information generated based on the theme option selected by the user is used as the target theme parameter.
[0016] In one embodiment, the generating and displaying of the target image includes: generating an initial target image; optimizing the initial target image and displaying the optimized target image; the optimization includes at least one of the following: filtering out target content information; image area repairing; redrawing based on a user's redrawing operation; and image enhancement.
[0017] In one embodiment, determining whether the electronic device enables the virtual portrait generation function includes: in response to detecting that a virtual portrait generation function control in a photo album of the electronic device is enabled, determining whether the electronic device enables the virtual portrait generation function.
[0018] According to a second aspect of an embodiment of the present disclosure, a virtual portrait generation device is provided, comprising a receiving unit, for obtaining target model parameters and target subject parameters selected by a user based on the template parameter options; a processing unit, for displaying template parameter options in response to determining that the electronic device enables a virtual portrait generation function, the template parameter options comprising model parameter options and subject parameter options, the subject parameter options being used to determine text prompt information, the text prompt information being used to prompt image subject information of a target virtual portrait to be generated, and the model parameter options being used to describe image attribute information of the target virtual portrait to be generated; based on the target model parameters and the target subject parameters, calling a virtual portrait generation model, wherein different virtual portrait generation models correspond to different template parameter options; based on the target model, generating and displaying a target virtual portrait, the target virtual portrait matching the target model parameters and the target subject parameters.
[0019] In one embodiment, the processing unit pre-trains the virtual portrait generation model in the following manner: obtain a portrait sample set selected by a user; pre-process the portrait sample set to obtain a portrait training set; determine a label data set corresponding to the portrait samples in the portrait training set, wherein the label data set includes text prompt information corresponding to the portrait samples; and train the virtual portrait generation model based on the label data set and the portrait training set.
[0020] In one embodiment, the processing unit obtains the portrait sample set selected by the user in the following manner: in response to detecting that the user triggers an operation to select a portrait sample set, an image selection path is provided; and the portrait selected by the user based on the image selection path is obtained to obtain the portrait sample set.
[0021] In one implementation, the processing unit preprocesses the portrait sample set to obtain a portrait training set by: screening portrait samples including a target portrait in the portrait sample set to obtain a first portrait sample set; and obtaining a portrait training set based on the first portrait sample set.
[0022] In one embodiment, the processing unit uses at least one of the following methods to screen portrait samples including a target portrait in the portrait sample set to obtain a first portrait sample set: perform face recognition on the portrait samples in the portrait sample set to obtain a target portrait; delete portrait samples of other portraits different from the target portrait; delete portrait samples including the target portrait and other portraits; retain portrait samples including at least faces and bodies; retain portrait samples whose body morphology meets morphological conditions, and delete portrait samples whose body morphology does not meet morphological conditions; retain portrait samples whose ratio between faces and bodies meets the ratio condition, and delete portrait samples whose ratio between faces and bodies does not meet the ratio condition; retain portrait samples whose contrast between portraits and backgrounds meets the contrast condition, and delete portrait samples whose contrast between portraits and backgrounds does not meet the contrast condition; in response to the number of portrait samples being lower than a preset number, prompt a user to reselect portrait samples to obtain portrait samples whose number of images meets the preset number.
[0023] In one embodiment, the processing unit obtains a portrait training set based on the first portrait sample set in the following manner: selecting portrait samples that meet image quality requirements in the first portrait sample set to obtain a second portrait sample set; and obtaining a portrait training set based on the second portrait sample set.
[0024] In one embodiment, the processing unit uses at least one of the following methods to screen portrait samples that meet the image quality conditions in the first portrait sample set: retain the first portrait sample whose image resolution is greater than a resolution threshold, and delete the first portrait sample whose image resolution is less than or equal to the resolution threshold; retain the first portrait sample whose posture of the set part of the human body meets the preset posture, and delete the first portrait sample whose posture of the set part of the human body does not meet the preset posture; retain the first portrait sample whose facial shape meets the facial shape conditions, and delete the first portrait sample whose facial shape does not meet the facial shape conditions; arrange the first portrait samples that meet the conditions in the first portrait sample set from large to small according to resolution, and select the first portrait samples whose number of images meets the preset number.
[0025] In one embodiment, the processing unit obtains a portrait training set based on the second portrait sample set in the following manner: performing image segmentation on the portrait samples in the second portrait sample set according to the face, upper body and body above the knees, respectively, to obtain a third portrait sample set; performing background removal on the face images and half-body images in the second portrait sample set, to obtain a fourth portrait sample set; performing resolution compression on the portrait samples with a resolution higher than a resolution threshold in the second portrait sample set, the third portrait sample set and the fourth portrait sample set, to obtain portrait samples with a preset resolution; and distinguishing between face sample images and body sample images of the portrait samples with the preset resolution and storing them separately, to obtain a portrait training set.
[0026] In one embodiment, the processing unit determines the label data set corresponding to the portrait samples in the portrait training set in the following manner: based on a multimodal visual language model, generating an initial text description of the portrait samples in the portrait training set; filtering out the preset text included in the initial text description, and the portrait samples corresponding to the preset text, to obtain the label data set corresponding to the portrait samples in the portrait training set.
[0027] In one embodiment, the processing unit trains a virtual portrait generation model based on the label data set and the portrait training set in the following manner: calling a first pre-trained model, and training a second pre-trained model based on the label data set and the portrait training set; based on the first pre-trained model and the second pre-trained model, repeatedly training each portrait in the portrait training set based on the label data set for a preset number of times to obtain a virtual portrait generation model; wherein the number of repeated training times for the face sample image is N times the number of repeated training times for the body sample image, and N is a positive integer greater than or equal to 2.
[0028] In one embodiment, the processing unit uses the following method to process the theme parameter options, including a default theme parameter option and a custom theme parameter option, wherein the default theme parameter option is text prompt information that has been generated and displayed, and the custom theme parameter option includes multiple theme options for generating text prompt information for user selection; the target theme parameter is determined in the following method: in response to not detecting that the user selects the custom theme parameter option, the text prompt information that has been generated and displayed is used as the target theme parameter; or in response to the user selecting the custom theme parameter option, the text prompt information generated based on the theme option selected by the user is used as the target theme parameter.
[0029] In one embodiment, the processing unit generates and displays the target image in the following manner: generates an initial target image; optimizes the initial target image and displays the optimized target image; the optimization includes at least one of the following: filtering out target content information; image area repair; redrawing based on a user's redrawing operation; and image enhancement.
[0030] In one embodiment, the processing unit determines whether the electronic device enables the virtual portrait generation function in the following manner: in response to detecting that a virtual portrait generation function control in a photo album of the electronic device is enabled, determining whether the electronic device enables the virtual portrait generation function.
[0031] According to a third aspect of an embodiment of the present disclosure, a virtual portrait generation device is provided, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to: execute the virtual portrait generation method described in the first aspect or any one of the implementations of the first aspect.
[0032] According to a fourth aspect of an embodiment of the present disclosure, a storage medium is provided, in which instructions are stored. When the instructions in the storage medium are executed by a processor of a terminal, the terminal is enabled to execute the virtual portrait generation method described in the first aspect or any one of the embodiments of the first aspect.
[0033] The technical solution provided by the embodiments of the present disclosure may include the following beneficial effects: obtaining a user portrait, training a virtual portrait generation model using the user portrait, providing a user with template parameter options, and generating a target image based on the user's selection of the template parameter options.
[0034] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0036] Figure 1 The figure is a flow chart of a method for generating a virtual portrait according to an exemplary embodiment.
[0037] Figure 2 The present invention is a flowchart of a method for pre-training a virtual portrait generation model according to an exemplary embodiment.
[0038] Figure 3 The figure is a flowchart of a method for acquiring a user portrait sample set according to an exemplary embodiment.
[0039] Figure 4 The figure is a flow chart of a method for preprocessing a user portrait according to an exemplary embodiment.
[0040] Figure 5 The present invention is a flowchart showing a method for screening a portrait sample set to obtain a first portrait sample set according to an exemplary embodiment.
[0041] Figure 6 The present invention is a flowchart showing a method for obtaining a portrait training set based on a first portrait sample set according to an exemplary embodiment.
[0042] Figure 7The present invention is a flowchart showing a method for screening portrait samples that meet image quality requirements in a first portrait sample set according to an exemplary embodiment.
[0043] Figure 8 The present invention is a flowchart showing a method for obtaining a portrait training set based on a second portrait sample set according to an exemplary embodiment.
[0044] Fig. 9 The present invention is a flowchart of a method for determining a label data set corresponding to a portrait sample in a portrait training set according to an exemplary embodiment.
[0045] Fig.10 is a schematic diagram of user portrait preprocessing according to an exemplary embodiment.
[0046] Fig.11 It is a schematic diagram of a method for obtaining a virtual portrait generation model based on a label data set and a portrait training set according to an exemplary embodiment.
[0047] Fig.12 It is a schematic diagram of a method for obtaining a virtual portrait generation model based on a label data set and an image training set according to an exemplary embodiment.
[0048] Fig.13 It is a basic principle diagram of LoRa according to an exemplary embodiment.
[0049] Fig.14 The invention is a flowchart showing a method for determining target theme parameters according to an exemplary embodiment.
[0050] Fig.15 The figure is a schematic diagram of a personalized character generation method according to an exemplary embodiment.
[0051] Fig.16 The invention is a flowchart of a method for generating and displaying a target image according to an exemplary embodiment.
[0052] Fig.17 The figure is a schematic diagram showing a personalized character image post-processing according to an exemplary embodiment.
[0053] Fig.18 The invention is a flowchart of a method for determining whether an electronic device enables a virtual portrait generation function according to an exemplary embodiment.
[0054] Fig.19 The figure is a schematic diagram of a method for generating a virtual portrait according to an exemplary embodiment.
[0055] Fig. 20 The figure is a block diagram of a virtual portrait generating device according to an exemplary embodiment.
[0056] Fig.21 The invention is a block diagram of a device for generating a virtual portrait according to an exemplary embodiment. DETAILED DESCRIPTION
[0057] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. 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 present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present invention as detailed in the appended claims.
[0058] The virtual portrait generation method provided by the embodiment of the present disclosure is applied to a scenario in which a user generates a virtual portrait from a portrait photo on an electronic device. The electronic device may be a terminal. The terminal may be a mobile phone, a tablet computer, or other terminals.
[0059] At present, there are many shortcomings in the related technologies for generating virtual portraits: the generated images may be distorted or unrealistic, especially in the generation of real-life images and the processing of complex scenes or details. For example, the character's posture, expression, lighting, etc. may not be natural enough; the generated images may have copyright and privacy issues. For example, the portraits generated using AI technology may involve legal issues such as portrait rights or the generated portraits may be used for illegal purposes, such as fraud, impersonation and other illegal acts; AI virtual portrait generation technology requires a large amount of data and computing resources to generate and train images, which may lead to some environmental and resource waste problems. Pure cloud operation requires a lot of money. In addition, other mobile platforms such as simple mobile phones cannot achieve large-scale function deployment, resource consumption is large, and model training cannot be achieved.
[0060] In view of this, the present disclosure provides a virtual portrait generation method, in which an electronic device receives an instruction to start a virtual portrait generation function, provides a user with template parameter options, and generates a target virtual portrait according to the user's selection parameters of the template parameter options, thereby improving the user experience.
[0061] Figure 1 is a flow chart of a method for generating a virtual portrait according to an exemplary embodiment. Figure 1 As shown, the following steps are included.
[0062] In step S11 , in response to determining that the electronic device enables the avatar generation function, template parameter options are displayed.
[0063] The template parameter options include model parameter options and theme parameter options. The theme parameter options are used to determine text prompt information. The text prompt information is used to prompt the image theme information of the target virtual portrait to be generated. The model parameter options are used to describe the image attribute information of the target virtual portrait to be generated.
[0064] In the embodiment of the present disclosure, the electronic device detects that the user turns on the virtual portrait generation function, and displays template parameter options to the user on the display interface, wherein the template parameter options include model parameter options and theme parameter options, and the model option parameters are used to adjust the image attribute information of the target virtual portrait, such as the number of generated pictures, the size of generated pictures, etc. The theme parameter options are used to generate the theme style of the image of the target virtual portrait, including the figure's shape, the figure's clothing, the background and the environment, etc.
[0065] In step S12, the target model parameters and target theme parameters selected by the user based on the template parameter options are obtained.
[0066] In step S13, based on the target model parameters and the target subject parameters, the virtual portrait generation model is called.
[0067] Among them, different virtual portrait generation models correspond to different template parameter options.
[0068] In the disclosed embodiment, different user pictures can generate different virtual portrait generation models, which also correspond to different template parameter options.
[0069] In the disclosed embodiment, the virtual portrait generation model is deployed in the cloud. When the electronic device receives the user portrait, the user portrait is uploaded to the cloud to train the virtual portrait generation model. After the model training is completed, the trained model is output to the electronic device.
[0070] In step S14, a target virtual portrait is generated and displayed based on the target model.
[0071] Among them, the target virtual portrait matches the target model parameters and the target subject parameters.
[0072] In the disclosed embodiment, the electronic device generates a target portrait according to a trained virtual portrait generation model and target model parameters and target subject parameters selected by a user.
[0073] In the disclosed embodiment, a portrait is equivalent to an image.
[0074] A method for pre-training a virtual portrait generation model is described below.
[0075] Figure 2 is a flowchart of a method for pre-training a virtual portrait generation model according to an exemplary embodiment. Figure 2As shown, the following steps are included.
[0076] In step S21, a portrait sample set selected by a user is obtained.
[0077] In the disclosed embodiment, the user can choose to upload a certain number of user portraits to the virtual portrait generation model. For example, the user can upload 25-50 pictures. It is understandable that there is a minimum number limit for the images uploaded by the user, for example, no less than 15. If the user uploads less than this number, the virtual portrait cannot be generated. Therefore, the more images the user uploads, the higher the similarity between the generated virtual portrait and the user. It should be noted that the more images the user uploads, the better. The more images the user uploads, the longer the model training time is, and the more cloud resources are occupied. Therefore, the number of images uploaded by the user is also subject to a maximum limit, for example, no more than 50.
[0078] In step S22, the portrait sample set is preprocessed to obtain a portrait training set.
[0079] In the disclosed embodiments, the user portrait sample set cannot be used directly to train the model. The images provided by the user have disadvantages such as high scene complexity and low image clarity. For example, if the user portrait contains multiple people, the model needs to analyze all the people in the image, which increases the complexity of the training model. For another example, if the image uploaded by the user contains a blurred face, it also increases the complexity of the training model. Therefore, data preprocessing of the user portrait sample set can effectively improve the quality of model training.
[0080] In step S23, a label data set corresponding to the portrait samples in the portrait training set is determined.
[0081] Among them, the label data set includes text prompt information corresponding to the portrait samples.
[0082] In the disclosed embodiment, the virtual portrait generation model needs to label the user portraits in the portrait training set to generate a label data set. It is understandable that when the model is trained, it needs to get an answer, that is, when the model receives the user portrait, it needs to understand the content in the user portrait. For example, when the user uploads an image of a person in the snow, the model analyzes the image and understands it as a person and snow, and presents it in the form of text, that is, labeling the portrait training set. By labeling the portrait training set, when the user generates a personalized image according to the template parameter options, such as a person in the snow, the electronic device can generate a similar image based on the image of the person in the snow uploaded by the previous user.
[0083] In step S24, a virtual portrait generation model is trained based on the label data set and the portrait training set.
[0084] In the disclosed embodiment, the electronic device obtains a user portrait sample set selected by the user, performs data preprocessing on the image sample set, and obtains a user portrait training set. According to the user portrait training set, a corresponding image label data set is determined. Then, based on the portrait training set and the image label data set.
[0085] The following is an explanation of the method for selecting the user portrait sample set.
[0086] Figure 3 is a flow chart showing a method for acquiring a user portrait sample set according to an exemplary embodiment. Figure 3 As shown, the following steps are included.
[0087] In step S31 , in response to detecting that a user triggers a selection operation of a portrait sample set, an image selection path is provided.
[0088] In step S32, the portrait selected by the user based on the image selection path is obtained to obtain a portrait sample set.
[0089] In the disclosed embodiment, after the user selects a certain number of portrait pictures and uploads them to the virtual portrait generation function, the electronic device can generate a portrait sample set based on these portrait pictures.
[0090] The present disclosure mentions preprocessing a user portrait sample set. A method for preprocessing a user portrait sample set is explained below.
[0091] Figure 4 is a flow chart of a method for preprocessing a user portrait according to an exemplary embodiment. Figure 4 As shown, the following steps are included.
[0092] In step S41, portrait samples including a target portrait are screened from the portrait sample set to obtain a first portrait sample set.
[0093] In step S42, a portrait training set is obtained based on the first portrait sample set.
[0094] In the disclosed embodiment, the electronic device needs to perform certain screening on the portrait sample set uploaded by the user, for example, screening out the portraits in the portrait pictures except for the ones that need to generate the virtual portraits, and generating the portrait training set. For example, in the photos uploaded by the user, person A appears 10 times, person B appears 5 times, and person C appears 1 time. The electronic device gives priority to the person who appears the most times and generates the virtual portrait of the person. When person A and person B appear the most times, the electronic device will ask the user which person's virtual portrait to generate.
[0095] In the embodiment of the present disclosure, the electronic device screens the user portraits uploaded by the user, and the user portraits that meet certain screening conditions are called a user portrait sample set.
[0096] A method for screening a portrait sample set to obtain a first portrait sample set is explained below.
[0097] Figure 5 is a flowchart of a method for screening a portrait sample set to obtain a first portrait sample set according to an exemplary embodiment. Figure 5 As shown, the following steps are included.
[0098] In step S51, face recognition is performed on the portrait samples in the portrait sample set to obtain a target portrait.
[0099] In step S52, portrait samples of other portraits different from the target portrait are deleted.
[0100] In step S53, the portrait samples including the target portrait and other portraits are deleted.
[0101] In step S54, the portrait samples including at least the face and the body are retained.
[0102] In step S55, the portrait samples whose human body morphology meets the morphological condition are retained, and the portrait samples whose human body morphology does not meet the morphological condition are deleted;
[0103] In the disclosed embodiment, a portrait image in which the human body morphology does not meet the morphological conditions, for example, a distorted human body, will reduce the quality of the training model.
[0104] In step S56, portrait samples whose ratio between face and body meets the ratio condition are retained, and portrait samples whose ratio between face and body does not meet the ratio condition are deleted.
[0105] In the disclosed embodiment, if the ratio between the face and the body does not meet the ratio condition, the quality of the training model will be reduced.
[0106] In step S57, the portrait samples whose contrast between the portrait and the background meets the contrast condition are retained, and the portrait samples whose contrast between the portrait and the background does not meet the contrast condition are deleted.
[0107] In the embodiment of the present disclosure, portrait samples in which the contrast between the portrait and the background does not meet the contrast condition will cause the model to misidentify the background in the portrait sample, thereby reducing the quality of the training model.
[0108] In step S58, in response to the number of portrait samples being lower than a preset number, the user is prompted to reselect portrait samples to obtain portrait samples whose image number meets the preset number.
[0109] In the disclosed embodiment, the above-mentioned deletion steps may be combined arbitrarily. For example, after the user uploads the portrait sample set, the electronic device performs the following operations on the portrait sample set: Identify the target portrait A for generating the virtual portrait from the portrait sample set. Delete the single person B or multiple people C and D portraits that are not related to the target portrait. Retain the samples of the target portrait A in the portrait sample set that include the face and the body, and retain the portrait samples whose body morphology meets the morphological conditions. Delete the portrait samples whose body morphology does not meet the morphological conditions, and retain the portrait samples whose ratio between the face and the body meets the ratio conditions. Delete the portrait samples whose ratio between the face and the body does not meet the ratio conditions, and retain the portrait samples whose contrast between the portrait and the background meets the contrast conditions. Delete the portrait samples whose contrast between the portrait and the background does not meet the contrast conditions. If the electronic device detects that the number of portrait sample sets is lower than the preset number after the screening and deletion operation, it will remind the user to continue uploading portrait samples until the number of images meets the preset number of portrait samples.
[0110] A method for obtaining a portrait training set based on a first portrait sample set is explained below.
[0111] Figure 6 is a flowchart of a method for obtaining a portrait training set based on a first portrait sample set according to an exemplary embodiment. Figure 6 As shown, the following steps are included.
[0112] In step S61, portrait samples that meet the image quality requirement are screened in the first portrait sample set to obtain a second portrait sample set.
[0113] In step S62, a portrait training set is obtained based on the second portrait sample set.
[0114] In the embodiment of the present disclosure, the first portrait sample set after the screening and deletion operation can generate a second portrait sample set, and the portrait training set is obtained according to the second portrait sample set.
[0115] A method for selecting portrait samples that meet the image quality requirement in the first portrait sample set is explained below.
[0116] Figure 7 is a flowchart of a method for screening portrait samples that meet image quality requirements in a first portrait sample set according to an exemplary embodiment. Figure 7 As shown, the following steps are included.
[0117] In step S71, the first portrait samples whose image resolution is greater than the resolution threshold are retained, and the first portrait samples whose image resolution is less than or equal to the resolution threshold are deleted.
[0118] In the embodiment of the present disclosure, the first portrait sample whose image resolution is less than or equal to the resolution threshold will reduce the quality of the training model.
[0119] In step S72, the first portrait samples whose posture of the set body part conforms to the preset posture are retained, and the first portrait samples whose posture of the set body part does not conform to the preset posture are deleted.
[0120] In the embodiment of the present disclosure, the first portrait sample whose posture of the set part of the human body does not conform to the preset posture is deleted to prevent the portrait sample from having limb distortion and reducing the quality of the training model.
[0121] In step S73, the first portrait samples whose face shapes meet the face shape conditions are retained, and the first portrait samples whose face shapes do not meet the face shape conditions are deleted.
[0122] In the embodiment of the present disclosure, the first portrait sample whose face morphology does not meet the face morphology condition is deleted to prevent the face / head distortion of the portrait sample and reduce the quality of the training model.
[0123] In step S74, the first portrait samples that meet the conditions in the first portrait sample set are arranged from large to small according to resolution, and the first portrait samples whose number of images meets the preset number are selected.
[0124] In the disclosed embodiment, the first portrait samples that meet the conditions in the first portrait sample set are arranged from large to small according to resolution, and portrait images with large resolution are preferentially selected to ensure the quality of the training model.
[0125] In the disclosed embodiment, the above-mentioned screening steps may be arbitrarily combined, for example, the electronic device performs the following operations on the portrait sample set: retain the first portrait sample whose posture of the set body part meets the preset posture, and delete the first portrait sample whose posture of the set body part does not meet the preset posture. Retain the first portrait sample whose facial morphology meets the facial morphology condition, and delete the first portrait sample whose facial morphology does not meet the facial morphology condition. Retain the first portrait sample whose facial morphology meets the facial morphology condition, and delete the first portrait sample whose facial morphology does not meet the facial morphology condition. Arrange the first portrait samples that meet the conditions in the first portrait sample set from large to small according to resolution, and select the first portrait sample whose number of images meets the preset number.
[0126] A method for obtaining a portrait training set based on the second portrait sample set is explained below.
[0127] Figure 8 is a flowchart of a method for obtaining a portrait training set based on a second portrait sample set according to an exemplary embodiment. Figure 8 As shown, the following steps are included.
[0128] In step S81, the portrait samples in the second portrait sample set are segmented into face, upper body and above-knee parts to obtain a third portrait sample set.
[0129] In the disclosed embodiment, the purpose of cutting the portrait sample model images in the second portrait sample set is to expand the data. It is understandable that the number of portrait sample sets uploaded by users is insufficient to train a high-quality model. Therefore, the quality of the training model can be improved by cutting the portrait sample sets to expand the data.
[0130] In step S82, background removal is performed on the face images and half-body images in the second portrait sample set to obtain a fourth portrait sample set.
[0131] In the disclosed embodiment, the purpose of performing background removal on the face images and half-body images in the second portrait sample set is to prevent the model from being disturbed by the portrait background when being trained with portrait data, thereby reducing the quality of the training model.
[0132] In step S83, resolution compression is performed on the portrait samples with resolutions higher than the resolution threshold in the second portrait sample set, the third portrait sample set and the fourth portrait sample set to obtain portrait samples with a preset resolution.
[0133] In the disclosed embodiment, the resolution of the user image input to the model is fixed. After the user image sample set is cut, the user image with a resolution greater than a resolution threshold needs to be compressed, and the user image with a resolution less than the resolution threshold needs to be padded.
[0134] In step S84, the portrait samples with a preset resolution are distinguished into face sample images and body sample images and stored separately to obtain a portrait training set.
[0135] In the embodiment of the present disclosure, the purpose of distinguishing face sample images and body sample images and storing them separately is that face sample images need to undergo multiple rounds of training, and the number of training times is greater than that of body sample images, so as to ensure the quality of model generation.
[0136] In the disclosed embodiment, the above steps may be combined arbitrarily, for example, the electronic device performs the following operations on the portrait sample set: for the portrait samples in the second portrait sample set, the images are cut according to the face, the upper body and the body above the knees, respectively, to obtain the third portrait sample set. The background of the face image and the half-body image in the second portrait sample set are removed to obtain the fourth portrait sample set. The resolution of the portrait samples in the second portrait sample set, the third portrait sample set and the fourth portrait sample set with a resolution higher than the resolution threshold is compressed to obtain portrait samples with a preset resolution. The face sample images and the body sample images of the portrait samples with the preset resolution are distinguished and stored separately to obtain a portrait training set.
[0137] The following is an explanation of a method for determining the label data set corresponding to the portrait samples in the portrait training set.
[0138] Fig. 9 is a flowchart of a method for determining a label data set corresponding to a portrait sample in a portrait training set according to an exemplary embodiment. Fig. 9 As shown, the following steps are included.
[0139] In step S91, an initial text description of the portrait samples in the portrait training set is generated based on the multimodal visual language model.
[0140] In step S92, the preset text included in the initial text description and the portrait samples corresponding to the preset text are screened out to obtain a label data set corresponding to the portrait samples in the portrait training set.
[0141] In the disclosed embodiment, the label data set required for model training needs corresponding text descriptions. For example, if a portrait image includes a person and blue clothes, the model will add a text description, i.e., "a person in blue clothes". However, the model will objectively perform text descriptions, and some text descriptions are not what the user wants, such as "a girl with freckles". Therefore, here, the label data set can be obtained by filtering out the text information corresponding to the preset text information through the preset text information, and combining the portrait sample.
[0142] Fig.10 FIG. 1 is a schematic diagram showing user portrait preprocessing according to an exemplary embodiment. Fig.10 As shown, the data preprocessing operation includes multiple steps. After obtaining the user portrait, it is necessary to ensure the correctness of the character, and perform character screening, face recognition, multi-person filtering, body recognition, face-to-body ratio detection, background detection and other operations on the user portrait. Among them, the purpose of character screening is to retain the same pictures as the target person and remove irrelevant people. The purpose of face recognition is to remove irrelevant people in combination with character screening. The purpose of multi-person filtering is to remove the situation where there are multiple people in the background or group photo. The purpose of body recognition is to ensure that the original picture is not just a face photo and a top photo, but to retain more images containing the human body and remove the distortion of the human body. The purpose of face-to-body ratio detection is to ensure the coordination of the face-to-body ratio in the case of blurred characters in the distance and only containing faces without human bodies in the case of head shots. The purpose of background detection is to detect the brightness and the contrast between the person and the background to ensure the clarity of the person relative to the background.
[0143] After ensuring the correctness of the user portrait, it is necessary to perform image quality screening operations on the user portrait, including image quality filtering, posture filtering, morphology filtering, image optimization and other operations. Among them, the purpose of image quality filtering is to retain images with a resolution greater than the resolution threshold, such as 512x768. Images with a resolution less than this will be forcibly deleted, and the user will be prompted with relevant instructions. The purpose of posture filtering is to perform posture recognition and remove distorted character postures. The purpose of morphology filtering is to combine posture recognition with character morphology filtering to ensure normal character morphology. The purpose of image optimization is to rename the filtered images and sort them in descending order according to high resolution to prepare for subsequent data enhancement.
[0144] After the user portrait is screened for image quality, data enhancement operations are required, including image cutting, cutout, resolution filtering and compression, and image enhancement. The purpose of image cutting is to expand the amount of user portrait data. For example, if a user uploads a full-body photo, it is mainly divided into three parts after image cutting: face, half-body, and above the knees. In this way, an original full-body image contains a total of four images. The purpose of cutout is to retain only the image of the person, and this operation is not performed on the image cut in the first step and the full-body image. This not only retains the richness of the background but also reduces the interference of the background in the detailed portrait data. The purpose of resolution filtering and compression is to filter out images below the resolution threshold (which is easily caused by cutting), and to perform resolution compression on all images that meet the requirements, compressing them to the resolution of the standard training data that reaches the resolution threshold. After the data enhancement operation, the user portrait is divided into two independent data files, the human body and the face, so that the face can be trained multiple times in the model to improve the similarity between the target image and the user. The human body data file and the face data file are collectively referred to as the picture set, that is, the image training set.
[0145] The image set after data enhancement also needs to be labeled. Among them, for the screened image data set, the image data is labeled through open source models such as Bootstrapping Language-Image Pre-training with Frozen Image Encoders and Large Language Models (BLIP2). It can be understood that BLIP 2 is an open source multimodal visual language pre-training technology that can provide zero-sample image-to-text generation capabilities for any large language model. Through open source models similar to BLIP 2, relevant text labels can be generated for the image set, but the content accuracy of the generated text labels cannot be guaranteed. Therefore, the labeling operation of the user's portrait involves a label optimization step. By comparing the preset text library, the content is filtered and the description words of some scenes are removed. For example: "blurred background, blur, spots, freckles..." and so on. The filtered text labels and the corresponding image data will be uploaded to the cloud training model as the training data of the model.
[0146] After preprocessing, the user portrait is uploaded to the cloud for training the model. The following is an explanation of a method for obtaining a virtual portrait generation model based on a labeled dataset and a portrait training set.
[0147] Fig.11 is a schematic diagram of a method for obtaining a virtual portrait generation model based on a label data set and a portrait training set according to an exemplary embodiment. Fig.11 As shown, the following steps are included.
[0148] In step S111, the first pre-trained model is called, and the second pre-trained model is trained based on the label data set and the portrait training set.
[0149] In the disclosed embodiment, the training of the virtual portrait generation model includes the training of two models, namely, the training of the first pre-trained model and the training of the second pre-trained model. The purpose of training the first pre-trained model is to enable the virtual portrait generation model to understand the background and style of the image, and to generate a variety of styles and backgrounds when generating the target image. The purpose of training the second pre-trained model using the user portrait training set is to enable the virtual portrait generation model to understand the user's characteristics, and to generate a portrait with a high degree of similarity to the user when generating the target image.
[0150] In step S112, based on the first pre-trained model and the second pre-trained model, each portrait in the portrait training set is repeatedly trained for a preset number of times based on the label data set to obtain a virtual portrait generation model.
[0151] The number of repeated training times of the face sample images is N times the number of repeated training times of the body sample images, where N is a positive integer greater than or equal to 2.
[0152] In the disclosed embodiment, the first pre-trained model and the second pre-trained model are trained by setting parameters for multiple rounds, and the first pre-trained model and the second pre-trained model with the best training quality, i.e., the highest evaluation index, are selected as virtual portrait generation models.
[0153] Fig.12 FIG. 1 is a schematic diagram showing a method for obtaining a virtual portrait generation model based on a label data set and an image training set according to an exemplary embodiment. Fig.12 As shown, the training data after data preprocessing is uploaded to the cloud for model training. Model training includes basic model selection and training, in which the basic model selection includes a personalized model, and then a personalized model selection and training is performed.
[0154] Among them, the model training method can use an open source model training method such as low-rank adaptation of large language models (LoRa). Fig.13 It is a basic principle diagram of LoRa according to an exemplary embodiment. Fig.13 In the example, x represents the dimension of the input data, d represents the value of the dimension of the input data, and the rectangle on the left represents the basic model, where the pre-trained weight is W∈R d×d , where W represents the weight matrix, R represents the matrix, and d represents the value of the data dimension. The trapezoidal part on the right represents the personalized model, and the parameter A represents the model parameter A initialized to a normal distribution, where N represents the normal distribution, σ represents the degree of dispersion of the distribution, and σ 2 Represents variance, parameter B represents model parameter B initialized to 0, r represents the dimension of personalized model, and h represents the dimension of output data. By using LoRA, the pre-trained basic model weight parameters are frozen. When the basic model parameters are frozen, additional personalized model layers are added to the model, and only these newly added personalized model parameters are trained ( Fig.13 The personalized model part on the right). Since the number of these newly added parameters is small, not only the cost of model fine-tuning is significantly reduced, but also the effect similar to full model fine-tuning can be achieved. Therefore, based on the principle of LoRa, the user's personalized data is used for training.
[0155] The basic model training can use open source models such as the Stable Diffusion model, and make large-scale adjustments to the Stable Diffusion through the real-person data set developed by the present invention. Compared with the Stable Diffusion trained by related technologies, the target image generated by the Stable Diffusion trained by the present invention is of higher quality.
[0156] The training parameters of the model can be set arbitrarily, for example: the number of repetitions of each image of the face data subset is 64, the number of repetitions of each image of the human body data itself is 48, the number of data samples captured in one training (Batch size) is set to 4, the rank of the LoRa model is 128, and the number of training rounds is 8. After the training is completed, the model with the smallest loss in the last three rounds of training is compared as the final model.
[0157] After the model is trained in the cloud, it needs to be sent to the electronic device. Among them, the personalized model and the basic model after training need to be quantized, for example, Int8 and Float16, and then sent to the electronic device. It can be understood that compared to directly sending the trained model to the device, the advantage of quantizing the trained model to Int8 and Float16 and then sending it to the electronic device is to reduce the amount of calculation and speed up the model reasoning. For example, if the model data is 1.312215454646484684, Int8 quantization is 1, which can reduce the amount of calculation. Therefore, users can receive the trained model earlier and use it.
[0158] After receiving the trained model, the electronic device displays multiple options on the display interface. A method for determining target theme parameters is explained below.
[0159] Fig.14 is a flow chart showing a method for determining target theme parameters according to an exemplary embodiment. Fig.12 As shown, the following steps are included.
[0160] In step S141, target theme parameters are determined.
[0161] In step S141A, in response to not detecting that the user has selected the custom theme parameter option, the generated and displayed text prompt information is used as the target theme parameter.
[0162] In step S141B, in response to the user selecting the custom theme parameter option, the text prompt information generated based on the theme option selected by the user is used as the target theme parameter.
[0163] In the disclosed embodiment, the user can select the default text prompt information as the target theme parameter, or customize the text information as the target theme parameter. For example, if the default text prompt information does not contain user and horse riding elements, the user can customize the text information "I ride a horse" as the target theme parameter.
[0164] The following is a schematic diagram of a personalized character generation method.
[0165] Fig.15 FIG. 1 is a schematic diagram showing a method for generating a personalized character according to an exemplary embodiment. Fig.15 As shown, after the cloud transmits the trained model to the electronic device, it needs multiple steps to generate personalized characters, including personalized model selection, personalized theme selection, model reasoning, personalized character generation and other operations. For the model sent from the cloud, the electronic device display interface first displays model parameter options and theme parameter options. The user first selects the model parameters, such as selecting the number of generated pictures to be 1-4, and the generated picture resolution to be 512, 768 or 1024. And the electronic device provides the user with a simple prompt text, such as a prompt to the user: "A man in a suit, with a city night scene as the background, full body". The content of the prompt text is limited to, for example, 50 characters, and will be combined with the prompt data of the theme parameters as the final prompt information. After selecting the model parameters, the user selects the theme parameters. The selection of personalized themes mainly includes character image, posture, clothing, background, overall environment, etc. The electronic device provides the user with customized theme parameter options. The character image can include realism, expression, etc., the posture can include full body, half body, head portrait, etc., the clothing can include suits, skirts, etc., the background can include cities, natural scenery, landscapes, etc., and the environment can include four seasons, day / night, blur, etc. The user may not select the theme parameters and only use the customized prompt text, such as "I am running on the beach". The theme parameters and prompt text selected by the user are used together as prompt information to guide the electronic device to complete the reasoning of the personalized model and generate a preliminary related character image.
[0166] In the disclosed embodiment, after the electronic device generates the personalized character image, it does not directly display it to the user, but performs post-processing operations on the personalized character image. A method for generating and displaying a target image is explained below.
[0167] The following is a flowchart of a method for generating and displaying a target image.
[0168] Fig.16 is a flowchart of a method for generating and displaying a target image according to an exemplary embodiment. Fig.16 As shown, the following steps are included.
[0169] In step S161, an initial target image is generated.
[0170] In step S162, the initial target image is optimized and the optimized target image is displayed.
[0171] In step S163, target content information is filtered out.
[0172] In step S164, image region restoration is performed.
[0173] In step S165 , a redrawing process is performed based on the user's redrawing operation.
[0174] In step S166, image enhancement processing is performed.
[0175] In the disclosed embodiment, after generating an initial target image, the electronic device filters out target content information, repairs the image area, performs redrawing operations based on the user, and performs redrawing and image enhancement operations on the initial target image, which can improve the quality of the target image and avoid user privacy exposure.
[0176] The following is an explanation of a schematic diagram of post-processing of a personalized character image.
[0177] Fig.17 is a schematic diagram showing a personalized character image post-processing according to an exemplary embodiment. After the personalized character is generated, the electronic device will not directly display the generated personalized character image to the user. It will only be displayed on the mobile phone interface after performing relevant post-processing steps, such as Fig.17 As shown. Post-processing of personalized characters requires multiple steps, including risk detection (privacy, violence, pornography), area repair, face repair, character image repair, high-definition repair and other operations, and finally generates personalized character images. For personalized characters, electronic devices need to perform risk detection to detect whether the personalized characters contain privacy, violence, pornography and other information. Risk detection is mainly controlled by prompt words in the personalized generation process. For example, the text content of the user-defined prompt words will be detected and identified through image recognition in the current step. After ensuring that the generated image is normal, it will be displayed to the user.
[0178] The electronic device performs repair operations on the personalized character after completing the risk detection, where the repair operations include regional repair, facial repair, character image repair and other operations. The purpose of regional repair is to redraw by selecting the region, and it is not applied to the face. Regional repair depends on the generation ability of the basic model and other LoRA models. The purpose of facial repair is to determine the repair area by selecting the region of the face and automatically identifying the face position (image segmentation), and to redraw the face by increasing the weight of the personalized model. The purpose of character image repair is to redraw the character by using a personalized model and adding image prompt text.
[0179] If the user is not satisfied with the personalized character image after the local area repair, he can return to the previous version for re-repair, or directly return to the personalized character generation stage. If the user is satisfied with the personalized character image after the local area repair, the electronic device performs a high-definition repair operation. That is, the low-resolution image is upsampled to generate a high-resolution image, for example, the image with a resolution of 512x768 can be upsampled to a size of 1024x1536. After personalized user data post-processing, the user can obtain a high-definition personalized character image.
[0180] It is understandable that after the user has trained the personalized model, the generation process can be performed an unlimited number of times. In addition, the number of cloud training parallels is set to a fixed threshold, such as 100 people, and those who exceed the threshold will be queued.
[0181] A method for determining whether an electronic device enables a virtual portrait generation function is explained below.
[0182] Fig.18 is a flowchart of a method for determining whether an electronic device enables a virtual portrait generation function according to an exemplary embodiment. Fig.18 As shown, the following steps are included.
[0183] In step S181, the virtual portrait generation function control in the photo album of the electronic device detects a user activation instruction.
[0184] In step S182, in response to detecting that a virtual portrait generation function control in a photo album of the electronic device is enabled, it is determined that the electronic device enables the virtual portrait generation function.
[0185] In the disclosed embodiment, the user can generate a virtual portrait by enabling a function.
[0186] The complete virtual portrait generation method is explained below.
[0187] Fig.19FIG. 1 is a schematic diagram of a method for generating a virtual portrait according to an exemplary embodiment. Fig.19 As shown, the user uploads the selected user portrait using the user album image. After the mobile phone receives the user portrait data, it performs pre-processing operations on the data to generate a training set and sends it to the cloud for model training. The trained model is quantized in the cloud and sent to the mobile phone. After the mobile phone receives the trained model, a variety of theme parameter options and model parameter options are displayed on the mobile phone display interface for the user to choose. The mobile phone performs model inference based on the personalized parameters such as theme parameters and model parameters selected by the user to generate the initial character image, and then performs post-processing operations including privacy detection and area repair on the character image to generate the final personalized character image. In the process of generating personalized character images, the user is allowed to repeat the operation multiple times until the expected image is generated.
[0188] In the disclosed embodiments, more realistic and natural images can be generated, more complex scenes and details can be processed, and more natural character postures, expressions, lighting, etc. can be generated.
[0189] In the disclosed embodiment, through dual privacy detection of prompt words and images, effective privacy protection can be performed, which can prevent portrait images from being used for illegal purposes and protect the legal rights of the person, such as the portrait right and privacy right.
[0190] In the disclosed embodiment, by combining cloud training with local reasoning, higher quality images can be generated in a shorter time, while saving computing resources and environmental resources, and fully utilizing the edge computing capabilities of electronic devices to improve resource utilization.
[0191] In the disclosed embodiments, the generated image can be automatically adjusted according to the user's needs and scenarios, and the generation algorithm can be continuously optimized according to the user's feedback and evaluation.
[0192] In the disclosed embodiment, a variety of image style options and model options are provided for users to choose from, which has a wider range of application scenarios, meets the creative needs of users, and allows users to generate their favorite images without leaving home, bringing more convenience and innovation to people.
[0193] Based on the same concept, the embodiment of the present disclosure also provides a virtual portrait generating device.
[0194] It is understandable that in order to realize the above functions, the virtual portrait generation device provided by the embodiment of the present disclosure includes hardware structures and / or software modules corresponding to the execution of each function. In combination with the units and algorithm steps of each example disclosed in the embodiment of the present disclosure, the embodiment of the present disclosure can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the technical solution of the embodiment of the present disclosure.
[0195] Fig. 20 FIG. 1 is a block diagram of a virtual portrait generating device 100 according to an exemplary embodiment. Fig. 20 The device 100 includes a receiving unit 101 and a processing unit 102.
[0196] A receiving unit 101 is used to obtain target model parameters and target theme parameters selected by a user based on template parameter options;
[0197] The processing unit 102 is used to display template parameter options in response to determining that the electronic device enables the virtual portrait generation function, the template parameter options including model parameter options and subject parameter options, the subject parameter options are used to determine text prompt information, the text prompt information is used to prompt the image subject information of the target virtual portrait to be generated, and the model parameter options are used to describe the image attribute information of the target virtual portrait to be generated; based on the target model parameters and the target subject parameters, call the virtual portrait generation model, wherein different virtual portrait generation models correspond to different template parameter options; based on the target model, generate and display the target virtual portrait, and the target virtual portrait matches the target model parameters and the target subject parameters.
[0198] In the embodiment of the present disclosure, the processing unit 102 is configured to obtain a portrait sample set selected by a user; preprocess the portrait sample set to obtain a portrait training set; determine a label data set corresponding to the portrait samples in the portrait training set, the label data set including text prompt information corresponding to the portrait samples; and train a virtual portrait generation model based on the label data set and the portrait training set.
[0199] In the embodiment of the present disclosure, the processing unit 102 is configured to provide an image selection path in response to detecting that a user triggers a selection operation of a portrait sample set; and obtain a portrait selected by the user based on the image selection path to obtain a portrait sample set.
[0200] In the embodiment of the present disclosure, the processing unit 102 is configured to screen portrait samples including a target portrait in the portrait sample set to obtain a first portrait sample set; and obtain a portrait training set based on the first portrait sample set.
[0201] In the embodiment of the present disclosure, the processing unit 102 is configured to perform face recognition on the portrait samples in the portrait sample set to obtain a target portrait; delete portrait samples of other portraits different from the target portrait; delete portrait samples including the target portrait and other portraits; retain portrait samples including at least faces and bodies; retain portrait samples whose body morphology meets the morphological conditions, and delete portrait samples whose body morphology does not meet the morphological conditions; retain portrait samples whose ratio between faces and bodies meets the ratio conditions, and delete portrait samples whose ratio between faces and bodies does not meet the ratio conditions; retain portrait samples whose contrast between portraits and backgrounds meets the contrast conditions, and delete portrait samples whose contrast between portraits and backgrounds does not meet the contrast conditions; in response to the number of portrait samples being lower than a preset number, prompt the user to reselect portrait samples to obtain portrait samples whose number of images meets the preset number.
[0202] In the embodiment of the present disclosure, the processing unit 102 is configured to select portrait samples that meet the image quality condition in the first portrait sample set to obtain a second portrait sample set; and obtain a portrait training set based on the second portrait sample set.
[0203] In the disclosed embodiment, the processing unit 102 is configured to retain the first portrait sample whose image resolution is greater than the resolution threshold, and delete the first portrait sample whose image resolution is less than or equal to the resolution threshold; retain the first portrait sample whose posture of the set part of the human body meets the preset posture, and delete the first portrait sample whose posture of the set part of the human body does not meet the preset posture; retain the first portrait sample whose facial morphology meets the facial morphology conditions, and delete the first portrait sample whose facial morphology does not meet the facial morphology conditions; arrange the first portrait samples that meet the conditions in the first portrait sample set from large to small according to resolution, and select the first portrait samples whose number of images meets the preset number.
[0204] In the disclosed embodiment, the processing unit 102 is configured to perform image segmentation on the portrait samples in the second portrait sample set according to the face, upper body and above-knee images, respectively, to obtain a third portrait sample set; perform background removal on the face images and half-body images in the second portrait sample set, to obtain a fourth portrait sample set; perform resolution compression on the portrait samples with a resolution higher than a resolution threshold in the second portrait sample set, the third portrait sample set and the fourth portrait sample set, to obtain portrait samples with a preset resolution; distinguish between face sample images and body sample images of the portrait samples with the preset resolution and store them separately, to obtain a portrait training set.
[0205] In the embodiment of the present disclosure, the processing unit 102 is configured to generate an initial text description of the portrait samples in the portrait training set based on the multimodal visual language model; filter out the preset text included in the initial text description, and the portrait samples corresponding to the preset text, to obtain a label data set corresponding to the portrait samples in the portrait training set.
[0206] In the disclosed embodiment, the processing unit 102 is configured to call a first pre-trained model, and train a second pre-trained model based on a label data set and a portrait training set; based on the first pre-trained model and the second pre-trained model, each portrait in the portrait training set is repeatedly trained a preset number of times based on the label data set to obtain a virtual portrait generation model; wherein the number of repeated training times of the face sample image is N times the number of repeated training times of the body sample image, and N is a positive integer greater than or equal to 2.
[0207] In the disclosed embodiment, the processing unit 102 is configured to, in response to not detecting that the user has selected a custom theme parameter option, use the generated and displayed text prompt information as the target theme parameter; or in response to the user selecting a custom theme parameter option, use the text prompt information generated based on the theme option selected by the user as the target theme parameter.
[0208] In the embodiment of the present disclosure, the processing unit 102 is configured to generate an initial target image; optimize the initial target image and display the optimized target image; the optimization process includes at least one of the following: filtering out target content information; image area repair; redrawing based on the user's redrawing operation; image enhancement.
[0209] In the embodiment of the present disclosure, the processing unit 102 is configured to determine whether the electronic device enables the virtual portrait generation function in response to detecting that a virtual portrait generation function control in a photo album of the electronic device is enabled.
[0210] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0211] Fig.21 1 is a block diagram of a device 200 for generating a virtual portrait according to an exemplary embodiment. For example, the device 200 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0212] Reference Fig.21, the device 200 may include one or more of the following components: a processing component 202 , a memory 204 , a power component 206 , a multimedia component 208 , an audio component 210 , an input / output (I / O) interface 212 , a sensor component 214 , and a communication component 216 .
[0213] The processing component 202 generally controls the overall operation of the device 200, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 202 may include one or more processors 220 to execute instructions to perform all or part of the steps of the above-described method. In addition, the processing component 202 may include one or more modules to facilitate interaction between the processing component 202 and other components. For example, the processing component 202 may include a multimedia module to facilitate interaction between the multimedia component 208 and the processing component 202.
[0214] The memory 204 is configured to store various types of data to support operations on the device 200. Examples of such data include instructions for any application or method operating on the device 200, contact data, phone book data, messages, pictures, videos, etc. The memory 204 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0215] The power component 206 provides power to the various components of the device 200. The power component 206 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 200.
[0216] The multimedia component 208 includes a screen that provides an output interface between the device 200 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 208 includes a front camera and / or a rear camera. When the device 200 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0217] The audio component 210 is configured to output and / or input audio signals. For example, the audio component 210 includes a microphone (MIC), and when the device 200 is in an operation mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 204 or sent via the communication component 216. In some embodiments, the audio component 210 also includes a speaker for outputting audio signals.
[0218] I / O interface 212 provides an interface between processing component 202 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0219] The sensor assembly 214 includes one or more sensors for providing various aspects of the status assessment of the device 200. For example, the sensor assembly 214 can detect the open / closed state of the device 200, the relative positioning of components, such as the display and keypad of the device 200, the sensor assembly 214 can also detect the position change of the device 200 or a component of the device 200, the presence or absence of user contact with the device 200, the orientation or acceleration / deceleration of the device 200 and the temperature change of the device 200. The sensor assembly 214 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 214 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 214 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor or a temperature sensor.
[0220] The communication component 216 is configured to facilitate wired or wireless communication between the device 200 and other devices. The device 200 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 216 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 216 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0221] In an exemplary embodiment, the apparatus 200 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to perform the above method.
[0222] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 204 including instructions, and the instructions can be executed by the processor 220 of the device 200 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0223] It is to be understood that in the present disclosure, "plurality" refers to two or more than two, and other quantifiers are similar. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. The singular forms "a", "the" and "the" are also intended to include plural forms, unless the context clearly indicates other meanings.
[0224] It is further understood that the terms "first", "second", etc. are used to describe various information, but such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other, and do not indicate a specific order or degree of importance. In fact, the expressions "first", "second", etc. can be used interchangeably. For example, without departing from the scope of the present disclosure, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as the first information.
[0225] It can be further understood that, unless otherwise specified, “connection” includes a direct connection without other components between the two, and also includes an indirect connection with other components between the two.
[0226] It is further understood that, although the operations are described in a specific order in the drawings in the embodiments of the present disclosure, it should not be understood as requiring the operations to be performed in the specific order shown or in a serial order, or requiring the execution of all the operations shown to obtain the desired results. In certain environments, multitasking and parallel processing may be advantageous.
[0227] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any modifications, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure.
[0228] It should be understood that the present disclosure is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the scope of the appended claims.
Claims
1. A method for generating a virtual portrait, characterized in that: include: In response to determining that the electronic device enables the virtual portrait generation function, displaying template parameter options, the template parameter options including model parameter options and theme parameter options, the theme parameter options are used to determine text prompt information, the text prompt information is used to prompt image theme information of the target virtual portrait to be generated, and the model parameter options are used to describe image attribute information of the target virtual portrait to be generated; Obtaining target model parameters and target theme parameters selected by the user based on the template parameter options; Based on the target model parameters and the target subject parameters, calling a virtual portrait generation model, wherein different virtual portrait generation models correspond to different template parameter options; Based on the target model, a target virtual portrait is generated and displayed, and the target virtual portrait matches the target model parameters and the target subject parameters.
2. The method according to claim 1, characterized in that The virtual portrait generation model is pre-trained in the following manner: Obtain a sample set of portraits selected by the user; Preprocessing the portrait sample set to obtain a portrait training set; Determine a label data set corresponding to the portrait sample in the portrait training set, wherein the label data set includes text prompt information corresponding to the portrait sample; Based on the label data set and the portrait training set, a virtual portrait generation model is trained.
3. The method according to claim 2, characterized in that The step of obtaining a portrait sample set selected by a user includes: In response to detecting that a user triggers a selection operation of a portrait sample set, providing an image selection path; The portrait selected by the user based on the image selection path is obtained to obtain a portrait sample set.
4. The method according to claim 2, characterized in that: The preprocessing of the portrait sample set to obtain a portrait training set includes: Selecting portrait samples including a target portrait from the portrait sample set to obtain a first portrait sample set; A portrait training set is obtained based on the first portrait sample set.
5. The method according to claim 4, characterized in that At least one of the following methods is adopted to select portrait samples including the target portrait in the portrait sample set to obtain a first portrait sample set: Perform face recognition on the portrait samples in the portrait sample set to obtain the target portrait; Delete portrait samples of other portraits that are different from the target portrait; Delete portrait samples including the target portrait and other portraits; Retain portrait samples that include at least faces and bodies; Keep the portrait samples whose human body shape meets the morphological conditions, and delete the portrait samples whose human body shape does not meet the morphological conditions; Keep the portrait samples whose face-to-body ratio meets the ratio condition, and delete the portrait samples whose face-to-body ratio does not meet the ratio condition; Keep the portrait samples whose contrast between the portrait and the background meets the contrast condition, and delete the portrait samples whose contrast between the portrait and the background does not meet the contrast condition; In response to the number of portrait samples being lower than a preset number, the user is prompted to reselect portrait samples to obtain portrait samples whose image number meets the preset number.
6. The method according to claim 4 or 5, characterized in that: The obtaining of a portrait training set based on the first portrait sample set comprises: Selecting portrait samples that meet the image quality requirement from the first portrait sample set to obtain a second portrait sample set; A portrait training set is obtained based on the second portrait sample set.
7. The method according to claim 6, characterized in that At least one of the following methods is used to select portrait samples that meet the image quality requirement from the first portrait sample set: retain the first portrait sample whose image resolution is greater than the resolution threshold, and delete the first portrait sample whose image resolution is less than or equal to the resolution threshold; retaining the first portrait sample whose posture of the set part of the human body conforms to the preset posture, and deleting the first portrait sample whose posture of the set part of the human body does not conform to the preset posture; retaining the first portrait sample whose face shape meets the face shape condition, and deleting the first portrait sample whose face shape does not meet the face shape condition; The first portrait samples that meet the conditions in the first portrait sample set are arranged from large to small according to resolution, and the first portrait samples whose image quantity meets the preset quantity are selected.
8. The method according to claim 6, characterized in that The obtaining of a portrait training set based on the second portrait sample set comprises: For the portrait samples in the second portrait sample set, image segmentation is performed according to the face, the upper body, and the body above the knees, respectively, to obtain a third portrait sample set; Perform background removal on the face images and half-body images in the second portrait sample set to obtain a fourth portrait sample set; performing resolution compression on portrait samples having resolutions higher than a resolution threshold in the second portrait sample set, the third portrait sample set, and the fourth portrait sample set to obtain portrait samples with a preset resolution; The portrait samples with a preset resolution are distinguished into face sample images and body sample images, and stored separately to obtain a portrait training set.
9. The method according to claim 2, characterized in that: Determining the label data set corresponding to the portrait samples in the portrait training set includes: Based on the multimodal visual language model, generating an initial text description of the portrait samples in the portrait training set; The preset text included in the initial text description and the portrait samples corresponding to the preset text are screened out to obtain a label data set corresponding to the portrait samples in the portrait training set.
10. The method according to claim 2, characterized in that The step of training a virtual portrait generation model based on the label data set and the portrait training set includes: Calling the first pre-trained model, and training the second pre-trained model based on the label data set and the portrait training set; Based on the first pre-trained model and the second pre-trained model, repeatedly training each portrait in the portrait training set based on the label data set for a preset number of times to obtain a virtual portrait generation model; The number of repeated training times of the face sample images is N times the number of repeated training times of the body sample images, where N is a positive integer greater than or equal to 2.
11. The method according to claim 1, characterized in that: The theme parameter options include a default theme parameter option and a custom theme parameter option, wherein the default theme parameter option is text prompt information that has been generated and displayed, and the custom theme parameter option includes a plurality of theme options for generating text prompt information for the user to select; The target theme parameters are determined in the following manner: In response to not detecting that the user has selected the custom theme parameter option, using the generated and displayed text prompt information as the target theme parameter; or In response to the user selecting the custom theme parameter option, the text prompt information generated based on the theme option selected by the user is used as the target theme parameter.
12. The method according to claim 1, characterized in that The generating and displaying of the target image comprises: Generate an initial target image; Optimizing the initial target image and displaying the optimized target image; The optimization process includes at least one of the following: Filter out target content information; Image region restoration; Perform redrawing based on the user's redrawing operation; Image enhancement processing.
13. The method according to claim 1, characterized in that The step of determining that the electronic device enables the virtual portrait generation function includes: In response to detecting that a virtual portrait generation function control in a photo album of the electronic device is enabled, it is determined that the electronic device enables the virtual portrait generation function.
14. A virtual portrait generating device, characterized in that: The device comprises: A receiving unit, configured to obtain target model parameters and target theme parameters selected by a user based on the template parameter options; A processing unit is used to, in response to determining that the electronic device enables a virtual portrait generation function, display template parameter options, the template parameter options including model parameter options and subject parameter options, the subject parameter options being used to determine text prompt information, the text prompt information being used to prompt image subject information of a target virtual portrait to be generated, and the model parameter options being used to describe image attribute information of the target virtual portrait to be generated; based on the target model parameters and the target subject parameters, call a virtual portrait generation model, wherein different virtual portrait generation models correspond to different template parameter options; based on the target model, generate and display a target virtual portrait, the target virtual portrait matching the target model parameters and the target subject parameters.
15. The device according to claim 14, characterized in that The processing unit pre-trains the virtual portrait generation model in the following manner: Obtain a sample set of portraits selected by the user; Preprocessing the portrait sample set to obtain a portrait training set; Determine a label data set corresponding to the portrait sample in the portrait training set, wherein the label data set includes text prompt information corresponding to the portrait sample; Based on the label data set and the portrait training set, a virtual portrait generation model is trained.
16. The device according to claim 15, characterized in that The processing unit obtains the portrait sample set selected by the user in the following manner: In response to detecting that a user triggers a selection operation of a portrait sample set, providing an image selection path; The portrait selected by the user based on the image selection path is obtained to obtain a portrait sample set.
17. The device according to claim 15, characterized in that The processing unit pre-processes the portrait sample set in the following manner to obtain a portrait training set: Selecting portrait samples including a target portrait from the portrait sample set to obtain a first portrait sample set; A portrait training set is obtained based on the first portrait sample set.
18. The device according to claim 17, characterized in that The processing unit selects portrait samples including the target portrait in the portrait sample set to obtain a first portrait sample set by using at least one of the following methods: Perform face recognition on the portrait samples in the portrait sample set to obtain the target portrait; Delete portrait samples of other portraits that are different from the target portrait; Delete portrait samples including the target portrait and other portraits; Retain portrait samples that include at least faces and bodies; Keep the portrait samples whose human body shape meets the morphological conditions, and delete the portrait samples whose human body shape does not meet the morphological conditions; Keep the portrait samples whose face-to-body ratio meets the ratio condition, and delete the portrait samples whose face-to-body ratio does not meet the ratio condition; Keep the portrait samples whose contrast between the portrait and the background meets the contrast condition, and delete the portrait samples whose contrast between the portrait and the background does not meet the contrast condition; In response to the number of portrait samples being lower than a preset number, the user is prompted to reselect portrait samples to obtain portrait samples whose image number meets the preset number.
19. The device according to claim 17 or 18, characterized in that The processing unit obtains a portrait training set based on the first portrait sample set in the following manner: Selecting portrait samples that meet the image quality requirement from the first portrait sample set to obtain a second portrait sample set; A portrait training set is obtained based on the second portrait sample set.
20. The device according to claim 19, characterized in that The processing unit selects portrait samples that meet the image quality condition from the first portrait sample set by using at least one of the following methods: retain the first portrait sample whose image resolution is greater than the resolution threshold, and delete the first portrait sample whose image resolution is less than or equal to the resolution threshold; retaining the first portrait sample whose posture of the set part of the human body conforms to the preset posture, and deleting the first portrait sample whose posture of the set part of the human body does not conform to the preset posture; retaining the first portrait sample whose face shape meets the face shape condition, and deleting the first portrait sample whose face shape does not meet the face shape condition; The first portrait samples that meet the conditions in the first portrait sample set are arranged from large to small according to resolution, and the first portrait samples whose image quantity meets the preset quantity are selected.
21. The device according to claim 19, characterized in that The processing unit obtains a portrait training set based on the second portrait sample set in the following manner: For the portrait samples in the second portrait sample set, image segmentation is performed according to the face, the upper body, and the body above the knees, respectively, to obtain a third portrait sample set; Perform background removal on the face images and half-body images in the second portrait sample set to obtain a fourth portrait sample set; performing resolution compression on portrait samples having resolutions higher than a resolution threshold in the second portrait sample set, the third portrait sample set, and the fourth portrait sample set to obtain portrait samples with a preset resolution; The face sample images and the body sample images with preset resolution are distinguished and stored separately to obtain a portrait training set.
22. The device according to claim 15, characterized in that The processing unit determines the label data set corresponding to the portrait samples in the portrait training set in the following manner: Based on the multimodal visual language model, generating an initial text description of the portrait samples in the portrait training set; The preset text included in the initial text description and the portrait samples corresponding to the preset text are screened out to obtain a label data set corresponding to the portrait samples in the portrait training set.
23. The device according to claim 15, characterized in that The processing unit trains a virtual portrait generation model based on the label data set and the portrait training set in the following manner: Calling the first pre-trained model, and training the second pre-trained model based on the label data set and the portrait training set; Based on the first pre-trained model and the second pre-trained model, repeatedly training each portrait in the portrait training set based on the label data set for a preset number of times to obtain a virtual portrait generation model; The number of repeated training times of the face sample images is N times the number of repeated training times of the body sample images, where N is a positive integer greater than or equal to 2.
24. The device according to claim 1, characterized in that The processing unit uses the following method to process the theme parameter options, including a default theme parameter option and a custom theme parameter option, wherein the default theme parameter option is text prompt information that has been generated and displayed, and the custom theme parameter option includes a plurality of theme options for generating text prompt information for selection by the user; The target theme parameters are determined in the following manner: In response to not detecting that the user has selected the custom theme parameter option, using the generated and displayed text prompt information as the target theme parameter; or In response to the user selecting the custom theme parameter option, the text prompt information generated based on the theme option selected by the user is used as the target theme parameter.
25. The device according to claim 14, characterized in that The processing unit generates and displays the target image in the following manner: Generate an initial target image; Optimizing the initial target image and displaying the optimized target image; The optimization process includes at least one of the following: Filter out target content information; Image region restoration; Perform redrawing based on the user's redrawing operation; Image enhancement processing.
26. The method according to claim 14, characterized in that The processing unit determines that the electronic device enables the virtual portrait generation function in the following manner: In response to detecting that a virtual portrait generation function control in a photo album of the electronic device is enabled, it is determined that the electronic device enables the virtual portrait generation function.
27. A virtual portrait generation device, characterized in that: include: processor; a memory for storing processor-executable instructions; Wherein, the processor is configured to: execute the virtual portrait generation method described in any one of claims 1 to 13.
28. A storage medium, characterized in that: The storage medium stores instructions, and when the instructions in the storage medium are executed by a processor of the terminal, the terminal is enabled to execute the virtual portrait generation method described in any one of claims 1 to 13.