Person image restoration method, device, electronic device, storage medium, and program product

The human image restoration method addresses issues of noise, blurring, and distortion in captured images by extracting luminance channels and using a neural network to enhance image quality and resolution.

JP7542156B2Active Publication Date: 2024-08-29SHENZHEN TETRAS AI TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
JP2023537450
Authority / Receiving Office
JP · JP
Patent Type
Patents
Current Assignee / Owner
Priority Date
2020-11-30
Filing Date
2021-04-27
Publication Date
2024-08-29
Estimated Expiration
2041-04-27

AI Technical Summary

Technical Problem

Conventional imaging devices often capture human images with issues such as noise, blurring, and local distortion due to design limitations and operational factors.

Method used

A human image restoration method that involves extracting a luminance channel from a face image, performing person image restoration using a trained neural network model, and fusing color channels to obtain a target face image, followed by image conversion processing to enhance the image quality.

Benefits of technology

The method effectively repairs facial images with noise, blurring, and distortion, improving the overall quality and resolution of the restored images.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 0007542156000005
    Figure 0007542156000005
  • Figure 0007542156000008
    Figure 0007542156000008
  • Figure 0007542156000013
    Figure 0007542156000013
Patent Text Reader

Abstract

A person image restoration method, device, electronic device, storage medium, and program product includes: acquiring a face image to be restored (S21); extracting a luminance channel from the face image to be restored and performing person image restoration based on the luminance channel to obtain a target face image (S22); fusing color channels of the target face image and the face image to be restored to obtain a first restored face image (S23); and performing image conversion processing on the first restored face image to obtain a second restored face image (S24). This method is advantageous in improving the quality of the restored face image and the overall restoration effect of the face image.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] This application claims priority to a Chinese patent application filed with the China Patent Office on November 30, 2020, bearing application number 202011386894.4 and entitled "Portrait image restoration method, apparatus, electronic device and computer storage medium", the entire contents of which are incorporated herein by reference.

[0002] The present application relates to the field of image processing technology, and in particular to a person image restoration method, apparatus, electronic device, storage medium and program product. [Background technology]

[0003] In the case of conventional imaging devices, the imaging effect may not be ideal when collecting images because of limitations imposed by factors such as the design of the device itself, the environment, the operation of the imaging operator, etc. In particular, when capturing images of people, problems such as large noise in the image of the person, blurring, and local distortion are often observed. Summary of the Invention

[0004] The present application provides a person image restoration method, an apparatus, an electronic device, a storage medium and a program product.

[0005] A first aspect of an embodiment of the present application provides a human image restoration method, which includes obtaining a facial image to be restored, extracting a luminance channel of the facial image to be restored, performing human image restoration based on the luminance channel to obtain a target facial image, fusing color channels of the target facial image and the facial image to be restored to obtain a first facial restoration image, and performing image conversion processing on the first facial restoration image to obtain a second facial restoration image.

[0006] In the embodiment of the present application, a luminance channel is extracted from a face image to be repaired, and a human image is repaired based on the extracted luminance channel to obtain a target face image with a repaired luminance channel, and a color channel is merged to obtain a repaired first face repaired image, and image conversion processing such as color correction and enlargement / reduction is performed on the first face repaired image so that the obtained second face repaired image maintains the color information of the face image to be repaired and the resolution of the face image to be repaired before enlargement / reduction. This is advantageous for repairing face images with problems such as noise, blur, and distortion, improves the quality of the repaired face image, and improves the overall repair effect of the face image.

[0007] According to the first aspect, in one possible embodiment, extracting the luminance channel of the facial image to be repaired includes, when the format of the facial image to be repaired is a first format, extracting the luminance channel of the facial image to be repaired, or, when the format of the facial image to be repaired is a second format, converting the format of the facial image to be repaired to the first format and extracting the luminance channel of the facial image to be repaired after format conversion.

[0008] In the embodiment of the present application, human image restoration is performed on a face image to be restored based on the luminance channel, so that for a face image to be restored in a first format from which the luminance channel can be directly extracted, the luminance channel can be directly extracted, and for a face image to be restored in a second format from which the luminance channel cannot be directly extracted, the face image is converted to the first format before the luminance channel is extracted. This ensures that human image restoration based on the luminance channel is possible for any face image to be restored in a plurality of formats, which is advantageous in improving the applicability of the face image to be restored to the format.

[0009] According to the first aspect, in one possible embodiment, the step of performing person image restoration based on the luminance channel to obtain a target face image includes inputting the luminance channel into a trained neural network model to perform person image restoration to obtain the target face image.

[0010] In an embodiment of the present application, human image inpainting is performed using a trained neural network model, which is advantageous for inpainting face images that are noisy, blurry, or distorted due to issues such as poor lighting, shaking, out-of-focus, and digital zoom, and improves the definition and texture details of human features, hair, and skin.

[0011] According to the first aspect, in one possible embodiment, the neural network model includes a first network, a second network, a third network, and a fourth network, the second network includes N (N is an integer greater than 1) blur upsampling modules, the blur upsampling in at least one blur upsampling module among the N blur upsampling modules includes a blur convolution, and a weight of a convolution kernel in the blur convolution is a predetermined constant value, and the neural network model has shortcut connections at the input of the first network, the output of the second network, and the output of the third network, and has shortcut connections at the output of the first network and the output of the fourth network.

[0012] In the embodiment of the present application, the input of the first network, the output of the second network, and the output of the third network are at the highest resolution scale, and the output of the first network and the output of the fourth network are at the lowest resolution scale, and the shortcut connection at the highest resolution scale and the lowest resolution scale is favorable to prevent overfitting of the neural network model, and the iteration speed during training can be made faster. Blurred upsampling includes a blurred convolution operation, and the weight of the adopted convolution kernel is kept constant from the beginning of the training of the neural network model, and its role corresponds to a low-pass filter, which is favorable to the generation of smooth and natural contours and hair during image restoration.

[0013] According to a first aspect, in one possible embodiment, the step of inputting the luminance channel into a trained neural network model to perform human image inpainting and obtain the target face image includes performing an encoding operation on the luminance channel using the first network to obtain a target feature map, and performing a decoding operation on the target feature map using the second network and the third network to obtain the target face image.

[0014] In the embodiment of the present application, the first network is used to reduce the size of the input luminance channel and extract the target feature map by encoding, the second network restores the size of the luminance channel during decoding, and at the same time, the third network ensures the stability of the neural network model during decoding, and finally obtains the target face image with the restored luminance channel.

[0015] According to the first aspect, in one possible embodiment, performing an encoding operation on the luminance channel using the first network to obtain a target feature map includes inputting the luminance channel to the first network for downsampling to obtain a first feature map, performing upper layer feature extraction on the first feature map using the fourth network to obtain an upper layer feature map, and superimposing the first feature map and the upper layer feature map to obtain the target feature map.

[0016] In the embodiment of the present application, the fourth network adopts a residual block structure, which is advantageous for extracting upper layer features. By overlapping the output of the first network and the output of the fourth network through shortcut connection, it is possible to prevent overfitting of the neural network model while enriching the feature information.

[0017] According to the first aspect, in one possible embodiment, performing a decoding operation on the target feature map using the second network and the third network to obtain the target face image includes: inputting the target feature map to the N blurred upsampling modules in the second network to perform blurred upsampling to obtain a second feature map; inputting feature maps output from the 1st to (N-1)th blurred upsampling modules of the N blurred upsampling modules to the third network to perform upsampling to obtain a third feature map; and superimposing the luminance channel, the second feature map, and the third feature map to obtain the target face image.

[0018] In the embodiment of the present application, the second network uses N blurred upsampling modules to perform blurred upsampling, restore the size of the target feature map, and is favorable to generating smooth and natural contours and hair. The third network performs upsampling on the feature maps output from the 1st to (N-1)th blurred upsampling modules in the second network, which is favorable to ensuring the stability of the neural network model, and the input of the first network, the output of the second network, and the output of the third network are overlapped by shortcut connection, which can prevent overfitting of the neural network model, while enriching the feature information and improving the restoration quality of the target face image.

