Face enhancement model training method and device and image generation method and device
By dynamically enhancing the first sample image and reducing the number of convolutional layer channels, the problem of large computational complexity and noise in the face enhancement processing of the GAN model is solved, and the efficiency and accuracy of the model are improved.
Patent Information
- Application Number
- CN202310184751.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-28
- Publication Date
- 2024-09-06
AI Technical Summary
Face enhancement processing based on the GAN model has the problems of large computational complexity and high noise in the output image, which affects the efficiency and accuracy of the model.
The second sample image is obtained by dynamically enhancing the first sample image, reducing the number of channels of each convolution layer in the face enhancement model, adjusting model parameters, reducing the amount of calculation and improving image quality.
It reduces the computational load of the face enhancement model, improves the accuracy of the model and the quality of the output image, and reduces the appearance of noise.
Smart Images

Figure CN118608401A
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing technology, and in particular to a method and device for training a face enhancement model, and a method and device for generating an image. Background Art
[0002] With the development of deep learning technology, clear images can be generated based on deep learning methods. For example, clear images can be generated based on the Generative Adversarial Networks (GAN) model. However, the amount of computation based on the GAN model is often large. At the same time, after the input image of the GAN model is enhanced, the output image of the GAN model often has too many noise points. Summary of the invention
[0003] The present disclosure provides a training method and device for a face enhancement model, and an image generation method and device. The method and device dynamically enhance a first sample image to obtain a second sample image, and reduce the number of channels of each convolutional layer in the face enhancement model, thereby reducing the amount of calculation of the face enhancement model, ensuring the quality of the output image of the face enhancement model, and improving the accuracy of the face enhancement model.
[0004] The technical solution of the present disclosure is as follows:
[0005] According to a first aspect of an embodiment of the present disclosure, a training method for a face enhancement model is provided, the method comprising: obtaining a first sample image and a second sample image corresponding to the first sample image, wherein the clarity of the first sample image is higher than that of the second sample image; training the face enhancement model for an i-th time based on the first sample image and the second sample image to obtain a sample enhanced image of the second sample image, where the value of i is an integer greater than or equal to 1; reducing the number of channels of each convolutional layer in the face enhancement model and adjusting the model parameters of the face enhancement model based on the sample enhanced image and the first sample image to obtain the face enhancement model during the i+1-th training; continuing to use the first sample image and the second sample image to train the face enhancement model for an i+1-th time until a training end condition is met to obtain a trained target face enhancement model.
[0006] According to an embodiment of the present disclosure, the process of acquiring the second sample image corresponding to the first sample image includes: performing enhancement processing on the first sample image to acquire the second sample image corresponding to the first sample image.
[0007] According to an embodiment of the present disclosure, the enhancing the first sample image to obtain a second sample image corresponding to the first sample image includes: obtaining an enhancement type for the first sample image and an enhancement coefficient corresponding to the enhancement type; and enhancing the first sample image according to the enhancement type and the enhancement coefficient to obtain the second sample image corresponding to the first sample image.
[0008] According to an embodiment of the present disclosure, after the first sample image is enhanced according to the enhancement type and the enhancement coefficient to obtain the second sample image corresponding to the first sample image, the method further includes: obtaining the data enhancement factor of the face enhancement model during the i-th training; judging whether it is necessary to adjust the enhancement coefficient of the first sample image according to the data enhancement factor; determining that it is necessary to adjust the enhancement coefficient of the first sample image, and re-enhancing the first sample image according to the enhancement type and the adjusted enhancement coefficient to obtain the second sample image during the i+1-th training.
[0009] According to one embodiment of the present disclosure, obtaining the data enhancement factor of the face enhancement model during the i-th training also includes: inputting the second sample image, the first sample image and the sample enhanced image into the discriminant network in the face enhancement model during the i-th training respectively to obtain a first output value of the second sample image, a second output value of the first sample image and a third output value of the sample enhanced image; obtaining a first mean of the second sample image, a second mean of the second sample image and a third mean of the sample enhanced image according to the first output value and the number of the second sample images, the second output value and the number of the first sample images, and the third output value and the number of the sample enhanced images; obtaining the data enhancement factor of the face enhancement model during the i-th training according to the first mean, the second mean and the third mean.
[0010] According to one embodiment of the present disclosure, based on the sample enhanced image and the first sample image, the number of channels of each convolutional layer in the face enhancement model is reduced, including: obtaining the reduction ratio of the number of channels of each convolutional layer in the face enhancement model during the i-th training; and reducing the number of channels of each convolutional layer in the face enhancement model during the i-th training according to the reduction ratio.
[0011] According to an embodiment of the present disclosure, after reducing the number of channels of each convolutional layer in the face enhancement model during the i-th training according to the reduction ratio, it also includes: obtaining a quality assessment result of the second sample image output by each convolutional layer in the face enhancement model during the i-th training; and judging whether to adjust the reduction ratio based on the quality assessment result.
[0012] According to one embodiment of the present disclosure, judging whether to adjust the reduction ratio based on the quality assessment result further includes: in response to the quality assessment result of the second sample image satisfying the image quality index, there is no need to adjust the reduction ratio; or in response to the quality assessment result of the second sample image not satisfying the image quality index, adjusting the reduction ratio of the number of channels of the convolutional layer that does not satisfy the image quality index.
[0013] According to one embodiment of the present disclosure, the process of acquiring the sample enhanced image of the second sample image includes: inputting the second sample image into the convolutional network and the linear mapping network of the face enhancement model to output the noise features and the attribute features of the second sample image; inputting the noise features and the attribute features into the generation network of the face enhancement model, and the generation network generates the sample enhanced image corresponding to the second sample image based on the noise features and the attribute features.
[0014] According to one embodiment of the present disclosure, the method of adjusting the model parameters of the face enhancement model to obtain the face enhancement model during the (i+1)th training includes: obtaining a first total loss function of a generation network and a second total loss function of a discriminant network of the face enhancement model during the (i)th training; and adjusting the model parameters of the face enhancement model during the (i+1)th training according to the first total loss function and the second total loss function to obtain the face enhancement model during the (i+1)th training.
[0015] According to one embodiment of the present disclosure, the method of obtaining the first total loss function of the generative network of the face enhancement model during the i-th training includes: obtaining a preset loss function of the face enhancement model during the i-th training; extracting features of the second sample image through a student model and a pre-trained teacher model to obtain a first feature extracted by the student model and a second feature extracted by the teacher model; obtaining a distillation loss function between the student model and the teacher model based on the first feature and the second feature; extracting features of the sample enhanced image and the first sample image through a pre-trained face recognition model to obtain a third feature of the sample enhanced image and a fourth feature of the first sample image; obtaining a similarity loss function between the sample enhanced image and the first sample image based on the third feature and the fourth feature; and using the preset loss function, the distillation loss function and the similarity loss function as the first total loss function.
[0016] According to one embodiment of the present disclosure, the obtaining of the second total loss function of the discriminant network of the face enhancement model during the i-th training includes: respectively inputting the first sample image and the sample enhanced image into the discriminant network of the face enhancement model during the i-th training to obtain a first eigenvalue of the first sample image and a second eigenvalue of the sample enhanced image; and obtaining the second total loss function based on the first eigenvalue and the second eigenvalue.
[0017] According to a second aspect of an embodiment of the present disclosure, there is provided an image processing method, the method comprising: acquiring an image to be processed; inputting the image to be processed into a target face enhancement model, and having the target face enhancement model output a target enhanced image of the image to be processed, wherein the target face enhancement model is a model trained using the training method of the face enhancement model described in the first aspect.
[0018] According to one embodiment of the present disclosure, the method also includes: inputting the image to be processed into a super-resolution model, and the super-resolution model outputs a high-definition image corresponding to the image to be processed; inputting the target enhanced image into a face parsing model, and the face parsing model outputs a regional segmentation image of the target enhanced image; and fusing the high-definition image, the regional segmentation image and the target enhanced image to obtain the target image of the image to be processed.
[0019] According to a third aspect of an embodiment of the present disclosure, a training device for a face enhancement model is provided, the device comprising: an acquisition module, used to acquire a first sample image and a second sample image corresponding to the first sample image, wherein the clarity of the first sample image is higher than that of the second sample image; a first training module, used to perform an i-th training on the face enhancement model based on the first sample image and the second sample image to obtain a sample enhanced image of the second sample image, where the value of i is an integer greater than or equal to 1; an adjustment module, used to reduce the number of channels of each convolutional layer in the face enhancement model and adjust the model parameters of the face enhancement model based on the sample enhanced image and the first sample image to obtain the face enhancement model at the i+1th training; and a second training module, used to continue to use the first sample image and the second sample image to perform an i+1th training on the face enhancement model until a training end condition is met to obtain a trained target face enhancement model.
[0020] According to an embodiment of the present disclosure, the acquisition module is further used to: perform enhancement processing on the first sample image to acquire a second sample image corresponding to the first sample image.
[0021] According to one embodiment of the present disclosure, the acquisition module is further used to: obtain an enhancement type for the first sample image and an enhancement coefficient corresponding to the enhancement type; and perform enhancement processing on the first sample image according to the enhancement type and the enhancement coefficient to obtain the second sample image corresponding to the first sample image.
[0022] According to one embodiment of the present disclosure, the acquisition module is also used to: obtain the data enhancement factor of the face enhancement model during the i-th training; determine whether it is necessary to adjust the enhancement coefficient of the first sample image based on the data enhancement factor; determine that it is necessary to adjust the enhancement coefficient of the first sample image, and re-enhance the first sample image according to the enhancement type and the adjusted enhancement coefficient to obtain the second sample image during the i+1-th training.
[0023] According to one embodiment of the present disclosure, the acquisition module is also used to: input the second sample image, the first sample image and the sample enhanced image into the discriminant network in the face enhancement model during the i-th training respectively to obtain the first output value of the second sample image, the second output value of the first sample image and the third output value of the sample enhanced image; obtain the first mean of the second sample image, the second mean of the second sample image and the third mean of the sample enhanced image according to the first output value and the number of the second sample images, the second output value and the number of the first sample images, and the third output value and the number of the sample enhanced images; obtain the data enhancement factor of the face enhancement model during the i-th training according to the first mean, the second mean and the third mean.
[0024] According to one embodiment of the present disclosure, the adjustment module is also used to: obtain the reduction ratio of the number of channels of each convolutional layer in the face enhancement model during the i-th training; and reduce the number of channels of each convolutional layer in the face enhancement model during the i-th training according to the reduction ratio.
[0025] According to one embodiment of the present disclosure, the adjustment module is further used to: obtain a quality assessment result of the second sample image output by each convolutional layer in the face enhancement model during the i-th training; and determine whether to adjust the reduction ratio based on the quality assessment result.
[0026] According to one embodiment of the present disclosure, the adjustment module is further used for: in response to the quality assessment result of the second sample image satisfying the image quality index, there is no need to adjust the reduction ratio; or in response to the quality assessment result of the second sample image not satisfying the image quality index, adjusting the reduction ratio of the number of channels of the convolutional layer that does not satisfy the image quality index.
[0027] According to one embodiment of the present disclosure, the first training module is also used to: input the second sample image into the convolutional network and the linear mapping network of the face enhancement model to output the noise features and attribute features of the second sample image; input the noise features and the attribute features into the generation network of the face enhancement model, and the generation network generates a sample enhanced image corresponding to the second sample image based on the noise features and the attribute features.
[0028] According to one embodiment of the present disclosure, the adjustment module is also used to: obtain a first total loss function of the generation network and a second total loss function of the discriminant network of the face enhancement model during the i-th training; adjust the model parameters of the face enhancement model during the i-th training according to the first total loss function and the second total loss function to obtain the face enhancement model during the (i+1)-th training.
[0029] According to one embodiment of the present disclosure, the adjustment module is also used to: obtain a preset loss function of the face enhancement model during the i-th training; extract features of the second sample image through a student model and a pre-trained teacher model to obtain a first feature extracted by the student model and a second feature extracted by the teacher model; obtain a distillation loss function between the student model and the teacher model based on the first feature and the second feature; extract features of the sample enhanced image and the first sample image through a pre-trained face recognition model to obtain a third feature of the sample enhanced image and a fourth feature of the first sample image; obtain a similarity loss function between the sample enhanced image and the first sample image based on the third feature and the fourth feature; and use the preset loss function, the distillation loss function and the similarity loss function as the first total loss function.
[0030] According to one embodiment of the present disclosure, the adjustment module is also used to: input the first sample image and the sample enhanced image into the discriminant network of the face enhancement model during the i-th training respectively to obtain the first eigenvalue of the first sample image and the second eigenvalue of the sample enhanced image; and obtain the second total loss function according to the first eigenvalue and the second eigenvalue.
[0031] According to a fourth aspect of an embodiment of the present disclosure, an image processing device is provided, comprising: a first acquisition module for acquiring an image to be processed; an output module for inputting the image to be processed into a target face enhancement model, and the target face enhancement model outputs a target enhanced image of the image to be processed, wherein the target face enhancement model is a model trained using the training method of the face enhancement model described in the first aspect.
[0032] According to one embodiment of the present disclosure, the device is also used to: input the image to be processed into a super-resolution model, and the super-resolution model outputs a high-definition image corresponding to the image to be processed; input the target enhanced image into a face parsing model, and the face parsing model outputs a regional segmentation image of the target enhanced image; and fuse the high-definition image, the regional segmentation image and the target enhanced image to obtain the target image of the image to be processed.
[0033] According to a fifth aspect of an embodiment of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement a training method for a face enhancement model provided in the embodiment of the first aspect of the present disclosure or an image processing method provided in the embodiment of the second aspect.
[0034] According to the sixth aspect of the embodiments of the present disclosure, a computer-readable storage medium is provided. When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the training method of the face enhancement model provided in the first aspect embodiment of the present disclosure or the image processing method provided in the second aspect embodiment.
[0035] According to the seventh aspect of the embodiments of the present disclosure, a computer program product is provided, including a computer program, characterized in that when the computer program is executed by a processor, it implements the training method of the face enhancement model provided in the first aspect of the present disclosure or the image processing method provided in the second aspect embodiment.
[0036] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:
[0037] A training method for a face enhancement model of an embodiment of the present disclosure obtains a first sample image and a second sample image corresponding to the first sample image, wherein the clarity of the first sample image is higher than that of the second sample image, performs the i-th training on the face enhancement model based on the first sample image and the second sample image, obtains a sample enhanced image of the second sample image, wherein the value of i is an integer greater than or equal to 1, reduces the number of channels of each convolutional layer in the face enhancement model based on the sample enhanced image and the first sample image, and adjusts the model parameters of the face enhancement model to obtain the face enhancement model at the time of the i+1-th training, and continues to use the first sample image and the second sample image to perform the i+1-th training on the face enhancement model until the training end condition is met to obtain the trained target face enhancement model. By dynamically enhancing the first sample image to obtain the second sample image and reducing the number of channels of each convolutional layer in the face enhancement model, the amount of computation of the face enhancement model is reduced, the quality of the output image of the face enhancement model is guaranteed, and the accuracy of the face enhancement model is improved.
[0038] 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
[0039] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.
[0040] Figure 1 The present invention is a flowchart of a method for training a face enhancement model according to an exemplary embodiment.
[0041] Figure 2 The figure is a flowchart of another method for training a face enhancement model according to an exemplary embodiment.
[0042] Figure 3 The figure is a flowchart of another method for training a face enhancement model according to an exemplary embodiment.
[0043] Figure 4 The figure is a flowchart of another method for training a face enhancement model according to an exemplary embodiment.
[0044] Figure 5 The figure is a flowchart of another method for training a face enhancement model according to an exemplary embodiment.
[0045] Figure 6 It is a flowchart of an image processing method according to an exemplary embodiment.
[0046] Figure 7 It is a flowchart of another image processing method according to an exemplary embodiment.
[0047] Figure 8 It is a flowchart of an image processing method according to an exemplary embodiment.
[0048] Fig. 9 The figure is a block diagram of a training device for a face enhancement model according to an exemplary embodiment.
[0049] Fig.10 is a block diagram of an image processing apparatus according to an exemplary embodiment.
[0050] Fig.11 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0051] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.
[0052] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. 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 disclosure as detailed in the appended claims.
[0053] Figure 1 A flowchart of a method for training a face enhancement model provided in an embodiment of the present disclosure.
[0054] like Figure 1 As shown, the training method of the face enhancement model includes the following steps:
[0055] S101, obtaining a first sample image and a second sample image corresponding to the first sample image, wherein the clarity of the first sample image is higher than the clarity of the second sample image.
[0056] It should be noted that the present disclosure does not limit the specific method for obtaining the first sample image, which can be selected according to actual conditions.
[0057] Optionally, a high-definition face dataset (Flickr-Faces-High-Quality, FFHQ for short) may be obtained, and an image may be selected from the high-definition face dataset FFHQ as the first sample image.
[0058] Among them, the high-definition face dataset FFHQ is a high-quality face dataset. The high-definition face dataset FFHQ contains 70,000 high-definition face images in the Portable Network Graphics (PNG) format with a resolution of 1024x1024.
[0059] Optionally, in order to reduce the energy consumption of the graphics processing unit (GPU) during the training of the face enhancement model, the resolution of the image in the high-definition face dataset FFHQ can be scaled to a resolution of 512x512 as the first sample image.
[0060] It should be noted that the first sample image and the second sample image have the same resolution, but the first sample image is a high definition (HD) image, and the second sample image is a low definition (LD) image.
[0061] The clarity of an image refers to the clarity of the detailed patterns and their boundaries on the image.
[0062] It should be noted that the clarity of an image is an important indicator for measuring image quality. Optionally, the clarity of an image can be evaluated using the Frechet Inception Distance (FID). The smaller the FID, the higher the image quality, that is, the higher the image clarity.
[0063] Optionally, after the first sample image is acquired, dynamic enhancement processing may be performed on the first sample image, that is, noise may be added to the first sample image to acquire the second sample image.
[0064] S102, training the face enhancement model for the i-th time based on the first sample image and the second sample image to obtain a sample enhanced image of the second sample image, where the value of i is an integer greater than or equal to 1.
[0065] In an embodiment of the present application, after obtaining the second sample image, the face enhancement model can be trained for the i-th time based on the first sample image and the second sample image to obtain a sample enhanced image of the second sample image, where the value of i is an integer greater than or equal to 1.
[0066] Optionally, after obtaining the second sample image, the second sample image can be input into the convolutional network and linear mapping network of the face enhancement model to output the noise features and attribute features of the second sample image, and the noise features and attribute features are input into the generation network of the face enhancement model, and the generation network generates a sample enhanced image corresponding to the second sample image based on the noise features (noise) and attribute features (style).
[0067] The noise feature is a feature of the second sample image, which can characterize the details of the second sample image, such as facial wrinkles, facial skin color, facial pores and other detail features.
[0068] It should be noted that the noise feature also characterizes the degradation of the second sample image. For example, noise generated by a sensor in an image acquisition device such as a camera may cause image degradation.
[0069] The attribute features are style features of the face of the second sample image, such as facial expression, facial orientation, facial shape, facial expression, facial identity information, and other style features related to the face.
[0070] S103, based on the sample enhanced image and the first sample image, reducing the number of channels of each convolutional layer in the face enhancement model, and adjusting the model parameters of the face enhancement model, to obtain the face enhancement model during the (i+1)th training.
[0071] It should be noted that in the process of convolution operation of the face enhancement model, the number of input and output channels often determines the amount of calculation. If the number of input and output channels is effectively reduced, the face enhancement model can be made lightweight. However, the reduction in the number of channels of each convolution layer will also have an impact on the image quality. Therefore, based on the sample enhanced image and the first sample image, the number of channels of each convolution layer in the face enhancement model can be dynamically reduced. Since each convolution layer has a different impact on the image quality, the number of channels of each convolution layer can be set to a different reduction ratio to ensure the image quality.
[0072] Optionally, based on the sample enhanced image and the first sample image, the number of channels of each convolutional layer in the face enhancement model can be dynamically reduced, and the loss function of the face enhancement model during the i-th training can be obtained to adjust the model parameters of the face enhancement model to obtain the face enhancement model during the i+1-th training.
[0073] S104, continue to use the first sample image and the second sample image to train the face enhancement model for the (i+1)th time, until the training end condition is met to obtain the trained target face enhancement model.
[0074] Optionally, after obtaining the face enhancement model during the i+1th training, the first sample image and the second sample image may be continuously used to train the face enhancement model for the i+1th time until the training end condition is met to obtain the trained target face enhancement model.
[0075] It should be noted that the present disclosure does not limit the setting of the training end condition, which can be selected according to actual conditions.
[0076] Optionally, the training stop condition may be set as the number of training times of the face enhancement model reaching a preset number threshold.
[0077] For example, when the number of training times of the face enhancement model reaches 10,000 times, the training is completed to obtain the target face enhancement model.
[0078] According to a training method of a face enhancement model of an embodiment of the present disclosure, a first sample image and a second sample image corresponding to the first sample image are obtained, wherein the clarity of the first sample image is higher than that of the second sample image, the face enhancement model is trained for the i-th time based on the first sample image and the second sample image to obtain a sample enhanced image of the second sample image, wherein the value of i is an integer greater than or equal to 1, and based on the sample enhanced image and the first sample image, the number of channels of each convolutional layer in the face enhancement model is reduced, and the model parameters of the face enhancement model are adjusted to obtain the face enhancement model at the time of the i+1-th training, and the first sample image and the second sample image are continuously used to train the face enhancement model for the i+1-th time until the training end condition is met to obtain the trained target face enhancement model. By dynamically enhancing the first sample image to obtain the second sample image, and reducing the number of channels of each convolutional layer in the face enhancement model, the amount of computation of the face enhancement model is reduced, the face enhancement model is made more lightweight, the quality of the output image of the face enhancement model is guaranteed, and the accuracy of the face enhancement model is improved.
[0079] Figure 2 is a flow chart of a training method for a face enhancement model according to an embodiment of the present disclosure. Based on the above embodiment, further combined with Figure 2 , the first sample image is enhanced to obtain a second sample image corresponding to the first sample image, and the specific process is explained, including the following steps:
[0080] S201: Obtain an enhancement type for a first sample image and an enhancement coefficient corresponding to the enhancement type.
[0081] It should be noted that the degradation of a camera in reality can be simulated according to the enhancement type of the first sample image.
[0082] It should be noted that the present disclosure does not limit the specific setting of the enhancement type of the first sample image, and it can be set according to actual conditions.
[0083] Optionally, the enhancement type of the first sample image can be Gaussian blur, Joint Photographic Experts Group (JPEG) compression, Gaussian noise, speckle noise, Poisson noise, random brightness, random contrast, random grayscale coefficient, randomly selected channel pixel inactivation (Channel Dropout), random color space exchange (channel shuffle), sensitivity noise, homomorphic filtering, nostalgic filtering, random discarding / filling of partial pixel blocks (Cutout), etc.
[0084] It should be noted that the present disclosure does not limit the setting of the enhancement coefficient.
[0085] For example, when the enhancement type for the first sample image is Gaussian blur, the enhancement coefficient corresponding to the enhancement type (Gaussian blur) may be set to 0.6.
[0086] S202: Perform enhancement processing on the first sample image according to the enhancement type and the enhancement coefficient to obtain a second sample image corresponding to the first sample image.
[0087] In the disclosed embodiment, after the enhancement type and the enhancement coefficient are acquired, the first sample image may be enhanced to acquire a second sample image corresponding to the first sample image.
[0088] Furthermore, after the second sample image is obtained, the data enhancement factor of the face enhancement model during the i-th training may be obtained, and according to the data enhancement factor, it is determined whether the enhancement coefficient of the first sample image needs to be adjusted.
[0089] Based on the above embodiments, further combined Figure 3 , a specific process after enhancing the first sample image according to the enhancement type and the enhancement coefficient to obtain a second sample image corresponding to the first sample image is explained, including the following steps:
[0090] S301, obtaining a data enhancement factor of a face enhancement model during the i-th training.
[0091] Optionally, the second sample image, the first sample image and the sample enhanced image can be respectively input into the discriminant network in the face enhancement model during the i-th training to obtain the first output value of the second sample image, the second output value of the first sample image and the third output value of the sample enhanced image; based on the first output value and the number of second sample images, the second output value and the number of first sample images, and the third output value and the number of sample enhanced images, the first mean of the second sample image, the second mean of the second sample image and the third mean of the sample enhanced image are obtained; based on the first mean, the second mean and the third mean, the data enhancement factor of the face enhancement model during the i-th training is obtained.
[0092] For example, after obtaining the first mean value E[D train ], the second mean value E[D validation ] and the third mean E[D generated ], the data enhancement factor r can be obtained using the following formula v :
[0093]
[0094] Among them, r vis the data enhancement factor of the face enhancement model during the i-th training, E[D train ] is the first mean of the second sample image, E[D validation ] is the second mean of the second sample image, E[D generated ] is the third mean of the sample enhanced image.
[0095] S302: Determine whether it is necessary to adjust the enhancement coefficient of the first sample image according to the data enhancement factor.
[0096] It should be noted that, when the data enhancement factor is larger, the enhancement coefficient of the first sample image needs to be increased, and when the data enhancement factor is smaller, the enhancement coefficient of the first sample image needs to be reduced.
[0097] Optionally, when the data enhancement factor is 0, the first sample image is not overfitted and the enhancement coefficient of the first sample image does not need to be adjusted; when the data enhancement factor is 1, the first sample image is overfitted and the enhancement coefficient of the first sample image needs to be adjusted.
[0098] S303: Determine that the enhancement coefficient of the first sample image needs to be adjusted, and re-enhance the first sample image according to the enhancement type and the adjusted enhancement coefficient to obtain a second sample image in the (i+1)th training.
[0099] In the disclosed embodiment, if the enhancement coefficient of the first sample image needs to be adjusted, the first sample image is enhanced again according to the enhancement type and the adjusted enhancement coefficient to obtain the second sample image in the (i+1)th training.
[0100] For example, when the time-varying value is 1, when the enhancement type for the first sample image is Gaussian blur, the enhancement coefficient is 0.6, the enhancement coefficient can be adjusted to 0.7, and the first sample image is re-enhanced according to the adjusted enhancement coefficient to obtain the second sample image during the i+1th training.
[0101] According to a training method of a face enhancement model of an embodiment of the present disclosure, the enhancement type of a first sample image and the enhancement coefficient corresponding to the enhancement type are obtained, and the first sample image is enhanced according to the enhancement type and the enhancement coefficient to obtain a second sample image corresponding to the first sample image, and the data enhancement factor of the face enhancement model during the i-th training can be obtained, and according to the data enhancement factor, it is determined whether the enhancement coefficient of the first sample image needs to be adjusted, and it is determined that the enhancement coefficient of the first sample image needs to be adjusted, and the first sample image is enhanced again according to the enhancement type and the adjusted enhancement coefficient to obtain the second sample image during the i+1-th training. Therefore, the present disclosure can dynamically adjust the enhancement coefficient of the first sample image according to the data enhancement factor of the face enhancement model in each iterative training process, thereby improving the quality of obtaining the second sample image and avoiding the problem of too much noise in the second sample image.
[0102] Figure 4 is a flow chart of a training method for a face enhancement model according to an embodiment of the present disclosure. Based on the above embodiment, further combined with Figure 4 , a specific process of reducing the number of channels of each convolutional layer in the face enhancement model based on the sample enhancement image and the first sample image is explained, including the following steps:
[0103] S401, obtaining a reduction ratio of the number of channels of each convolutional layer in the face enhancement model during the i-th training.
[0104] It should be noted that in the process of reducing the number of channels of each convolutional layer, the impact of each convolutional layer on the image quality is different, so the number of channels of each convolutional layer needs to be set to a different reduction ratio.
[0105] It should be noted that the present disclosure does not limit the setting of the reduction ratio, which can be set according to actual conditions.
[0106] Optionally, the reduction ratio of the number of channels of each convolutional layer can be set to 25%, 50%, 75%, etc.
[0107] For example, the reduction ratio of the number of channels of the first convolutional layer in the face enhancement model during the i-th training can be set to 25%, the reduction ratio of the number of channels of the second convolutional layer in the face enhancement model during the i-th training can be set to 50%, and the reduction ratio of the number of channels of the last convolutional layer in the face enhancement model during the i-th training can be set to 70%.
[0108] S402, reducing the number of channels of each convolutional layer in the face enhancement model during the i-th training according to the reduction ratio.
[0109] It should be noted that after obtaining the reduction ratio, the number of channels of each convolutional layer in the face enhancement model during the i-th training can be reduced according to the reduction ratio.
[0110] For example, when the convolution kernel is the same, if the number of input / output channels of the second convolution layer is 32 / 64, when the reduction ratio is 50%, according to the reduction ratio, the number of input / output channels of the second convolution layer after reduction is 16 / 32.
[0111] Furthermore, after reducing the number of channels of each convolutional layer in the face enhancement model during the i-th training according to the reduction ratio, the quality evaluation results of the second sample images output by each convolutional layer in the face enhancement model during the i-th training can be obtained, and based on the quality evaluation results, it is determined whether to adjust the reduction ratio.
[0112] Optionally, in response to the quality assessment result of the second sample image satisfying the image quality index, there is no need to adjust the reduction ratio.
[0113] Optionally, in response to the quality assessment result of the second sample image failing to meet the image quality index, the reduction ratio of the number of channels of the convolutional layer failing to meet the image quality index is adjusted.
[0114] According to a training method of a face enhancement model of an embodiment of the present disclosure, the reduction ratio of the number of channels of each convolutional layer in the face enhancement model during the i-th training is obtained, and the number of channels of each convolutional layer in the face enhancement model during the i-th training is reduced according to the reduction ratio, and the quality evaluation result of the second sample image output by each convolutional layer in the face enhancement model during the i-th training is obtained, and according to the quality evaluation result, it is determined whether to adjust the reduction ratio. Therefore, the present disclosure dynamically reduces the number of channels of each convolutional layer in the face enhancement model according to the reduction ratio, reduces the amount of calculation of the face enhancement model, makes the face enhancement model more lightweight, and ensures the quality of the image output by the face enhancement model, thereby improving the accuracy of the face enhancement model.
[0115] Figure 5 is a flow chart of a training method for a face enhancement model according to an embodiment of the present disclosure. Based on the above embodiment, further combined with Figure 5 , the specific process of adjusting the model parameters of the face enhancement model to obtain the face enhancement model during the i+1th training is explained, including the following steps:
[0116] S501, obtaining a first total loss function of a generative network and a second total loss function of a discriminative network of a face enhancement model during the i-th training.
[0117] Optionally, a preset loss function of the face enhancement model during the i-th training may be obtained. For example, the preset loss function may be r1 loss, logistic loss function, non-saturating loss function, or the like.
[0118] Optionally, the features of the second sample image can be extracted using a student model and a pre-trained teacher model to obtain a first feature extracted by the student model and a second feature extracted by the teacher model, and a distillation loss function between the student model and the teacher model is obtained based on the first feature and the second feature.
[0119] For example, in order to reduce GPU training time and other issues, knowledge distillation is added to the training of the face enhancement model. The distillation loss function between the student model and the teacher model can be obtained according to the first feature and the second feature, that is, the mean squared error loss and perceptual loss of the pixel.
[0120] Optionally, in order to ensure the consistency of the identity document (ID) between the second sample image and the target enhanced image, feature extraction can be performed on the sample enhanced image and the first sample image through a pre-trained face recognition model to obtain a third feature of the sample enhanced image and a fourth feature of the first sample image, and based on the third feature and the fourth feature, a similarity loss function (Idloss) between the sample enhanced image and the first sample image is obtained.
[0121] Furthermore, the preset loss function, the distillation loss function and the similarity loss function may be added together, and the sum of the preset loss function, the distillation loss function and the similarity loss function may be used as the first total loss function.
[0122] Optionally, the first sample image and the sample enhanced image are respectively input into the discriminant network of the face enhancement model during the i-th training to obtain the first eigenvalue of the first sample image and the second eigenvalue of the sample enhanced image, and the second total loss function is obtained based on the first eigenvalue and the second eigenvalue.
[0123] S502, adjusting the model parameters of the face enhancement model during the i-th training according to the first total loss function and the second total loss function, to obtain the face enhancement model during the (i+1)-th training.
[0124] In the embodiment of the present disclosure, after obtaining the first total loss function and the second total loss function, the model parameters of the face enhancement model during the i-th training can be adjusted according to the first total loss function and the second total loss function to obtain the face enhancement model during the i+1-th training.
[0125] According to a training method for a face enhancement model of an embodiment of the present disclosure, by obtaining the first total loss function of the generating network and the second total loss function of the discriminating network of the face enhancement model during the i-th training, the model parameters of the face enhancement model during the i-th training are adjusted according to the first total loss function and the second total loss function, and the face enhancement model during the i+1-th training is obtained. Therefore, the present disclosure adjusts the model parameters of the face enhancement model during the i-th training through the first total loss function and the second total loss function, laying a foundation for subsequently improving the accuracy and precision of the target face enhancement model.
[0126] Figure 6 A flowchart of an image processing method provided in an embodiment of the present disclosure is provided.
[0127] like Figure 6 As shown, the image processing method comprises the following steps:
[0128] S601, obtaining an image to be processed.
[0129] Optionally, the image to be processed may be any picture with a face, and the image to be processed is a low-definition image (LD).
[0130] It should be noted that after the image to be processed is obtained, the image to be processed can be input into a face detection model to obtain the face region of the image to be processed.
[0131] S602, inputting the image to be processed into a target face enhancement model, and the target face enhancement model outputs a target enhanced image of the image to be processed.
[0132] It should be noted that when attempting to perform face enhancement processing on an image to be processed, the image to be processed may be input into a target face enhancement model, and the target face enhancement model outputs a target enhanced image of the image to be processed.
[0133] Among them, the target face enhanced image is a trained convergent model.
[0134] It should be noted that the target enhanced image is a high-definition image (HD).
[0135] According to an image processing method of an embodiment of the present disclosure, an image to be processed is acquired and input into a target face enhancement model, and the target face enhancement model outputs a target enhanced image of the image to be processed, so that the image to be processed can be subjected to face enhancement processing through a converged target face enhancement model, thereby ensuring the face enhancement effect and improving the quality of the image to be processed.
[0136] Figure 7 is a flowchart of an image processing method according to an embodiment of the present disclosure. Based on the above embodiment, further combined with Figure 7 , the specific process of obtaining the target image of the image to be processed is explained, including the following steps:
[0137] S701, input the image to be processed into the super-resolution model, and the super-resolution model outputs a high-definition image corresponding to the image to be processed.
[0138] Optionally, the image to be processed (LD) may be input into the super-resolution model, and the super-resolution model may generate a high-definition image corresponding to the image to be processed, wherein the face portion of the high-definition image corresponding to the image to be processed is not enhanced.
[0139] S702, inputting the target enhanced image into a face parsing model, and the face parsing model outputs a region segmentation image of the target enhanced image.
[0140] Optionally, the target enhanced image can be input into a face parsing model to further segment the target enhanced image, that is, the background and person (including hair, face, neck, etc.) in the target enhanced image are segmented to obtain a regional segmentation image of the target enhanced image.
[0141] S703, fusing the high-definition image, the region segmentation image and the target enhanced image to obtain a target image of the image to be processed.
[0142] It should be noted that after obtaining the high-definition image, the region segmentation image and the target enhanced image, the high-definition image, the region segmentation image and the target enhanced image can be fused (post-processed) to obtain the target image (HD) of the image to be processed, wherein the clarity of the target image is higher than that of the image to be processed.
[0143] The process of processing the image proposed in the present disclosure is explained below.
[0144] For example, Figure 8As shown, firstly, the image to be processed, i.e., a low-definition image (LD), is obtained, the low-definition image (LD) is input into the super-resolution model, the high-definition image corresponding to the image to be processed is output, the low-definition image (LD) is output into the face detection model, the face region of the image to be processed is output, the face region of the image to be processed is enhanced by the target face enhancement model, for example, details such as face and hair, to obtain the target enhanced image, the target enhanced image is input into the face parsing model, the target enhanced image is further segmented, the face parsing model outputs the regional segmentation image of the target enhanced image, and finally the high-definition image, the regional segmentation image and the target enhanced image are fused (post-processed) to obtain the target image of the image to be processed, i.e., the high-definition image (HD).
[0145] According to an image processing method of an embodiment of the present disclosure, an image to be processed is input into a super-resolution model, the super-resolution model outputs a high-definition image corresponding to the image to be processed, a target enhanced image is input into a face analysis model, the face analysis model outputs a region segmentation image of the target enhanced image, the high-definition image, the region segmentation image and the target enhanced image are fused to obtain a target image of the image to be processed, so that the image to be processed can be face enhanced by a converged target face enhancement model, thereby ensuring the face enhancement effect and improving the quality of the image to be processed.
[0146] Fig. 9 The figure is a block diagram of a training device for a face enhancement model according to an exemplary embodiment.
[0147] like Fig. 9 As shown, the training device 1000 for the face enhancement model includes: an acquisition module 110, a first training module 120, an adjustment module 130 and a second training module 140.
[0148] An acquisition module 110 is configured to acquire a first sample image and a second sample image corresponding to the first sample image, wherein the clarity of the first sample image is higher than the clarity of the second sample image;
[0149] A first training module 120, configured to perform an i-th training on a face enhancement model based on the first sample image and the second sample image to obtain a sample enhanced image of the second sample image, where the value of i is an integer greater than or equal to 1;
[0150] An adjustment module 130, configured to reduce the number of channels of each convolutional layer in the face enhancement model and adjust the model parameters of the face enhancement model based on the sample enhanced image and the first sample image, so as to obtain the face enhancement model during the (i+1)th training;
[0151] The second training module 140 is used to continue to use the first sample image and the second sample image to perform the (i+1)th training on the face enhancement model until the training end condition is met to obtain the trained target face enhancement model.
[0152] Furthermore, the acquisition module 110 is further configured to: perform enhancement processing on the first sample image to obtain a second sample image corresponding to the first sample image.
[0153] Furthermore, the acquisition module 110 is also used to: obtain an enhancement type for the first sample image and an enhancement coefficient corresponding to the enhancement type; and enhance the first sample image according to the enhancement type and the enhancement coefficient to obtain the second sample image corresponding to the first sample image.
[0154] Furthermore, the acquisition module 110 is also used to: obtain the data enhancement factor of the face enhancement model during the i-th training; determine whether it is necessary to adjust the enhancement coefficient of the first sample image based on the data enhancement factor; determine that it is necessary to adjust the enhancement coefficient of the first sample image, and re-enhance the first sample image according to the enhancement type and the adjusted enhancement coefficient to obtain the second sample image during the i+1-th training.
[0155] Furthermore, the acquisition module 110 is also used to: input the second sample image, the first sample image and the sample enhanced image into the discriminant network in the face enhancement model during the i-th training respectively to obtain a first output value of the second sample image, a second output value of the first sample image and a third output value of the sample enhanced image; obtain a first mean of the second sample image, a second mean of the second sample image and a third mean of the sample enhanced image according to the first output value and the number of the second sample images, the second output value and the number of the first sample images, and the third output value and the number of the sample enhanced images; obtain a data enhancement factor of the face enhancement model during the i-th training according to the first mean, the second mean and the third mean.
[0156] Furthermore, the adjustment module 130 is also used to: obtain the reduction ratio of the number of channels of each convolutional layer in the face enhancement model during the i-th training; and reduce the number of channels of each convolutional layer in the face enhancement model during the i-th training according to the reduction ratio.
[0157] Furthermore, the adjustment module 130 is also used to: obtain a quality assessment result of the second sample image output by each convolutional layer in the face enhancement model during the i-th training; and determine whether to adjust the reduction ratio based on the quality assessment result.
[0158] Furthermore, the adjustment module 130 is also used for: in response to the quality assessment result of the second sample image satisfying the image quality index, there is no need to adjust the reduction ratio; or in response to the quality assessment result of the second sample image not satisfying the image quality index, adjusting the reduction ratio of the number of channels of the convolutional layer that does not meet the image quality index.
[0159] Furthermore, the first training module 120 is also used to: input the second sample image into the convolutional network and the linear mapping network of the face enhancement model to output the noise features and attribute features of the second sample image; input the noise features and the attribute features into the generation network of the face enhancement model, and the generation network generates a sample enhanced image corresponding to the second sample image based on the noise features and the attribute features.
[0160] Furthermore, the adjustment module 130 is also used to: obtain a first total loss function of the generative network and a second total loss function of the discriminative network of the face enhancement model during the i-th training; adjust the model parameters of the face enhancement model during the i-th training according to the first total loss function and the second total loss function to obtain the face enhancement model during the i+1-th training.
[0161] Furthermore, the adjustment module 130 is also used to: obtain a preset loss function of the face enhancement model during the i-th training; extract features of the second sample image through a student model and a pre-trained teacher model to obtain a first feature extracted by the student model and a second feature extracted by the teacher model; obtain a distillation loss function between the student model and the teacher model based on the first feature and the second feature; extract features of the sample enhanced image and the first sample image through a pre-trained face recognition model to obtain a third feature of the sample enhanced image and a fourth feature of the first sample image; obtain a similarity loss function between the sample enhanced image and the first sample image based on the third feature and the fourth feature; and use the preset loss function, the distillation loss function and the similarity loss function as the first total loss function.
[0162] Furthermore, the adjustment module 130 is also used to: input the first sample image and the sample enhanced image into the discriminant network of the face enhancement model during the i-th training respectively to obtain the first eigenvalue of the first sample image and the second eigenvalue of the sample enhanced image; and obtain the second total loss function according to the first eigenvalue and the second eigenvalue.
[0163] According to a training device for a face enhancement model of an embodiment of the present disclosure, a first sample image and a second sample image corresponding to the first sample image are obtained, wherein the clarity of the first sample image is higher than that of the second sample image, the face enhancement model is trained for the i-th time based on the first sample image and the second sample image to obtain a sample enhanced image of the second sample image, wherein the value of i is an integer greater than or equal to 1, and based on the sample enhanced image and the first sample image, the number of channels of each convolutional layer in the face enhancement model is reduced, and the model parameters of the face enhancement model are adjusted to obtain the face enhancement model at the time of the i+1-th training, and the first sample image and the second sample image are continuously used to train the face enhancement model for the i+1-th time until the training end condition is met to obtain the trained target face enhancement model. By dynamically enhancing the first sample image to obtain the second sample image and reducing the number of channels of each convolutional layer in the face enhancement model, the amount of computation of the face enhancement model is reduced, the face enhancement model is made more lightweight, the quality of the output image of the face enhancement model is guaranteed, and the accuracy of the face enhancement model is improved.
[0164] Fig.10 is a block diagram of an image processing apparatus according to an exemplary embodiment.
[0165] like Fig.10 As shown, the image processing device 2000 includes: a first acquisition module 210 and an output module 120 .
[0166] A first acquisition module 210, used to acquire an image to be processed;
[0167] The output module 220 is used to input the image to be processed into a target face enhancement model, and the target face enhancement model outputs a target enhanced image of the image to be processed, wherein the target face enhancement model is a model trained using the training method of the face enhancement model described in the first aspect.
[0168] Furthermore, the device 2000 is also used to: input the image to be processed into a super-resolution model, and the super-resolution model outputs a high-definition image corresponding to the image to be processed; input the target enhanced image into a face parsing model, and the face parsing model outputs a region segmentation image of the target enhanced image; and fuse the high-definition image, the region segmentation image and the target enhanced image to obtain the target image of the image to be processed.
[0169] According to an image processing device of an embodiment of the present disclosure, an image to be processed is acquired and input into a target face enhancement model, and the target face enhancement model outputs a target enhanced image of the image to be processed, so that the image to be processed can be subjected to face enhancement processing through a converged target face enhancement model, thereby ensuring the face enhancement effect and improving the quality of the image to be processed.
[0170] In order to implement the above embodiments, the present disclosure also provides an electronic device, such as Fig.11 As shown, the electronic device 3000 includes: a processor 301; one or more memories 302 for storing executable instructions of the processor 301; wherein the processor 301 is configured to execute the training method or image processing method of the face enhancement model described in the above embodiment. The processor 301 and the memory 302 are connected via a communication bus.
[0171] In order to implement the above embodiments, the present disclosure further provides a computer-readable storage medium including instructions, such as a memory 302 including instructions, and the above instructions can be executed by the processor 301 of the device 1000 or the device 2000 to complete the above method. Optionally, the 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.
[0172] In order to implement the above embodiments, the present disclosure also provides a computer program product, including a computer program, characterized in that when the computer program is executed by a processor, it implements the training method or image processing method of the face enhancement model described in the above embodiments.
[0173] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0174] It should be understood that the present disclosure is not limited to the exact 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 appended claims.
Claims
1. A training method for a face enhancement model, It is characterized in that The method comprises: Acquire a first sample image and a second sample image corresponding to the first sample image, wherein the clarity of the first sample image is higher than the clarity of the second sample image; Performing an i-th training on the face enhancement model based on the first sample image and the second sample image to obtain a sample enhanced image of the second sample image, where the value of i is an integer greater than or equal to 1; Based on the sample enhanced image and the first sample image, reducing the number of channels of each convolutional layer in the face enhancement model, and adjusting the model parameters of the face enhancement model, to obtain the face enhancement model during the (i+1)th training; Continue to use the first sample image and the second sample image to train the face enhancement model for the (i+1)th time, until the training end condition is met to obtain the trained target face enhancement model.
2. The method according to claim 1, It is characterized in that The process of acquiring the second sample image corresponding to the first sample image includes: The first sample image is enhanced to obtain a second sample image corresponding to the first sample image.
3. The method according to claim 2, It is characterized in that The performing enhancement processing on the first sample image to obtain a second sample image corresponding to the first sample image includes: Acquire an enhancement type for the first sample image and an enhancement coefficient corresponding to the enhancement type; The first sample image is enhanced according to the enhancement type and the enhancement coefficient to obtain the second sample image corresponding to the first sample image.
4. The method according to claim 3, It is characterized in that After performing enhancement processing on the first sample image according to the enhancement type and the enhancement coefficient to obtain the second sample image corresponding to the first sample image, the method further includes: Obtaining a data enhancement factor of the face enhancement model during the i-th training; According to the data enhancement factor, determining whether it is necessary to adjust the enhancement coefficient of the first sample image; It is determined that the enhancement coefficient of the first sample image needs to be adjusted, and the first sample image is re-enhanced according to the enhancement type and the adjusted enhancement coefficient to obtain the second sample image during the (i+1)th training.
5. The method according to claim 4, It is characterized in that The step of obtaining the data enhancement factor of the face enhancement model during the i-th training also includes: Inputting the second sample image, the first sample image and the sample enhanced image into the discriminant network in the face enhancement model during the i-th training respectively, to obtain a first output value of the second sample image, a second output value of the first sample image and a third output value of the sample enhanced image; Obtaining a first mean of the second sample images, a second mean of the second sample images, and a third mean of the sample enhanced images according to the first output value and the number of the second sample images, the second output value and the number of the first sample images, and the third output value and the number of the sample enhanced images; According to the first mean, the second mean and the third mean, a data enhancement factor of the face enhancement model during the i-th training is obtained.
6. The method according to claim 1, It is characterized in that The reducing the number of channels of each convolutional layer in the face enhancement model based on the sample enhanced image and the first sample image includes: Obtaining a reduction ratio of the number of channels of each convolutional layer in the face enhancement model during the i-th training; According to the reduction ratio, the number of channels of each convolutional layer in the face enhancement model during the i-th training is reduced.
7. The method according to claim 6, It is characterized in that After reducing the number of channels of each convolutional layer in the face enhancement model during the i-th training according to the reduction ratio, the method further includes: Obtaining a quality assessment result of the second sample image output by each convolutional layer in the face enhancement model during the i-th training; According to the quality evaluation result, it is determined whether to adjust the reduction ratio.
8. The method according to claim 7, It is characterized in that The determining, according to the quality assessment result, whether to adjust the reduction ratio further includes: In response to the quality assessment result of the second sample image satisfying the image quality index, there is no need to adjust the reduction ratio; or In response to the quality assessment result of the second sample image failing to meet the image quality index, a reduction ratio of the number of channels of the convolutional layer failing to meet the image quality index is adjusted.
9. The method according to claim 1, It is characterized in that The process of acquiring the sample enhanced image of the second sample image includes: Inputting the second sample image into the convolutional network and the linear mapping network of the face enhancement model to output the noise features and attribute features of the second sample image; The noise feature and the attribute feature are input into a generation network of the face enhancement model, and the generation network generates a sample enhanced image corresponding to the second sample image based on the noise feature and the attribute feature.
10. The method according to claim 1, It is characterized in that The adjusting the model parameters of the face enhancement model to obtain the face enhancement model during the (i+1)th training includes: Obtaining a first total loss function of a generative network and a second total loss function of a discriminative network of the face enhancement model during the i-th training; According to the first total loss function and the second total loss function, the model parameters of the face enhancement model during the i-th training are adjusted to obtain the face enhancement model during the i+1-th training.
11. The method according to claim 10, It is characterized in that The obtaining of the first total loss function of the generative network of the face enhancement model during the i-th training includes: Obtaining a preset loss function of the face enhancement model during the i-th training; Extracting features of the second sample image by using a student model and a pre-trained teacher model to obtain a first feature extracted by the student model and a second feature extracted by the teacher model; According to the first feature and the second feature, obtaining a distillation loss function between the student model and the teacher model; Performing feature extraction on the sample enhanced image and the first sample image by using a pre-trained face recognition model to obtain a third feature of the sample enhanced image and a fourth feature of the first sample image; According to the third feature and the fourth feature, obtaining a similarity loss function between the sample enhanced image and the first sample image; The preset loss function, the distillation loss function and the similarity loss function are used as the first total loss function.
12. The method according to claim 10, It is characterized in that The obtaining of the second total loss function of the discriminant network of the face enhancement model during the i-th training includes: Inputting the first sample image and the sample enhanced image into the discriminant network of the face enhancement model during the i-th training respectively to obtain a first eigenvalue of the first sample image and a second eigenvalue of the sample enhanced image; The second total loss function is obtained according to the first eigenvalue and the second eigenvalue.
13. An image processing method, It is characterized in that The method comprises: Get the image to be processed; The image to be processed is input into a target face enhancement model, and the target face enhancement model outputs a target enhanced image of the image to be processed, wherein the target face enhancement model is a model trained using the training method for the face enhancement model as described in any one of claims 1 to 12.
14. The method according to claim 13, It is characterized in that The method further comprises: Inputting the image to be processed into a super-resolution model, and having the super-resolution model output a high-definition image corresponding to the image to be processed; Inputting the target enhanced image into a face parsing model, and having the face parsing model output a region segmentation image of the target enhanced image; The high-definition image, the region segmentation image and the target enhanced image are fused to obtain a target image of the image to be processed.
15. A training device for a face enhancement model, It is characterized in that The device comprises: an acquisition module, configured to acquire a first sample image and a second sample image corresponding to the first sample image, wherein the clarity of the first sample image is higher than the clarity of the second sample image; a first training module, configured to perform an i-th training on a face enhancement model based on the first sample image and the second sample image to obtain a sample enhanced image of the second sample image, where the value of i is an integer greater than or equal to 1; An adjustment module, used to reduce the number of channels of each convolutional layer in the face enhancement model and adjust the model parameters of the face enhancement model based on the sample enhanced image and the first sample image, so as to obtain the face enhancement model during the (i+1)th training; The second training module is used to continue to use the first sample image and the second sample image to perform the (i+1)th training on the face enhancement model until the training end condition is met to obtain the trained target face enhancement model.
16. The device according to claim 15, It is characterized in that The acquisition module is further used for: The first sample image is enhanced to obtain a second sample image corresponding to the first sample image.
17. The device according to claim 16, It is characterized in that The acquisition module is further used for: Acquire an enhancement type for the first sample image and an enhancement coefficient corresponding to the enhancement type; The first sample image is enhanced according to the enhancement type and the enhancement coefficient to obtain the second sample image corresponding to the first sample image.
18. The device according to claim 17, It is characterized in that The acquisition module is further used for: Obtaining a data enhancement factor of the face enhancement model during the i-th training; According to the data enhancement factor, determining whether it is necessary to adjust the enhancement coefficient of the first sample image; It is determined that the enhancement coefficient of the first sample image needs to be adjusted, and the first sample image is re-enhanced according to the enhancement type and the adjusted enhancement coefficient to obtain the second sample image during the (i+1)th training.
19. The device according to claim 18, It is characterized in that The acquisition module is further used for: Inputting the second sample image, the first sample image and the sample enhanced image into the discriminant network in the face enhancement model during the i-th training respectively, to obtain a first output value of the second sample image, a second output value of the first sample image and a third output value of the sample enhanced image; Obtaining a first mean of the second sample images, a second mean of the second sample images, and a third mean of the sample enhanced images according to the first output value and the number of the second sample images, the second output value and the number of the first sample images, and the third output value and the number of the sample enhanced images; According to the first mean, the second mean and the third mean, a data enhancement factor of the face enhancement model during the i-th training is obtained.
20. The device according to claim 15, It is characterized in that The adjustment module is further used for: Obtaining a reduction ratio of the number of channels of each convolutional layer in the face enhancement model during the i-th training; According to the reduction ratio, the number of channels of each convolutional layer in the face enhancement model during the i-th training is reduced.
21. The device according to claim 20, It is characterized in that The adjustment module is further used for: Obtaining a quality assessment result of the second sample image output by each convolutional layer in the face enhancement model during the i-th training; According to the quality evaluation result, it is determined whether to adjust the reduction ratio.
22. The device according to claim 21, It is characterized in that The adjustment module is further used for: In response to the quality assessment result of the second sample image satisfying the image quality index, there is no need to adjust the reduction ratio; or In response to the quality assessment result of the second sample image failing to meet the image quality index, a reduction ratio of the number of channels of the convolutional layer failing to meet the image quality index is adjusted.
23. The device according to claim 15, It is characterized in that The first training module is further used for: Inputting the second sample image into the convolutional network and the linear mapping network of the face enhancement model to output the noise features and attribute features of the second sample image; The noise feature and the attribute feature are input into a generation network of the face enhancement model, and the generation network generates a sample enhanced image corresponding to the second sample image based on the noise feature and the attribute feature.
24. The device according to claim 15, It is characterized in that The adjustment module is further used for: Obtaining a first total loss function of a generative network and a second total loss function of a discriminative network of the face enhancement model during the i-th training; According to the first total loss function and the second total loss function, the model parameters of the face enhancement model during the i-th training are adjusted to obtain the face enhancement model during the i+1-th training.
25. The device according to claim 24, It is characterized in that The adjustment module is further used for: Obtaining a preset loss function of the face enhancement model during the i-th training; Extracting features of the second sample image by using a student model and a pre-trained teacher model to obtain a first feature extracted by the student model and a second feature extracted by the teacher model; According to the first feature and the second feature, obtaining a distillation loss function between the student model and the teacher model; Performing feature extraction on the sample enhanced image and the first sample image by using a pre-trained face recognition model to obtain a third feature of the sample enhanced image and a fourth feature of the first sample image; According to the third feature and the fourth feature, obtaining a similarity loss function between the sample enhanced image and the first sample image; The preset loss function, the distillation loss function and the similarity loss function are used as the first total loss function.
26. The device according to claim 24, It is characterized in that The adjustment module is further used for: Inputting the first sample image and the sample enhanced image into the discriminant network of the face enhancement model during the i-th training respectively to obtain a first eigenvalue of the first sample image and a second eigenvalue of the sample enhanced image; The second total loss function is obtained according to the first eigenvalue and the second eigenvalue.
27. An image processing device, It is characterized in that The device comprises: A first acquisition module, used for acquiring an image to be processed; An output module is used to input the image to be processed into a target face enhancement model, and the target face enhancement model outputs a target enhanced image of the image to be processed, wherein the target face enhancement model is a model trained using the training method of the face enhancement model as described in any one of claims 1 to 12.
28. The device according to claim 27, It is characterized in that The device is also used for: Inputting the image to be processed into a super-resolution model, and having the super-resolution model output a high-definition image corresponding to the image to be processed; Inputting the target enhanced image into a face parsing model, and having the face parsing model output a region segmentation image of the target enhanced image; The high-definition image, the region segmentation image and the target enhanced image are fused to obtain a target image of the image to be processed.
29. An electronic device, It is characterized in that include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the training method or image processing method of the face enhancement model as described in any one of claims 1 to 12 or claims 13 to 14 is implemented.
30. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, it implements the training method or image processing method of the face enhancement model as described in any one of claims 1-12 or claims 13-14.
31. A computer program product, comprising a computer program, which, when executed by a processor, implements the training method or image processing method of the face enhancement model according to any one of claims 1-12 or claims 13-14.
Citation Information
Patent Citations
Image enhancement model training method and device, image enhancement method and device and storage medium
CN110163235A
Image processing method and device, storage medium and electronic equipment
CN113592733A
Model training method, face recognition method, device, equipment, medium and product
CN114140862A
Target detection method and apparatus, storage medium, and terminal
WO2022111352A1
