Image restoration model training method, image restoration method and device

Through the training method of the image restoration model, using the regional discriminator, contour restoration network and super-resolution upsampling network, combined with the loss function to adjust parameters, the problem of insufficient clarity of facial images under low illumination is solved, and effective image noise reduction and Contour restoration improves the overall clarity of facial images.

CN118262198BActive Publication Date: 2024-08-27HANGZHOU HIKVISION DIGITAL TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410676163.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-28
Publication Date
2024-08-27
Estimated Expiration
2044-05-28

AI Technical Summary

Technical Problem

In low-illumination scenes, traditional imaging technology is difficult to effectively improve the clarity of facial images, resulting in serious noise that affects facial contours and visual perception.

Method used

Using an image restoration model training method, through the pre-trained regional discriminator, contour restoration network and super-resolution upsampling network, combined with the loss function, the parameters are adjusted from multiple angles until the total loss function converges, thereby improving the clarity of the facial image. .

Benefits of technology

Effectively reduce noise and improve the contour restoration effect of facial images, improve image interpolation details, enhance facial delicacy, and significantly improve the clarity of facial images.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118262198B
    Figure CN118262198B
Patent Text Reader

Abstract

The embodiment of the present application provides a training method, an image restoration method and a device for an image restoration model, the method comprising: inputting a facial image sample into a pre-trained region discriminator to obtain an image sample, and inputting the image sample into a contour restoration network, outputting a contour restoration image, calculating a first loss value of a first loss function, inputting the contour restoration image into a super-resolution upsampling network, outputting an upsampled image, calculating a second loss value of a second loss function, inputting the upsampled image into a pre-trained fineness adjustment network, calculating a third loss value of a third loss function, adjusting the parameters of the contour restoration network based on the first loss value, and adjusting the parameters of the super-resolution upsampling network based on the second loss value alternately until the total loss function converges, adjusting the parameters of the contour restoration network and the super-resolution upsampling network based on the loss value, until the total loss function converges, and obtaining an image restoration model. This can improve the clarity of facial images.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] In low-light scenes, high imaging effects are required of image acquisition equipment. If traditional imaging technology is used, that is, high-gain processing is performed in low illumination, obvious noise will appear in the collected facial images, which will damage the facial contour and affect the visual perception of the face.

[0003] Therefore, in order to improve the clarity of facial images captured by an image capture device under low illumination, an image restoration method that can improve the clarity of facial images is needed. Summary of the invention

[0004] The purpose of the embodiments of the present application is to provide a training method for an image restoration model, an image restoration method and a device to improve the clarity of facial images. The specific technical solution is as follows:

[0005] In a first aspect, an embodiment of the present application provides a method for training an image restoration model, the method comprising:

[0006] Inputting a facial image sample into a pre-trained region discriminator to obtain an image sample having facial region information, wherein the facial image sample includes noise;

[0007] Inputting the image sample into a contour restoration network, and calculating a first loss value of a first loss function according to a contour restoration image output by the contour restoration network, wherein the first loss function is used to characterize image denoising and contour restoration effects;

[0008] Inputting the contour restoration image into a super-resolution upsampling network, and calculating a second loss value of a second loss function according to an upsampled image output by the super-resolution upsampling network, wherein the second loss function is used to characterize an image interpolation effect;

[0009] Inputting the upsampled image into a pre-trained fineness adjustment network, and calculating a third loss value of a third loss function according to a facial restoration image output by the fineness adjustment network, wherein the third loss function is used to characterize the fineness of the image;

[0010] Calculate the loss value of the total loss function according to the first loss value, the second loss value and the third loss value;

[0011] Adjusting the parameters of the contour restoration network based on the first loss value and adjusting the parameters of the super-resolution upsampling network based on the second loss value alternately until the total loss function converges;

[0012] Based on the loss value, the parameters of the contour restoration network and the super-resolution upsampling network are adjusted until the total loss function converges to obtain an image restoration model, which includes the region discriminator, the adjusted contour restoration network, the adjusted super-resolution upsampling network and the fineness adjustment network.

[0013] In a second aspect, an embodiment of the present application provides an image restoration method, the method comprising:

[0014] Obtaining a facial image to be processed;

[0015] The facial image to be processed is input into a pre-trained image restoration model to obtain a restored facial image, wherein the image restoration model is pre-trained according to the method described in any one of the first aspects above.

[0016] In a third aspect, an embodiment of the present application provides a training device for an image restoration model, the device comprising:

[0017] An image sample acquisition module, used for inputting a facial image sample into a pre-trained region discriminator to obtain an image sample with facial region information, wherein the facial image sample includes noise;

[0018] a first loss value calculation module, used for inputting the image sample into a contour restoration network, and calculating a first loss value of a first loss function according to a contour restoration image output by the contour restoration network, wherein the first loss function is used to characterize image denoising and contour restoration effects;

[0019] A second loss value calculation module is used to input the contour restoration image into the super-resolution upsampling network, and calculate a second loss value of a second loss function according to the upsampled image output by the super-resolution upsampling network, where the second loss function is used to characterize the image interpolation effect;

[0020] a third loss value calculation module, configured to input the upsampled image into a pre-trained fineness adjustment network, and calculate a third loss value of a third loss function according to a facial restoration image output by the fineness adjustment network, wherein the third loss function is used to characterize the fineness of the image;

[0021] A loss value calculation module, used to calculate the loss value of the total loss function according to the first loss value, the second loss value and the third loss value;

[0022] A contour restoration network parameter adjustment module, used to adjust the parameters of the contour restoration network based on the first loss value, and to adjust the parameters of the super-resolution upsampling network based on the second loss value alternately, until the total loss function converges;

[0023] The image restoration model acquisition module is used to adjust the parameters of the contour restoration network and the super-resolution upsampling network based on the loss value until the total loss function converges to obtain the image restoration model, wherein the image restoration model includes the region discriminator, the adjusted contour restoration network, the adjusted super-resolution upsampling network and the fineness adjustment network.

[0024] In a fourth aspect, an embodiment of the present application provides an image restoration device, the device comprising:

[0025] A facial image acquisition module to be processed, used to acquire the facial image to be processed;

[0026] The restored facial image acquisition module is used to input the facial image to be processed into a pre-trained image restoration model to obtain a restored facial image, wherein the image restoration model is pre-trained according to the method described in any one of the first aspects above.

[0027] Beneficial effects of the embodiments of the present application:

[0028] In the solution provided by the embodiment of the present application, since the first loss function is used to characterize the image denoising and contour restoration effects, the second loss function is used to characterize the image interpolation effect, and the third loss function is used to characterize the image fineness, then in the process of training the image restoration model, the restoration effect of the facial image is considered from multiple angles, and the parameters of the contour restoration network are first adjusted based on the first loss value, and then the parameters of the super-resolution upsampling network are adjusted based on the second loss value. After the contour restoration network and the super-resolution upsampling network are trained, the parameters of the contour restoration network and the upsampling network are adjusted based on the first loss value, the second loss value, and the third loss value until the total loss function converges, so that the effects of image denoising and contour restoration, the effects of image interpolation, and facial fineness all meet certain requirements, and in the process of training the image restoration model, combined with facial area information, the trained image restoration model is more accurate, so that the facial image can be better restored, thereby improving the clarity of the facial image. Of course, it is not necessary to achieve all the advantages described above at the same time for any product or method of implementing the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other embodiments can also be obtained based on these drawings.

[0030] Figure 1 A flowchart of a method for training an image restoration model provided in an embodiment of the present application;

[0031] Figure 2 A schematic diagram of facial region identification provided in an embodiment of the present application;

[0032] Figure 3 A schematic diagram of facial image sample conversion provided by an embodiment of the present application;

[0033] Figure 4 A schematic diagram of image restoration network training provided in an embodiment of the present application;

[0034] Figure 5 Another schematic diagram of the image restoration network training provided in the embodiment of the present application;

[0035] Figure 6 A specific flow chart of the training method of the image restoration model provided in the embodiment of the present application;

[0036] Figure 7 A schematic diagram of the structure of a training device for an image restoration model provided in an embodiment of the present application;

[0037] Figure 8 A schematic diagram of the structure of an image restoration device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0038] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in 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. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field based on the present application belong to the scope of protection of the present application.

[0039] In order to improve the clarity of facial images, the embodiments of the present application provide a training method for an image restoration model, an image restoration method, an apparatus, an electronic device, a computer-readable storage medium, and a computer program product. The following first introduces a training method for an image restoration model provided in the embodiments of the present application.

[0040] The training method of an image restoration model provided in an embodiment of the present application can be applied to any device that needs to train an image restoration model, for example, it can be a processor, a server, a desktop computer, a laptop computer, etc., which is not specifically limited here. For the sake of clear description, it is referred to as an electronic device below.

[0041] like Figure 1 As shown, a training method for an image restoration model comprises:

[0042] S101, inputting a facial image sample into a pre-trained region discriminator to obtain an image sample with facial region information, wherein the facial image sample includes noise;

[0043] S102, inputting the image sample into a contour restoration network, and calculating a first loss value of a first loss function according to a contour restoration image output by the contour restoration network, where the first loss function is used to characterize image denoising and contour restoration effects;

[0044] S103, inputting the contour restoration image into a super-resolution upsampling network, and calculating a second loss value of a second loss function according to an upsampled image output by the super-resolution upsampling network, where the second loss function is used to characterize an image interpolation effect;

[0045] S104, inputting the upsampled image into a pre-trained fineness adjustment network, and calculating a third loss value of a third loss function according to a facial restoration image output by the fineness adjustment network, wherein the third loss function is used to characterize the fineness of the image;

[0046] S105, calculating a loss value of a total loss function according to the first loss value, the second loss value, and the third loss value;

[0047] S106, adjusting the parameters of the contour restoration network based on the first loss value, and adjusting the parameters of the super-resolution upsampling network based on the second loss value alternately, until the total loss function converges;