[0019] According to the first aspect, in one possible embodiment, the third network includes (N-1) upsampling modules, and the step of inputting the feature map output from the first to (N-1)th blurred upsampling modules of the N blurred upsampling modules to the third network for upsampling to obtain a third feature map includes compressing the number of channels of the feature map output from the first blurred upsampling module of the N blurred upsampling modules to obtain a first compressed feature map, and inputting the first compressed feature map to the first upsampling module of the (N-1) upsampling modules for upsampling. the (N-1) upsampling modules to obtain the third feature map; compressing the number of channels of the feature map output from the i-th (i is an integer greater than 1 and less than N) blurred upsampling module among the N blurred upsampling modules to obtain a second compressed feature map; overlaying the feature map output from the (i-1)th upsampling module among the (N-1) upsampling modules and the second compressed feature map, inputting the feature map obtained by overlaying into the i-th upsampling module among the (N-1) upsampling modules for upsampling; and obtaining the third feature map through processing by the (N-1) upsampling modules.

[0020] In the embodiment of the present application, the number of channels of the feature maps output from the 1st to (N-1)th blurred upsampling modules among the N blurred upsampling modules is compressed, thereby ensuring that the number of channels of the inputs to at least one upsampling module in the third network are all the same, which is advantageous to improving the stability of the neural network model.

[0021] According to a first aspect, in one possible embodiment, obtaining the facial image to be repaired includes performing face detection on a collected original image, cropping the facial image based on a position of the detected face in the original image, and scaling the facial image to obtain the facial image to be repaired.

[0022] In an embodiment of the present application, after face detection is performed on the original image collected by the user, the face image is cropped and scaled to a certain size, which is advantageous for realizing restoration of large-sized face images.

[0023] According to the first aspect, in one possible embodiment, after scaling the face image to obtain the face image to be repaired, the method further includes performing person image segmentation on the original image to obtain a person image mask, and after obtaining a second face repaired image, the method further includes performing Gaussian blurring on edges of the person image mask, and pasting the face in the second face repaired image back onto the original image after cropping based on the crop position of the face image in the original image and the person image mask, thereby completing the restoration of the original image.

[0024] In the embodiment of the present application, the position of the face in the original image can be identified based on the cut-out position of the face image in the original image and the person image mask. This allows the restored face in the second face restoration image to be pasted back into the original image, the background part remains the background in the original image, and Gaussian blurring is performed on the edge of the person image mask before pasting the face back, making the final restoration image smoother and more natural.

[0025] According to the first aspect, in one possible embodiment, performing an image conversion process on the first face repaired image to obtain a second face repaired image includes performing color correction on the first face repaired image, determining a scaling ratio, and if the scaling ratio is greater than a predetermined ratio, scaling the color-corrected first face repaired image using super-resolution technology to obtain the second face repaired image.

[0026] In the embodiment of the present application, a color correction is performed on the first face repaired image, and the color-corrected first face repaired image is scaled to restore its size to the size of the cropped face image, thereby obtaining a high-quality second face repaired image. If the scale factor for scaling the first face repaired image exceeds a preset scale factor, scaling using a super-resolution technique is advantageous in improving the resolution of the second face repaired image.

[0027] According to the first aspect, in one possible embodiment, before obtaining a facial image to be repaired, the method further includes: constructing a sample image pair including a first facial image and a second facial image obtained based on the first facial image; inputting the sample image pair into a neural network for training and outputting a repaired image of the second facial image; determining a target loss based on the repaired image and the first facial image; and adjusting parameters of the neural network to minimize the target loss to obtain the neural network model.

[0028] In the embodiment of the present application, the neural network is trained using paired sample images, in which there are degraded images that are sufficiently close to the images with image quality problems actually collected. Training the neural network using such sample image pairs is favorable for improving the generalization of the neural network model. By minimizing the target loss, the repaired image output from the neural network model can be as close as possible to the quality of the first face image, and the processing of details such as contours and hair of the repaired image can be increased.

[0029] According to the first aspect, in one possible embodiment, the target loss comprises at least one of a regression loss, a perceptual loss, a generative adversarial loss, and a context loss.

[0030] In an embodiment of the present application, by training a neural network model using a target loss including at least one of a regression loss, a perceptual loss, an adversarial generation loss, and a context loss, the neural network model can comprehensively repair multiple problems existing in a degraded image and improve the quality of person image restoration.

[0031] According to the first aspect, in one possible embodiment, the constituting of the sample image pair includes: acquiring a preset first face image; if image quality of the first face image is not degraded, performing atmospheric turbulence degradation on the first face image to obtain a first degraded image, performing downsampling on the first degraded image, obtaining a target degraded image, performing upsampling on the target degraded image, obtaining a second degraded image, obtaining a third degraded image based on the second degraded image, compressing the third degraded image using a preset compression quality parameter to obtain a fourth degraded image, determining a rectangular area in the fourth degraded image, identifying a target area in the first face image corresponding to the rectangular area, replacing corresponding pixel values ​​in the rectangular area with pixel values ​​in the target area, obtaining the second face image, and constituting the sample image pair with the first face image and the second face image; or, if image quality of the first face image is degraded, constituting the sample image pair with two first face images, and determining one of the two as the second face image.

[0032] In the embodiment of the present application, the image quality of the first face image is judged, and if the first face image itself is relatively clear and its image quality is not degraded, a series of degradation processes are performed on the first face image, and one second face image with degradation problem is synthesized, and the second face image is made similar to the actually collected degraded image, thereby simulating the scene of repairing the true degraded image. If the first face image itself has a degradation problem, there is no need to perform degradation processes on it, and two first face images may be used as they are to form a sample image pair, simulating the scene of repairing the true degraded image.

[0033] According to the first aspect, in one possible embodiment, obtaining a third degraded image based on the second degraded image includes: adding noise to a luminance channel of the second degraded image, performing non-local means noise removal on the second degraded image, and obtaining the third degraded image; or performing a blurring operation on the second degraded image, obtaining a fifth degraded image, adding noise to a luminance channel of the fifth degraded image, and performing non-local means noise removal on the fifth degraded image, and obtaining the third degraded image.

[0034] In the embodiment of the present application, various degradation processes are performed on the second degraded image using methods such as blurring, noise superposition, non-local means noise removal, etc., to cause various degradation problems in the third degraded image, which is advantageous in subsequently training the neural network model using images with various degradation problems.

[0035] A second aspect of the present invention is a person image restoration device, comprising: an image acquisition module for acquiring a face image to be restored; a person image inpainting module for extracting a luminance channel of the face image to be inpainted, and performing person image inpainting based on the luminance channel to obtain a target face image; an image fusion module for merging color channels of the target face image and the repair target face image to obtain a first repaired face image; and an image adjustment module for performing image conversion processing on the first face-repaired image to obtain a second face-repaired image.

[0036] A third aspect of an embodiment of the present application provides an electronic device including an input device and an output device, further including a processor suitable for implementing one or more instructions, and a computer storage medium having stored thereon one or more instructions that can be loaded by the processor to cause it to perform the steps of any of the embodiments of the first aspect described above.

[0037] A fourth aspect of an embodiment of the present application provides a computer storage medium having stored thereon one or more instructions that, when loaded by a processor, cause the processor to perform the steps of any of the embodiments of the first aspect described above.

[0038] A fifth aspect of an embodiment of the present application provides a computer program product including computer readable code, the computer readable code, when executed in an electronic device, causing a processor in the electronic device to perform steps of any of the embodiments of the first aspect described above.

[0039] As can be seen from this, in the embodiment of the present application, a face image to be repaired is obtained, a luminance channel of the face image to be repaired is extracted, a person image repair is performed based on the luminance channel, a target face image is obtained, a first face repaired image is obtained by fusing the color channels of the target face image and the face image to be repaired, and an image conversion process is performed on the first face repaired image to obtain a second face repaired image. In this way, a luminance channel is extracted from the face image to be repaired, and a person image repair is performed based on the extracted luminance channel to obtain a target face image with a restored luminance channel, and then a color channel is combined to obtain a restored first face repaired image, and further, an image conversion process such as color correction and enlargement / reduction is performed on the first face repaired image, so that the obtained second face repaired image maintains the color information of the face image to be repaired and the resolution of the face image to be repaired before enlargement / reduction. This is advantageous for repairing face images with problems such as noise, blur, and distortion, improves the quality of the face image after repair, and improves the overall repair effect of the face image. [Brief description of the drawings]

