Image restoration model training method and apparatus, image restoration method and apparatus, and electronic device

Through the image repair model training method based on the style generation adversarial network and the feature extraction network, the problems of low accuracy and poor practicality of face image repair in the existing technology are solved, and a more efficient face image repair effect is achieved.

WO2024188008A1PCT designated stage expired Publication Date: 2024-09-19XIAMEN MEITUZHIJIA TECH

Patent Information

Application Number
PCT/CN2024/076393
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-03-13
Filing Date
2024-02-06
Publication Date
2024-09-19

AI Technical Summary

Technical Problem

The existing technology relies on clear areas for repair in face image repair, which leads to problems such as low repair accuracy and poor practicability when facial information is seriously missing or the image is uneven.

Method used

The image repair model training method based on style generation adversarial network and feature extraction network is used to generate adversarial loss value, absolute value loss value and gradient difference loss value through iterative optimization to improve the accuracy and practicality of facial image repair.

Benefits of technology

It significantly improves the accuracy and practicality of face image repair, can generate high-definition face images more accurately, reduces repair errors, and improves the reliability and performance of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024076393_19092024_PF_FP_ABST
    Figure CN2024076393_19092024_PF_FP_ABST
Patent Text Reader

Abstract

An image restoration model training method and apparatus, an image restoration method and apparatus, and an electronic device, relating to the technical field of computers. The method comprises: training on the basis of a first training image set to obtain a style generative adversarial network, and forming the style generative adversarial network, a feature extraction network and a discriminator into an initial image restoration model (S1001); obtaining a plurality of target face images on the basis of a second training image set, and inputting each target face image into the feature extraction network for feature extraction to obtain a feature vector (S1002); outputting a predicted face image by means of the style generative adversarial network according to the feature vector and noise information outputted by a coding layer (S1003); and determining loss information according to the predicted face images and the second training image set, performing iterative optimization on the initial image restoration model on the basis of the loss information until a preset condition is met, using the initial image restoration model when the preset condition is met as a target image restoration model, and stopping training (S1004).
Need to check novelty before this filing date? Find Prior Art

Description

Image restoration model training method, image restoration method, device and electronic device

[0001] Related applications

[0002] This application claims priority to Chinese patent application No. 2023102347754, filed on March 13, 2023, entitled “Image restoration model training method, image restoration method, device and electronic device,” the entire text of which is hereby incorporated by reference. Technical Field

[0003] The present application relates to the field of computer technology, and in particular to an image restoration model training method, an image restoration method, a device, and an electronic device. Background Art

[0004] With the development of artificial intelligence technology, people have begun to use neural network technology to repair images, such as repairing old photos or blurred facial images.

[0005] In related technologies, in order to repair a facial image, the relatively clear areas in the image to be repaired can be used to fill and repair damaged or blurred areas. For example, based on a sample block repair algorithm, the priority of each area to be repaired can be determined based on the damaged or blurred area to be repaired and the surrounding clear areas in the image to be repaired, and each area to be repaired can be repaired in descending order of priority. Specifically, a matching standard can be formulated based on the minimum absolute square difference, and the matching blocks that best match each area to be repaired can be found from a large number of possible sample blocks and filled into each area to be repaired, finally obtaining a repaired facial image.

[0006] However, because related art solutions require repairing blurred or missing areas based on the clearer areas of the image to be repaired, if the image to be repaired is severely missing facial information or the image is uneven, the repaired face image will differ significantly from the original. Therefore, this solution suffers from low accuracy and poor practicality.

[0007] Summary of the Invention

[0008] A first aspect of an embodiment of the present application provides an image restoration model training method, the method comprising:

[0009] A style generative adversarial network is trained based on the first training image set, and the style generative adversarial network, a feature extraction network, and a discriminator are combined into an initial image restoration model, wherein the feature extraction network includes a plurality of encoding layers and a fully connected layer connected in sequence;

[0010] obtaining a plurality of target face images based on the second training image set, and inputting each of the target face images into the feature extraction network for feature extraction to obtain a feature vector;

[0011] Outputting, by the style generative adversarial network, at least one predicted face image based on the feature vector and noise information output by at least one encoding layer in the feature extraction network;

[0012] Loss information is determined based on each of the predicted facial images and the second training image set, and the initial image restoration model is iteratively optimized based on the loss information until a preset condition is met. The initial image restoration model that meets the preset condition is used as the target image restoration model, and training is stopped.

[0013] Optionally, obtaining a plurality of target face images based on the second training image set, and inputting each of the target face images into the feature extraction network for feature extraction to obtain a feature vector, comprises:

[0014] performing degradation processing on the initial facial images in the second training image set to obtain the target facial images, wherein the quality of the target facial images is lower than the quality of the initial facial images;

[0015] Inputting each target face image into the first encoding layer of the feature extraction network, and encoding each target face image in turn by each encoding layer of the feature extraction network to obtain a feature map;

[0016] The fully connected layer in the feature extraction network performs dimension adjustment on the feature map to obtain the feature vector.

[0017] Optionally, the performing degradation processing on the initial facial images in the second training image set to obtain the target facial images includes:

[0018] Filtering the initial face image based on a bilateral filtering algorithm, and blurring the initial face image using a convolution kernel;

[0019] Downsample the blurred features and perform Gaussian noise processing;

[0020] The features processed with Gaussian noise are compressed and up-sampled to obtain the target face image.

[0021] Optionally, the style generation adversarial network includes multiple style generation modules, and the style generation modules are connected in sequence;

[0022] Outputting at least one predicted face image by the style generative adversarial network according to the feature vector and noise information output by each encoding layer in the feature extraction network includes:

[0023] Mapping the feature vector into a latent space feature through a mapping network in the style generation adversarial network;

[0024] The latent space features are input into each of the style generation modules, and the noise information output by at least one coding layer is input into each of the style generation modules according to the arrangement order of each coding layer in the initial image restoration model to obtain each of the predicted facial images.

[0025] Optionally, inputting the noise information output by at least one coding layer into each of the pattern generation modules according to the arrangement order of the coding layers in the initial image restoration model to obtain each of the predicted facial images includes:

[0026] Determining the arrangement order of each of the pattern generation modules;

[0027] If the arrangement order of the pattern generation module is 1, the latent space features, the preset constant term, and the random noise are input into the pattern generation module, and the pattern generation module outputs the decoding information;

[0028] If the arrangement order of the pattern generation module is not 1 and is less than a preset value, the latent space feature, the decoded information output by the previous pattern generation module, and random noise are input into the pattern generation module, and the pattern generation module outputs the decoded information;

[0029] If the arrangement order of the pattern generation modules is equal to or greater than a preset value, the latent space features, the feature map output by the encoding layer corresponding to the style generation module immediately preceding the pattern generation module, and the information output by the style generation module immediately preceding the pattern generation module are input into the pattern generation module, and the pattern generation module outputs decoding information;

[0030] The decoded information output by the last style generation module is used as the predicted face image.

[0031] Optionally, determining loss information according to each of the predicted facial images and the second training image set includes:

[0032] Determining an initial face image corresponding to each of the target face images in the second training image set;