[0048] S107, based on the loss value, adjusting the parameters of the contour restoration network and the super-resolution upsampling network until the total loss function converges, to obtain an image restoration model, wherein the image restoration model includes the region discriminator, the adjusted contour restoration network, the adjusted super-resolution upsampling network and the fineness adjustment network.

[0049] It can be seen that in the solution provided in the embodiment of the present application, since the first loss function is used to characterize the image denoising and contour restoration effects, the second loss function is used to characterize the image interpolation effect, and the third loss function is used to characterize the image fineness, then in the process of training the image restoration model, the restoration effect of the facial image is considered from multiple angles, and the parameters of the contour restoration network are first adjusted based on the first loss value, and then the parameters of the super-resolution upsampling network are adjusted based on the second loss value. After the contour restoration network and the super-resolution upsampling network are trained respectively, the parameters of the contour restoration network and the upsampling network are continued to be adjusted based on the first loss value, the second loss value and the third loss value until the total loss function converges, so that the effects of image denoising and contour restoration, the effects of image interpolation, and the facial fineness all meet certain requirements, and in the process of training the image restoration model, the facial area information is combined to make the trained image restoration model more accurate, so that the facial image can be better restored, thereby improving the clarity of the facial image.

[0050] Under low illumination conditions (such as at night), due to the low illumination of the scene, visibility is low, and the facial image captured by the image acquisition device has serious noise, resulting in blurred faces, which has a great impact on subsequent facial recognition and detection. In order to improve the clarity of facial images, the present application provides a training method for an image restoration model and an image restoration method.

[0051] When using a deep learning-based image restoration model to process facial images, the adaptability of the scene is required to be high. It is necessary to design a reasonable network according to the actual situation and obtain the applicable parameters of the network through certain training methods. The initial image restoration model provided in the embodiment of the present application may include four parts, namely a pre-trained region discriminator, a contour restoration network, a super-resolution upsampling network, and a pre-trained fineness adjustment network, and the pre-trained region discriminator, the contour restoration network, the super-resolution upsampling network, and the pre-trained fineness adjustment network are connected in sequence. Among them, the parameters in the pre-trained region discriminator and the parameters of the pre-trained fineness adjustment network have been pre-trained.

[0052] In step S101, the electronic device may input a facial image sample into a pre-trained region discriminator to obtain an image sample having facial region information, wherein the pre-trained region discriminator is used to distinguish facial regions included in the facial image sample and mark each facial region.

[0053] For example, the facial region may include facial features, non-facial features, and background regions. Specifically, the facial features are connected regions consisting of eyes, nose, and mouth, the non-facial features are disconnected regions of the face, and the background region is the region outside the connected and disconnected regions in the image. Figure 2 As shown, the facial area includes a facial feature area 201, that is, a connected area within the gray line, a facial non-facial feature area 202, that is, a non-connected area included in the face outside the gray line, and a background area 203.

[0054] The facial image sample is a facial image including noise. In one embodiment, the electronic device may first obtain a facial image without noise, and then input the facial image without noise into a noise processing model to obtain a facial image including noise.

[0055] In another embodiment, the electronic device can directly acquire a facial image including noise in a low-illuminance environment. Illuminance refers to the energy of visible light received per unit area, and the unit is lux. Low-illuminance environments include about 0.1 lux under a street lamp, about 0.02 lux under a full moon, and about 0.0002 lux under starlight. For example, the electronic device can acquire a facial image acquired by an image acquisition device when the street lamp illumination is 0.1 lux. The facial image includes noise and can be used as a facial image sample.

[0056] The bit depth of the facial image sample can be 8 bits, 10 bits, 12 bits, etc., which is not specifically limited here. Since the bit depth is the amount of color information included in each pixel, in order to enable the facial image sample to better display the color details and smoothness of the face, the bit depth of the facial image samples in the embodiments of the present application is 12 bits.

[0057] If the image captured by the image acquisition device is in Bayer format, that is, the facial image sample is an image in Bayer format, then before the electronic device inputs the facial image sample into the pre-trained region discriminator, the facial image sample can be matrix-converted to achieve channel separation. For example, if the facial image sample is a 384x384x1 Bayer format image, before inputting it into the pre-trained region discriminator, the electronic device can perform the following matrix conversion: Figure 3 The matrix conversion form shown performs matrix conversion on the facial image samples, that is, separates the blue (B), green (G), and red (R) channels, and converts them into 192x192x4 facial image samples.

[0058] In step S102, the electronic device may input the image sample into the contour restoration network, output the contour restoration image after being processed by the contour restoration network, and then calculate the first loss value of the first loss function according to the contour restoration image. The contour restoration network may include one channel or multiple channels. The first loss function may be used to characterize the image denoising and contour restoration effects, that is, when pre-constructing the first loss function, the effect of removing facial noise in the contour restoration image and the reconstruction effect of the facial contour are emphasized.

[0059] In one embodiment, since the image sample has facial region information, the contour restoration image also has facial region information, and the first loss function can be constructed in combination with the image features of each facial region in the contour restoration image, so that the electronic device can calculate the loss value of the first loss function based on the difference between the image features of each facial region included in the contour restoration image and the image features of the facial region included in the corresponding reference image. The image features may include color features, structural features, texture features, and pixel values ​​of pixels, etc., which are not specifically limited here.

[0060] For example, the contour-restored image includes three facial areas, namely, the facial features area, the facial non-facial features area and the background area. Then, when the electronic device calculates the first loss value of the first loss function, the loss value of the first loss function can be calculated based on the differences between the image features of the facial features area, the facial non-facial features area and the background area in the contour-restored image and the image features of the facial features area, the facial non-facial features area and the background area in the corresponding reference image.

[0061] The contour restoration network is connected to the super-resolution upsampling network. After the electronic device obtains the contour restoration image, the contour restoration image can be input into the super-resolution upsampling network. After being processed by the super-resolution upsampling network, the upsampling image is output, and then the second loss value of the second loss function is calculated according to the upsampling image, that is, step S103 is executed. Among them, the super-resolution upsampling network can include one channel or multiple channels. The second loss function is used to characterize the image interpolation effect, that is, when the second loss function is pre-constructed, the effect of restoring facial details in the upsampling image is focused on.

[0062] In one embodiment, since the contour restoration image has facial region information, the upsampled image also has facial region information, and the second loss function can be constructed in combination with the image features of each facial region in the upsampled image, so that the electronic device can calculate the loss value of the second loss function based on the difference between the image features of each facial region included in the upsampled image and the image features of the facial region included in the corresponding reference image.

[0063] The super-resolution upsampling network is connected to the fineness adjustment network. In step S104, after the electronic device obtains the upsampled image, the upsampled image can be input into the pre-trained fineness adjustment network to output a facial restoration image, and then the third loss value of the third loss function is calculated according to the facial restoration image output by the fineness adjustment network. The third loss function is used to characterize the fineness of the image, that is, the fineness of facial restoration can be controlled by the fineness adjustment network.

[0064] In one embodiment, the detail adjustment network processes an image in RGB format. Then, before inputting the upsampled image into the detail adjustment network, the electronic device may convert the upsampled image into an image in RGB format, or the super-resolution upsampling network may output an image in RGB format, that is, the upsampled image is an image in RGB format.

[0065] By combining the first loss function, the second loss function and the third loss function, a total loss function can be constructed, so that in the process of training the image restoration model, multi-angle adjustment of the restoration effect of the facial image can be achieved. The electronic device can calculate the loss value of the total loss function according to the first loss value, the second loss value and the third loss value, that is, execute step S105.

[0066] In one implementation, during the training of the image restoration model, the electronic device may adjust the parameters of the contour restoration network based on the first loss value, and adjust the parameters of the super-resolution upsampling network based on the second loss value alternately, until the total loss function converges, i.e., executing step S106. In other words, the electronic device may alternately train the contour restoration network and the super-resolution upsampling network, i.e., first adjust the parameters of the contour restoration network, then adjust the parameters of the super-resolution upsampling network, and then continue to adjust the parameters of the contour restoration network until both networks are trained.

[0067] After the electronic device completes the alternating training of the contour restoration network and the super-resolution upsampling network, the parameters of the contour restoration network and the super-resolution upsampling network can be further adjusted and optimized in combination with the pre-trained fineness adjustment network. That is, in step S107, the electronic device can adjust the parameters of the contour restoration network and the super-resolution upsampling network based on the loss value of the total loss function until the total loss function converges to obtain an image restoration model. In this way, the image restoration model can include a region discriminator, an adjusted contour restoration network, an adjusted super-resolution upsampling network, and a fineness adjustment network.

[0068] For example, Figure 4 As shown in the figure, the initial image restoration model consists of four parts, namely, a pre-trained region discriminator ①, a contour restoration network ②, a super-resolution upsampling network ③, and a pre-trained fineness adjustment network ④. The pre-trained region discriminator ①, the contour restoration network ②, the super-resolution upsampling network ③, and the pre-trained fineness adjustment network ④ are connected in sequence.

[0069] The contour restoration network ② and the super-resolution upsampling network ③ both have only one channel, that is, the image restoration model is a single-channel model. Taking a square image with a facial image sample of 12 bits and a side length of 384 as an example, the electronic device can first separate the channels of the facial image sample and convert it into a facial image sample of 192x192x4. Then, the facial image sample of 192x192x4 is input into the pre-trained region discriminator ① to obtain an image sample with facial region information. The image sample is 192x192x4 in size. The image sample is input into the contour restoration network ②, the contour restoration image is output, and the first loss value of the first loss function is calculated. .

[0070] Among them, in the contour restoration network ②, there are two encoding modules and two decoding modules. The electronic device inputs the 192x192x4 image sample to the encoding module 1 (96x96x32) and encoding module 2 (48x48x48) connected in sequence included in the channel, encodes the image sample according to the preset encoding rules, and obtains the feature code 1 of the image sample, that is, the encoding result.