[0040] In order to more clearly describe the technical means in the embodiments of the present application or the prior art, the following briefly introduces drawings necessary for the description of the embodiments or the prior art. The drawings in the following description are only some embodiments of the present application, and it is obvious to those skilled in the art that other drawings can be obtained based on these drawings without creative work. [Figure 1] FIG. 1 is a schematic diagram of an application environment according to an embodiment of the present application. [Diagram 2] FIG. 2 is a flow diagram of a person image restoration method according to an embodiment of the present application. [Diagram 3] FIG. 2 is a schematic diagram of a neural network model according to an embodiment of the present application. [Figure 4] FIG. 2 is a schematic diagram of decoding feature maps according to an embodiment of the present application; [Diagram 5] FIG. 2 is a schematic diagram of a sample image pair configuration according to an embodiment of the present application. [Figure 6] FIG. 2 is a schematic diagram of pixel value replacement according to an embodiment of the present application; [Figure 7] FIG. 13 is a flow diagram of another person image restoration method according to an embodiment of the present application. [Figure 8] 1 is a schematic diagram illustrating the configuration of a person image restoration device according to an embodiment of the present application. [Figure 9] FIG. 13 is a schematic diagram illustrating the configuration of another person image restoration device according to an embodiment of the present application. [Figure 10] FIG. 1 is a schematic diagram illustrating the configuration of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0041] In order to allow those skilled in the art to better understand the technical means of the present application, the technical means in the embodiments of the present application will be described below clearly and completely with reference to the drawings in the embodiments of the present application. It is clear that the described embodiments are only some embodiments of the present application, and are not all of the embodiments. Based on the embodiments in the present application, other embodiments that a person skilled in the art can obtain without creative work are all included in the claims of the present application.

[0042] The terms "comprise" and "have" and any variations thereof appearing in the specification, claims and drawings of this application are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally further include steps or units not listed, or may optionally include other steps or units inherent to the process, method, product or device. In addition, terms such as "first," "second," and "third" are used to distinguish different objects, and are not intended to describe a particular order.

[0043] In the embodiment of the present application, a technical means for performing person image restoration on a face image is proposed, which is favorable to improving the quality of the face image after restoration and improving the overall restoration effect of the face image. Specifically, it can be implemented based on the application environment shown in FIG. 1, and as shown in FIG. 1, the application environment includes an image collection device and a server. The image collection device may be a mobile phone, a tablet, a camera, a video camera, etc. The server may be an independent physical server, a server cluster or a distributed system, and may even be a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, and big data and artificial intelligence platforms. Specifically, the image collection device is used to capture or collect an image, and the image may be a single photo or a video, for example, a user's selfie, a video captured in a video capture scene, etc. Due to circumstances such as lighting failure, shaking, out of focus, and digital zoom during image capture, the face in the image has various problems such as noise, blur, and distortion. At this time, the user can request the server to repair the face in the image by sending a person image repair request to the server via the image collecting device. After the server receives the image collected by the image collecting device, it performs a series of operations such as face detection, face segmentation, face repair, etc., and finally outputs an image with a repaired face. It should be understood that models such as face detection, face segmentation, face repair, etc. can be placed on the server, and the server can realize the entire process of person image repair by calling these models. It should be noted that the person image repair method proposed in the embodiments of the present application may be executed by the server or may be executed by the image collecting device, for example, a model such as face image repair may be placed on the image collecting device.

[0044] Hereinafter, the person image restoration method according to the embodiment of the present application will be described in detail with reference to the related drawings.

[0045] Referring to Fig. 2, Fig. 2 is a flow schematic diagram of a person image restoration method according to an embodiment of the present application, which is applied to a server and includes steps S21 to S24, as shown in Fig. 2.

[0046] In S21, a face image to be restored is obtained.

[0047] In a specific embodiment of the present application, the face image to be repaired refers to a face image obtained from an original image with poor imaging effect and directly used for repair. For the original image collected by the image collecting device, face detection is performed using a face detection algorithm, and the face image is cut out based on the position of the detected face in the original image. For example, face detection is performed using Faster R-CNN (Faster Region-Convolutional Neural Networks, a faster candidate region-based convolutional neural network detector), YOLO (You Only Look Once, a YOLO object detector), etc., and a square face image is cut out based on the face detection frame, and the cut-out face image is enlarged or reduced to a preset size, whereby the face image to be repaired is obtained, and repair of a large-sized face image, for example, with a resolution of 896*896, can be realized. Then, using a person image segmentation technique, the person image and background mask are divided from the original image collected by the image collecting device, and the mask matrix is ​​denoted as M. However, the person image mask is represented as 1, and the background part is represented as 0.

[0048] In S22, the luminance channel of the face image to be restored is extracted, and a human image restoration is performed based on the luminance channel to obtain a target face image.

[0049] In a specific embodiment of the present application, the target face image refers to an image obtained by performing luminance channel restoration on a face image to be restored. When the format of the face image to be restored is a first format, the luminance channel of the face image to be restored is extracted, and person image restoration is performed based on this luminance channel to obtain a target face image. When the format of the face image to be restored is a second format, the format of the face image to be restored is converted to the first format, and then the luminance channel of the face image to be restored after the format conversion is extracted, and person image restoration is performed based on this luminance channel to obtain a target face image. The first format is a YUV format, and the second format is an RGB format. In short, for a face image to be restored in a YUV format, the luminance channel can be directly extracted, and for a face image to be restored in an RGB format, the face image to be restored can be converted to the first format and then the luminance channel can be extracted. In this way, person image restoration can be performed based on the luminance channel for any of the face images to be restored in a plurality of formats, and the applicability to the formats of the face images to be restored is wider.

[0050] In one possible embodiment, the step of performing person image inpainting based on the luminance channel to obtain a target face image includes inputting the luminance channel into a trained neural network model to perform person image inpainting to obtain the target face image.

[0051] Specifically, a trained neural network model is used to restore a person's image. The neural network model mainly includes a first network, a second network, a third network, and a fourth network, as shown in FIG. 3. For a face image to be restored, a luminance channel is extracted through an input layer. The first network performs encoding using a plurality of downsampling modules. The fourth network performs upper layer feature extraction for the output of the first network. The second network and the third network perform decoding for the superposition of the output of the first network and the output of the fourth network. The superposition of the input of the first network, the output of the second network, and the output of the third network is processed in the output layer to obtain a target face image of the same size as the face image to be restored. This target face image is a face image with a luminance channel restored, and the first face restoration image is output by fusing the color channels of the target face image and the face image to be restored. Here, the second network includes N blurred upsampling modules, and the blurred upsampling in at least one of the N blurred upsampling modules includes blurred convolution, and the weight of the convolution kernel in the blurred convolution is a preset constant value. The neural network model has shortcut connections at the input of the first network, the output of the second network, and the output of the third network, and shortcut connections at the output of the first network and the output of the fourth network. The input of the first network, the output of the second network, and the output of the third network are at the highest resolution scale, and the output of the first network and the output of the fourth network are at the lowest resolution scale, and the shortcut connections at the highest resolution scale and the lowest resolution scale are favorable to preventing overfitting of the neural network model, and can make the iteration speed faster during training.Blurred upsampling involves a blurred convolution operation, and the weights of the adopted convolution kernel are fixed from the beginning of the training of the neural network model, and its role is equivalent to a low-pass filter, which is advantageous for generating smooth and natural contours and hair during image restoration. Such a neural network model is advantageous for restoration of the target face image that is noisy, blurred, or distorted due to problems such as poor lighting, shaking, defocus, and digital zoom, and improves the definition and texture details of human facial features, hair, and skin.

[0052] In one possible embodiment, the step of inputting the luminance channel into a trained neural network model to perform human image inpainting and obtain the target face image includes performing an encoding operation on the luminance channel using the first network to obtain a target feature map, and performing a decoding operation on the target feature map using the second network and the third network to obtain the target face image.

[0053] In a specific embodiment of the present application, performing an encoding operation on the luminance channel using the first network to obtain a target feature map includes: inputting the luminance channel into the first network for downsampling to obtain a first feature map; performing upper layer feature extraction on the first feature map using the fourth network to obtain an upper layer feature map; and superimposing the first feature map and the upper layer feature map to obtain the target feature map.