[0033] splicing the target face images, the initial face images, and the predicted face images into a plurality of image pairs, and inputting the image pairs into the discriminator;

[0034] The loss information is determined by the discriminator based on each of the image pairs.

[0035] Optionally, determining the loss information according to each of the image pairs by the discriminator includes:

[0036] The discriminator calculates and generates an adversarial loss value based on each of the target face images and each of the predicted face images;

[0037] Calculating an absolute value loss (Smooth L1 Loss), an additional angular edge loss (Arcface Loss), and a gradient difference loss value according to each of the initial face images and each of the predicted face images;

[0038] Based on weighted summation of the generated adversarial loss value, the absolute value loss value, the additional angle edge loss value and the gradient difference loss value, the obtained sum is used as the loss information.

[0039] A second aspect of the embodiments of the present application provides an image restoration method, the method comprising:

[0040] Acquire an image to be repaired and input the image to be repaired into an image repair model, where the image repair model is any target image repair model trained in the first aspect, and the image repair model includes: a feature extraction network and a style generation adversarial network;

[0041] The feature extraction network extracts features from the image to be repaired to obtain a target feature vector;

[0042] The style generation adversarial network outputs a restored image of the image to be restored based on the target feature vector and noise information output by each encoding layer in the feature extraction network.

[0043] Optionally, the style generation adversarial network includes a plurality of style generation modules, each of which is connected in sequence; and outputting a restored image of the image to be restored by the style generation adversarial network based on the target feature vector and noise information output by each encoding layer in the feature extraction network includes:

[0044] Obtaining target latent space features based on the target feature vector mapping;

[0045] Determining the arrangement order of each of the pattern generation modules;

[0046] If the arrangement order of the pattern generation module is 1, the target latent space features, the preset constant term, and the noise information output by the last coding layer in each coding layer are input into the pattern generation module, and the pattern generation module outputs the target decoding information;

[0047] If the arrangement order of the pattern generation module is not 1, the target latent space feature, the target decoding information output by the style generation module before the style generation module, and the noise information output by the coding layer corresponding to the style generation module in each coding layer are input into the style generation module, and the style generation module outputs the target decoding information;

[0048] The target decoding information output by the last style generation module is used as the restored image.

[0049] A third aspect of the embodiments of the present application provides an image restoration model training device, the device comprising:

[0050] A composition module, configured to train a style generative adversarial network based on a first training image set, and combine the style generative adversarial network, a feature extraction network, and a discriminator to form an initial image restoration model, wherein the feature extraction network includes a plurality of sequentially connected encoding layers and a fully connected layer;

[0051] A first extraction module is configured to obtain a plurality of target face images based on the second training image set, and input each of the target face images into the feature extraction network for feature extraction to obtain a feature vector;

[0052] A first output module, configured to output at least one predicted face image by the style generative adversarial network based on the feature vector and noise information output by at least one encoding layer in the feature extraction network;

[0053] An optimization module is used to determine loss information based on each of the predicted facial images and the second training image set, iteratively optimize the initial image restoration model based on the loss information until a preset condition is met, use the initial image restoration model that meets the preset condition as the target image restoration model, and stop training.

[0054] A fourth aspect of the embodiments of the present application provides an image restoration device, comprising:

[0055] An input acquisition module is used to acquire an image to be repaired and input the image to be repaired into an image repair model, wherein the image repair model includes: a feature extraction network and a style generation adversarial network;

[0056] A second extraction module is configured to extract features of the image to be repaired by the feature extraction network to obtain a feature vector;

[0057] The second output module is configured to output a restored image of the image to be restored based on the feature vector and the noise information output by each encoding layer in the feature extraction network by the style generation adversarial network.

[0058] A fifth aspect of an embodiment of the present application provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and runnable on the processor. When the computer program is executed by the processor, it implements the image restoration model training method of the first aspect and the image restoration method of the second aspect.

[0059] A sixth aspect of an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the image restoration model training method of the first aspect and the image restoration method of the second aspect.

[0060] The details of one or more embodiments of the present application are set forth in the accompanying drawings and the description below. Other features, objects, and advantages of the present application will become apparent from the description, drawings, and claims. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.

[0062] FIG1 is a flow chart of a first image restoration model training method provided in an embodiment of the present application;

[0063] FIG2 is a flow chart of a second image restoration model training method provided in an embodiment of the present application;

[0064] FIG3 is a flow chart of a third image restoration model training method provided in an embodiment of the present application;

[0065] FIG4 is a flow chart of a fourth image restoration model training method provided in an embodiment of the present application;

[0066] FIG5 is a flowchart of a fifth image restoration model training method provided in an embodiment of the present application;

[0067] FIG6 is a flowchart of a sixth image restoration model training method provided in an embodiment of the present application;

[0068] FIG7 is a flow chart of an image restoration method provided by an embodiment of the present application;

[0069] FIG8 is a schematic structural diagram of an image restoration model provided in an embodiment of the present application;

[0070] FIG9 is a schematic structural diagram of an image restoration model training device provided in an embodiment of the present application;

[0071] FIG10 is a schematic structural diagram of an image restoration device provided in an embodiment of the present application;

[0072] FIG11 is a schematic structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0073] To make the objectives, technical solutions, and advantages of the embodiments of the present application more clear, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Generally, the components of the embodiments of the present application described and shown in the drawings herein can be arranged and designed in various different configurations.

[0074] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for protection, but merely represents selected embodiments of the present application. All other embodiments obtained by persons of ordinary skill in the art based on the embodiments in the present application without creative work are within the scope of protection of the present application.

[0075] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, it does not need to be further defined or explained in subsequent drawings.

[0076] In the description of this application, it should be noted that the terms "first", "second", "third", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0077] It should also be noted that, in the description of this application, unless otherwise expressly specified or limited, the terms "disposed," "installed," "connected," and "connected" should be understood in a broad sense. For example, they can refer to fixed connections, detachable connections, or integral connections; they can refer to mechanical connections or electrical connections; they can refer to direct connections or indirect connections through an intermediate medium; and they can refer to internal connections between two components. Those skilled in the art will understand the specific meanings of the above terms in this application based on the specific circumstances.

[0078] In related technologies, in order to repair a facial image, the relatively clear areas in the image to be repaired can be used to fill in and repair damaged or blurred areas. For example, based on a sample block repair algorithm, the priority of each area to be repaired can be determined based on the damaged or blurred area to be repaired and the surrounding clear areas in the image to be repaired, and each area to be repaired can be repaired in descending order of priority. Specifically, a matching criterion can be formulated based on the minimum absolute square difference, and the matching blocks that best match each area to be repaired can be found from a large number of possible sample blocks and filled into each area to be repaired, ultimately obtaining a repaired facial image.

[0079] However, because related art solutions require repairing blurred or missing areas based on the clearer areas of the image to be repaired, if the image to be repaired is severely missing facial information or the image is uneven, the repaired face image will differ significantly from the original. Therefore, this solution suffers from low accuracy and poor practicality.

