Method and device for improving definition of face image
1. A method for improving the definition of a face image is characterized by comprising the following steps:
acquiring a face image with definition to be improved;
and inputting the face image into a model trained by degradation operation to obtain the face image with improved definition.
2. The method of claim 1, wherein: the training step of the model trained by the degeneration operation comprises:
acquiring a high-definition picture of a training face image;
carrying out degradation operation on the training face image to obtain a low-definition picture;
inputting the low-definition picture into a pre-constructed convolutional neural network model to obtain a generated picture;
calculating the loss between the generated picture and the high-definition picture;
judging whether the loss is converged;
if not, optimizing the parameters of the convolutional neural network model by adopting an adaptive moment estimation algorithm;
and repeating the steps until the loss is converged and the definition of the generated image meets the requirement, and storing the parameters of the convolutional neural network model to obtain a model trained by the degeneration operation.
3. The method of claim 1, wherein: the degeneration operation comprises the steps of:
performing fuzzy operation with 50% probability;
performing noise adding operation with the probability of 20%;
JPEG compression operation with a probability of 70%;
and carrying out zooming operation until the picture length and width are 1/4 sizes of the length and width of the high-definition picture respectively.
4. The method of claim 2, further comprising:
inputting the high-definition picture into a pre-constructed multilayer discrimination model to obtain a first probability that the high-definition picture is true;
inputting the generated picture into the multilayer discrimination model to obtain a second probability that the generated picture is false;
respectively calculating the first probability and the second probability and the loss of 1 by using a Hinge loss function, and summing the two calculated losses to obtain a loss sum;
judging whether the loss and convergence occur;
if not, optimizing the parameters of the multilayer discrimination model by adopting a self-adaptive moment estimation algorithm;
and repeating the steps until the loss and the convergence are achieved, and storing the multilayer discriminant model at the moment.
5. The method of claim 1, wherein: inputting the face image into a model trained by degradation operation to obtain a face image with improved definition, wherein the method comprises the following steps:
preprocessing the face image to obtain an original noise-reduction face image only containing a face;
and inputting the original noise-reduced face image into the model.
6. The method of claim 5, wherein: the preprocessing the face image to obtain an original noise-reduced face image only containing a face comprises:
inputting the face image into a pre-constructed face recognition model to obtain face data, wherein the face data comprises positions of a face frame, a left eye, a right eye, a nose tip, a left mouth corner and a right mouth corner;
cutting the face image according to the face data to obtain an original face image;
carrying out face selection alignment operation on the original face image to obtain an original aligned face image;
carrying out scaling operation on the original alignment image by using a cubic interpolation algorithm to obtain an original scaled face image with the size of 128x 128;
and carrying out noise reduction operation on the original scaled face image to obtain an original noise-reduced face image.
7. The method of claim 6, further comprising:
inputting the original noise-reduced face image into the model to obtain a high-definition noise-reduced face image;
preprocessing the high-definition noise-reduction face image to obtain a high-definition face image;
and fusing the high-definition face image into the face image to obtain a final image.
8. The method of claim 7, wherein: the preprocessing of the high-definition noise-reduction face image to obtain a high-definition face image comprises the following steps:
carrying out scaling operation on the high-definition noise-reduction face image by using a cubic interpolation algorithm to obtain a high-definition scaling face image with the size consistent with that of the original face image;
and carrying out rotation reduction operation on the high-definition face image to obtain a high-definition face image, wherein the position of the face in the high-definition face image is consistent with the position of the face in the original face image.
9. The method of claim 7, wherein: the step of fusing the high-definition face image into the face image to obtain a final image comprises:
inputting the high-definition face image into a pre-constructed portrait segmentation model to obtain a high-definition face mask image;
carrying out corrosion, expansion and fuzzy operations on the high-definition face mask image to obtain a high-definition face feathering mask image;
and taking the pixel value in the high-definition face feathering mask image as a weight, and fusing the high-definition face image into the face image to obtain a final image.
10. A human face image definition improving device is characterized by comprising:
the face image acquisition module is used for acquiring a face image with definition to be improved;
and the human face image input module is used for inputting the human face image into the model trained by the degradation operation to obtain the human face image with improved definition.
Background
In the current picture editing application for improving the definition of the photos in the market, a user can input the photos to improve the definition of the photos. However, when the sharpness of the picture is improved, the effect of the used method on the face image is relatively general. The traditional method carries out targeted optimization on a face image, only simple noise reduction operation can be carried out, the face has heavy smearing sense while noise reduction is carried out, a large amount of face details are lost, and the improvement effect of definition is poor.
Disclosure of Invention
In order to overcome the defects of the prior art, the invention provides a method and a device for improving the definition of a face image, and aims to solve the problems that the traditional method for improving the definition of a face photo enables the face to have a heavy smearing sense, a large amount of face details are lost, and the improvement effect of the definition is poor.
The technical scheme adopted by the invention for solving the technical problems is as follows:
on the one hand, the method comprises the following steps of,
a method for improving the definition of a face image comprises the following steps:
acquiring a face image with definition to be improved;
and inputting the face image into a model trained by degradation operation to obtain the face image with improved definition.
Further, the training step of the model trained by the degeneration operation includes:
acquiring a high-definition picture of a training face image;
carrying out degradation operation on the training face image to obtain a low-definition picture;
inputting the low-definition picture into a pre-constructed convolutional neural network model to obtain a generated picture;
calculating the loss between the generated picture and the high-definition picture;
judging whether the loss is converged;
if not, optimizing the parameters of the convolutional neural network model by adopting an adaptive moment estimation algorithm;
and repeating the steps until the loss is converged and the definition of the generated image meets the requirement, and storing the parameters of the convolutional neural network model to obtain a model trained by the degeneration operation.
Further, the degeneration operation comprises the steps of:
performing fuzzy operation with 50% probability;
performing noise adding operation with the probability of 20%;
JPEG compression operation with a probability of 70%;
and carrying out zooming operation until the picture length and width are 1/4 sizes of the length and width of the high-definition picture respectively.
Further, still include:
inputting the high-definition picture into a pre-constructed multilayer discrimination model to obtain a first probability that the high-definition picture is true;
inputting the generated picture into the multilayer discrimination model to obtain a second probability that the generated picture is false;
respectively calculating the first probability and the second probability and the loss of 1 by using a Hinge loss function, and summing the two calculated losses to obtain a loss sum;
judging whether the loss and convergence occur;
if not, optimizing the parameters of the multilayer discrimination model by adopting a self-adaptive moment estimation algorithm;
and repeating the steps until the loss and the convergence are achieved, and storing the multilayer discriminant model at the moment.
Further, inputting the face image into a model trained by a degeneration operation to obtain a face image with improved definition comprises:
preprocessing the face image to obtain an original noise-reduction face image only containing a face;
and inputting the original noise-reduced face image into the model.
Further, the preprocessing the face image to obtain an original noise-reduced face image only including a face includes:
inputting the face image into a pre-constructed face recognition model to obtain face data, wherein the face data comprises positions of a face frame, a left eye, a right eye, a nose tip, a left mouth corner and a right mouth corner;
cutting the face image according to the face data to obtain an original face image;
carrying out face selection alignment operation on the original face image to obtain an original aligned face image;
carrying out scaling operation on the original alignment image by using a cubic interpolation algorithm to obtain an original scaled face image with the size of 128x 128;
and carrying out noise reduction operation on the original scaled face image to obtain an original noise-reduced face image.
Further, the original noise-reduced face image is input into the model to obtain a high-definition noise-reduced face image;
preprocessing the high-definition noise-reduction face image to obtain a high-definition face image;
and fusing the high-definition face image into the face image to obtain a final image.
Further, the preprocessing the high-definition noise-reduction face image to obtain a high-definition face image includes:
carrying out scaling operation on the high-definition noise-reduction face image by using a cubic interpolation algorithm to obtain a high-definition scaling face image with the size consistent with that of the original face image;
and carrying out rotation reduction operation on the high-definition face image to obtain a high-definition face image, wherein the position of the face in the high-definition face image is consistent with the position of the face in the original face image.
Further, the fusing the high-definition face image into the face image to obtain a final image includes:
inputting the high-definition face image into a pre-constructed portrait segmentation model to obtain a high-definition face mask image;
carrying out corrosion, expansion and fuzzy operations on the high-definition face mask image to obtain a high-definition face feathering mask image;
and taking the pixel value in the high-definition face feathering mask image as a weight, and fusing the high-definition face image into the face image to obtain a final image.
On the other hand, in the case of a liquid,
a human face image definition improving device comprises:
the face image acquisition module is used for acquiring a face image with definition to be improved;
and the human face image input module is used for inputting the human face image into the model trained by the degradation operation to obtain the human face image with improved definition.
This application adopts above technical scheme, possesses following beneficial effect at least:
according to the method and the device for improving the definition of the face image, after the face image with the definition to be improved is obtained, the face image is input into a model trained through degradation operation to obtain the face image with the improved definition. Because the model is subjected to degradation operation training, namely, the originally clear image is processed into the image with low definition, and then the image with low definition is used as a training sample to obtain the clear image, so that the definition of the face image can be greatly improved after the face image with the definition to be improved is input into the model.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart of a method for improving sharpness of a face image according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of model training trained by degenerate operation according to an embodiment of the present invention;
fig. 3 is a schematic diagram of a low-definition picture obtained after a high-definition picture degradation operation according to an embodiment of the present invention;
fig. 4 is a specific implementation manner of improving the definition of a face image according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of a device for improving the sharpness of a face image according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the following detailed description of the technical solutions of the present invention is provided with reference to the accompanying drawings and examples. It is to be understood that the embodiments described are only a few embodiments of the present application and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the examples given herein without making any creative effort, shall fall within the protection scope of the present application.
Referring to fig. 1, an embodiment of the present invention provides a method for improving a sharpness of a face image, including the following steps:
acquiring a face image with definition to be improved;
and inputting the face image into the model trained by the degradation operation to obtain the face image with improved definition.
According to the method for improving the definition of the face image, provided by the embodiment of the invention, after the face image with the definition to be improved is obtained, the face image is input into a model trained through degradation operation to obtain the face image with the improved definition. Because the model is subjected to degradation operation training, namely, the originally clear image is processed into the image with low definition, and then the image with low definition is used as a training sample to obtain the clear image, so that the definition of the face image can be greatly improved after the face image with the definition to be improved is input into the model.
As a supplementary explanation to the above-described embodiment, the training step of the model trained by the degeneration operation includes:
acquiring a high-definition picture of a training face image; specifically, a face picture is randomly selected from the FFHQ data set, the size of the face picture is scaled to 512x512, and the face picture is subjected to gray scale operation with the probability of 30% to obtain a high-definition picture. Among them, FFHQ is collectively called Flickr-Faces-High-Quality (Flickr-Faces-HQ), and was originally created as a reference for a generative countermeasure network (GAN), and training data set used for StyleGAN was also developed in 2019 by england. The FFHQ is a high-quality face data set, comprises 70000 PNG format high-definition face images with 1024 × 1024 resolutions, is rich and diverse in age, race and image background, has obvious difference, also has very many changes in face attributes, has different ages, sexes, races, skin colors, expressions, facial forms, hair styles, face postures and the like, covers various face peripheral accessories such as common glasses, sunglasses, hats, hair accessories, scarves and the like, and therefore, the data set can be used for developing face attribute classification or face semantic segmentation models.
Carrying out degradation operation on the training face image to obtain a low-definition picture; wherein the degeneration operation comprises the steps of:
(1) performing fuzzy operation with 50% probability;
(2) performing noise adding operation with the probability of 20%;
(3) JPEG compression operation with a probability of 70%;
(4) and performing zooming operation until the picture length and width are 1/4 sizes which are the length and width of the high-definition picture respectively.
Inputting the low-definition picture into a pre-constructed convolutional neural network model to obtain a generated picture; it should be noted that the parameters of the pre-constructed convolutional neural network model are initialized by using a kaiming initialization method to generate the parameters of the model. The kaiming initialization is a weight initialization method commonly used in the training of convolutional neural networks, and is not described in detail here.
Calculating the loss between the generated picture and the high-definition picture; specifically, the loss between the generated picture and the high-definition picture is calculated by using a cross entropy loss function.
Judging whether the loss is converged;
if not, optimizing the parameters of the convolutional neural network model by adopting an adaptive moment estimation algorithm;
and repeating the steps until the loss is converged and the definition of the generated image meets the requirement, and storing the parameters of the convolutional neural network model to obtain a model trained by the degeneration operation. It can be understood that the loss is not completely decreased, but is a shaking and descending process, the process is trained to a state that the loss tends to fluctuate up and down, meanwhile, the effect is not necessarily in accordance with the requirement, and the effect is required to be observed artificially at variable time.
As an optional implementation manner of the embodiment of the present invention, the method further includes:
inputting the high-definition picture into a pre-constructed multilayer discrimination model to obtain a first probability that the high-definition picture is true;
inputting the generated picture into a multilayer discrimination model to obtain a second probability that the generated picture is false;
respectively calculating the first probability and the second probability and the loss of 1 by using a Hinge loss function, and summing the two calculated losses to obtain a loss sum;
judging whether the loss and convergence occur;
if not, optimizing parameters of the multilayer discrimination model by adopting an adaptive moment estimation algorithm;
and repeating the steps until loss and convergence are achieved, and storing the multilayer discriminant model at the moment.
The multilayer discrimination model is used for judging whether a generated picture is the same as a high-definition picture, and in the field of machine learning, the discrimination model is a method for modeling the relation between unknown data y and known data x. The discriminant model is a method based on probability theory. Knowing the input variable x, the discriminant model predicts y by constructing a conditional probability distribution P (y | x). In the application, the high-definition picture is really known data, and the generated picture is fake unknown data. Because the parameters of the multi-level discrimination model constructed at the beginning are not accurate, the multi-level discrimination model needs to be updated and adjusted for many times.
In the actual operation process, the step of inputting the face image into the model trained by the degradation operation to obtain the face image with improved definition comprises the following steps:
preprocessing the face image to obtain an original noise-reduction face image only containing a face; specifically, a face image is input into a pre-constructed face recognition model to obtain face data, wherein the face data comprises positions of a face frame, a left eye, a right eye, a nose tip, a left mouth corner and a right mouth corner;
cutting the face image according to the face data to obtain an original face image;
carrying out face selection alignment operation on the original face image to obtain an original aligned face image; the left eye and the right eye of the face in the middle original aligned face image are in horizontal positions, and the middle position of the left eye and the right eye is in the center of the original aligned face image.
Scaling the original alignment image by using a cubic interpolation algorithm to obtain an original scaled face image with the size of 128x 128; cubic interpolation, first proposed by Davidon in 1959, is an iterative algorithm that approximates a function with a cubic interpolation polynomial to find the approximate minimum point of the function.
And carrying out noise reduction operation on the original scaled face image by using a noise reduction algorithm based on discrete cosine transform to obtain the original noise-reduced face image.
And inputting the original noise-reduced face image into a model to obtain a high-definition noise-reduced face image, wherein the size of the high-definition noise-reduced face image is 512x512, and the skin quality of the face in the high-definition noise-reduced face image is improved and the detail definition of the face is improved.
Preprocessing the high-definition noise-reduction face image to obtain a high-definition face image; specifically, carrying out scaling operation on the high-definition noise-reduction face image by using a cubic interpolation algorithm to obtain a high-definition scaling face image with the size consistent with that of the original face image;
carrying out rotation reduction operation on the high-definition face image to obtain a high-definition face image, wherein the position of the face in the high-definition face image is consistent with the position of the face in the original face image
And fusing the high-definition face image into the face image to obtain a final image. Specifically, a high-definition face image is input into a pre-constructed portrait segmentation model to obtain a high-definition face mask image; the human image segmentation model can receive an input image and output a human image mask image, the pixel value range of the human image mask image is 0-1, and the pixel value represents the confidence coefficient that the pixel belongs to the human image. The specific portrait segmentation model implementation mode can adopt a proper implementation scheme according to needs.
Carrying out corrosion, expansion and fuzzy operations on the high-definition face mask image to obtain a high-definition face feathering mask image; the expansion operation, the corrosion operation and the fuzzy operation are classic algorithms in the aspect of image processing, and specific implementation methods are available on OpenCV. And will not be described in detail herein.
And taking the pixel value in the high-definition face feathering mask image as a weight, and fusing the high-definition face image into the face image to obtain a final image. The specific calculation is as follows: and recording the pixel value in the high-definition face feathering mask image as a, recording the pixel value in the original image as B, recording the pixel value of the high-definition face image as S, and recording the pixel value of the final image as R, and then calculating by using a formula R-S a + B (1-a) to obtain the final image with improved face skin quality and improved face detail definition.
To more clearly illustrate the embodiments of the present invention, a specific implementation is provided below, as shown in figure 4,
s1, model training module (as shown in figure 2)
1. A generative model G is constructed by using a convolutional neural network, and parameters of the generative model G are initialized by using a kaiming initialization method.
2. A multi-layer discriminant model D is constructed using a convolutional neural network.
3. Randomly selecting a face picture from the FFHQ data set, zooming to the size of 512x512, and carrying out gray level operation on the face picture with the probability of 30% to obtain a high-definition picture HR.
4. And performing a degradation operation on the high-definition picture HR to obtain a low-definition picture LR, wherein the degradation operation includes the following steps (as shown in fig. 3):
(1) performing fuzzy operation with 50% probability;
(2) performing noise adding operation with the probability of 20%;
(3) JPEG compression operation with a probability of 70%;
(4) a zoom operation is performed to a size of 1/4 where the picture aspect is the aspect of the HR, respectively.
5. And inputting the low-definition picture LR into the generated model G, and calculating according to the parameters of the generated model G to obtain a generated picture SR.
6. And calculating the loss LG between the generated picture SR and the original high-definition picture HR by using a cross entropy loss function, and updating the parameters of the generated model G by using an adaptive moment estimation algorithm.
7. And inputting the high-definition picture HR into the multilayer discrimination model D, and calculating according to the parameters of the multilayer discrimination model D to obtain the probability DH that the high-definition picture HR is true.
8. And inputting the generated picture SR into the multilayer discrimination model D, and calculating according to the parameters of the multilayer discrimination model D to obtain the probability DS that the generated picture SR is false.
9. The sum of the losses (DH and 1 loss) + (DS and 1 loss) is calculated using the Hinge loss function, and the parameters that generate model D are updated using the adaptive moment estimation algorithm.
10. And repeating the steps 3-9 until the loss LG is converged and the generated picture SR generated by the generated model G achieves the effects of improving the skin of the face and improving the definition of the details of the face, storing the generated model G, and finishing the model training.
S2, face preprocessing module
1. And acquiring an original image by using the mobile client.
2. And loading a face recognition model to the mobile client, wherein the face recognition model can receive an input image and output the input image as face data in the input image, and the face data comprises positions of a face frame, a left eye, a right eye, a nose tip, a left mouth corner and a right mouth corner. The specific implementation mode of the face recognition model can adopt a proper implementation scheme according to the requirement.
3. And inputting the original image into a face recognition model, and performing recognition operation to obtain face data in the image.
4. And according to the face data, performing cutting operation on the original image to obtain an original face image.
5. And carrying out face rotation alignment operation on the original face image to obtain the original aligned face image, wherein the left eye and the right eye of the face in the original aligned face image are in a horizontal position, and the middle position of the left eye and the right eye is in the center of the original aligned face image.
6. And carrying out scaling operation on the original aligned face image by using a cubic interpolation algorithm to obtain an original scaled face image with the size of 128x 128.
7. And carrying out noise reduction operation on the original scaled face image by using a noise reduction algorithm based on discrete cosine transform to obtain the original noise-reduced face image.
S3, model calculation module
1. And inputting the original noise-reduced face image into a stored generation model G to obtain a high-definition noise-reduced face image with improved face skin and improved face detail definition, wherein the size of the high-definition noise-reduced face image is 512x 512.
2. And carrying out scaling operation on the high-definition noise-reduction face image by using a cubic interpolation algorithm to obtain a high-definition scaled face image with the size consistent with that of the original face image.
3. And carrying out rotation reduction operation on the high-definition zoomed face image to obtain a high-definition face image, wherein the position of the face in the high-definition face image is consistent with the position of the face in the original face image.
S4. fusion module
1. And loading a portrait segmentation model to the mobile client, wherein the portrait segmentation model can receive an input image and output a portrait mask image, and the pixel value range of the portrait mask image is 0-1, wherein the pixel value represents the confidence coefficient that the pixel belongs to the portrait. The specific portrait segmentation model implementation mode can adopt a proper implementation scheme according to needs.
2. And inputting the high-definition face image into a face segmentation model to obtain a high-definition face mask image.
3. And carrying out corrosion, expansion and fuzzy operations on the high-definition face mask image to obtain the high-definition face feathering mask image.
4. And (3) taking the pixel value in the high-definition face feathering mask image as a weight, and fusing the high-definition face image into the original image to obtain the final image with the improved face skin and the improved face detail definition. The specific calculation is as follows: and recording the pixel value in the high-definition face feathering mask image as a, recording the pixel value in the original image as B, recording the pixel value of the high-definition face image as S, and recording the pixel value of the final face skin improvement and face detail definition improvement image as R, and then calculating to obtain the final face skin improvement and face detail definition improvement image through a formula R ═ S × a + B (1-a).
In an embodiment, the present invention further provides a device for improving sharpness of a face image, as shown in fig. 5, including:
a face image obtaining module 51, configured to obtain a face image with sharpness to be improved;
and the face image input module 52 is configured to input the face image into the model trained by the degeneration operation to obtain a face image with improved definition.
Wherein the training step of the model trained by the degeneration operation comprises:
acquiring a high-definition picture of a training face image; carrying out degradation operation on the training face image to obtain a low-definition picture; the degraded operation comprises the following steps: performing fuzzy operation with 50% probability; performing noise adding operation with the probability of 20%; JPEG compression operation with a probability of 70%; and performing zooming operation until the picture length and width are 1/4 sizes which are the length and width of the high-definition picture respectively. Inputting the low-definition picture into a pre-constructed convolutional neural network model to obtain a generated picture; calculating the loss between the generated picture and the high-definition picture; judging whether the loss is converged; if not, optimizing the parameters of the convolutional neural network model by adopting an adaptive moment estimation algorithm; and repeating the steps until the loss is converged and the definition of the generated image meets the requirement, and storing the parameters of the convolutional neural network model to obtain a model trained by the degeneration operation.
The method also comprises the steps of inputting the high-definition picture into a pre-constructed multilayer discrimination model to obtain a first probability that the high-definition picture is true; inputting the generated picture into a multilayer discrimination model to obtain a second probability that the generated picture is false; respectively calculating the first probability and the second probability and the loss of 1 by using a Hinge loss function, and summing the two calculated losses to obtain a loss sum; judging whether the loss and convergence occur; if not, optimizing parameters of the multilayer discrimination model by adopting an adaptive moment estimation algorithm; and repeating the steps until loss and convergence are achieved, and storing the multilayer discriminant model at the moment.
As an optional mode in the embodiment of the present invention, inputting a face image into a model trained by a degeneration operation to obtain a face image with improved definition includes:
preprocessing the face image to obtain an original noise-reduction face image only containing a face; and inputting the original noise-reduced face image into the model.
The method for preprocessing the face image to obtain the original noise-reduced face image only containing the face comprises the following steps: inputting a face image into a pre-constructed face recognition model to obtain face data, wherein the face data comprises positions of a face frame, a left eye, a right eye, a nose tip, a left mouth corner and a right mouth corner; cutting the face image according to the face data to obtain an original face image; carrying out face selection alignment operation on the original face image to obtain an original aligned face image; scaling the original alignment image by using a cubic interpolation algorithm to obtain an original scaled face image with the size of 128x 128; and carrying out noise reduction operation on the original zoomed face image to obtain the original noise-reduced face image.
Further comprising: inputting the original noise-reduced face image into a model to obtain a high-definition noise-reduced face image; preprocessing the high-definition noise-reduction face image to obtain a high-definition face image; and fusing the high-definition face image into the face image to obtain a final image.
Wherein, the high definition face image that makes an uproar is fallen to high definition carries out the preliminary treatment and obtains high definition face image and includes: carrying out scaling operation on the high-definition noise-reduction face image by using a cubic interpolation algorithm to obtain a high-definition scaling face image with the size consistent with that of the original face image; and carrying out rotation reduction operation on the high-definition face image to obtain the high-definition face image, wherein the position of the face in the high-definition face image is consistent with the position of the face in the original face image.
Further, the step of fusing the high-definition face image into the face image to obtain a final image comprises: inputting the high-definition face image into a pre-constructed portrait segmentation model to obtain a high-definition face mask image; carrying out corrosion, expansion and fuzzy operations on the high-definition face mask image to obtain a high-definition face feathering mask image; and taking the pixel value in the high-definition face feathering mask image as a weight, and fusing the high-definition face image into the face image to obtain a final image.
According to the device for improving the definition of the face image, provided by the embodiment of the invention, a face image acquisition module acquires a face image with definition to be improved; the human face image input module inputs the human face image into the model trained by the degradation operation to obtain the human face image with improved definition. A data degradation mode and a training mode are designed, so that a model learns how to generate a high-quality picture for improving the skin of the human face and improving the definition of the details of the human face, and the model is used for generating the picture of the human face, so that the effects of improving the skin of the human face and improving the definition of the details of the human face can be obtained.
It is understood that the same or similar parts in the above embodiments may be mutually referred to, and the same or similar parts in other embodiments may be referred to for the content which is not described in detail in some embodiments.
It should be noted that, in the description of the present application, the terms "first", "second", etc. are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. Further, in the description of the present application, the meaning of "a plurality" means at least two unless otherwise specified.
Any process or method descriptions in flow charts or otherwise described herein may be understood as representing modules, segments, or portions of code which include one or more executable instructions for implementing specific logical functions or steps of the process, and the scope of the preferred embodiments of the present application includes other implementations in which functions may be executed out of order from that shown or discussed, including substantially concurrently or in reverse order, depending on the functionality involved, as would be understood by those reasonably skilled in the art of the present application.
It should be understood that portions of the present application may be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, the various steps or methods may be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, any one or combination of the following techniques, which are known in the art, may be used: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application specific integrated circuit having an appropriate combinational logic gate circuit, a Programmable Gate Array (PGA), a Field Programmable Gate Array (FPGA), or the like.
It will be understood by those skilled in the art that all or part of the steps carried by the method for implementing the above embodiments may be implemented by hardware associated with program instructions, and the program may be stored in a computer readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.
In addition, functional units in the embodiments of the present application may be integrated into one processing module, or each unit may exist alone physically, or two or more units are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. The integrated module, if implemented in the form of a software functional module and sold or used as a stand-alone product, may also be stored in a computer readable storage medium.
The storage medium mentioned above may be a read-only memory, a magnetic or optical disk, etc.
In the description herein, reference to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the application. In this specification, the schematic representations of the terms used above do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
Although embodiments of the present application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present application, and that variations, modifications, substitutions and alterations may be made to the above embodiments by those of ordinary skill in the art within the scope of the present application.
- 上一篇:石墨接头机器人自动装卡簧、装栓机
- 下一篇:图像处理方法、装置、设备及存储介质