[0054] Here, the first feature map refers to a low-resolution feature map obtained by performing downsampling by multiple downsampling modules in the first network, and the upper layer feature map refers to a feature map obtained by performing depth feature extraction using the fourth network. The first feature map and the upper layer feature map are superimposed by shortcut connection to obtain a target feature map. It should be understood that superimposing the output of the first network and the output of the fourth network by shortcut connection can prevent overfitting of the neural network model while enriching feature information. The fourth network can be a residual block, which is a normal setting in the residual network and is good at extracting depth features or extracting upper layer features.

[0055] In a specific embodiment of the present application, as shown in FIG. 4, the above-mentioned second network and the third network are used to perform a decoding operation on the target feature map to obtain the target face image, S41 inputting the target feature map into the N blurred upsampling modules in the second network to perform blurred upsampling to obtain a second feature map; S42: inputting the feature maps output from the 1st to (N-1)th blur upsampling modules of the N blur upsampling modules into the third network for upsampling to obtain a third feature map; and S43 superimposing the luminance channel, the second feature map and the third feature map to obtain the target face image.

[0056] Here, the blurred upsampling module in the second network has a symmetrical configuration with the downsampling module in the first network and is used to restore the size of the target feature map. The second feature map refers to a feature map obtained by performing blurred upsampling by N blurred upsampling modules. The convolution layer in at least one blurred upsampling module performs convolution processing in the manner of standard convolution-blurred convolution-standard convolution. As shown in FIG. 3, the processing order of the N blurred upsampling modules is, from left to right, the first blurred upsampling module, the second blurred upsampling module, the third blurred upsampling module, ..., the Nth blurred upsampling module, and the feature maps output from the first to (N-1)th blurred upsampling modules of the N blurred upsampling modules are input to the third network for upsampling, and the third feature map, i.e., the feature map output by upsampling in the third network, is obtained, and the target face image is obtained by superimposing the high-resolution luminance channel, the second feature map, and the third feature map. The third network is advantageous in ensuring the stability of the neural network model by upsampling the feature maps output from the first to (N-1)th blurred upsampling modules in the second network, and is advantageous in ensuring the stability of the neural network model by superimposing the input of the first network, the output of the second network, and the output of the third network by shortcut connection, which can prevent overfitting of the neural network model, while being advantageous in enriching feature information and improving the restoration quality of the target face image.

[0057] In one possible embodiment, the third network includes (N-1) upsampling modules, and the step of inputting the feature map output from the first to (N-1)th blurred upsampling modules of the N blurred upsampling modules to the third network for upsampling to obtain a third feature map includes compressing the number of channels of the feature map output from the first blurred upsampling module of the N blurred upsampling modules to obtain a first compressed feature map, and inputting the first compressed feature map to the first upsampling module of the (N-1) upsampling modules for upsampling. compressing the number of channels of the feature map output from the i-th (i is an integer greater than 1 and less than N) blurred upsampling module among the N blurred upsampling modules to obtain a second compressed feature map; overlaying the feature map output from the (i-1)-th upsampling module among the (N-1) upsampling modules and the second compressed feature map, inputting the feature map obtained by the overlaying to the i-th upsampling module among the (N-1) upsampling modules for upsampling; and obtaining the third feature map through processing by the (N-1) upsampling modules.

[0058] Next, refer to FIG. 3. The processing order of the (N-1) upsampling modules in the third network is, from left to right, the first upsampling module, the second upsampling module, ... the (N-1)th upsampling module, and the upsampling in at least one upsampling module is completed using standard convolution. The feature maps output from the first to (N-1)th blurred upsampling modules are first compressed in number of channels before being input to the upsampling modules of the third network, so that the number of channels of the feature maps input to at least one upsampling module is the same. Specifically, the first compressed feature map is a feature map obtained by compressing the number of channels of the feature map output from the first blurred upsampling module, and the second compressed feature map is a feature map obtained by compressing the number of channels of the feature map output from the i-th blurred upsampling module. Since the first upsampling module does not have an immediately preceding upsampling module, it may directly compress the number of channels of the feature map output from the first blurred upsampling module, and input the first compressed feature map to the first upsampling module for upsampling. Since the i-th upsampling module has an immediately preceding upsampling module (i.e., the (i-1)-th upsampling module), the input to the i-th upsampling module is a superposition of the feature map output from the (i-1)-th upsampling module and the compressed feature map output from the i-th blurred upsampling module.In simple terms, the input to the second upsampling module is a superposition of the feature map output from the first upsampling module and the compressed feature map output from the second blurred upsampling module, the input to the third upsampling module is a superposition of the feature map output from the second upsampling module and the compressed feature map output from the third blurred upsampling module, and the input to the (N-1)th upsampling module is a superposition of the feature map output from the (N-2)th upsampling module and the compressed feature map output from the (N-1)th blurred upsampling module. In this way, the third feature map is output after upsampling processing by the (N-1) upsampling modules in the third network. By compressing the number of channels of the feature maps output from the first to (N-1)th blurred upsampling modules, it is possible to ensure that the number of channels of the inputs to at least one upsampling module in the third network are all the same, which is advantageous to improving the stability of the neural network model.

[0059] In S23, the color channels of the target face image and the face image to be repaired are merged to obtain a first face repaired image.

[0060] In a specific embodiment of the present application, the first face repaired image refers to a face image obtained through repair using a neural network model and merging color channels. For the target face image whose luminance channel has been repaired, the ratio information of the color channel of the face image to be repaired is calculated, and the color channels of the target face image and the face image to be repaired are fused according to the calculated ratio to realize image enhancement, and the first face repaired image is output.

[0061] In S24, an image conversion process is performed on the first face-corrected image to obtain a second face-corrected image.

[0062] In a specific embodiment of the present application, a local color correction is performed on the first face repaired image, and the color-corrected first face repaired image is scaled to restore its size to the size of the face image cropped in step S21, thereby obtaining a second face repaired image with relatively good quality, which is advantageous for improving the resolution of the second face repaired image. First, a magnification currently required for scaling is identified based on the size of the first face repaired image and the size of the cropped face image, and when the scaling ratio exceeds 1.5 times, the size of the first face repaired image is restored by scaling by 2 times using a super-resolution technique. For example, the scaling may be performed using a Super-Resolution Convolutional Neural Network (SRCNN).

[0063] In one possible embodiment, after obtaining the second face repaired image, the method comprises: The method further includes performing Gaussian blurring on edges of the person image mask, and pasting the face in the second face repaired image back into the original image after cropping based on the crop position of the face image in the original image and the person image mask, thereby completing the restoration of the original image.

[0064] The position of the face in the original image can be identified based on the cut-out position of the face image in the original image and the person image mask. This allows the restored face in the second face repaired image to be pasted back onto the original image after the cut-out, the background part remains the background in the original image, and Gaussian blurring is performed on the edges of the person image mask based on the mask matrix M before the face image is pasted back, making the final repaired image smoother and more natural.

[0065] In one possible embodiment, before obtaining the facial image to be repaired, the method further includes: constructing a sample image pair including a first facial image and a second facial image obtained based on the first facial image; inputting the sample image pair into a neural network for training and outputting a repaired image of the second facial image; determining a target loss based on the repaired image and the first facial image; and adjusting parameters of the neural network to minimize the target loss to obtain the neural network model.

[0066] Here, for training the neural network model, paired images, that is, a first face image and a second face image in a sample image pair, are adopted. The first face image refers to an image prepared in advance, and the second face image refers to a degraded image obtained based on the first face image and having image quality problems such as out-of-focus, noise, compression loss, aliasing due to sampling, and residual after noise removal by an ISP (Image Signal Processor). The second face image may be exactly the same as the first face image, or may be a face image obtained by performing degradation processing on the first face image. The two images have exactly the same information except for the presence or absence of image quality degradation. Since such a sample image pair is difficult to find in actually collected images, the second face image may be synthesized based on the first face image. The constructed sample image pair is input to the neural network for training, and the face in the second face image is restored by the method shown in steps S22 and S23 to obtain a restored image of the second face image. Then, the target loss is calculated based on this restored image and the first face image. The target loss includes at least one of a regression loss, a perceptual loss, a generative adversarial loss, and a context loss. A trained neural network model is obtained by adjusting parameters of the neural network based on the target loss to minimize the target loss.

[0067] Here, the regression loss is

number

[0068] Perceptual loss is

number