[0080] To this end, an embodiment of the present application provides an image restoration model training method, which obtains a style generative adversarial network based on a first training image set, and combines the style generative adversarial network, a feature extraction network, and a discriminator to form an initial image restoration model. Multiple target facial images are obtained based on a second training image set, and each target facial image is input into the feature extraction network for feature extraction to obtain a feature vector. The style generative adversarial network outputs at least one predicted facial image based on the feature vector and noise information output by at least one encoding layer in the feature extraction network. Loss information is determined based on each predicted facial image and the second training image set. The initial image restoration model is iteratively optimized based on the loss information until a preset condition is met. The initial image restoration model that meets the preset condition is used as the target image restoration model, and training is stopped. This can achieve the effect of improving the accuracy and practicality of face restoration.

[0081] The present application embodiment is described by taking the image restoration model training method applied in an electronic device as an example. However, this does not mean that the present application embodiment can only be applied to electronic devices for image restoration model training.

[0082] The image restoration model training method provided in the embodiment of the present application is explained in detail below.

[0083] FIG1 is a flowchart of an image restoration model training method provided by the present application. The method can be applied to a computer device, which can be any terminal device or server. Referring to FIG1 , an embodiment of the present application provides an image restoration model training method, including steps 1001-1004.

[0084] Step 1001: A style generative adversarial network is trained based on a first training image set, and the style generative adversarial network, a feature extraction network, and a discriminator are combined to form an initial image restoration model.

[0085] Optionally, the first training image set may include multiple high-definition facial images. Each high-definition facial image may be a red-green-blue (RGB) image, and each high-definition facial image may have high quality, such as high contrast and signal-to-noise ratio, and low distortion.

[0086] Furthermore, the style generative adversarial network can randomly generate high-definition facial images based on random vectors and random noise sampled from a Gaussian distribution. The random vectors can be vectors used to represent facial feature information in each high-definition facial image, and the random noise can be used to represent facial details in each high-definition facial image.

[0087] During the training of the style generation adversarial network, the random vector and the random noises, or the latent space features corresponding to the random vector and the random noises, may be concatenated and then input into the style generation adversarial network. This embodiment of the present application does not limit this.

[0088] In addition, the style generation adversarial network may include multiple style generation modules, and each style generation module is connected in sequence.

[0089] For example, after inputting the corresponding random vectors into the style generation adversarial network, each style generation module can decode or parse each vector to output corresponding decoding information, and the decoding information output by the last style generation module in each style generation module is an image.

[0090] In addition, any possible training method can be used to train the style generative adversarial network, and the embodiments of the present application are not limited to this.

[0091] Optionally, the feature extraction network includes a plurality of encoding layers and a fully connected layer connected in sequence. The feature extraction network can extract features from an input facial image and output a feature vector corresponding to the input facial image.

[0092] In addition, the last encoding layer in each encoding layer can be connected to the fully connected layer, and the fully connected layer can be connected to the style generation adversarial network.

[0093] Each coding layer can extract features from the image or information input to the feature extraction network to output corresponding tensors or vectors, and each coding layer except the last coding layer can output a feature map to the next coding layer. The last coding layer in each coding layer can output a feature map to the fully connected layer.

[0094] For another example, each coding layer can be considered as an encoder as a whole.

[0095] The fully connected layer can map the received feature map to ensure that the style generation adversarial network can accurately identify, parse, and process the information output by the feature extraction network.

[0096] The discriminator can determine the performance of the initial image restoration model by judging the authenticity of the output of the style generative adversarial network, which is not limited in this embodiment of the present application.

[0097] Optionally, the initial image restoration model may be a network model for restoring an image. Optionally, the initial image restoration model may refer to an image restoration model that has not yet been trained or has not yet been trained.

[0098] Generally, the input of the initial image restoration model can be any low-quality, low-definition facial image, and the output of the initial image restoration model can be a high-quality facial image obtained after repairing the input facial image. The embodiments of the present application do not limit this.

[0099] It is worth noting that since the style generative adversarial network can generate high-quality, high-definition facial images based on random vectors and random noise, and the feature extraction network can output the feature vector of the facial image, it can ensure that the initial image restoration model can repair the input facial image when a facial image is input, and then output a restored facial image, so that the initial image restoration model can be trained subsequently.

[0100] Step 1002: obtaining a plurality of target face images based on the second training image set, and inputting each target face image into the feature extraction network for feature extraction to obtain a feature vector.

[0101] Optionally, the second training image set may be the same as the first training image set, or may be different from the first training image set, which is not limited in this embodiment of the present application.

[0102] Exemplarily, the second training image set may include only multiple high-definition face images, or it may include multiple high-definition face images and low-definition face images corresponding to each high-definition face image, or it may include multiple image pairs of high-definition face images and low-definition face images. The embodiments of the present application are not limited to this.

[0103] That is, if the second training image set includes multiple high-definition face images, then these multiple high-definition face images can be regarded as the original images of each target face image.

[0104] Optionally, each target facial image may refer to a low-definition facial image of lower quality, which is not limited in the embodiments of the present application.

[0105] In addition, each target facial image can be sequentially input into the feature extraction network for feature extraction to obtain multiple feature vectors. In other words, the feature vector can be a vector corresponding to a target facial image, and the feature vector is used to represent the characteristic information and overall content of the face in the target facial image.

[0106] The dimension of the feature vector can be (1, 512) or any other possible dimension, which is not limited in the embodiment of the present application.

[0107] It's worth noting that since each target facial image is a low-quality, low-definition facial image, each feature vector is a vector used to characterize the characteristic information and overall content of the face in the low-definition facial image. This allows each target facial image to be converted into a feature vector, ensuring that when the feature extraction network subsequently inputs this feature vector into the style-generating adversarial network, the style-generating adversarial network can recognize and interpret the feature vector, thereby ensuring the practicality of the image restoration model training method.

[0108] Step 1003: The style generative adversarial network outputs at least one predicted face image based on the feature vector and noise information output by at least one encoding layer in the feature extraction network.

[0109] Optionally, the noise information may refer to a feature map output when the encoding layer encodes each target facial image, and the noise information may be used to supplement facial details in each target facial image.

[0110] In addition, the noise information output by at least one encoding layer in the feature extraction network may refer to a feature map output by a part of the encoding layers in the feature extraction network.

[0111] Optionally, the predicted facial image may refer to a restored facial image obtained by repairing the target facial image by the initial image restoration model or the style generation adversarial network in the initial image restoration model.

[0112] It's worth noting that since the style-based GAN can generate high-definition facial images based on random vectors and random noise sampled from a Gaussian distribution, after inputting the feature vectors and noise information into the style-based GAN, it can generate a high-quality, restored facial image. This facilitates subsequent training of the initial image restoration model based on the predicted facial image.

[0113] Step 1004: Determine loss information based on each predicted facial image and the second training image set, iteratively optimize the initial image restoration model based on the loss information until a preset condition is met, use the initial image restoration model that meets the preset condition as the target image restoration model, and stop training.

[0114] Optionally, the loss information can be used to characterize the performance of the initial image restoration model, and can also be used to characterize the difference between each predicted face image and the original image in the second training image set, or the difference between each predicted face image and the target face image obtained based on the second training image set.

[0115] Optionally, the preset condition may refer to the number of iterations reaching a certain threshold, or the loss information being less than or equal to a preset loss value, which is not limited in the embodiments of the present application.