[0071] The electronic device can input feature code 1 into decoding module 1 (96x96x32), decode feature code 1 according to the decoding rule corresponding to the preset coding rule, obtain the decoding result corresponding to decoding module 1, input the decoding result corresponding to decoding module 1 into decoding module 2 (192x192x4), and decode the input decoding result according to the decoding rule corresponding to the preset coding rule based on the coding result corresponding to coding module 1, and obtain the decoding result corresponding to decoding module 2. Then, the decoding result corresponding to decoding module 2 is fused with the image sample of 192x192x4 to obtain the contour restoration image corresponding to the channel.

[0072] The electronic device inputs the contour restoration image into the super-resolution upsampling network ③, processes it through the super-resolution upsampling module (384x384x3), outputs the upsampled image, and calculates the second loss value of the second loss function , where the upsampled image is a 384x384x3 RGB image, and then the upsampled image is input into the pre-trained fineness adjustment network④, namely VGG Net, outputs the facial restoration image, and calculates the third loss value of the third loss function .

[0073] The electronic device can alternately train the contour restoration network ② and the super-resolution upsampling network ③ until both networks are trained, and further adjust and optimize the parameters of the contour restoration network ② and the parameters of the super-resolution upsampling network ③ in combination with the pre-trained fineness adjustment network ④ until the total loss function converges to obtain an image restoration model. The image restoration model may include a region discriminator, an adjusted contour restoration network, an adjusted super-resolution upsampling network, and a fineness adjustment network.

[0074] The image restoration model in the embodiment of the present application combines the Bayer domain image contour restoration neural network and the super-resolution upsampling neural network, which can achieve the super-resolution upsampling function of the facial image while reducing the facial image noise.

[0075] It should be noted that in the technical solution of this application, the acquisition, storage, use, processing, transmission, provision and disclosure of user personal information involved are all carried out with the authorization of the user. User personal information, for example, facial image samples in the embodiments of this application.

[0076] It can be seen that in this embodiment, since the first loss function is used to characterize the image denoising and contour restoration effects, the second loss function is used to characterize the image interpolation effect, and the third loss function is used to characterize the image fineness, then in the process of training the image restoration model, the restoration effect of the facial image is considered from multiple angles, and the parameters of the contour restoration network are first adjusted based on the first loss value, and then the parameters of the super-resolution upsampling network are adjusted based on the second loss value. After the contour restoration network and the super-resolution upsampling network are trained respectively, the parameters of the contour restoration network and the upsampling network are continued to be adjusted based on the first loss value, the second loss value and the third loss value until the total loss function converges, so that the effects of image denoising and contour restoration, the effects of image interpolation, and the facial fineness all meet certain requirements, and in the process of training the image restoration model, combined with the facial area information, the trained image restoration model is more accurate, so that the facial image can be better restored, and then the clarity of the facial image can be improved.

[0077] As an implementation of the embodiment of the present application, the contour restoration network may include multiple channels.

[0078] The step of calculating the first loss value of the first loss function according to the contour restoration image output by the contour restoration network may include:

[0079] Step a, for each channel of the contour restoration network, according to the difference between the color features and structural features of each facial region included in the contour restoration image output by the channel and the color features and structural features of the facial region included in the corresponding first reference image, calculating the structural loss value of the structural loss function included in the pre-constructed first loss function;

[0080] Step b, calculating a pixel loss value of a pixel value loss function included in a pre-constructed first loss function according to a difference between a pixel value of each pixel point in the facial region included in the contour restoration image output by the channel and a pixel value of a pixel point corresponding to the pixel point in the corresponding first reference image;

[0081] The first loss function corresponding to the contour restoration network is used to characterize the image denoising and contour restoration effects. In one embodiment, the pre-constructed first loss function may include two parts, one for the structural loss function and the other for the pixel value loss function. The structural loss function may be constructed based on the color features and structural features of each facial region included in the contour restoration image output by each channel, and the pixel value loss function may be constructed based on the pixel values ​​of the pixel points of each facial region included in the contour restoration image output by each channel.

[0082] Then, for each channel of the contour restoration network, after obtaining the contour restoration image output by the channel, the electronic device can calculate the structural loss value of the structural loss function included in the pre-constructed first loss function according to the difference between the color features and structural features of each facial region included in the contour restoration image and the color features and structural features of the facial region included in the corresponding first reference image. The color features may include chromaticity, brightness, contrast, etc.

[0083] And the electronic device can calculate the pixel loss value of the pixel value loss function included in the pre-constructed first loss function according to the difference between the pixel value of each pixel point in the facial region included in the contour restoration image and the pixel value of the pixel point corresponding to the pixel point in the corresponding first reference image. Wherein, for each facial region, the first loss value can be obtained by calculating the difference between the pixel value of each pixel point in the facial region and the pixel value of the pixel point corresponding to the pixel point in the corresponding first reference image, and then calculating the average value of the absolute values ​​of all the differences.

[0084] Step c: calculating a first loss value of the first loss function according to the structural loss value, the pixel loss value, the first preset weight and the second preset weight corresponding to each channel.

[0085] Since the constructed structure loss function and pixel value loss function have different focuses, in order to facilitate the adjustment of the first loss function from different angles, certain weights can be given to the structure loss function and the pixel value loss function to better adjust the image denoising and contour reconstruction effects.

[0086] Then, the electronic device can calculate the first loss value of the first loss function according to the structural loss value, the pixel loss value, the first preset weight and the second preset weight corresponding to each channel. The first preset weight is the weight corresponding to the structural loss function, the second preset weight is the weight corresponding to the pixel value loss function, and the first preset weight and the second preset weight can be the same or different.

[0087] The first preset weight and the second preset weight of each channel of the contour restoration network can be shared, that is, the weight corresponding to the structural loss function corresponding to each channel of the contour restoration network is the first preset weight, and the weight corresponding to the pixel loss function corresponding to each channel is the second preset weight.

[0088] For example, the first preset weight is c, the second preset weight is d, and the contour restoration network includes three channels, namely contour restoration channel 1, contour restoration channel 2, and contour restoration channel 3. Then, for the structural loss functions corresponding to contour restoration channel 1, contour restoration channel 2, and contour restoration channel 3, the weights are all a, and for the pixel loss functions corresponding to contour restoration channel 1, contour restoration channel 2, and contour restoration channel 3, the weights are all b.

[0089] In one embodiment, the electronic device can calculate the first loss value of the first loss function according to the following formula based on the structural loss value, pixel loss value, first preset weight and second preset weight corresponding to each channel: :

[0090] ;

[0091] in, For the The structural loss value corresponding to the jth facial region in the contour restoration image output by the channel, For the The pixel loss value corresponding to the jth facial region in the contour restoration image output by the channel, is the number of facial regions in the contour restoration image, is the number of channels of the contour restoration network, is the first preset weight, is the second preset weight.

[0092] The number k of facial regions in the contour restoration image and the number n of channels of the contour restoration network can be set according to actual conditions, for example, k is 3 and n is 3. The first preset weight c can control the strength of the structural loss function. The larger c is, the better the correction of color features such as image chromaticity, brightness, contrast and structural features. The second preset weight d can control the strength of the pixel value loss function. The larger d is, the smoother the facial processing in the image is. The first preset weight c and the second preset weight d can be set according to actual conditions and are not specifically limited here.

[0093] It can be seen that in this embodiment, since the pre-constructed first loss function can include two parts, one part is the structural loss function, and the other part is the pixel value loss function, and the structural loss function and the pixel value loss function are respectively assigned a first preset weight and a second preset weight, after the electronic device calculates the structural loss value and the pixel loss value corresponding to each channel, the first loss value of the first loss function can be calculated according to the structural loss value, the pixel loss value, the first preset weight and the second preset weight corresponding to each channel, and then the parameters of the contour restoration network are adjusted based on the first loss value to further improve the processing of facial color features, structural features and facial smoothness, so as to achieve the requirements of image denoising and contour reconstruction effects and improve the clarity of facial images.

[0094] As an implementation method of an embodiment of the present application, the number of channels of the super-resolution upsampling network is the same as the number of channels of the contour restoration network, and each channel of the contour restoration network is correspondingly connected to a channel of the super-resolution upsampling network.

[0095] For example, the contour restoration network includes three channels, namely contour restoration channel 1, contour restoration channel 2 and contour restoration channel 3, and the super-resolution upsampling network also includes three channels, namely super-resolution upsampling channel 1, super-resolution upsampling channel 2 and super-resolution upsampling channel 3. Then, contour restoration channel 1 is connected to super-resolution upsampling channel 1, contour restoration channel 2 is connected to super-resolution upsampling channel 2, and contour restoration channel 3 is connected to super-resolution upsampling channel 3.

[0096] The step of calculating the second loss value of the second loss function according to the upsampled image output by the super-resolution upsampling network may include:

[0097] Step a, for each channel of the super-resolution upsampling network, according to the difference between the high-frequency texture features of each facial region included in the upsampled image output by the channel and the high-frequency texture features of the facial region included in the corresponding second reference image, calculating the high-frequency loss value of the high-frequency loss function included in the pre-constructed second loss function;

[0098] Step b, calculating a low-frequency loss value of a low-frequency loss function included in a pre-constructed second loss function according to a difference between a low-frequency texture feature of each facial region included in the up-sampled image output by the channel and a low-frequency texture feature of the facial region included in a corresponding second reference image;

[0099] The second loss function corresponding to the super-resolution upsampling network is used to characterize the image interpolation effect. In one embodiment, the pre-constructed second loss function may include two parts, one part is a high-frequency loss function, and the other part is a low-frequency loss function. Among them, the high-frequency loss function can be constructed based on the high-frequency texture features of each facial area included in the up-sampled image output by each channel, and can be used to characterize the effect of restoring the contour information of the whole face and facial features to protect the high-frequency texture information of the face. The low-frequency loss function can be constructed based on the low-frequency texture features of each facial area included in the up-sampled image output by each channel, and can be used to characterize the effect of restoring the flat area of ​​the face, so that the low-frequency area of ​​the face is smooth and not abrupt, so as to protect the low-frequency texture information of the face.