[0069] The generative adversarial loss is

number

[0070] The context loss is

number

[0071] In this embodiment, the neural network is trained using paired sample images, and the sample image pair includes a degraded image that is sufficiently close to an image with image quality problems actually collected. Training the neural network using such a sample image pair is advantageous to improving the generalization of the neural network model. By minimizing the target loss, the repaired image output from the neural network model can be made as close to the quality of the first face image as possible, and the processing of details such as contours and hair of the repaired image can be increased. By training the neural network model using a target loss including at least one of regression loss, perception loss, adversarial generation loss, and context loss, the neural network model can comprehensively repair multiple problems present in the degraded image and improve the quality of the person image repair.

[0072] In one possible embodiment, as shown in FIG. 5, constructing the sample image pair, as described above, includes the following steps:

[0073] In S501, the first face image set in advance is acquired.

[0074] In S502, it is determined whether or not the image quality of the first face image has deteriorated. If YES, step S503 is executed, and if NO, step S504 is executed.

[0075] In S503, the sample image pair is formed by two of the first face images, and one of the two images is determined as the second face image.

[0076] In S504, atmospheric turbulence degradation is performed on the first face image to obtain a first degraded image.

[0077] In S505, downsampling is performed on the first degraded image to obtain a target degraded image.

[0078] In S506, the target degraded image is upsampled to obtain a second degraded image.

[0079] In S507, a third degraded image is obtained based on the second degraded image.

[0080] In S508, the third degraded image is compressed using a preset compression quality parameter to obtain a fourth degraded image.

[0081] In S509, a rectangular area is determined in the fourth degraded image, and a target area corresponding to the rectangular area is identified in the first face image.

[0082] In S510, pixel values ​​in the target region are substituted for corresponding pixel values ​​in the rectangular region to obtain the second face image, and the first face image and the second face image constitute the sample image pair.

[0083] Here, for the first face image, first, the image quality is judged, and it is judged whether the image quality has deteriorated. If the image quality has deteriorated, there is no need to perform deterioration processing, and a sample image pair is formed by two first face images, and one of the two is determined as the second face image. If the image quality has not deteriorated, deterioration processing is performed, specifically, it can be realized by using a preset algorithm. When the first face image is input and the original first face image is finally returned, the image quality of the first face image itself has deteriorated, and if it is not returned, atmospheric disturbance is performed on the first face image with a certain probability to obtain a first deteriorated image, downsampling is performed on the first deteriorated image by 0 to 8 times, a target deteriorated image with a low resolution is obtained, and corresponding upsampling is performed on the target deteriorated image, a second deteriorated image with the same resolution as the first deteriorated image is obtained, noise is added to the luminance channel of the second deteriorated image, non-local mean noise removal is performed, and a third deteriorated image is obtained. Alternatively, the second degraded image may be first blurred to obtain a corresponding degraded image (i.e., a fifth degraded image), and noise may be added to the luminance channel of the degraded image, and non-local mean noise removal may be performed to obtain a third degraded image. By performing various degradation processes on the second degraded image using methods such as blurring, noise superposition, and non-local mean noise removal, various degradation problems may be generated in the third degraded image, which is advantageous for training a neural network model using images with various degradation problems thereafter. The third degraded image is subjected to a JPEG compression operation using a preset compression quality parameter. Here, the compression quality parameter may be set according to the actual situation. For the fourth degraded image obtained by compression, as shown in FIG. 6, a rectangular area is randomly selected, a target area corresponding to the area is selected in the first face image, and pixel values ​​in the rectangular area are replaced with pixel values ​​in the target area, whereby synthesis of the degraded image is completed, and a second face image is obtained, and the first face image and the second face image constitute one sample image pair. In this embodiment, the training images are synthesized using the above-mentioned more complicated image synthesis method, so that the resulting second face image is closer to the actual degraded image than the conventional synthesis method.

[0084] In this embodiment, the image quality of the first face image is judged, and if the first face image itself is relatively clear and its image quality is not deteriorated, a series of deterioration processes are performed on the first face image, and a second face image with a deterioration problem is synthesized, so that the second face image is similar to the actually collected deteriorated image, thereby simulating the scene of repairing the true deteriorated image. If the first face image itself has a deterioration problem, there is no need to perform deterioration processes on it, and two first face images may be directly used to construct a sample image pair, to simulate the scene of repairing the true deteriorated image.

[0085] As can be seen from this, in the embodiment of the present application, a face image to be repaired is obtained, a luminance channel of the face image to be repaired is extracted, a person image repair is performed based on the luminance channel, a target face image is obtained, a first face repaired image is obtained by fusing the color channels of the target face image and the face image to be repaired, and an image conversion process is performed on the first face repaired image to obtain a second face repaired image. In this way, a luminance channel is extracted from the face image to be repaired, and a person image repair is performed based on the extracted luminance channel to obtain a target face image with a restored luminance channel, and then a color channel is combined to obtain a restored first face repaired image, and further, an image conversion process such as color correction and enlargement / reduction is performed on the first face repaired image, so that the obtained second face repaired image maintains the color information of the face image to be repaired and the resolution of the face image to be repaired before enlargement / reduction. This is advantageous for repairing face images with problems such as noise, blur, and distortion, improves the quality of the face image after repair, and improves the overall repair effect of the face image.

[0086] Referring to Fig. 7, Fig. 7 shows a flow schematic diagram of another portrait image restoration method according to an embodiment of the present application. As shown in Fig. 7, it includes steps S71 to S76.

[0087] In S71, a face image to be restored is obtained.

[0088] In S72, if the format of the face image to be restored is the first format, the luminance channel of the face image to be restored is extracted, and step S74 is executed.

[0089] In S73, if the format of the face image to be repaired is the second format, the format of the face image to be repaired is converted to the first format, and the luminance channel of the face image to be repaired after the format conversion is extracted.

[0090] In S74, the person image is restored based on the luminance channel to obtain a target face image.

[0091] In S75, the color channels of the target face image and the face image to be repaired are merged to obtain a first face repaired image.

[0092] In S76, an image conversion process is performed on the first face repaired image to obtain a second face repaired image.

[0093] Specific embodiments of the above steps S71 to S76 have already been described in the embodiments shown in Figures 2 to 6, and can achieve the same or similar beneficial effects, and will not be described further here.

[0094] According to the description of the method embodiments shown in Fig. 2 to Fig. 6, the embodiment of the present application further provides a person image restoration apparatus. Referring to Fig. 8, Fig. 8 shows a schematic diagram of the configuration of the person image restoration apparatus according to the embodiment of the present application. As shown in Fig. 8, the apparatus includes: an image acquisition module 81 for acquiring a face image to be restored; a person image inpainting module 82 for extracting a luminance channel of the face image to be inpainted, and performing person image inpainting based on the luminance channel to obtain a target face image; an image fusion module 83 for merging color channels of the target face image and the repair target face image to obtain a first repaired face image; and an image adjustment module 84 for performing an image conversion process on the first face repaired image to obtain a second face repaired image.

[0095] In one possible embodiment, in extracting the luminance channel of the face image to be inpainted, the person image inpainting module 82 specifically: When the format of the facial image to be repaired is a first format, it is used to extract the luminance channel of the facial image to be repaired, or when the format of the facial image to be repaired is a second format, it is used to convert the format of the facial image to be repaired to the first format and extract the luminance channel of the facial image to be repaired after the format conversion.

[0096] In one possible embodiment, in performing person image inpainting based on the luminance channel to obtain a target face image, the person image inpainting module 82 specifically performs the following steps: The luminance channel is input into a trained neural network model to perform human image inpainting and obtain the target face image.

[0097] In one possible embodiment, the neural network model includes a first network, a second network, a third network, and a fourth network, the second network includes N (N is an integer greater than 1) blurred upsampling modules, the blurred upsampling in at least one of the N blurred upsampling modules includes blurred convolution, and a weight of a convolution kernel in the blurred convolution is a preset constant value, and the neural network model has shortcut connections at the input of the first network, the output of the second network, and the output of the third network, and has shortcut connections at the output of the first network and the output of the fourth network.

[0098] In one possible embodiment, the luminance channel is input to a trained neural network model to perform person image inpainting to obtain the target face image, and the person image inpainting module 82 specifically includes the following steps: The first network is used to perform an encoding operation on the luminance channel to obtain a target feature map, and the second network and the third network are used to perform a decoding operation on the target feature map to obtain the target face image.