[0116] Optionally, the target image restoration model may refer to a trained initial image restoration model, or may refer to an initial image restoration model with higher performance when the restoration quality is low or there are missing facial images. This embodiment of the present application does not limit this.

[0117] It is worth noting that since the initial image inpainting model in steps 1001-1003 has not yet been trained or optimized, the predicted facial images output by the initial image inpainting model may be of low quality, blurry, or significantly different from the original images. Therefore, it is necessary to determine the loss information and then the performance of the initial image inpainting model, and to adjust and optimize the parameters of the initial image inpainting model accordingly, so as to continuously improve the performance of the initial image inpainting model in inpainting each target facial image during the iterative optimization process.

[0118] It is worth noting that since the loss information represents the difference between the predicted face image output by the initial image restoration model and the original image or target face image in the second training image set, iterative correction of the initial image restoration model through the loss information can effectively reduce the error output by the initial image restoration model, thereby improving the accuracy of the initial image restoration model.

[0119] In this way, the reliability and accuracy of training the initial image restoration model can be improved, thereby improving the accuracy of the target image restoration model in restoring the input low-definition face image to generate a high-definition face image.

[0120] In an embodiment of the present application, a style generative adversarial network is obtained by training based on a first training image set, and the style generative adversarial network, a feature extraction network, and a discriminator form an initial image restoration model. A plurality of target face images are obtained based on a second training image set, and each target face image is input into the feature extraction network for feature extraction to obtain a feature vector. The style generative adversarial network outputs at least one predicted face image based on the feature vector and the noise information output by at least one coding layer in the feature extraction network. Loss information is determined based on each predicted face image and the second training image set, and the initial image restoration model is iteratively optimized based on the loss information until a preset condition is met. The initial image restoration model that meets the preset condition is used as the target image restoration model, and training is stopped.

[0121] Among them, a style generative adversarial network is trained based on the first training image set, and the style generative adversarial network, feature extraction network and discriminator are combined to form an initial image restoration model, which can obtain an initial image restoration model that can repair the input face image and then output the restored face image.

[0122] Based on the second training image set, multiple target facial images are obtained and input into the feature extraction network for feature extraction to obtain feature vectors. This allows each target facial image to be converted into a feature vector, ensuring that the feature extraction network can subsequently input the feature vector into the style generative adversarial network, allowing the style generative adversarial network to recognize and interpret the feature vector.

[0123] The GAN outputs at least one predicted facial image based on the feature vector and the noise information output by at least one encoding layer in the feature extraction network. After the feature vector and the noise information are input into the GAN, it can generate a high-quality, restored facial image. This facilitates subsequent training of the initial image restoration model based on the predicted facial image.

[0124] Loss information is determined based on each predicted facial image and the second training image set, and the initial image restoration model is iteratively optimized based on the loss information until a preset condition is met. The initial image restoration model that meets the preset condition is used as the target image restoration model, and training is stopped.

[0125] Since the loss information represents the difference between the predicted face image output by the initial image restoration model and the original image or target face image in the second training image set, iterative correction of the initial image restoration model through the loss information can effectively reduce the error output by the initial image restoration model, thereby improving the accuracy of the image restored by the initial image restoration model.

[0126] In other words, by training the initial image restoration model based on the generative adversarial network, we can obtain a target image restoration model that can accurately generate high-definition facial images. This can improve the accuracy and practicality of face restoration.

[0127] In one possible implementation, referring to FIG. 2 , a plurality of target face images are obtained based on the second training image set, and each target face image is input into the feature extraction network for feature extraction to obtain a feature vector, including steps 1005 - 1007 .

[0128] Step 1005: Degrade the initial facial images in the second training image set to obtain target facial images.

[0129] Optionally, in the present application, degradation processing may refer to an operation that reduces image quality. For example, degradation processing may include: reducing image quality, increasing the blurriness of an image, reducing an image, or compressing an image, etc. The embodiments of the present application do not limit this.

[0130] Optionally, each initial facial image may be the aforementioned multiple high-definition facial images in the second training image set.

[0131] Optionally, the quality of each target facial image is lower than the quality of each initial facial image.

[0132] For example, image quality can generally be evaluated using parameters such as the signal-to-noise ratio, contrast, distortion, and blur. For example, the higher the image quality, the higher the signal-to-noise ratio and contrast, and the lower the distortion and blur. The lower the image quality, the lower the signal-to-noise ratio and contrast, and the higher the distortion and blur.

[0133] In this way, low-quality, low-definition target face images can be obtained, which facilitates the subsequent extraction of feature vectors of each target face image to train the initial image restoration model.

[0134] Step 1006: Input each target face image into the first encoding layer in the feature extraction network, and encode it in turn through each encoding layer in the feature extraction network to obtain a feature map.

[0135] Optionally, each coding layer may include a 3×3 convolution layer and a nonlinear activation layer.

[0136] For example, each encoding layer can be regarded as an encoder E, and the fully connected layer can be represented by F. Then the feature vector output by the fully connected layer can be represented by z lq =F(E(I lq ))express.

[0137] Among them, I lq is the target face image.

[0138] Since the coding layers are connected sequentially, the first coding layer may refer to the first coding layer arranged among the coding layers.

[0139] Optionally, encoding by each coding layer in the feature extraction network in sequence may mean that any coding layer encodes the received feature map or information and outputs the encoded feature map or information to the next coding layer, until the last coding layer outputs the encoded feature map to the fully connected layer.

[0140] For example, after a target face image is input into the first coding layer, the first coding layer can output a tensor with a dimension of (1, 512, 4, 4). After each coding layer is encoded in sequence, the last coding layer can output a (1, 512*4*4) = (1, 8192)-dimensional vector, that is, the feature map can be a (1, 8192)-dimensional vector.

[0141] In this way, the encoding of each target face image can be completed, and the encoded feature map can be output to the fully connected layer.

[0142] Step 1007: The fully connected layer in the feature extraction network performs dimension adjustment on the feature map to obtain the feature vector.

[0143] Optionally, the dimensionality adjustment may refer to adjusting the dimensions of the feature maps output by each encoding layer after encoding each target face image to the dimensions required for input into the above-mentioned style generative adversarial network, which may specifically refer to a dimensionality reduction operation.

[0144] For example, if the feature map obtained in step 1006 can be a (1, 8192)-dimensional vector, after dimension adjustment, a (1, 512)-dimensional feature vector can be obtained.

[0145] In this way, each target face image can be converted into a feature vector for characterizing the characteristic information and overall content of the face in the low-definition face image, so as to ensure that after the feature extraction network inputs the feature vector into the style generation adversarial network, the style generation adversarial network can recognize and parse the feature vector, thereby ensuring the practicality of the image restoration model training method.

[0146] In a possible implementation, referring to FIG. 3 , the initial facial images in the second training image set are degraded to obtain target facial images, including steps 1008 - 1010 .

[0147] Step 1008: Filter the initial facial image based on a bilateral filtering algorithm, and blur the initial facial image using a convolution kernel.

[0148] Optionally, the bilateral filtering algorithm may be implemented based on a bilateral filter, and filtering the initial face image based on the bilateral filtering algorithm may simulate a skin resurfacing effect.