[0100] Then, for each channel of the super-resolution upsampling network, after obtaining the upsampled image output by the channel, the electronic device can calculate the high-frequency loss value of the high-frequency loss function included in the pre-constructed second loss function based on the difference between the high-frequency texture features of each facial area included in the upsampled image and the high-frequency texture features of the facial area included in the corresponding second reference image.

[0101] And the electronic device calculates the low-frequency loss value of the low-frequency loss function included in the pre-constructed second loss function based on the difference between the low-frequency texture features of each facial area included in the upsampled image and the low-frequency texture features of the facial area included in the corresponding second reference image.

[0102] Step c: calculating a second loss value of the second loss function according to the high-frequency loss value, the low-frequency loss value, the third preset weight and the fourth preset weight corresponding to each channel.

[0103] Since the constructed high-frequency loss function and low-frequency loss function have different focuses, in order to facilitate the adjustment of the second loss function from different angles, certain weights can be given to the high-frequency loss function and the low-frequency loss function to better adjust the image interpolation effect.

[0104] Then, the electronic device can calculate the second loss value of the second loss function according to the high-frequency loss value, the low-frequency loss value, the third preset weight and the fourth preset weight corresponding to each channel. The third preset weight is the weight corresponding to the high-frequency loss function, the second preset weight is the weight corresponding to the low-frequency loss function, and the third preset weight and the fourth preset weight can be the same or different.

[0105] The third preset weight and the fourth preset weight of each channel of the super-resolution upsampling network can be shared, that is, the weight corresponding to the high-frequency loss function corresponding to each channel of the super-resolution upsampling network is the third preset weight, and the weight corresponding to the low-frequency loss function corresponding to each channel is the fourth preset weight.

[0106] For example, the third preset weight is e, the fourth preset weight is f, and the super-resolution upsampling network includes three channels, namely super-resolution upsampling channel 1, super-resolution upsampling channel 2 and super-resolution upsampling channel 3. Then, for the high-frequency loss functions corresponding to super-resolution upsampling channel 1, super-resolution upsampling channel 2 and super-resolution upsampling channel 3, the weights are all e, and for the low-frequency loss functions corresponding to super-resolution upsampling channel 1, super-resolution upsampling channel 2 and super-resolution upsampling channel 3, the weights are all f.

[0107] In one embodiment, the electronic device can calculate the second loss value of the second loss function according to the high-frequency loss value, the low-frequency loss value, the third preset weight and the fourth preset weight corresponding to each channel according to the following formula: :

[0108] ;

[0109] ;

[0110] ;

[0111] in, is the number of channels of the super-resolution upsampling network, For the The high-frequency loss value corresponding to the upsampled image output by each channel, For the The low-frequency loss value corresponding to the upsampled image output by each channel, is the third preset weight, is the fourth preset weight, For the The label value of the pixel value of the pixel in the second reference image of the channel, is the predicted value of the pixel value of each pixel in the upsampled image, The first preset zoom control strength, For the The number of pixels in the upsampled image output by channels, For the The position of the pixel in the upsampled image output by the channels, For the The upsampled image output by channels The pixel value of the pixel point in the facial area is The squared error between the pixel values ​​of the pixels corresponding to the facial regions, The square error value corresponding to a facial region is the minimum value of the square error values ​​corresponding to multiple facial regions. is the Laplace filter, Zoom control strength for the second preset.

[0112] First preset zoom control strength Zoom with second preset to control intensity The default is 1. The third preset weight You can control the strength of the high-frequency loss function. The fourth preset weight The strength of the low-frequency loss function can be controlled. The third preset weight e and the fourth preset weight f can be set according to actual conditions and are not specifically limited here.

[0113] Since the super-resolution upsampling network is multi-channel, the electronic device can obtain the upsampled image corresponding to each channel. In one embodiment, the electronic device can weightedly fuse the upsampled images of each channel according to the preset size according to the following formula to obtain the fused upsampled image, which is input into the pre-trained fineness adjustment network:

[0114] ;

[0115] =1;

[0116] in, is the pixel value of the pixel in the fused upsampled image, For the The pixel value of the pixel in the upsampled image output by the channels, For the The weight of each channel, It can be set according to the image information of the upsampled image, such as , indicating that the upsampled image output by the first channel has the most image information, so the weight is the largest, and so on, the upsampled image output by the nth channel has the least image information and the smallest weight. The preset size can be the image size required for input to the pre-trained fineness adjustment network, and is not specifically limited here.

[0117] It can be seen that in this embodiment, since the pre-constructed second loss function can include two parts, one part is a high-frequency loss function, and the other part is a low-frequency loss function, and the third preset weight and the fourth preset weight are respectively assigned to the high-frequency loss function and the low-frequency loss function, after the electronic device calculates the high-frequency loss value and the low-frequency loss value corresponding to each channel, the second loss value of the second loss function can be calculated according to the high-frequency loss value, the low-frequency loss value, the third preset weight and the fourth preset weight corresponding to each channel, and then the parameters of the super-resolution upsampling network are adjusted based on the second loss value to further improve the detail processing of the facial high-frequency texture and the facial low-frequency texture, thereby achieving the image interpolation effect and improving the clarity of the facial image.

[0118] As an implementation manner of an embodiment of the present application, the step of calculating the loss value of the total loss function according to the first loss value, the second loss value and the third loss value may include:

[0119] The loss value of the total loss function is calculated according to the following formula: :

[0120] ;

[0121] ;

[0122] in, For the contour restoration network The first loss value corresponding to the jth facial region in the contour restoration image output by the channel, is the super-resolution upsampling network The second loss value corresponding to the upsampled image output by channels, is the third loss value, is the number of facial regions in the contour restoration image, is the preset weight corresponding to the jth facial region, is the fifth preset weight, is the sixth preset weight, a is the seventh preset weight, b is the eighth preset weight, The number of channels for the contour restoration network.

[0123] In one implementation, the electronic device may add the first loss value, the second loss value, and the third loss value according to a certain weight to obtain the loss value of the total loss function. Since the contour restoration network and the super-resolution upsampling network may be single-channel or multi-channel, in the case of multi-channel, the electronic device needs to add the first loss value and the second loss value of each channel, and then add the sum with the third loss value.

[0124] As shown in the following formula, when both the contour restoration network and the super-resolution upsampling network are multi-channel, the loss value of the total loss function is divided into two parts, one of which is the multi-channel loss value , that is, the sum of the first loss value and the second loss value in each multi-pass, and a part of it is the third loss value , the multi-channel loss value and the third loss value are added based on the fifth preset weight p and the sixth preset weight q to obtain the loss value of the total loss function:

[0125] ;

[0126] Among them, in the process of image restoration model training, the weights of different parts in the total loss function are related to the step length, which is a nonlinear attenuation mapping. Specifically, the fifth preset weight p and the sixth preset weight q satisfy the sum of 1. In the process of image restoration model training, as the training step length increases, the value of p gradually increases and the value of q gradually decreases until p=1 and q=0. The degree of change of the fifth preset weight p and the sixth preset weight q with the training step length can be designed according to needs and is not specifically limited here.

[0127] In one embodiment, the electronic device can calculate the third loss value according to the following formula: :

[0128] = ;

[0129] Among them, the fineness adjustment network is an n-layer network. For multi-layer networks The weight of the loss function corresponding to the layer, For the The channel value of the layer, For the The height value of the layer, For the The width value of the layer, For the The predicted value of the pixel value of the pixel in the facial restoration image output by the layer, For the The label value of the pixel value of the pixel point in the third reference facial image corresponding to the layer.

[0130] When the electronic device adds the first loss value and the second loss value in each multi-pass, the sum may be performed based on the seventh preset weight a and the eighth preset weight b. For the i-th channel, the first loss value and the second loss value may be added according to the following formula:

[0131] ;

[0132] in, For the contour restoration network The first loss value corresponding to the jth facial region in the contour restoration image output by the channel, is the first super-resolution upsampling network The second loss value corresponding to the upsampled image output by channels, is the number of facial regions in the contour restoration image, is the preset weight corresponding to the jth facial region, =1, and generally for facial features The value is larger.

[0133] The larger the seventh preset weight a is, the more conducive it is to the image noise reduction effect, and the larger the eighth preset weight b is, the more conducive it is to the image interpolation effect, which can better enhance facial details and reduce facial stiffness. The seventh preset weight a and the eighth preset weight b can be set according to actual conditions and are not specifically limited here.

[0134] For example, Figure 5 As shown, the contour restoration network ② includes three channels, and the corresponding first loss values ​​are , as well as , the super-resolution upsampling network ③ includes three channels, and the corresponding second loss values ​​are , as well as , the loss function corresponding to the fineness adjustment network ④ is , then the electronic device can , , , , , as well as Add them together to get the loss value of the total loss function.

[0135] It can be seen that in this embodiment, the electronic device can add the first loss value, the second loss value and the third loss value in a certain ratio to calculate the loss value of the total loss function, and can adjust the fifth preset weight and the sixth preset weight according to the relationship between the fifth preset weight, the sixth preset weight and the step size to adjust the training effect of the image restoration model from multiple angles to make the trained image restoration model more accurate.

[0136] As an implementation manner of an embodiment of the present application, the step of adjusting the parameters of the contour restoration network based on the first loss value and adjusting the parameters of the super-resolution upsampling network based on the second loss value alternately until the total loss function converges may include:

[0137] Step a, when the fifth preset weight and the sixth preset weight are the first preset values, the seventh preset weight is 1, and the eighth preset weight is 0, based on the loss value of the total loss function corresponding to each image sample, adjusting the parameters of the contour restoration network until the total loss function meets the convergence condition;

[0138] In the process of training the image restoration model by the electronic device, the contour restoration network and the super-resolution upsampling network can be trained separately. When training the contour restoration network, the super-resolution upsampling network can be ignored first, then the seventh preset weight can be set to 1, the eighth preset weight can be set to 0, and the fifth preset weight and the sixth preset weight can be set to the same value.

[0139] In this way, when the fifth preset weight and the sixth preset weight are the first preset values, the seventh preset weight is 1, and the eighth preset weight is 0, the electronic device can adjust the parameters of the contour restoration network based on the loss value of the total loss function corresponding to each image sample until the total loss function meets the convergence condition. Among them, the first preset value can be set to 0.5, that is, the fifth preset weight and the sixth preset weight are both 0.5, which is not specifically limited here.

[0140] In one embodiment, while adjusting the parameters of the contour restoration network, the first preset weight and the second preset weight can be fine-tuned. When the total loss function meets the convergence condition, the facial contour restoration effect is observed to train the image restoration model to the desired effect.

[0141] Step b, when the fifth preset weight and the sixth preset weight are the second preset value, the seventh preset weight is 0, and the eighth preset weight is 1, return to the step of inputting the image sample into the contour restoration network, and adjust the parameters of the super-resolution upsampling network based on the loss value of the total loss function corresponding to each image sample until the total loss function meets the convergence condition;

[0142] When training the super-resolution upsampling network, the contour restoration network can be ignored first, then the seventh preset weight can be set to 0, the eighth preset weight can be set to 1, and the fifth preset weight and the sixth preset weight can be set to the same value.

[0143] In this way, when the fifth preset weight and the sixth preset weight are the second preset values, the seventh preset weight is 0, and the eighth preset weight is 1, the electronic device can adjust the parameters of the super-resolution upsampling network based on the loss value of the total loss function corresponding to each image sample until the total loss function meets the convergence condition. Among them, the second preset value can be set to 0.5, that is, the fifth preset weight and the sixth preset weight are both 0.5, which is not specifically limited here.

[0144] In one embodiment, while adjusting the parameters of the super-resolution upsampling network, the third preset weight and the fourth preset weight can be fine-tuned. When the total loss function meets the convergence condition, the facial detail interpolation effect is observed to train the image restoration model to the desired effect.

[0145] Step c, returning to the step of adjusting the parameters of the contour restoration network based on the loss value of the total loss function corresponding to each image sample when the fifth preset weight and the sixth preset weight are the first preset values, the seventh preset weight is 1, and the eighth preset weight is 0, until the total loss function meets the convergence condition.

[0146] After the electronic device completes adjusting the parameters of the super-resolution upsampling network, it is necessary to continue adjusting the parameters of the contour restoration network so that the total loss function can still meet the convergence conditions. Therefore, the electronic device can alternately train the contour restoration network and the super-resolution upsampling network until the total loss function always converges, that is, the facial denoising and contour restoration effects, as well as the image interpolation effects are basically stable.

[0147] The step of adjusting the parameters of the contour restoration network and the super-resolution upsampling network based on the loss value until the total loss function converges to obtain the image restoration model may include:

[0148] When the fifth preset weight, the sixth preset weight, the seventh preset weight and the eighth preset weight are the third preset value, return to the step of inputting the image sample into the contour restoration network, and adjust the parameters of the contour restoration network and the super-resolution upsampling network based on the loss value of the total loss function corresponding to each image sample until the total loss function meets the convergence condition, thereby obtaining the image restoration model.

[0149] After the electronic device completes the alternating training of the contour restoration network and the super-resolution upsampling network, it can further combine the fineness adjustment network to train the image restoration model, that is, based on the loss value of the total loss function corresponding to each image sample, adjust the parameters of the contour restoration network and the super-resolution upsampling network at the same time until the total loss function meets the convergence conditions.

[0150] In one embodiment, the electronic device can adjust the parameters of the contour restoration network and the super-resolution upsampling network in combination with the fifth preset weight and the sixth preset weight. Specifically, the electronic device can adjust the fifth preset weight and the sixth preset weight according to the preset step size, so that the fifth preset weight increases according to the preset step size until it is 1, and the sixth preset weight decreases according to the preset step size until it is 0, and the sum of the fifth preset weight and the sixth preset weight is 1. Among them, the preset step size can be 0.1, which is not specifically limited here.

[0151] In one embodiment, while adjusting the parameters of the contour restoration network and the super-resolution upsampling network in combination with the fifth preset weight and the sixth preset weight, the first preset weight, the second preset weight, the third preset weight and the fourth preset weight can be fine-tuned. When the total loss function meets the convergence condition, an image restoration model is obtained so that the image restoration model is trained to the desired effect.

[0152] It can be seen that in this embodiment, the electronic device can first adjust the parameters of the contour restoration network based on the first loss value, and then adjust the parameters of the super-resolution upsampling network based on the second loss value. After the contour restoration network and the super-resolution upsampling network are trained respectively, the parameters of the contour restoration network and the upsampling network are continued to be adjusted based on the first loss value, the second loss value and the third loss value until the total loss function converges. In this way, the effects of image denoising and contour restoration, and image interpolation are optimized, the facial image can be better restored, and the clarity of the facial image can be improved.

[0153] As an implementation method of the embodiment of the present application, each channel of the contour restoration network includes multiple encoding modules and multiple decoding modules, and the number of decoding modules is the same as the number of encoding modules; the step of inputting the image sample into the contour restoration network may include:

[0154] For the first channel, the electronic device can input the image sample into the sequentially connected encoding modules included in the channel, encode the image sample according to the preset encoding rule, and obtain the encoding result of the image sample. For the first decoding module of the first channel, the electronic device can input the encoding result of the channel into the first decoding module, decode the encoding result of the channel according to the decoding rule corresponding to the preset encoding rule, and obtain the decoding result corresponding to the first decoding module.

[0155] For a decoding module other than the first one, the electronic device may input the decoding result corresponding to the previous decoding module of the non-first decoding module into the non-first decoding module, and decode the input decoding result according to the decoding rule corresponding to the preset encoding rule based on the encoding result corresponding to the encoding module corresponding to the previous decoding module, to obtain the decoding result corresponding to the non-first decoding module. Moreover, for the last decoding module, the decoding result corresponding to the decoding module may be fused with the input image sample to obtain the contour restoration image corresponding to the channel.

[0156] In each channel, the contour restoration network includes multiple encoding modules and multiple decoding modules. The number of decoding modules and the number of encoding modules can be set according to actual needs, such as 2, 3, etc., and are not specifically limited here.

[0157] For example, Figure 5 As shown in the figure, the image restoration model can include four parts, namely, a pre-trained region discriminator ①, a contour restoration network ②, a super-resolution upsampling network ③, and a pre-trained fineness adjustment network ④. The contour restoration network ③ includes three channels, each of which includes two encoding modules and two decoding modules.

[0158] The electronic device inputs the 192x192x4 facial image sample into the pre-trained region discriminator① to obtain an image sample with facial region information, and the size is still 192x192x4.

[0159] For the first channel, the electronic device may not downsample the image sample, and directly input the 192x192x4 image sample into the encoding module 1 (96x96x32) and encoding module 2 (48x48x48) connected in sequence included in the channel, encode the image sample according to the preset encoding rule, and obtain the feature code 1 of the image sample, that is, the encoding result. The electronic device may input the feature code 1 into the decoding module 1 (96x96x32), decode the feature code 1 according to the decoding rule corresponding to the preset encoding rule, and obtain the decoding result corresponding to the decoding module 1.

[0160] The electronic device can input the decoding result corresponding to the decoding module 1 to the decoding module 2 (192x192x4), and decode the input decoding result according to the decoding rule corresponding to the preset encoding rule based on the encoding result corresponding to the encoding module 1, and obtain the decoding result corresponding to the decoding module 2. Then, the decoding result corresponding to the decoding module 2 is fused with the image sample of 192x192x4 to obtain the contour restoration image corresponding to the channel.

[0161] For a non-first channel, the electronic device downsamples the image sample according to the preset image size of the channel to obtain a downsampled image. For a first encoding module, the downsampled image is input to the first encoding module included in the channel, and the downsampled image is encoded according to the preset encoding rule to obtain an encoding result corresponding to the first encoding module.

[0162] For a non-first coding module of a non-first channel, the electronic device can input the coding result corresponding to the previous coding module of the non-first coding module into the non-first coding module, and based on the target coding result of the coding module corresponding to the previous coding module in the previous channel, encode the input coding result according to a preset coding rule to obtain the coding result corresponding to the non-first coding module, wherein the target coding result is a coding result of the same size as the coding result corresponding to the previous coding module.

[0163] For the first decoding module of a non-first channel, the electronic device can input the encoding result of the channel into the first decoding module, decode the encoding result according to the decoding rule corresponding to the preset encoding rule, and obtain the decoding result corresponding to the first encoding module. For the non-first decoding module of a non-first channel, the electronic device can input the decoding result corresponding to the previous decoding module of the non-first decoding module into the non-first decoding module, based on the encoding result of the encoding module corresponding to the previous decoding module and the target decoding result of the decoding module corresponding to the previous decoding module in the previous channel, decode the input decoding result according to the decoding rule corresponding to the preset encoding rule, and obtain the decoding result corresponding to the non-first encoding module, wherein the target decoding result is a decoding result of the same size as the decoding result corresponding to the previous decoding module.

[0164] Furthermore, for the last decoding module, the decoding result corresponding to the decoding module may be fused with the input image sample to obtain a contour restoration image corresponding to the channel.