[0099] In one possible embodiment, in performing an encoding operation on the luminance channel using the first network to obtain a target feature map, the person image inpainting module 82 specifically includes: The luminance channel is input to the first network for downsampling to obtain a first feature map; the fourth network is used to perform upper layer feature extraction on the first feature map to obtain an upper layer feature map; and the first feature map and the upper layer feature map are superimposed to obtain the target feature map.

[0100] In one possible embodiment, in performing a decoding operation on the target feature map using the second network and the third network to obtain the target face image, the person image inpainting module 82 specifically includes the following steps: The target feature map is input to the N blurred upsampling modules in the second network to perform blurred upsampling to obtain a second feature map; feature maps output from the 1st to (N-1)th blurred upsampling modules of the N blurred upsampling modules are input to the third network to perform upsampling to obtain a third feature map; and the luminance channel, the second feature map and the third feature map are superimposed to obtain the target face image.

[0101] In one possible embodiment, the third network includes (N-1) upsampling modules, and the feature maps output from the first to (N-1)-th blur upsampling modules of the N blur upsampling modules are input to the third network for upsampling to obtain the third feature map. Specifically, the person image restoration module 82: compressing a number of channels of a feature map output from a first blurred upsampling module among the N blurred upsampling modules to obtain a first compressed feature map; inputting the first compressed feature map into a first upsampling module among the (N-1) upsampling modules to perform upsampling; compressing a number of channels of a feature map output from an i-th blurred upsampling module (i is an integer greater than 1 and less than N) among the N blurred upsampling modules to obtain a second compressed feature map; superimposing the feature map output from the (i-1)-th upsampling module among the (N-1) upsampling modules and the second compressed feature map, and inputting the feature map obtained by the superposition into the i-th upsampling module among the (N-1) upsampling modules to perform upsampling; and obtaining the third feature map through processing by the (N-1) upsampling modules.

[0102] In one possible embodiment, in obtaining a face image to be repaired, the image acquisition module 81 specifically: The method is used to perform face detection on the collected original image, crop the face image based on the position of the detected face in the original image, and scale the face image to obtain the face image to be repaired.

[0103] In one possible embodiment, the image acquisition module 81 is further used to perform person image segmentation on the original image to obtain a person image mask.

[0104] In one possible embodiment, the image adjustment module 84 further comprises: It is used to perform Gaussian blurring on the edges of the person image mask, and to paste the face in the second face repaired image back onto the original image after cutting based on the cut-out position of the face image in the original image and the person image mask, thereby completing the restoration of the original image.

[0105] In one possible embodiment, in performing an image conversion process on the first face repaired image to obtain a second face repaired image, the image adjustment module 84 specifically performs the following steps: The method includes performing color correction on the first face repaired image, determining a scaling factor, and if the scaling factor is greater than a predetermined factor, using super-resolution technology to scale the first face repaired image after color correction to obtain the second face repaired image.

[0106] In one possible embodiment, as shown in FIG. 9, the apparatus further includes a model construction module 85, which: The method includes constructing a sample image pair including a first facial image and a second facial image obtained based on the first facial image, inputting the sample image pair into a neural network for training, outputting a restored image of the second facial image, determining a target loss based on the restored image and the first facial image, and adjusting parameters of the neural network to minimize the target loss to obtain the neural network model.

[0107] In one possible embodiment, the target loss includes at least one of a regression loss, a perceptual loss, a generative adversarial loss, and a context loss.

[0108] In one possible embodiment, in constructing the sample image pairs, the model construction module 85 specifically: The method includes obtaining a predetermined first facial image, and if image quality of the first facial image is not deteriorated, performing atmospheric turbulence degradation on the first facial image to obtain a first degraded image, performing downsampling on the first degraded image, obtaining a target degraded image, performing upsampling on the target degraded image, obtaining a second degraded image, obtaining a third degraded image based on the second degraded image, compressing the third degraded image using a predetermined compression quality parameter to obtain a fourth degraded image, determining a rectangular area in the fourth degraded image, identifying a target area in the first facial image corresponding to the rectangular area, replacing corresponding pixel values ​​in the rectangular area with pixel values ​​in the target area, obtaining the second facial image, and constituting the sample image pair using the first facial image and the second facial image; or, if image quality of the first facial image is deteriorated, constituting the sample image pair using two first facial images, and determining one of the two as the second facial image.

[0109] In one possible embodiment, in obtaining the third degraded image based on the second degraded image, the model construction module 85 specifically: The method is used to add noise to a luminance channel of the second degraded image, perform non-local means noise removal on the second degraded image, and obtain the third degraded image, or to perform a blurring operation on the second degraded image, obtain a fifth degraded image, add noise to a luminance channel of the fifth degraded image, and perform non-local means noise removal on the fifth degraded image, and obtain the third degraded image.

[0110] According to an embodiment of the present application, each or all of the units of the person image restoration device shown in FIG. 8 or FIG. 9 may be integrated into one or several other units, or one or more of the units may be further divided into several smaller units, and the same operation can be realized without affecting the realization of the technical effect of the embodiment of the present application. The above units are divided based on logical functions, and in actual applications, the function of one unit may be realized by several units, or the functions of several units may be realized by one unit. In other embodiments of the present application, the person image restoration device may include other units, and in actual applications, these functions may be realized by cooperation with other units, or by cooperation with several units.

[0111] According to another embodiment of the present application, a computer program (including a program code) capable of executing each step of the method shown in Fig. 2 or Fig. 7 may be executed on, for example, a general-purpose computing device including a processing element and a storage element such as a central processing unit (CPU), a random access memory (RAM), and a read-only memory (ROM), to configure the person image restoration apparatus shown in Fig. 8 or Fig. 9, and realize the person image restoration method of the embodiment of the present application. The computer program may be written in, for example, a computer-readable storage medium, and may be loaded into the computing device via the computer-readable storage medium to be executed.

[0112] According to the above description of the method embodiment and the device embodiment, the embodiment of the present application further provides an electronic device. Referring to Fig. 10, the electronic device includes at least a processor 1001, an input device 1002, an output device 1003, and a computer storage medium 1004. The processor 1001, the input device 1002, the output device 1003, and the computer storage medium 1004 in the electronic device can be connected by a bus or other means.

[0113] The computer storage medium 1004 may be stored in the storage of the electronic device. The computer storage medium 1004 is used to store a computer program including program instructions, and the processor 1001 is used to execute the program instructions stored in the computer storage medium 1004. The processor 1001 (also called CPU (Central Processing Unit)) is a computing core and control core of the electronic device, and is suitable for implementing one or more instructions, specifically, for loading and executing one or more instructions to implement a corresponding method flow or a corresponding function. The computer storage medium may be a volatile storage medium or a non-volatile storage medium.

[0114] In one embodiment, the processor 1001 of an electronic device according to an embodiment of the present application is used to perform a series of human image restoration processes, including acquiring a facial image to be restored, extracting a luminance channel of the facial image to be restored, performing human image restoration based on the luminance channel to obtain a target facial image, fusing the color channels of the target facial image and the facial image to be restored to obtain a first facial restoration image, and performing an image conversion process on the first facial restoration image to obtain a second facial restoration image.

[0115] In another embodiment, the processor 1001 executing the above-mentioned extracting the luminance channel of the facial image to be repaired includes extracting the luminance channel of the facial image to be repaired when the format of the facial image to be repaired is a first format, or converting the format of the facial image to be repaired to the first format and extracting the luminance channel of the facial image to be repaired after the format conversion when the format of the facial image to be repaired is a second format.

[0116] In another embodiment, the processor 1001 executes the above-mentioned step of performing person image restoration based on the luminance channel to obtain a target face image, which includes inputting the luminance channel into a trained neural network model to perform person image restoration and obtain the target face image.

[0117] In another embodiment, the neural network model includes a first network, a second network, a third network, and a fourth network, the second network includes N (N is an integer greater than 1) blurred upsampling modules, the blurred upsampling in at least one blurred upsampling module among the N blurred upsampling modules includes blurred convolution, and a weight of a convolution kernel in the blurred convolution is a preset constant value, and the neural network model has shortcut connections at the input of the first network, the output of the second network, and the output of the third network, and has shortcut connections at the output of the first network and the output of the fourth network.