[0149] Optionally, the convolution kernel may be a convolution kernel for blurring an image.

[0150] The blur processing operation may include: Gaussian blur and / or motion blur, which is not limited in the embodiment of the present application.

[0151] In this way, the simulation effect of each target face image on facial details can be improved.

[0152] Step 1009: Down-sampling the blurred features and performing Gaussian noise processing.

[0153] Optionally, downsampling the blurred initial facial image may refer to reducing the initial facial image, and the reduction ratio of the initial facial image may be set according to actual needs.

[0154] Gaussian noise processing may refer to adding Gaussian noise to the initial face image.

[0155] Step 1010: compress and upsample the features processed with Gaussian noise to obtain the target face image.

[0156] Optionally, the compression process may refer to still image compression (Joint Photographic Experts Group, abbreviated as JPEG). The compression rate of the compression process may be (100-q)%, and q may be any positive real number, which may be adjusted according to actual needs.

[0157] Optionally, the features after the compression process can be upsampled. The upsampling process can be regarded as amplifying the features after the compression process. Generally, the result obtained after upsampling the features after the compression process is the target face image, which is not limited in the embodiments of the present application.

[0158] The magnification factor for the compressed features can be set based on actual needs. Generally, the product of the magnification factor for the compressed features and the magnification factor for the initial facial image is 1. This ensures that the resulting target facial images are the same size as the initial facial images.

[0159] It should be noted that the degradation process may include: filtering based on a bilateral filtering algorithm, blurring, downsampling, and compression. Generally, upsampling can be considered as an operation performed after the degradation process to restore the image to its original size before downsampling.

[0160] For example, the initial face image can be degraded using the following formula:

[0161] Among them, I hq is the input initial face image, k represents the convolution kernel used for blurring, ↓ s Indicates the scale of sampling, n σ Indicates adding Gaussian noise with variance σ to the initial face image, JPEG q Indicates that JPEG image compression with a compression rate of (100-q)% is applied to the original image. lq is the target face image corresponding to the initial face image, and BF represents the bilateral filter.

[0162] Specifically, the filtering process of the bilateral filtering algorithm can be implemented by the following formula:

[0163] Among them, w(i,j,x,y) represents the bilateral filtering weight value at point (i,j) in the spatial domain S, point (i,j) can be any point in the spatial domain S, point (x,y) is the coordinate of the center point of the spatial domain S, I hq (i, j) represents the pixel value of the initial face image at point (i, j).

[0164] in addition, represents the variance of the Gaussian distribution in the spatial domain S, Represents the range variance.

[0165] In this way, the degradation processing of the initial face image can be achieved. In addition, after the degradation processing is completed, the corresponding upsampling processing can be performed to ensure that the size of each target face image is the same as the initial face image, so that it can be subsequently input into the feature extraction network for processing.

[0166] In one possible implementation, referring to FIG4 , the style generative adversarial network outputs at least one predicted face image based on the feature vector and the noise information output by each coding layer in the feature extraction network, including steps 1011-1012.

[0167] Step 1011: Map the feature vector into latent space features through the mapping network in the style generative adversarial network.

[0168] Optionally, the mapping network can be connected to the above-mentioned fully connected layer, and can also be connected to each style generation module in the style generation adversarial network.

[0169] The input of the mapping network is the feature vector output by the fully connected layer, and the output of the mapping network is the latent space feature.

[0170] Optionally, the latent space feature can generally be a tensor or vector of any dimension, generally a 4-dimensional tensor. And the dimension of each of the random noises can generally be the same as the dimension of the latent space feature.

[0171] In the process of training the style generative adversarial network, the latent space features corresponding to the random vector can be spliced ​​with each random noise and then input into the style generative adversarial network. For example, the latent space features corresponding to any random vector can be a (1, 512, 4, 4)-dimensional tensor, and each random noise can also be a (1, 512, 4, 4)-dimensional tensor. Then, after splicing the latent space features corresponding to any random vector with any random noise in the second dimension, a (1, 1024, 4, 4)-dimensional tensor can be obtained. This embodiment of the present application is not limited to this.

[0172] It is worth noting that, generally, the feature vector is a random vector that conforms to a uniform or Gaussian distribution. However, the distribution of various initial facial images is very complex. Therefore, by mapping the feature vector to a more complex latent space through the mapping network and expressing it through the features of the latent space, the richness of the feature vector can be improved. In this way, the problem of not being able to accurately represent the target facial image due to the feature vector not conforming to a uniform or Gaussian distribution can be avoided.

[0173] Step 1012: Input the latent space features into each style generation module, and input the noise information output by at least one coding layer into each style generation module according to the arrangement order of each coding layer in the initial image restoration model to obtain each predicted face image.

[0174] Optionally, each coding layer corresponds to each style generation model. Generally, the first coding layer corresponds to the last style generation model, ..., and the last coding layer corresponds to the first style generation model.

[0175] For example, if there are 9 style generation models, 9 coding layers are required. Generally, the Nth coding layer needs to output noise information to the 10th-Nth style generation models, where N is a positive integer less than or equal to 9.

[0176] In this way, each style generation module can generate each predicted face image based on the latent space features and each noise information. Moreover, because the latent space features have a higher expression richness, the accuracy and reliability of generating each predicted face image can be further improved.

[0177] In one possible implementation, according to the arrangement order of the coding layers in the initial image restoration model, the noise information output by at least one coding layer is input into each pattern generation module to obtain each predicted face image, including:

[0178] Determine the order in which each style generation module is arranged.

[0179] Optionally, the arrangement order of the pattern generation modules may refer to the order in which the pattern generation modules are connected in sequence.

[0180] If the arrangement order of the pattern generation module is 1, the latent space feature, the preset constant term and the random noise are input into the pattern generation module, and the pattern generation module outputs the decoding information.

[0181] Optionally, the preset constant term may be a constant used to enable the pattern generation module to perform normal decoding, and the preset constant term may be generated by any network layer or module and input to the pattern generation module.

[0182] Optionally, the decoding information may be used to represent image data obtained by the pattern generation module by decoding the latent space features, the preset constant term, and the random noise.

[0183] It is worth noting that since there is no other style generation module before the style generation module with the arrangement order of 1, the constant term needs to be input to enable the first style generation module to be decoded normally.

[0184] If the arrangement order of the style generation module is not 1 and is less than a preset value, the latent space feature, the decoded information output by the style generation module before the style generation module, and random noise are input into the style generation module, and the style generation module outputs the decoded information.

[0185] Optionally, the preset value may be determined by relevant technical personnel according to actual needs. Generally, the preset value is smaller than the number of each style generation module, and the preset value may be set to be smaller.

[0186] It is worth noting that since there are other style generation modules before the style generation module whose arrangement order is not 1, the decoding information output by the style generation module before this style generation module needs to be output to these style generation modules, so that the corresponding decoding of the encoded data of each encoding layer can be achieved.

[0187] In addition, since random noise input that obeys Gaussian distribution is still used in each style generation module whose arrangement order is less than the preset value, the input of random Gaussian noise can be maintained, so that the style generation adversarial network maintains a high generation ability, thereby improving the quality of generating the preset face image.