[0165] For example, Figure 5As shown, for the second channel, the electronic device can downsample (resize) the image sample according to the image size of 96x96x4 to obtain 96x96x4 image samples, and then input the 96x96x4 image samples to the encoding module 1 (48x48x32) of the channel. After obtaining the encoding result corresponding to the encoding module 1, the encoding result is input to the encoding module 2 (24x24x48). The encoding module 2 can encode the encoding result corresponding to the encoding module 1 based on the downsampled result of the encoding result corresponding to the encoding module 1 in the first channel to obtain feature code 2. The electronic device can input feature code 2 to the decoding module 1 (48x48x32), decode feature code 2 according to the decoding rule corresponding to the preset encoding rule, and obtain the decoding result corresponding to the decoding module 1.

[0166] The electronic device can input the decoding result corresponding to decoding module 1 into decoding module 2 (96x96x4), and decode the decoding result according to the decoding rule corresponding to the preset encoding rule based on the encoding result corresponding to encoding module 1 and the down-sampling result of the decoding result corresponding to decoding module 1 in the first channel, to obtain the decoding result corresponding to decoding module 2. Then, the decoding result corresponding to decoding module 2 is fused with the 96x96x4 image sample to obtain the contour restoration image corresponding to the channel.

[0167] Similarly, for the third channel, the electronic device can downsample (resize) the image sample according to the image size of 48x48x4 to obtain a 48x48x4 image sample, and then input the 48x48x4 image sample to the encoding module 1 (24x24x32) of the channel, and after obtaining the encoding result corresponding to the encoding module 1, input the encoding result to the encoding module 2 (12x12x48), and the encoding module 2 can encode the encoding result corresponding to the encoding module 1 based on the downsampled result of the encoding result corresponding to the encoding module 1 in the second channel to obtain the feature code 3. The electronic device can input the feature code 3 to the decoding module 1 (24x24x32), decode the feature code 3 according to the decoding rule corresponding to the preset encoding rule, and obtain the decoding result corresponding to the decoding module 1.

[0168] The electronic device can input the decoding result corresponding to decoding module 1 into decoding module 2 (48x48x4), and decode the decoding result according to the decoding rule corresponding to the preset encoding rule based on the encoding result corresponding to encoding module 1 and the down-sampling result of the decoding result corresponding to decoding module 1 in the second channel, to obtain the decoding result corresponding to decoding module 2. Then, the decoding result corresponding to decoding module 2 is fused with the 48x48x4 image sample to obtain the contour restoration image corresponding to the channel.

[0169] Since the contour restoration images output by the first channel, the second channel, and the third channel included in the contour restoration network have different sizes, the contour restoration image output by each channel can be input into the channel of the super-resolution upsampling network ③ corresponding to the channel for upsampling. That is, the contour restoration image output by the first channel is input into the super-resolution upsampling module (384x384x3) corresponding to the first channel, the contour restoration image output by the second channel is input into the super-resolution upsampling module (192x192x3) corresponding to the second channel, and the contour restoration image output by the third channel is input into the super-resolution upsampling module (96x96x3) corresponding to the third channel, and then the upsampled images of each channel are weighted fused according to the preset size to obtain the fused upsampled image, that is, the output RGB image (384x384x3), which is input into the fineness adjustment network ④, that is, output to VGGNet.

[0170] In the process of training the image restoration model, the first loss value corresponding to the contour restoration network can be used, that is, , as well as , the second loss value corresponding to the super-resolution upsampling network, that is , as well as , and the fourth function value corresponding to the fineness adjustment network , adjust the parameters of the contour restoration network and the super-resolution upsampling network until the total loss function converges.

[0171] It can be seen that in this embodiment, in the process of the contour restoration network using the encoding module to encode the image sample, not only the encoding result of the current channel is considered, but also the encoding result of the previous channel is combined; in the process of the decoding module processing the encoding result, not only the encoding result of the current channel is considered, but also the encoding result of the current channel and the decoding result of the previous channel are combined. In this way, the image information included in the contour restoration image output by each channel is more comprehensive, which is beneficial to the image denoising and contour restoration effects.

[0172] Corresponding to the above-mentioned training method of an image restoration model, the embodiment of the present application further provides an image restoration method. The following is an introduction to an image restoration method provided by the embodiment of the present application.

[0173] An image restoration method, the method comprising:

[0174] Step a, obtaining a facial image to be processed;

[0175] The facial image to be processed acquired by the electronic device is an image including noise. It can be an image acquired in real time by an image acquisition device in a low-light scene, or it can be an image stored in a specified path. These are all reasonable.

[0176] Step b: inputting the facial image to be processed into a pre-trained image restoration model to obtain a restored facial image.

[0177] The image restoration model is pre-trained according to the image restoration model training method described in any of the above embodiments.

[0178] Since the pre-trained image restoration model combines the effects of image denoising and contour restoration, the effects of image interpolation, and facial fineness for training during the training process, it can effectively restore facial images including noise. Therefore, after the electronic device inputs the facial image to be processed into the pre-trained image restoration model, it obtains a restored facial image with high clarity, which is of great significance for subsequent operations such as facial detection and facial recognition.

[0179] It can be seen that in the solution provided in the embodiment of the present application, since the pre-trained image restoration model considers the restoration effect of facial images from multiple angles, the effects of image denoising and contour restoration, the effects of image interpolation, and facial fineness all meet certain requirements, and in the process of training the image restoration model, the facial area information is combined to make the trained image restoration model more accurate. Therefore, by inputting the acquired facial image to be processed into the pre-trained image restoration model, the facial image to be processed can be better restored, so that the restored facial image is clearer, thereby improving the clarity of the facial image.

[0180] Figure 6 A specific flow chart of the training method of the image restoration model provided in the embodiment of the present application. Figure 6 The training method of the image restoration model provided in the embodiment of the present application is introduced by way of example. Figure 6 As shown, the training method of the image restoration model provided in the embodiment of the present application may include the following steps:

[0181] S601, input a facial image sample;

[0182] When the electronic device obtains a facial image sample, it may input the facial image sample into a pre-trained region discriminator, wherein the facial image sample may be an image of a size of 192x192x4.

[0183] S602, pre-trained region discriminator processing;

[0184] The region discriminator can determine different facial regions in the facial image sample by using pre-set region determination conditions or different region features, for example, dividing the facial image sample into facial features region, facial non-features region and background region. In this way, after being processed by the region discriminator, the electronic device can obtain an image sample with facial region information.

[0185] S603, constructing a loss function based on the image sample with facial region information;

[0186] In order to consider the restoration effect of facial images from multiple angles, before training the image restoration model, multiple targeted loss functions can be constructed first, and a total loss function can be constructed based on each loss function. The loss function constructed in the embodiment of the present application includes a first loss function, a second loss function, and a third loss function. Figure 4 As shown, the first loss function is the loss function corresponding to the contour restoration network ②, the second loss function is the loss function corresponding to the super-resolution upsampling network ③, and the third loss function is the loss function corresponding to the fineness adjustment network ④.

[0187] S604, contour restoration network training;

[0188] After determining each loss function, the electronic device can first train the local network, that is, train the contour restoration network and the super-resolution upsampling network respectively. Then the electronic device can input the image sample into the contour restoration network, calculate the first loss value of the first loss function according to the contour restoration image output by the contour restoration network, and adjust the parameters of the contour restoration network based on the first loss value until the total loss function converges.

[0189] S605, super-resolution upsampling network training;

[0190] After the contour restoration network is trained, the electronic device can train the super-resolution upsampling network, calculate the second loss value of the second loss function, and adjust the parameters of the super-resolution upsampling network based on the second loss value until the total loss function converges.

[0191] S606, the training of the contour restoration network and the super-resolution upsampling network is performed alternately;

[0192] The electronic device can alternately train the contour restoration network and the super-resolution upsampling network. After adjusting the parameters of the contour restoration network, the parameters of the super-resolution upsampling network are adjusted, and then the parameters of the contour restoration network are continued to be adjusted until both networks are trained.

[0193] S607, fine-tuning global network parameters.

[0194] After training the contour restoration network and the super-resolution upsampling network, the electronic device can further fine-tune the global network parameters, that is, based on the loss value of the total loss function, adjust the parameters of the contour restoration network and the super-resolution upsampling network until the total loss function converges to obtain the image restoration model.

[0195] For example, the electronic device obtains a facial image sample in the Bayer format, reconstructs the facial image sample to obtain a reconstructed facial image sample, and then inputs the reconstructed facial image sample into a pre-trained region discriminator to obtain an image sample with facial region information. After the electronic device determines the number of channels of the contour restoration network and the super-resolution upsampling network, the network parameters are initialized.

[0196] During the training of the facial restoration module, the fifth preset weight p=0.5, the sixth preset weight q=0.5, the seventh preset weight a=1, and the eighth preset weight b=0 are set, and the parameters of the contour restoration network are adjusted based on the first loss value until the total loss function converges. The first preset weight c and the second preset weight d can be fine-tuned according to actual conditions, and the facial contour restoration situation is observed until the desired effect is achieved.

[0197] Then set the fifth preset weight p=0.5, the sixth preset weight q=0.5, the seventh preset weight a=0, and the eighth preset weight b=1, and adjust the parameters of the super-resolution upsampling network based on the second loss value until the total loss function converges. The third preset weight e and the fourth preset weight f can be fine-tuned according to actual conditions, and the generation of facial details is observed until the desired effect is achieved.

[0198] The electronic device alternately trains the contour restoration network and the super-resolution upsampling network until the loss function converges, that is, the effects of facial denoising, contour restoration, and image interpolation tend to be stable.

[0199] Finally, p=0.5, q=0.5, a=0.5, b=0.5 are set, and the parameters of the contour restoration network and the super-resolution upsampling network are adjusted based on the loss value of the total loss function. p can be increased according to the preset step size, and q can be reduced according to the preset step size. p and q always satisfy p+q=1 until p increases to 1 and q decreases to 0. When the loss function converges, the image restoration model is obtained. And the first preset weight c, the second preset weight q, the third preset weight e, and the fourth preset weight f can be fine-tuned according to the actual situation until the desired effect is achieved.