[0118] In another embodiment, the processor 1001 executes the above-mentioned step of inputting the luminance channel into a trained neural network model to perform human image inpainting and obtain the target face image, including: performing an encoding operation on the luminance channel using the first network to obtain a target feature map; and performing a decoding operation on the target feature map using the second network and the third network to obtain the target face image.

[0119] In another embodiment, the processor 1001 executes the encoding operation on the luminance channel using the first network to obtain a target feature map, comprising: inputting the luminance channel to the first network for downsampling to obtain a first feature map; performing upper layer feature extraction on the first feature map using the fourth network to obtain an upper layer feature map; and overlaying the first feature map and the upper layer feature map to obtain the target feature map.

[0120] In another embodiment, the processor 1001 executes the decoding operation on the target feature map using the second network and the third network to obtain the target face image, inputting the target feature map into the N blurred upsampling modules in the second network to perform blurred upsampling to obtain a second feature map; inputting feature maps output from the 1st to (N-1)th blurred upsampling modules of the N blurred upsampling modules into the third network to perform upsampling to obtain a third feature map; and overlaying the luminance channel, the second feature map, and the third feature map to obtain the target face image.

[0121] In another embodiment, the third network includes (N-1) upsampling modules, and the processor 1001 executes the above-mentioned step of inputting the feature maps output from the first to (N-1)th blurred upsampling modules of the N blurred upsampling modules to the third network for upsampling to obtain a third feature map, the step of compressing the number of channels of the feature map output from the first blurred upsampling module of the N blurred upsampling modules to obtain a first compressed feature map, and inputting the first compressed feature map to the first upsampling module of the (N-1) upsampling modules to obtain a third compressed feature map. the (N-1) upsampling modules to obtain the third feature map; compressing the number of channels of the feature map output from the i-th (i is an integer greater than 1 and less than N) blurred upsampling module among the N blurred upsampling modules to obtain a second compressed feature map; overlaying the feature map output from the (i-1)-th upsampling module among the (N-1) upsampling modules and the second compressed feature map, inputting the feature map obtained by overlaying into the i-th upsampling module among the (N-1) upsampling modules for upsampling; and obtaining the third feature map through processing by the (N-1) upsampling modules.

[0122] In another embodiment, the processor 1001 executes the above-mentioned obtaining the facial image to be repaired, which includes performing face detection on the collected original image, cropping the facial image based on the position of the detected face in the original image, and scaling the facial image to obtain the facial image to be repaired.

[0123] In another embodiment, after scaling the face image to obtain the face image to be repaired, the processor 1001 is further used to perform person image segmentation on the original image to obtain a person image mask, and after obtaining a second face repaired image, the processor 1001 is further used to perform Gaussian blurring on the edges of the person image mask, and based on the cut-out position of the face image in the original image and the person image mask, paste the face in the second face repaired image back onto the original image after cut-out, thereby completing the repair of the original image.

[0124] In another embodiment, the processor 1001 executes the above-mentioned image conversion processing on the first face repaired image to obtain a second face repaired image, which includes performing color correction on the first face repaired image, determining a scaling ratio, and, if the scaling ratio is greater than a predetermined ratio, scaling the color-corrected first face repaired image using super-resolution technology to obtain the second face repaired image.

[0125] In another embodiment, before obtaining the facial image to be repaired, the processor 1001 is further used to construct a sample image pair including a first facial image and a second facial image obtained based on the first facial image, input the sample image pair into a neural network for training, and output a repaired image of the second facial image, determine a target loss based on the repaired image and the first facial image, and adjust parameters of the neural network to minimize the target loss to obtain the neural network model.

[0126] In another embodiment, the target loss includes at least one of a regression loss, a perceptual loss, a generative adversarial loss, and a context loss.

[0127] In another embodiment, the processor 1001 executes the above-mentioned constituting a sample image pair, includes: acquiring a preset first facial image; if the image quality of the first facial image is not degraded, performing atmospheric turbulence degradation on the first facial image to obtain a first degraded image, performing downsampling on the first degraded image, obtaining a target degraded image, performing upsampling on the target degraded image, obtaining a second degraded image, obtaining a third degraded image based on the second degraded image, compressing the third degraded image using a preset compression quality parameter to obtain a fourth degraded image, determining a rectangular area in the fourth degraded image, identifying a target area in the first facial image corresponding to the rectangular area, replacing corresponding pixel values ​​in the rectangular area with pixel values ​​in the target area, obtaining the second facial image, and constituting the sample image pair with the first facial image and the second facial image; or, if the image quality of the first facial image is degraded, constituting the sample image pair with two of the first facial images, and determining one of the two as the second facial image.

[0128] In another embodiment, the processor 1001 executing the above-mentioned obtaining a third degraded image based on the second degraded image includes adding noise to a luminance channel of the second degraded image, performing non-local means noise removal on the second degraded image, and obtaining the third degraded image, or performing a blurring operation on the second degraded image, obtaining a fifth degraded image, adding noise to a luminance channel of the fifth degraded image, and performing non-local means noise removal on the fifth degraded image, and obtaining the third degraded image.

[0129] Exemplarily, the electronic device may be a computer, a computer host, a server, a cloud server, a server cluster, or any image collecting device such as a camera head, a video camera, etc. The electronic device includes, but is not limited to, a processor 1001, an input device 1002, an output device 1003, and a computer storage medium 1004. The input device 1002 may be a keyboard, a touch screen, etc., and the output device 1003 may be a speaker, a display, an RF transmitter, etc. Those skilled in the art will appreciate that the schematic diagrams above are merely examples of electronic devices, and are not limiting, and may include more or less components than those shown, may combine some components, or may be different components.

[0130] Furthermore, when the computer program is executed by the processor 1001 of the electronic device, the steps in the above-mentioned person image restoration method are realized, so that any of the embodiments of the above-mentioned person image restoration method can be applied to the electronic device and achieve the same or similar beneficial effects.

[0131] The embodiment of the present application further provides a computer storage medium (Memory) which is a memory device in an electronic device and is used to store programs and data. It is understood that the computer storage medium here may include a storage medium built into the terminal, and may of course include an extended storage medium supported by the terminal. The computer storage medium provides a storage space in which an operating system of the terminal is stored. In addition, the storage space further stores one or more instructions suitable for being loaded and executed by the processor 1001, and these instructions may be one or more computer programs (including program codes). It should be noted that the computer storage medium here may be a high-speed RAM memory, or may be a non-volatile memory such as at least one disk memory. Optionally, it may be at least one computer storage medium separate from the processor 1001. In one embodiment, the processor 1001 may load and execute one or more instructions stored in the computer storage medium to realize the corresponding steps in the above-mentioned person image restoration method.

[0132] Exemplarily, a computer program in a computer storage medium includes a computer program code, which may be in a source code form, an object code form, an executable file, or any intermediate form, etc. The computer-readable medium may include any entity or device capable of carrying the computer program code, a recording medium, a U-disk, a removable hard disk, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electric carrier wave signal, an electric communication signal, and a software distribution medium, etc.

[0133] Furthermore, when the computer program in the computer storage medium is executed by a processor, the steps in the above-mentioned person image restoration method are realized, so that all of the embodiments of the above-mentioned person image restoration method can be applied to the computer storage medium to achieve the same or similar beneficial effects.

[0134] Above, the examples of the present application have been introduced in detail. Although the present specification uses specific examples to explain the principles and embodiments of the present application, the explanation of the above examples is merely for the purpose of facilitating understanding of the method and core idea of ​​the present application. Those skilled in the art can modify the specific embodiments and application scope based on the idea of ​​the present application, and therefore the contents of this specification should not be understood as limiting the present application.

Claims

1. A person image restoration method, comprising: Obtaining a face image to be repaired; extracting a luminance channel of the face image to be restored, and performing person image restoration based on the luminance channel to obtain a target face image; Fusing color channels of the target face image and the face image to be repaired to obtain a first face repaired image; performing an image conversion process on the first face repaired image to obtain a second face repaired image; The above-mentioned, performing person image restoration based on the luminance channel to obtain a target face image, inputting the luminance channel into a trained neural network model to perform person image inpainting to obtain the target face image; the neural network model includes a first network, a second network, a third network, and a fourth network; The second network includes N blurred upsampling modules (N is an integer greater than 1), and the blurred upsampling in at least one of the N blurred upsampling modules includes a blurred convolution, and a weight of a convolution kernel in the blurred convolution is a preset constant value; The method for human image restoration, wherein the neural network model has shortcut connections at the input of the first network, the output of the second network, and the output of the third network, and has shortcut connections at the output of the first network and the output of the fourth network.