[0188] If the arrangement order of the style generation module is equal to or greater than a preset value, the latent space feature, the feature map output by the encoding layer corresponding to the style generation module before the style generation module, and the information output by the style generation module before the style generation module are input into the style generation module, and the style generation module outputs the decoding information.

[0189] It is worth noting that, since each style generation module whose arrangement order is equal to or greater than the preset value inputs the feature map output by the encoding layer corresponding to the style generation module before the style generation module, the generated preset face image can be supplemented with more feature information from the target face image, thereby reducing the difference between the preset face image and the target face image.

[0190] The decoded information output by the last style generation module is used as the predicted face image.

[0191] It is worth noting that each style generation module can be regarded as a decoder as a whole. The decoder can re-parse the information contained in this feature vector and generate it into an image. Then the decoded information output by the last style generation module in each style generation module can be an image, that is, the predicted face image.

[0192] In a possible implementation, referring to FIG. 5 , loss information is determined based on each predicted facial image and the second training image set, including steps 1013 - 1015 .

[0193] Step 1013: Determine the initial face image corresponding to each target face image in the second training image set.

[0194] In this way, the corresponding relationship between each target face image and each initial face image can be accurately determined.

[0195] Step 1014: Splice each target face image, each initial face image, and each predicted face image into a plurality of image pairs, and input each image pair into the discriminator.

[0196] For example, if each initial face image is represented by I lq Indicates that each predicted face image is represented by Indicates that each initial face image is represented by I hq Indicates that the image pair obtained after stitching can be used indicates that, and G represents the above-mentioned style generative adversarial network.

[0197] In one possible approach, if the second training image set includes multiple image pairs of high-definition facial images and low-definition facial images, that is, the second training image set includes multiple initial image pairs consisting of target facial images and corresponding initial facial images, then the initial image pairs corresponding to each target facial image and each predicted facial image can be directly spliced ​​into multiple image pairs. This embodiment of the present application is not limited to this.

[0198] Step 1015: The discriminator determines the loss information based on each image pair.

[0199] In this way, the loss information characterizing the performance of the initial image restoration model, the difference between each predicted face image and the original image in the second training image set, or the difference between each predicted face image and the target face image obtained based on the second training image set can be accurately determined.

[0200] In one possible implementation, referring to FIG. 6 , the discriminator determines the loss information based on each image pair, including steps 1016 - 1018 .

[0201] Step 1016: The discriminator calculates and generates an adversarial loss value based on each target face image and each predicted face image.

[0202] For example, the generative adversarial loss value can be calculated according to the following formula:

[0203] Among them, G and D represent the above-mentioned style generative adversarial network and the discriminator, respectively, and concat represents the splicing operation.

[0204] Step 1017: Calculate the absolute value loss value, the additional corner edge loss value, and the gradient difference loss value based on each initial face image and each predicted face image.

[0205] For example, the absolute loss value L can be calculated according to the following formula: smooth l1 :

[0206] The additional angular edge loss value L can be calculated according to the following formula id :

[0207] Among them, Arcface represents the open source Arcface network.

[0208] The gradient difference loss value can also be calculated according to the following formula:

[0209] in, and Represents I hq and The number of pixels, express The pixel value at coordinate (i-1, j).

[0210] In this way, the gradient difference loss value can be used to determine the differences in horizontal and vertical gradients between each predicted face image and each initial face image, which facilitates the calculation of the difference values ​​of details such as hair, thereby improving the performance of the target image restoration model or the initial image restoration model in generating more detailed content.

[0211] Step 1018: Perform a weighted sum based on the generated adversarial loss value, the absolute value loss value, the additional angle edge loss value and the gradient difference loss value, and use the obtained sum as the loss information.

[0212] In this way, the loss information can be accurately determined, which facilitates accurate, reliable and effective training of the initial image restoration model to ensure the performance of the target image restoration model in generating facial images.

[0213] In one possible approach, when a style generative adversarial network is trained based on a first training image set, an initial generative adversarial network can be established based on a preset structure, and then multiple low-definition face images are obtained based on each high-definition face image in the first training image set. Random vectors are then extracted from each low-definition face image, and the random vectors and random noise are input into each style generation module in the initial generative adversarial network.

[0214] Each style generation module can include a style modulation layer. After inputting the corresponding random vector into the style modulation layer, a stylized feature is obtained. The stylized feature is then concatenated with random noise and subjected to style modulation including upsampling. The modulated result is then output to the next style generation module. The final style generation module uses the modulated result as the facial image output during the training process.

[0215] Then, the corresponding loss function can be used to calculate the network loss information of the face image output by the last style generation module, and the initial generative adversarial network can be iteratively optimized based on the network loss information. The initial generative adversarial network that meets the performance standards can be used as the style generative adversarial network that finally constitutes the initial image restoration model.

[0216] In this way, the training of the style generation adversarial network can be completed.

[0217] FIG7 is a flowchart of an image restoration model training method provided by the present application, which can be applied to the above-mentioned electronic device. Referring to FIG7 , an embodiment of the present application provides an image restoration method, including steps 2001-2003.

[0218] Step 2001: Acquire an image to be repaired, and input the image to be repaired into an image repair model.

[0219] Optionally, the image to be repaired can be an image of any quality, any contrast, signal-to-noise ratio, degree of distortion and / or resolution, and the image to be repaired can include the entire face or part of the face, which is not limited in this embodiment of the present application.

[0220] Optionally, the image restoration model is a target image restoration model trained by any of the above embodiments, and the image restoration model includes: a feature extraction network and a style generation adversarial network.

[0221] Specifically, inputting the image to be repaired into the image repair model may refer to inputting the image to be repaired into the first coding layer in the image repair model.

[0222] Step 2002: The feature extraction network performs feature extraction on the image to be repaired to obtain a target feature vector.

[0223] Optionally, the target feature vector can be obtained by encoding the image to be repaired in sequence through multiple encoding layers in the feature extraction network and outputting the encoding results, that is, outputting the feature map, and then adjusting the dimension of the feature map output by the last encoding layer through the fully connected layer in the feature extraction network.

[0224] Step 2003: The style generative adversarial network outputs a restored image of the image to be restored based on the target feature vector and the noise information output by each coding layer in the feature extraction network.

[0225] Optionally, the restored image is an image obtained after the image to be restored is restored by the image restoration model. The signal-to-noise ratio, contrast, clarity, quality and other indicators of the restored image are all higher than those of the image to be restored.

[0226] It is worth noting that in step 2003, when the style generation adversarial network outputs the repaired image based on the target feature vector and the noise information output by each coding layer, it is necessary to use the noise information output by all coding layers in the feature extraction network.

[0227] In one possible embodiment, the style generative adversarial network outputs a restored image of the image to be restored based on the target feature vector and noise information output by each encoding layer in the feature extraction network, including:

[0228] The target latent space features are obtained based on the target feature vector mapping.

[0229] Determine the order in which each style generation module is arranged.

[0230] If the arrangement order of the pattern generation module is 1, the target latent space feature, the preset constant term, and the noise information output by the last coding layer in each coding layer are input into the pattern generation module, and the pattern generation module outputs the target decoding information.