[0200] It can be seen that in the solution provided in the embodiment of the present application, since the first loss function is used to characterize the image denoising and contour restoration effects, the second loss function is used to characterize the image interpolation effect, and the third loss function is used to characterize the image fineness, then in the process of training the image restoration model, the restoration effect of the facial image is considered from multiple angles, and the parameters of the contour restoration network are first adjusted based on the first loss value, and then the parameters of the super-resolution upsampling network are adjusted based on the second loss value. After the contour restoration network and the super-resolution upsampling network are trained respectively, the parameters of the contour restoration network and the upsampling network are continued to be adjusted based on the first loss value, the second loss value and the third loss value until the total loss function converges, so that the effects of image denoising and contour restoration, the effects of image interpolation, and the facial fineness all meet certain requirements, and in the process of training the image restoration model, the facial area information is combined to make the trained image restoration model more accurate, so that the facial image can be better restored, thereby improving the clarity of the facial image.

[0201] Corresponding to the above-mentioned training method of the image restoration model, the embodiment of the present application further provides a training device for the image restoration model. The following is an introduction to the training device for the image restoration model provided in the embodiment of the present application.

[0202] like Figure 7 As shown, a training device for an image restoration model comprises:

[0203] An image sample acquisition module 710 is used to input a facial image sample into a pre-trained region discriminator to obtain an image sample with facial region information, wherein the facial image sample includes noise;

[0204] A first loss value calculation module 720, used to input the image sample into a contour restoration network, and calculate a first loss value of a first loss function according to the contour restoration image output by the contour restoration network, wherein the first loss function is used to characterize image denoising and contour restoration effects;

[0205] A second loss value calculation module 730 is used to input the contour restoration image into the super-resolution upsampling network, and calculate a second loss value of a second loss function according to the upsampled image output by the super-resolution upsampling network, where the second loss function is used to characterize the image interpolation effect;

[0206] A third loss value calculation module 740 is used to input the upsampled image into a pre-trained fineness adjustment network, and calculate a third loss value of a third loss function according to the facial restoration image output by the fineness adjustment network, wherein the third loss function is used to characterize the fineness of the image;

[0207] A loss value calculation module 750, configured to calculate a loss value of a total loss function according to the first loss value, the second loss value, and the third loss value;

[0208] A contour restoration network parameter adjustment module 760, configured to adjust the parameters of the contour restoration network based on the first loss value, and to adjust the parameters of the super-resolution upsampling network based on the second loss value alternately, until the total loss function converges;

[0209] The image restoration model acquisition module 770 is used to adjust the parameters of the contour restoration network and the super-resolution upsampling network based on the loss value until the total loss function converges, thereby obtaining an image restoration model. The image restoration model includes the region discriminator, the adjusted contour restoration network, the adjusted super-resolution upsampling network, and the fineness adjustment network.

[0210] It can be seen that in the solution provided in the embodiment of the present application, since the first loss function is used to characterize the image denoising and contour restoration effects, the second loss function is used to characterize the image interpolation effect, and the third loss function is used to characterize the image fineness, then in the process of training the image restoration model, the restoration effect of the facial image is considered from multiple angles, and the parameters of the contour restoration network are first adjusted based on the first loss value, and then the parameters of the super-resolution upsampling network are adjusted based on the second loss value. After the contour restoration network and the super-resolution upsampling network are trained respectively, the parameters of the contour restoration network and the upsampling network are continued to be adjusted based on the first loss value, the second loss value and the third loss value until the total loss function converges, so that the effects of image denoising and contour restoration, the effects of image interpolation, and the facial fineness all meet certain requirements, and in the process of training the image restoration model, the facial area information is combined to make the trained image restoration model more accurate, so that the facial image can be better restored, thereby improving the clarity of the facial image.

[0211] Corresponding to the above-mentioned image restoration method, the embodiment of the present application further provides an image restoration device. The following is an introduction to an image restoration device provided by the embodiment of the present application.

[0212] like Figure 8 As shown, an image restoration device, the device comprising:

[0213] The facial image to be processed acquisition module 810 is used to acquire the facial image to be processed;

[0214] The restored facial image acquisition module 820 is used to input the facial image to be processed into a pre-trained image restoration model to obtain a restored facial image, wherein the image restoration model is pre-trained according to the image restoration model training method described in any of the above embodiments.

[0215] It can be seen that in the solution provided in the embodiment of the present application, since the pre-trained image restoration model considers the restoration effect of facial images from multiple angles, the effects of image denoising and contour restoration, the effects of image interpolation, and facial fineness all meet certain requirements, and in the process of training the image restoration model, the facial area information is combined to make the trained image restoration model more accurate. Therefore, by inputting the acquired facial image to be processed into the pre-trained image restoration model, the facial image to be processed can be better restored, so that the restored facial image is clearer, thereby improving the clarity of the facial image.

[0216] The present application also provides an electronic device, including:

[0217] Memory, used to store computer programs;

[0218] The processor is used to implement the image restoration model training method or image restoration method described in any of the above embodiments when executing the program stored in the memory.

[0219] Furthermore, the electronic device may further include a communication bus and / or a communication interface, and the processor, the communication interface, and the memory communicate with each other via the communication bus.

[0220] It can be seen that in the solution provided in the embodiment of the present application, since the first loss function is used to characterize the image denoising and contour restoration effects, the second loss function is used to characterize the image interpolation effect, and the third loss function is used to characterize the image fineness, then in the process of training the image restoration model, the restoration effect of the facial image is considered from multiple angles, and the parameters of the contour restoration network are first adjusted based on the first loss value, and then the parameters of the super-resolution upsampling network are adjusted based on the second loss value. After the contour restoration network and the super-resolution upsampling network are trained respectively, the parameters of the contour restoration network and the upsampling network are continued to be adjusted based on the first loss value, the second loss value and the third loss value until the total loss function converges, so that the effects of image denoising and contour restoration, the effects of image interpolation, and the facial fineness all meet certain requirements, and in the process of training the image restoration model, the facial area information is combined to make the trained image restoration model more accurate, so that the facial image can be better restored, thereby improving the clarity of the facial image.

[0221] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0222] The communication interface is used for communication between the above electronic device and other devices.

[0223] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0224] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0225] In another embodiment provided in the present application, a computer-readable storage medium is also provided, which stores a computer program. When the computer program is executed by a processor, it implements the steps of any of the above-mentioned image restoration model training methods or image restoration methods.

[0226] In another embodiment provided in the present application, a computer program product comprising instructions is also provided, which, when executed on a computer, enables the computer to execute any image restoration model training method or image restoration method in the above-mentioned embodiments.

[0227] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a solid-state hard disk (SSD), etc.

[0228] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0229] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, electronic device, computer-readable storage medium, and computer program product embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.

[0230] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.

Claims

1. A training method for an image restoration model, characterized in that: The method comprises: Inputting a facial image sample into a pre-trained region discriminator to obtain an image sample having facial region information, wherein the facial image sample includes noise; Inputting the image sample into a contour restoration network, and calculating a first loss value of a first loss function according to a contour restoration image output by the contour restoration network, wherein the first loss function is used to characterize image denoising and contour restoration effects; Inputting the contour restoration image into a super-resolution upsampling network, and calculating a second loss value of a second loss function according to an upsampled image output by the super-resolution upsampling network, wherein the second loss function is used to characterize an image interpolation effect; Inputting the upsampled image into a pre-trained fineness adjustment network, and calculating a third loss value of a third loss function according to a facial restoration image output by the fineness adjustment network, wherein the third loss function is used to characterize the fineness of the image; Calculate the loss value of the total loss function according to the first loss value, the second loss value and the third loss value; Adjusting the parameters of the contour restoration network based on the first loss value, and adjusting the parameters of the super-resolution upsampling network based on the second loss value alternately until the total loss function converges; Based on the loss value, adjusting the parameters of the contour restoration network and the super-resolution upsampling network until the total loss function converges, thereby obtaining an image restoration model, wherein the image restoration model includes the region discriminator, the adjusted contour restoration network, the adjusted super-resolution upsampling network, and the fineness adjustment network; The contour restoration network includes a plurality of channels; the step of calculating a first loss value of a first loss function according to a contour restoration image output by the contour restoration network includes: For each channel of the contour restoration network, according to the difference between the color features and structural features of each facial region included in the contour restoration image output by the channel and the color features and structural features of the facial region included in the corresponding first reference image, a structural loss value of the structural loss function included in the pre-constructed first loss function is calculated; Calculate a pixel loss value of a pixel value loss function included in a pre-constructed first loss function according to a difference between a pixel value of each pixel point in the facial region included in the contour restoration image output by the channel and a pixel value of a pixel point corresponding to the pixel point in the corresponding first reference image; Calculate a first loss value of the first loss function according to the structural loss value, the pixel loss value, the first preset weight, and the second preset weight corresponding to each channel; The number of channels of the super-resolution upsampling network is the same as the number of channels of the contour restoration network, and each channel of the contour restoration network is correspondingly connected to a channel of the super-resolution upsampling network; The step of calculating a second loss value of a second loss function according to the upsampled image output by the super-resolution upsampling network comprises: For each channel of the super-resolution upsampling network, according to the difference between the high-frequency texture features of each facial region included in the upsampled image output by the channel and the high-frequency texture features of the facial region included in the corresponding second reference image, calculate the high-frequency loss value of the high-frequency loss function included in the pre-constructed second loss function; Calculate a low-frequency loss value of a low-frequency loss function included in a pre-constructed second loss function according to a difference between a low-frequency texture feature of each facial region included in the up-sampled image output by the channel and a low-frequency texture feature of the facial region included in a corresponding second reference image; The second loss value of the second loss function is calculated according to the high-frequency loss value, the low-frequency loss value, the third preset weight and the fourth preset weight corresponding to each channel.