2. The step of extracting the luminance channel of the face image to be restored comprises: extracting the luminance channel of the facial image to be retouched when the format of the facial image to be retouched is a first format; or The method for restoring a human image according to claim 1, further comprising: when the format of the facial image to be restored is a second format, converting the format of the facial image to be restored to the first format, and extracting the luminance channel of the facial image to be restored after the format conversion.

3. The above-mentioned luminance channel is inputted into a trained neural network model to perform human image restoration and obtain the target face image, performing an encoding operation on the luminance channel using the first network to obtain a target feature map; and performing a decoding operation on the target feature map using the second network and the third network to obtain the target face image.

4. The step of performing an encoding operation on the luminance channel using the first network to obtain a target feature map includes: inputting the luminance channel into the first network for downsampling to obtain a first feature map; performing upper layer feature extraction on the first feature map using the fourth network to obtain an upper layer feature map; and overlapping the first feature map and the higher-level feature map to obtain the target feature map.

5. performing a decoding operation on the target feature map using the second network and the third network to obtain the target face image; inputting the target feature map to the N blurred upsampling modules in the second network to perform blurred upsampling to obtain a second feature map; inputting the feature maps output from the 1st to (N-1)th blur upsampling modules of the N blur upsampling modules into the third network for upsampling to obtain a third feature map; The method of claim 3 or 4, further comprising: overlapping the luminance channel, the second feature map and the third feature map to obtain the target face image.

6. the third network includes (N-1) upsampling modules; The above-mentioned feature maps output from the first to (N-1)-th blur upsampling modules among the N blur upsampling modules are input to the third network for upsampling to obtain a third feature map, Compressing a number of channels of a feature map output from a first blurred upsampling module among the N blurred upsampling modules to obtain a first compressed feature map; inputting the first compressed feature map to a first upsampling module among the (N-1) upsampling modules for upsampling; Compressing a number of channels of a feature map output from an i-th blurred upsampling module (i is an integer greater than 1 and less than N) among the N blurred upsampling modules to obtain a second compressed feature map; superimposing a feature map output from the (i-1)th upsampling module of the (N-1) upsampling modules and the second compressed feature map, and inputting the feature map obtained by superimposing into the i-th upsampling module of the (N-1) upsampling modules to perform upsampling; and obtaining the third feature map through processing by the (N-1) upsampling modules.

7. A method for restoring a person image, comprising: Obtaining a face image to be repaired; extracting a luminance channel of the face image to be restored, and performing person image restoration based on the luminance channel to obtain a target face image; Fusing color channels of the target face image and the face image to be repaired to obtain a first face repaired image; performing an image conversion process on the first face repaired image to obtain a second face repaired image; The above-mentioned acquisition of a face image to be repaired is performed by performing face detection on the collected original images; cropping a face image based on a position of the detected face in the original image; and scaling the facial image to obtain the facial image to be repaired; After scaling the face image to obtain the face image to be repaired, the method includes: performing person image segmentation on the original image to obtain a person image mask; After obtaining the second face repaired image, the method further comprises: performing a Gaussian blur on edges of the person image mask; The person image restoration method further includes pasting the face in the second face restoration image back into the original image after cropping based on the cropping position of the face image in the original image and the person image mask, thereby completing the restoration of the original image.

8. A person image restoration method, comprising: Obtaining a face image to be repaired; extracting a luminance channel of the face image to be restored, and performing person image restoration based on the luminance channel to obtain a target face image; Fusing color channels of the target face image and the face image to be repaired to obtain a first face repaired image; performing an image conversion process on the first face repaired image to obtain a second face repaired image; The above-mentioned image conversion process is performed on the first face repaired image to obtain a second face repaired image. performing color correction on the first face repaired image; Identifying a scaling factor; A human image restoration method comprising: if the enlargement / reduction ratio is greater than a predetermined ratio, enlarging or reducing the first face restoration image after color correction using super-resolution technology to obtain the second face restoration image.

9. A method for restoring a person image, comprising: Obtaining a face image to be repaired; extracting a luminance channel of the face image to be restored, and performing person image restoration based on the luminance channel to obtain a target face image; Fusing color channels of the target face image and the face image to be repaired to obtain a first face repaired image; performing an image conversion process on the first face repaired image to obtain a second face repaired image; The above-mentioned, performing person image restoration based on the luminance channel to obtain a target face image, inputting the luminance channel into a trained neural network model to perform person image inpainting to obtain the target face image; Before obtaining a face image to be retouched, the method includes: constructing a sample image pair including a first facial image and a second facial image obtained based on the first facial image; inputting the sample image pairs into a neural network for training, and outputting a restored image of the second facial image; determining a target loss based on the restoration image and the first facial image; The method for person image restoration further includes: adjusting parameters of the neural network to minimize the target loss to obtain the neural network model.

10. The method of claim 9 , wherein the target loss includes at least one of a regression loss, a perceptual loss, a generative adversarial loss, and a context loss.

11. The step of constructing the sample image pair as described above includes: acquiring the first face image that is set in advance; If the image quality of the first face image is not deteriorated, performing atmospheric turbulence degradation on the first facial image to obtain a first degraded image; downsampling the first degraded image to obtain a target degraded image; upsampling the target degraded image to obtain a second degraded image; obtaining a third degraded image based on the second degraded image; compressing the third degraded image using a preset compression quality parameter to obtain a fourth degraded image; determining a rectangular area in the fourth degraded image and identifying a target area in the first face image corresponding to the rectangular area; replacing pixel values ​​in the target region with corresponding pixel values ​​in the rectangular region to obtain the second facial image, and forming the sample image pair by the first facial image and the second facial image; or The person image restoration method of claim 9, further comprising: when the image quality of the first facial image is deteriorated, forming the sample image pair using two of the first facial images, and determining one of the two as the second facial image.

12. The step of obtaining a third degraded image based on the second degraded image includes: adding noise to a luminance channel of the second degraded image and performing non-local means denoising on the second degraded image to obtain the third degraded image; or performing a blurring operation on the second degraded image to obtain a fifth degraded image; The method of claim 11 , further comprising: adding noise to a luminance channel of the fifth degraded image; and performing non-local means denoising on the fifth degraded image to obtain the third degraded image.

13. A method for restoring a person image, comprising the steps of: Obtaining a face image to be repaired; Extracting a luminance channel of the face image to be restored, inputting the luminance channel into a trained neural network model including a first network, a second network, a third network, and a fourth network to perform human image restoration, thereby obtaining a target face image; Fusing color channels of the target face image and the face image to be repaired to obtain a first face repaired image; performing an image conversion process on the first face repaired image to obtain a second face repaired image; The above-mentioned luminance channel is inputted into a trained neural network model to perform human image restoration and obtain the target face image, performing an encoding operation on the luminance channel using the first network to obtain a target feature map; performing a decoding operation on the target feature map using the second network and the third network to obtain the target face image; The step of performing an encoding operation on the luminance channel using the first network to obtain a target feature map includes: inputting the luminance channel into the first network for downsampling to obtain a first feature map; performing upper layer feature extraction on the first feature map using the fourth network to obtain an upper layer feature map; and overlapping the first feature map with the higher layer feature map to obtain the target feature map.

14. A person image restoration device comprising a processing unit for executing the method according to any one of claims 1 to 13.

15. An electronic device including an input device and an output device, A processor adapted to implement one or more instructions; and a computer storage medium having stored thereon one or more instructions loaded by said processor to cause said processor to perform the person image restoration method of any one of claims 1 to 13.

16. A computer storage medium having stored thereon one or more instructions, when loaded by a processor, for causing the processor to carry out the method for person image restoration according to any one of claims 1 to 13.

17. A computer program product comprising computer readable code, A computer program product, when the computer readable code runs in an electronic device, causing a processor in the electronic device to carry out the method according to any one of claims 1 to 13.

Citation Information

Patent Citations

  • Image restoration method and device

    CN109389562A