[0231] If the arrangement order of the style generation module is not 1, the target latent space feature, the target decoding information output by the style generation module before the style generation module, and the noise information output by the coding layer corresponding to the style generation module in each coding layer are input into the style generation module, and the style generation module outputs the target decoding information.

[0232] Illustratively, the nth coding layer in each coding layer corresponds to the M+1-nth coding layer in each pattern generation module, where M is the number of coding layers or the number of pattern generation modules, and n is a positive integer less than or equal to M.

[0233] When the arrangement order of the style generation module is not 1, the noise information output by the coding layer corresponding to the style generation module in each coding layer is input into each style generation module, which may mean that the noise information output by all coding layers except the last coding layer is input into the corresponding style generation module respectively.

[0234] In this way, it can be ensured that the consistency of feature information between the image to be restored and the restored image can be maintained.

[0235] The target decoding information output by the last style generation module is used as the restored image.

[0236] In this way, the image to be repaired can be repaired based on the image repair model.

[0237] It should be noted that the image restoration method and the image restoration model training method provided in this application correspond to each other. Some terms in the embodiments corresponding to the image restoration method have been defined in the embodiments corresponding to the image restoration model training method. For details, please refer to any of the above embodiments.

[0238] It is understood that when executing the image restoration method, the steps in the various embodiments of the corresponding image restoration model training method should also be executed. That is, after the training is completed and the target image restoration model is obtained, when applying the target image restoration model or the image restoration model, the steps executed based on the initial image restoration model during the training process can be referred to for image restoration.

[0239] In addition, since the performance of the target image restoration model obtained through training is already high, when applying the target image restoration model or the image restoration model, there is no need to call the discriminator in the model to execute the loss function or iterative optimization process.

[0240] It should be understood that, although the various steps in the flowcharts involved in the various embodiments described above are displayed in sequence according to the instructions of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowcharts involved in the various embodiments described above can include multiple steps or multiple stages, and these steps or stages are not necessarily executed and completed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of steps or stages in other steps.

[0241] Figure 8 is a structural schematic diagram of an image restoration model provided in an embodiment of the present application. Referring to Figure 8 , the image restoration model A shown in Figure 8 includes a style generation adversarial network Y, a feature extraction network T, and a discriminator P.

[0242] It can be seen that the feature extraction network T includes an encoder B and a fully connected layer q, and the encoder B also includes multiple encoding layers b connected in sequence.

[0243] The style generation adversarial network Y includes a mapping network y and a decoder j, and the decoder j also includes multiple style generation modules s connected in sequence.

[0244] Specifically, the last encoding layer b in each encoding layer b is connected to the fully connected layer q, and the fully connected layer q is connected to the mapping network y, and the mapping network y is connected to each style generation module s respectively.

[0245] The first style generation module s in each style generation module s is also used to input a constant term.

[0246] In addition, each coding layer b is connected to each style generation module s in the order of arrangement. Specifically, the first coding layer b is connected to the last style generation module s...the last coding layer b is connected to the first style generation module s.

[0247] The image restoration model A can be the above-mentioned initial image restoration model, target image restoration model or image restoration model. The working principle and beneficial effects of the image restoration model A can be specifically described in the above-mentioned other embodiments, and the embodiments of this application will not be repeated here.

[0248] The following describes the devices, equipment, and computer-readable storage media used to execute the image restoration model training method provided in this application. The specific implementation process and technical effects are described above and will not be repeated below.

[0249] FIG9 is a schematic diagram of the structure of an image restoration model training device provided in an embodiment of the present application. Referring to FIG9 , the device includes:

[0250] The composition module 301 is used to train a style generation adversarial network based on the first training image set, and combine the style generation adversarial network, the feature extraction network and the discriminator to form an initial image restoration model.

[0251] Optionally, the feature extraction network includes multiple encoding layers and a fully connected layer connected in sequence.

[0252] The first extraction module 302 is configured to obtain a plurality of target face images based on the second training image set, and input each target face image into the feature extraction network for feature extraction to obtain a feature vector.

[0253] The first output module 303 is configured to output at least one predicted face image by the style generative adversarial network based on the feature vector and noise information output by at least one encoding layer in the feature extraction network.

[0254] The optimization module 304 is used to determine the loss information based on each predicted facial image and the second training image set, iteratively optimize the initial image restoration model based on the loss information until the preset conditions are met, use the initial image restoration model that meets the preset conditions as the target image restoration model, and stop training.

[0255] FIG10 is a schematic diagram of the structure of an image restoration model training device provided in an embodiment of the present application. Referring to FIG10 , the device includes:

[0256] The input acquisition module 401 is used to acquire the image to be repaired and input the image to be repaired into the image repair model.

[0257] Optionally, the image restoration model includes: a feature extraction network and a style generation adversarial network.

[0258] The second extraction module 402 is configured to perform feature extraction on the image to be repaired by the feature extraction network to obtain a feature vector.

[0259] The second output module 403 is configured to output a restored image of the image to be restored based on the feature vector and the noise information output by each coding layer in the feature extraction network by the style generation adversarial network.

[0260] The above-mentioned device is used to execute the method provided in the above-mentioned embodiment. Its implementation principle and technical effect are similar and will not be repeated here.

[0261] The above modules can be one or more integrated circuits configured to implement the above methods, such as one or more application-specific integrated circuits (ASICs), one or more microcontrollers, or one or more field programmable gate arrays (FPGAs). For another example, when a module is implemented by scheduling program code through a processing element, the processing element can be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules can be integrated together and implemented in the form of a system-on-a-chip (SOC).

[0262] FIG11 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Referring to FIG11 , the electronic device includes: a memory 501 and a processor 502. The memory 501 stores a computer program that can be executed on the processor 502. When the processor 502 executes the computer program, the steps of any of the above-mentioned method embodiments are implemented.

[0263] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.

[0264] Optionally, the present application also provides a program product, such as a computer-readable storage medium, comprising a program, which, when executed by a processor, is used to execute any of the above-mentioned image restoration model training methods or image restoration method embodiments.

[0265] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0266] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0267] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0268] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium and includes a number of instructions for causing an electronic device (which can be a personal computer, server, or network device, etc.) or a processor to perform some steps of the methods of each embodiment of the present application. The aforementioned storage medium includes: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc., various media that can store program code.

[0269] The above are only specific embodiments of the present application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.

[0270] The above description is merely a preferred embodiment of the present application and is not intended to limit the present application. Various modifications and variations are possible for those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present application shall be included within the scope of protection of the present application.

Claims

1. A method for training an image restoration model, comprising: A style generation adversarial network is obtained by training based on the first training image set, and the style generation adversarial network, a feature extraction network and a discriminator are used to form an initial image restoration model, wherein the feature extraction network includes a plurality of encoding layers and a fully connected layer connected in sequence; Obtaining a plurality of target face images based on the second training image set, and inputting each of the target face images into the feature extraction network for feature extraction to obtain a feature vector; The style generation adversarial network outputs at least one predicted face image according to the feature vector and noise information output by at least one encoding layer in the feature extraction network; Loss information is determined according to each of the predicted facial images and the second training image set, and the initial image restoration model is iteratively optimized based on the loss information until a preset condition is met. The initial image restoration model that meets the preset condition is used as the target image restoration model, and training is stopped.