2. The method according to claim 1, characterized in that The step of calculating the first loss value of the first loss function according to the structural loss value, the pixel loss value, the first preset weight and the second preset weight corresponding to each channel includes: The first loss value of the first loss function is calculated according to the following formula : ; in, For the The structural loss value corresponding to the jth facial region in the contour restoration image output by the channel, For the The pixel loss value corresponding to the jth facial region in the contour restoration image output by the channel, is the number of facial regions in the contour restoration image, is the number of channels of the contour restoration network, is the first preset weight, is the second preset weight.

3. The method according to claim 1, characterized in that The step of calculating the second loss value of the second loss function according to the high-frequency loss value, the low-frequency loss value, the third preset weight, and the fourth preset weight corresponding to each channel includes: The second loss value of the second loss function is calculated according to the following formula : ; ; ; in, is the number of channels of the super-resolution upsampling network, For the The high-frequency loss value corresponding to the upsampled image output by each channel, For the The low-frequency loss value corresponding to the upsampled image output by each channel, is the third preset weight, is the fourth preset weight, For the The label value of the pixel value of the pixel in the second reference image of the channel, is the predicted value of the pixel value of the pixel point in the upsampled image, The first preset zoom control strength, is the number of pixels in the upsampled image, is the position of the pixel in the upsampled image, For the The upsampled image output by channels The pixel value of the pixel point corresponding to the facial area is The square error value between the pixel values ​​of the pixels corresponding to the facial regions, the The square error value corresponding to a facial region is the minimum value of the square error values ​​corresponding to multiple facial regions. is the Laplace filter, Zoom control strength for the second preset.

4. The method according to claim 3, characterized in that The step of calculating the loss value of the total loss function according to the first loss value, the second loss value and the third loss value comprises: The loss value of the total loss function is calculated according to the following formula: : ; ; in, is the first The first loss value corresponding to the jth facial region in the contour restoration image output by the channel, is the first The second loss value corresponding to the upsampled image output by channels, is the third loss value, is the number of facial regions in the contour restoration image, is the preset weight corresponding to the jth facial region, is the fifth preset weight, is the sixth preset weight, is the seventh preset weight, is the eighth preset weight, The number of channels of the contour restoration network; The step of adjusting the parameters of the contour restoration network based on the first loss value and adjusting the parameters of the super-resolution upsampling network based on the second loss value alternately until the total loss function converges comprises: When the fifth preset weight and the sixth preset weight are the first preset values, the seventh preset weight is 1, and the eighth preset weight is 0, adjusting the parameters of the contour restoration network based on the loss value of the total loss function corresponding to each image sample until the total loss function satisfies a convergence condition; When the fifth preset weight and the sixth preset weight are the second preset values, the seventh preset weight is 0, and the eighth preset weight is 1, returning to the step of inputting the image sample into the contour restoration network, and adjusting the parameters of the super-resolution upsampling network based on the loss value of the total loss function corresponding to each image sample until the total loss function meets the convergence condition; Returning to the step of adjusting the parameters of the contour restoration network based on the loss value of the total loss function corresponding to each image sample when the fifth preset weight and the sixth preset weight are the first preset value, the seventh preset weight is 1, and the eighth preset weight is 0, until the total loss function satisfies the convergence condition; The step of adjusting the parameters of the contour restoration network and the super-resolution upsampling network based on the loss value until the total loss function converges to obtain the image restoration model comprises: When the fifth preset weight, the sixth preset weight, the seventh preset weight and the eighth preset weight are the third preset value, return to the step of inputting the image sample into the contour restoration network, and adjust the parameters of the contour restoration network and the super-resolution upsampling network based on the loss value of the total loss function corresponding to each image sample until the total loss function meets the convergence condition, thereby obtaining the image restoration model.

5. The method according to any one of claims 1 to 4, characterized in that: Each channel of the contour restoration network includes a plurality of encoding modules and a plurality of decoding modules, and the number of the decoding modules is the same as the number of the encoding modules; The step of inputting the image sample into a contour restoration network comprises: For a first channel, the image sample is input into the sequentially connected encoding modules included in the channel, and the image sample is encoded according to a preset encoding rule to obtain an encoding result of the image sample; for a first decoding module of the first channel, the encoding result of the channel is input into the first decoding module, and the encoding result of the channel is decoded according to a decoding rule corresponding to the preset encoding rule to obtain a decoding result corresponding to the first decoding module; for a non-first decoding module, the decoding result corresponding to a previous decoding module of the non-first decoding module is input into the non-first decoding module, and based on the encoding result corresponding to the encoding module corresponding to the previous decoding module, the input decoding result is decoded according to a decoding rule corresponding to the preset encoding rule to obtain a decoding result corresponding to the non-first decoding module; For a first encoding module other than the first channel, down-sample the image sample according to an image size preset for the channel to obtain a down-sampled image; input the down-sampled image to a first encoding module included in the channel, encode the down-sampled image according to the preset encoding rule, and obtain an encoding result corresponding to the first encoding module; For a non-first encoding module of a non-first channel, an encoding result corresponding to a previous encoding module of the non-first encoding module is input into the non-first encoding module, and based on a target encoding result of an encoding module corresponding to the previous encoding module in a previous channel, the input encoding result is encoded according to the preset encoding rule to obtain an encoding result corresponding to the non-first encoding module, wherein the target encoding result is an encoding result having the same size as the encoding result corresponding to the previous encoding module; For a first decoding module other than the first channel, inputting the encoding result of the channel into the first decoding module, decoding the encoding result according to a decoding rule corresponding to the preset encoding rule, and obtaining a decoding result corresponding to the first encoding module; For a non-first decoding module of a non-first channel, a decoding result corresponding to a previous decoding module of the non-first decoding module is input into the non-first decoding module, and based on the encoding result of the encoding module corresponding to the previous decoding module and the target decoding result of the decoding module corresponding to the previous decoding module in the previous channel, the input decoding result is decoded according to the decoding rule corresponding to the preset encoding rule to obtain a decoding result corresponding to the non-first encoding module, wherein the target decoding result is a decoding result of the same size as the decoding result corresponding to the previous decoding module.

6. An image restoration method, characterized in that: The method comprises: Obtaining a facial image to be processed; The facial image to be processed is input into a pre-trained image restoration model to obtain a restored facial image, wherein the image restoration model is pre-trained according to the method according to any one of claims 1-5.

7. A training device for an image restoration model, characterized in that: The device comprises: An image sample acquisition module, used for inputting a facial image sample into a pre-trained region discriminator to obtain an image sample with facial region information, wherein the facial image sample includes noise; a first loss value calculation module, used for inputting the image sample into a contour restoration network, and calculating a first loss value of a first loss function according to a contour restoration image output by the contour restoration network, wherein the first loss function is used to characterize image denoising and contour restoration effects; A second loss value calculation module is used to input the contour restoration image into the super-resolution upsampling network, and calculate a second loss value of a second loss function according to the upsampled image output by the super-resolution upsampling network, where the second loss function is used to characterize the image interpolation effect; a third loss value calculation module, configured to input the upsampled image into a pre-trained fineness adjustment network, and calculate a third loss value of a third loss function according to a facial restoration image output by the fineness adjustment network, wherein the third loss function is used to characterize the fineness of the image; A loss value calculation module, used to calculate the loss value of the total loss function according to the first loss value, the second loss value and the third loss value; A contour restoration network parameter adjustment module, used to adjust the parameters of the contour restoration network based on the first loss value, and to adjust the parameters of the super-resolution upsampling network based on the second loss value alternately, until the total loss function converges; An image restoration model acquisition module is used to adjust the parameters of the contour restoration network and the super-resolution upsampling network based on the loss value until the total loss function converges to obtain an image restoration model, wherein the image restoration model includes the region discriminator, the adjusted contour restoration network, the adjusted super-resolution upsampling network, and the fineness adjustment network; Wherein, the contour restoration network includes a plurality of channels; The first loss value calculation module is specifically used to calculate, for each channel of the contour restoration network, a structural loss value of a structural loss function included in a pre-constructed first loss function according to the difference between the color features and structural features of each facial region included in the contour restoration image output by the channel and the color features and structural features of the facial region included in the corresponding first reference image; calculate a pixel loss value of a pixel value loss function included in the pre-constructed first loss function according to the difference between the pixel value of a pixel point in each facial region included in the contour restoration image output by the channel and the pixel value of a pixel point corresponding to the pixel point in the corresponding first reference image; calculate a first loss value of the first loss function according to the structural loss value, the pixel loss value, the first preset weight and the second preset weight corresponding to each channel; The number of channels of the super-resolution upsampling network is the same as the number of channels of the contour restoration network, and each channel of the contour restoration network is correspondingly connected to a channel of the super-resolution upsampling network; The second loss value calculation module is specifically used to calculate, for each channel of the super-resolution upsampling network, the high-frequency loss value of the high-frequency loss function included in the pre-constructed second loss function according to the difference between the high-frequency texture features of each facial area included in the up-sampled image output by the channel and the high-frequency texture features of the facial area included in the corresponding second reference image; calculate the low-frequency loss value of the low-frequency loss function included in the pre-constructed second loss function according to the difference between the low-frequency texture features of each facial area included in the up-sampled image output by the channel and the low-frequency texture features of the facial area included in the corresponding second reference image; calculate the second loss value of the second loss function according to the high-frequency loss value, the low-frequency loss value, the third preset weight and the fourth preset weight corresponding to each channel.

8. An image restoration device, characterized in that: The device comprises: A facial image acquisition module to be processed, used to acquire the facial image to be processed; The restored facial image acquisition module is used to input the facial image to be processed into a pre-trained image restoration model to obtain a restored facial image, wherein the image restoration model is pre-trained according to the method according to any one of claims 1-5.