2. The image restoration model training method according to claim 1, wherein: The step of obtaining a plurality of target face images based on the second training image set, and inputting each of the target face images into the feature extraction network for feature extraction to obtain a feature vector includes: Performing degradation processing on the initial face images in the second training image set to obtain the target face images, wherein the quality of the target face images is lower than the quality of the initial face images; Inputting each of the target face images into the first encoding layer in the feature extraction network, and encoding them in turn by each encoding layer in the feature extraction network to obtain a feature map; The feature map is dimensionally adjusted by a fully connected layer in the feature extraction network to obtain the feature vector.

3. The image restoration model training method according to claim 2, wherein: The step of performing degradation processing on the initial face images in the second training image set to obtain the target face images comprises: Filtering the initial face image based on a bilateral filtering algorithm, and blurring the initial face image using a convolution kernel; Downsample the blurred features and perform Gaussian noise processing; The features processed by Gaussian noise are compressed and up-sampled to obtain the target face image.

4. The image restoration model training method according to claim 1, wherein: The style generation adversarial network includes a plurality of style generation modules, and each of the style generation modules is connected in sequence; The method of outputting at least one predicted face image by the style generative adversarial network according to the feature vector and the noise information output by each encoding layer in the feature extraction network includes: Mapping the feature vector into a latent space feature through a mapping network in the style generation adversarial network; The latent space features are input into each of the style generation modules, and the noise information output by at least one coding layer is input into each of the style generation modules according to the arrangement order of each coding layer in the initial image restoration model, so as to obtain each of the predicted face images.

5. The image restoration model training method according to claim 4, wherein: The step of inputting the noise information output by at least one coding layer into each of the style generation modules according to the arrangement order of each coding layer in the initial image restoration model to obtain each of the predicted face images comprises: Determining the arrangement order of each of the pattern generation modules; If the arrangement order of the pattern generation module is 1, the latent space feature, the preset constant term and the random noise are input into the pattern generation module, and the pattern generation module outputs the decoding information; If the arrangement order of the style generation module is not 1 and is less than a preset value, the latent space feature, the decoded information output by the style generation module before the style generation module, and the random noise are input into the style generation module, and the style generation module outputs the decoded information; If the arrangement order of the style generation module is equal to or greater than a preset value, the latent space feature, the feature map output by the encoding layer corresponding to the style generation module before the style generation module, and the style generation module The information output by the previous style generation module is input into the style generation module, and the style generation module outputs the decoded information; The decoded information output by the last style generation module is used as the predicted face image.

6. The image restoration model training method according to claim 1, wherein: The determining of loss information according to each of the predicted face images and the second training image set includes: Determine an initial face image corresponding to each of the target face images in the second training image set; splicing each of the target face images, each of the initial face images and each of the predicted face images into a plurality of image pairs, and inputting each of the image pairs into the discriminator; The loss information is determined by the discriminator based on each of the image pairs.

7. The image restoration model training method according to claim 6, wherein: The determining of the loss information by the discriminator according to each of the image pairs comprises: The discriminator calculates and generates an adversarial loss value based on each of the target face images and each of the predicted face images; Calculate an absolute value loss value, an additional angle edge loss value, and a gradient difference loss value according to each of the initial face images and each of the predicted face images; Based on weighted summation of the generated adversarial loss value, the absolute value loss value, the additional angle edge loss value and the gradient difference loss value, the obtained sum is used as the loss information.

8. An image restoration method, comprising: Acquire an image to be repaired, and input the image to be repaired into an image repair model, wherein the image repair model is a target image repair model trained according to any one of claims 1 to 7, and the image repair model includes: a feature extraction network and a style generation adversarial network; The feature extraction network extracts features from the image to be repaired to obtain a target feature vector; The style generation adversarial network outputs a restored image of the image to be restored based on the target feature vector and noise information output by each encoding layer in the feature extraction network.

9. The image restoration method according to claim 8, wherein: The style generation adversarial network includes a plurality of style generation modules, and each of the style generation modules is connected in sequence; The method of outputting a restored image of the image to be restored by the style generation adversarial network according to the target feature vector and noise information output by each encoding layer in the feature extraction network includes: Obtaining target latent space features based on the target feature vector mapping; Determining the arrangement order of each of the pattern generation modules; If the arrangement order of the style generation module is 1, the target latent space feature, the preset constant term, and the noise information output by the last encoding layer in each encoding layer are input into the style generation module, and the style generation module outputs the target decoding information; If the arrangement order of the style generation module is not 1, the target latent space feature, the target decoding information output by the style generation module before the style generation module, and the noise information output by the coding layer corresponding to the style generation module in each coding layer are input into the style generation module, and the style generation module outputs the target decoding information; The target decoding information output by the last style generation module is used as the restored image.

10. An image restoration model training device, comprising: A composition module, configured to obtain a style generative adversarial network based on a first training image set, and to form an initial image restoration model with the style generative adversarial network, a feature extraction network, and a discriminator, wherein the feature extraction network includes a plurality of encoding layers and a fully connected layer connected in sequence; A first extraction module, used to obtain a plurality of target face images based on the second training image set, and input each of the target face images into the feature extraction network for feature extraction to obtain a feature vector; A first output module, configured to output at least one predicted face image by the style generation adversarial network according to the feature vector and noise information output by at least one encoding layer in the feature extraction network; An optimization module is used to determine loss information according to each of the predicted face images and the second training image set, based on The loss information iteratively optimizes the initial image restoration model until a preset condition is met, and the initial image restoration model that meets the preset condition is used as the target image restoration model, and the training is stopped.

11. An image restoration device, comprising: An input acquisition module is used to acquire an image to be repaired and input the image to be repaired into an image repair model, wherein the image repair model includes: a feature extraction network and a style generation adversarial network; A second extraction module, configured to extract features of the image to be repaired by the feature extraction network to obtain a feature vector; The second output module is used to output a restored image of the image to be restored according to the feature vector and the noise information output by each encoding layer in the feature extraction network by the style generation adversarial network.

12. An electronic device comprising: A memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the computer program, the steps of the method described in any one of claims 1 to 9 are implemented.

13. A computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.

Citation Information

Patent Citations

  • A semantic image restoration method based on a DenseNet generative adversarial network

    CN109559287A

  • Image denoising method based on multi-channel GAN

    CN112270654A

  • Portrait restoration model training method, portrait restoration method and portrait restoration device

    CN113160079A

  • Method and device for repairing target face image

    CN113592724A

  • Face image blind restoration method and system

    CN113763268A

Cited By

  • Internet of Things privacy leakage detection method and system based on high-order feature data enhancement

    CN119337372A

  • Face image restoration method and system based on reinforcement learning image content screening

    CN119494798A

  • Multi-degraded image restoration method based on self-adaptive prompt

    CN119515734A

  • Prediction method and device for motion state corresponding to space grid and automatic driving vehicle

    CN119810790A

  • Sound field distribution diagram generation method of electromagnetic ultrasonic transducer and electronic equipment

    CN119846080A