Image optimization method, correction model training method and device
By optimizing the RDN model and combining it with correction model processing, the long time-consuming and profile problems of RDN network inference are solved, the efficiency and quality of image optimization are improved, and the face image is ensured to be in the frontal state in the preset direction.
Patent Information
- Application Number
- CN202210576940.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-25
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2042-05-25
AI Technical Summary
Existing RDN networks take a long time to infer when processing face images and cannot straighten side faces, affecting image quality and subsequent processing efficiency.
By optimizing the RDN model, a super-resolution model is obtained, and combined with the pre-trained correction model, the image is first optimized in the super-resolution model, and then corrected when the conditions are met to ensure that the face image is front-facing in the preset direction. state, reducing complex convolution calculations and improving inference speed and image quality.
It improves the efficiency of image optimization, ensures the frontal state of the face image in the preset direction, avoids texture loss caused by correction processing, and improves image quality and convenience of subsequent processing.
Smart Images

Figure CN114897700B
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to an image optimization method, a correction model training method and a device. Background Art
[0002] With the development of electronic information technology, facial images have been widely used in scenarios such as video surveillance, access control authentication, and attendance punching. In practical applications, due to the influence of factors such as hardware equipment and usage conditions, the image quality of facial images may not be ideal, and even the face in the facial image may be in a side face state, which affects subsequent related processing. In order to improve the image quality, the RDN (Residual Dense Network) network (also known as the RDN model) is currently widely used to optimize the low-resolution (LR) face images to generate high-resolution (HR) face images. However, the RDN network has problems such as long inference time and inability to change the side face in the face image. Therefore, how to efficiently improve the image quality and obtain a face image with a front face is a technical problem that needs to be solved urgently. Summary of the invention
[0003] The present application provides an image optimization method, a correction model training method and a device to improve the optimization efficiency of the image and solve the side face problem in the face image.
[0004] In a first aspect, an embodiment of the present application provides an image optimization method, comprising:
[0005] Obtaining a face image to be optimized;
[0006] Inputting the face image into a super-resolution model for optimization processing to obtain a first super-resolution image; the super-resolution model is obtained by optimizing the RDN model;
[0007] If the face in the first super-resolution image meets the preset correction condition, the first super-resolution image is input into the correction model for face correction processing to obtain a corrected image; the face in the corrected image is in a frontal state in a preset direction;
[0008] The corrected image is input into the super-resolution model for optimization processing to obtain a second super-resolution target optimized image.
[0009] It can be seen that in the embodiment of the present application, the face image to be optimized is input into the super-resolution model for optimization processing to obtain a first super-resolution image, and when the face in the first super-resolution image meets the preset correction condition, the first super-resolution image is input into the correction model for face correction processing to obtain a correction image in a frontal face state in a preset direction; and the correction image is input into the super-resolution model for optimization processing again to obtain a second super-resolution target optimized image. Since the super-resolution model used in this process is obtained by optimizing the existing RDN model, compared with the existing RDN model, the complex multi-dimensional calculation processing of convolution is reduced, thereby improving the reasoning speed of the model, thereby improving the optimization efficiency of the image; at the same time, when the preset correction condition is met, the correction model is used to perform face correction processing, so that the face in the target optimized image is in a frontal face state in a preset direction, which provides guarantee and convenience for subsequent related processing based on the target optimized image; further, after obtaining the corrected image, the super-resolution model is used for optimization processing again, which avoids problems such as texture loss caused by the face correction process, and further ensures the image quality.
[0010] In a second aspect, an embodiment of the present application provides a method for training a correction model, comprising:
[0011] Acquire a plurality of training sample images; wherein the faces of people in the training sample images are in a profile state in a preset direction;
[0012] The training sample image is input into the model to be trained for training processing to obtain a correction model; wherein the correction model is used to perform face correction processing on the image to be corrected that meets the preset correction conditions to obtain a corrected image; the face in the corrected image is in a frontal state in the preset direction.
[0013] It can be seen that in the embodiment of the present application, by acquiring multiple training sample images, and the faces in the training sample images are in a side face state in a preset direction, and training processing is performed based on the training sample images to obtain a correction model, the correction model can be used to perform face correction processing on the images to be corrected that meet the preset correction conditions to obtain a corrected image, so that the faces in the corrected image are in a front face state in the preset direction, which not only solves the side face problem in the image and realizes image optimization, but also provides guarantee and convenience for subsequent related processing.
[0014] In a third aspect, an embodiment of the present application provides an image optimization device, including:
[0015] An acquisition module, used for acquiring a face image to be optimized;
[0016] A first optimization module is used to input the face image into a super-resolution model for optimization processing to obtain a first super-resolution image; the super-resolution model is obtained by optimizing the RDN model;
[0017] A correction module, configured to input the first super-resolution image into a correction model to perform face correction processing to obtain a corrected image if the face in the first super-resolution image meets a preset correction condition; the face in the corrected image is in a frontal state in a preset direction;
[0018] The second optimization module is used to input the corrected image into the super-resolution model for optimization processing to obtain a second super-resolution target optimized image.
[0019] In a fourth aspect, an embodiment of the present application provides a training device for a calibration model, comprising:
[0020] An acquisition module is used to acquire a plurality of training sample images; the faces of people in the training sample images are in a side face state in a preset direction;
[0021] The training module is used to input the training sample image into the model to be trained for training processing to obtain a correction model; wherein the correction model is used to perform face correction processing on the image to be corrected that meets the preset correction conditions and output a corrected image; the face in the corrected image is in a frontal state in the preset direction.
[0022] In a fifth aspect, an embodiment of the present application provides an electronic device, including:
[0023] A processor; and a memory arranged to store computer executable instructions, wherein the executable instructions are configured to be executed by the processor, the executable instructions including steps for executing the image optimization method provided in the first aspect above, or the executable instructions including steps for executing the training method of the correction model provided in the second aspect above.
[0024] In a sixth aspect, an embodiment of the present application provides a storage medium for storing computer-executable instructions, wherein the executable instructions enable a computer to execute the steps in the image optimization method provided in the first aspect, or the executable instructions enable a computer to execute the steps in the correction model training method provided in the second aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate one or more embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0026] Figure 1 A schematic diagram of the structure of an existing RDN model provided in an embodiment of the present application;
[0027] Figure 2 A schematic diagram of the structure of the RDB provided in the embodiment of the present application;
[0028] Figure 3 A schematic diagram of an application scenario of an image optimization method provided in an embodiment of the present application;
[0029] Figure 4 A schematic diagram of a flow chart of an image optimization method provided in an embodiment of the present application;
[0030] Figure 5 A schematic diagram of the structure of the super-resolution model provided in the embodiment of the present application;
[0031] Figure 6 A schematic diagram of the structure of the calibration model provided in the embodiment of the present application;
[0032] Figure 7 A schematic diagram of the face correction process provided in the embodiment of the present application;
[0033] Figure 8 A flowchart of a training method for a correction model provided in an embodiment of the present application;
[0034] Fig. 9 A schematic diagram of the module composition of an image optimization device provided in an embodiment of the present application;
[0035] Fig.10 A schematic diagram of the module composition of a training device for a correction model provided in an embodiment of the present application;
[0036] Fig.11 A schematic diagram of the structure of an electronic device provided for one or more embodiments of the present application. DETAILED DESCRIPTION
[0037] In order to enable those skilled in the art to better understand the technical solutions in one or more embodiments of the present application, the technical solutions in one or more embodiments of the present application will be clearly and completely described below in conjunction with the drawings in one or more embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on one or more embodiments of the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this document.
[0038] The structure of the existing RDN model is as follows Figure 1 As shown in the figure, it mainly includes four parts: SFENet (Shallow Feature Extraction Net), RDBs (Residual Dense Blocks), DFF (Dense Feature Fusion) and Up-Sampling Net. Among them, RDB = Residual block + Dense block. The structural diagram of RDB is as follows: Figure 2As shown. Considering that the existing RDN model can improve the resolution of facial images to a certain extent, the 3*3 convolutions (i.e., the size of the convolution kernel is 3*3) included in its various parts require complex multi-dimensional calculations, so there is a problem of time-consuming reasoning, and the RDN model cannot straighten the face in the face image that is in a side face state. Based on this, the embodiment of the present application provides an image optimization method, a correction model training method and a device, which improves the existing RDN model to obtain a super-resolution model, and pre-trains the correction model, so that when the face image to be optimized is obtained, the face image is input into the super-resolution model for optimization processing to obtain a first super-resolution image; and when the face in the first super-resolution image meets the preset correction conditions, the first super-resolution image is input into the correction model for face correction processing to obtain a corrected image; the face in the corrected image is in a front face state in a preset direction; and the corrected image is input into the super-resolution model for optimization processing again to obtain a second super-resolution target optimized image. Since the super-resolution model used is optimized from the existing RDN model, compared with the existing RDN model, it reduces the complex multi-dimensional computational processing of convolution, thereby improving the inference speed of the model and further improving the image optimization efficiency; at the same time, when the preset correction conditions are met, the correction model is used to perform face correction processing, so that the face in the target optimized image is in a frontal state in the preset direction, which provides protection and convenience for subsequent related processing based on the target optimized image; furthermore, after obtaining the corrected image, the super-resolution model is used to perform optimization processing again, which avoids problems such as texture loss caused by the face correction process, and further ensures the image quality.
[0039] Figure 3 A schematic diagram of an application scenario of an image optimization method provided in an embodiment of the present application, such as Figure 3 As shown, the scenario may include: a server and a terminal device with a collection function, and the server and the terminal device are connected through network communication. Among them, the terminal device can be an independent camera device, such as a camera device, etc.; the terminal device can also be a mobile device such as a mobile phone, a tablet computer, a desktop computer, a portable notebook computer, etc. equipped with a camera module such as a camera. The server can be an independent server or a server cluster composed of multiple servers; an image optimization device is deployed in the server, and the image optimization device is used to execute the image optimization method provided in this application.
[0040] In one embodiment, the server may have functions such as image optimization and identity recognition, for example, in scenarios such as access control authentication and attendance clocking in. Accordingly, the terminal device may be an independent camera device, which may record the video data of the target user (the video data includes the face of the target user) or collect the face image of the target user, and send an image processing request to the server based on the recorded video data or the collected face image; after receiving the image processing request, the server obtains the face image to be optimized from the image processing request based on the image optimization device deployed by itself, and inputs the face image into the super-resolution model obtained by optimizing the RDN model for optimization processing to obtain a first super-resolution image; if the face in the first super-resolution image meets the preset correction condition, the first super-resolution image is input into the correction model for face correction processing to obtain a corrected image in a frontal face state in a preset direction; and the corrected image is input into the super-resolution model for optimization processing again to obtain a second super-resolution target optimized image. The server performs identity recognition processing on the target user according to the target optimized image, and sends the identity recognition result to the access control device or attendance punching device, so that the access control device executes access release or the attendance device executes attendance punching and other related processing.
[0041] In another embodiment, the server may have image optimization functions and business processing functions, such as in the processing scenarios of online payment, online account opening, etc. Correspondingly, the terminal device may be a mobile device of the target user. The mobile device of the target user may record the video data of the target user (the video data includes the face of the target user) or collect the face image of the target user based on the payment operation or business processing operation of the target user, and send a business processing request to the server based on the recorded video data or collected face image, as well as the determined payment information or business processing information. After receiving the business processing request, the server obtains the face image of the target user from the business processing request based on the image optimization device deployed by itself, determines the obtained face image as the face image to be optimized, and inputs it into the super-resolution model obtained by optimizing the RDN model for optimization processing to obtain a first super-resolution image; if the face in the first super-resolution image meets the preset correction condition, the first super-resolution image is input into the correction model for face correction processing to obtain a corrected image in a frontal state in a preset direction; and the corrected image is input into the super-resolution model for optimization processing again to obtain a second super-resolution target optimized image. The server identifies the target user based on the target optimized image, and when it is determined that the identity of the target user is valid based on the identification result, it performs payment processing based on the payment information in the business processing request, or performs corresponding business processing based on the business processing information in the business processing request, and sends the processing result to the target user's mobile device.
[0042] It should be pointed out that the application scenario of the image optimization method provided in the embodiment of the present application is not limited to the above application scenario, which can be set as needed in actual application. For example, the image optimization device can also be deployed in a terminal device, and after recording the video data of the target user (the video data includes the face of the target user) or collecting the face image of the target user, the terminal device determines the face image as the face image to be optimized and inputs it into the super-resolution model obtained by optimizing the RDN model for optimization processing to obtain a first super-resolution image; if the face in the first super-resolution image meets the preset correction condition, the first super-resolution image is input into the correction model for face correction processing to obtain a corrected image in a frontal state in a preset direction; the corrected image is input into the super-resolution model for optimization processing again to obtain a second super-resolution target optimized image; and based on the target image, the target user is identified, and corresponding operations are performed according to the identification result, or the identification result is sent to the server so that the server performs subsequent processing, or the target optimized image is sent to the server so that the server performs relevant processing, etc. The application scenarios of the image optimization method provided in the embodiment of the present application are not listed one by one here.
[0043] Based on the above application scenario architecture, an embodiment of the present application provides an image optimization method. Figure 4 A flowchart of an image optimization method provided in an embodiment of the present application is shown in FIG. Figure 4 The method in can be performed by an image optimization device. Figure 4 As shown, the method comprises the following steps:
[0044] Step S102, obtaining a face image to be optimized.
[0045] Among them, the facial image to be optimized can be a facial image that needs to be optimized in any scenario, such as the facial image of the user to be released in the access control scenario, the facial image of the user requesting payment in the payment scenario, the facial image of the user purchasing the ticket in the ticket purchase scenario, the facial image of the user to be clocked in in the attendance clocking-in scenario, etc. It can be understood that the image optimization method provided in the embodiment of the present application can be applied to any scenario that requires image optimization, and accordingly, the method for obtaining the facial image to be optimized can be set according to the needs in different scenarios, and this is not specifically limited in the present application.
[0046] Step S104, inputting the face image into a super-resolution model for optimization processing to obtain a first super-resolution image; wherein the super-resolution model is obtained by optimizing the RDN model.
[0047] In order to improve the inference efficiency of the model and thus improve the optimization efficiency of the image, in the embodiment of the present application, the existing RDN model is improved in advance, each 3*3 convolution in the existing RDN model is replaced with a hole transposed convolution, and after training, a super-resolution model is obtained. The structure of the super-resolution model is as follows: Figure 5 As shown in the figure, the super-resolution model is used to optimize the input image and output the corresponding super-resolution image. Compared with the existing RDN model, it can not only improve the image optimization efficiency, but also improve the image resolution, that is, improve the image quality.
[0048] Step S106, if the face in the first super-resolution image meets the preset correction condition, the first super-resolution image is input into the correction model for face correction processing to obtain a corrected image; wherein the face in the corrected image is in a frontal state in a preset direction.
[0049] The preset direction includes a first preset direction and / or a second preset direction.
[0050] Specifically, determine whether the face in the first super-resolution image meets the preset correction condition. If the result is yes, input the first super-resolution image into the correction model for face correction processing, and output the corrected image. Wherein, determining whether the face in the first super-resolution image meets the preset correction condition may include: determining whether the face in the first super-resolution image is in a frontal state in both the first preset direction and the second preset direction. If not, determine that the face in the first super-resolution image meets the preset correction condition; if so, determine that the face in the first super-resolution image does not meet the preset correction condition. Wherein, the first preset direction may be the y-axis direction in the three-dimensional space, and the second preset direction may be the z-axis direction in the three-dimensional space; that is, when the yaw angle (also called the yaw angle) of the face in the first super-resolution image is not zero, and / or the roll angle (also called the roll angle) is not zero, it is determined that the face in the first super-resolution image meets the preset correction condition. It can be understood that when the yaw angle of the face in the first super-resolution image is not zero, it indicates that the face in the first super-resolution image is in a side face state in the y-axis direction, and when the roll angle of the face in the first super-resolution image is not zero, it indicates that the face in the first super-resolution image is in a side face state in the z-axis direction. Accordingly, the face in the corrected image is in a front face state in both the first preset direction and the second preset direction.
[0051] Step S108, inputting the corrected image into the super-resolution model for optimization processing to obtain a target optimized image of a second super-resolution.
[0052] Taking into account that the texture of the image may be lost during the process of performing face correction on the first super-resolution image through the correction model, in order to ensure the image quality, in an embodiment of the present application, after obtaining the corrected image, the corrected image is also optimized based on the super-resolution model to obtain a second super-resolution target optimized image.
[0053] In the embodiment of the present application, the face image to be optimized is input into the super-resolution model for optimization processing to obtain a first super-resolution image, and when the face in the first super-resolution image meets the preset correction condition, the first super-resolution image is input into the correction model for face correction processing to obtain a correction image in a frontal face state in a preset direction; and the correction image is input into the super-resolution model for optimization processing again to obtain a second super-resolution target optimized image. Since the super-resolution model used in this process is obtained by optimizing the existing RDN model, compared with the existing RDN model, the complex multi-dimensional calculation processing of convolution is reduced, thereby improving the reasoning speed of the model, and thus improving the optimization efficiency of the image; at the same time, when the preset correction condition is met, the correction model is used to perform face correction processing, so that the face in the target optimized image is in a frontal face state in a preset direction, which provides guarantee and convenience for subsequent related processing based on the target optimized image; further, after obtaining the corrected image, the super-resolution model is used for optimization processing again, which avoids problems such as texture loss caused by the face correction process, and further ensures the image quality.
[0054] In order to obtain a clearer facial image and thus provide a better basis for optimization processing, in one or more embodiments of the present application, video data including the face of the target user may be recorded, and the facial image to be optimized of the target user may be obtained from the video data. Correspondingly, step S102 may include the following steps S102-2 to S102-6:
[0055] Step S102-2: extract multiple frames of original images from the video data of the target user according to a preset frame interval.
[0056] Among them, the preset frame interval and the length of the video data can be set according to needs in actual applications. For example, the preset frame interval is 3 frames, that is, one frame is extracted every 3 video frames and used as the original image; the length of the video data is, for example, 2 seconds.
[0057] Step S102-4, determining the clarity of each frame of the original image according to a preset blur detection method.
[0058] Among them, the preset blur detection method can be a detection method based on the Laplace operator, a detection method based on the Brenner gradient function, a detection method based on the Tenengrad gradient function, etc., which can be set according to needs in actual applications, and this application does not make specific limitations on this.
[0059] Step S102-6, obtaining a face image to be optimized based on the determined definition, wherein the original image with the highest definition includes the face image to be optimized.
[0060] Specifically, the clarity is sorted to obtain the original image with the highest clarity; the face detection model is used to perform face detection on the original image with the highest clarity to obtain face coordinates; based on the face coordinates, the face image to be optimized of the target user is captured from the original image with the highest clarity. More specifically, the clarity of each determined original image is sorted in order from small to large, or the clarity of each determined original image is sorted in order from large to small to obtain the original image with the highest clarity. The original image with the highest clarity is input into a pre-trained face detection model, so that the face detection model is used to perform face detection on the original image with the highest clarity, and the coordinate information of the four vertices of the quadrilateral face frame is output; the coordinate information is determined as face coordinates, and according to the face frame corresponding to the face coordinates, the face image to be optimized is captured from the original image with the highest clarity.
[0061] Further, intercepting the face image to be optimized from the original image with the highest definition may include: intercepting the face image from the original image with the highest definition, determining whether the intercepted face image is in a frontal state in a third preset direction, and if so, determining the intercepted face image as the face image to be optimized; if not, rotating the intercepted face image in the third preset direction to obtain the face image to be optimized, wherein the face in the face image to be optimized is in a frontal state in the third preset direction. The third preset direction may be the x-axis direction in the three-dimensional coordinates.
[0062] In one embodiment, the above-mentioned face detection model can be a yolov5 model. In order to be able to detect faces at different angles, in the embodiment of the present application, when constructing the training set of the yolov5 model, each of the multiple face images to be trained can be rotated by 90 degrees, 180 degrees and 270 degrees respectively, thereby not only expanding the number of training samples, but also enabling the trained yolov5 model to detect faces at different angles. It should be pointed out that the specific training process of the yolov5 model can refer to the training process of the existing face detection model, which will not be repeated in this application; in addition, the face detection model is not limited to the above-mentioned yolov5 model, which can be set according to needs in actual applications.
[0063] Therefore, by recording the video data of the target user, extracting multiple original images from the video data, and obtaining the target user's face image to be optimized from the original image with the highest clarity, the quality of the face image is improved, providing a favorable basis for subsequent processing.
[0064] It should be pointed out that the method for obtaining facial images is not limited to the above method. In practical applications, for different application scenarios, the method for obtaining facial images can be set according to needs. For example, in scenarios such as access control authentication, payment, attendance clocking, etc., it is also possible to only take a facial image of the target user and determine it as the facial image to be optimized. For another example, for security monitoring scenarios in public places, facial images can be obtained from recorded video data. At this time, each frame of the original image of the video data may include multiple faces. When it is necessary to perform identity recognition and other processing on each user who has visited the public place, each frame of the original image of the video data can be extracted, and a face detection model can be used to perform face detection processing on each frame of the extracted original image to obtain face coordinates; determine whether the identity of the user corresponding to the face coordinates has been recognized. If not, the user is determined as the target user, and the face image to be optimized of the target user is intercepted from the corresponding original image according to the face coordinates. Alternatively, each frame of the original image of the video data can be extracted, and a pre-trained face detection model can be used to perform face detection processing on each frame of the extracted original image to obtain face coordinates; the corresponding face image can be intercepted from the corresponding original image according to the face coordinates; the similarity between each face image can be determined according to a preset method, and each face image corresponding to a similarity greater than a similarity threshold can be determined as a face image set of the same target user; for each face image in each face image set, the clarity of each face image can be determined according to a preset blur detection method, and the clarity can be sorted to obtain the highest clarity, and the face image corresponding to the highest clarity can be determined as the face image to be optimized for the target user. When it is necessary to perform identity recognition and other processing on a target user who has visited the public place, face tracking processing can be performed based on the recorded video data according to a preset face tracking method to obtain at least one face image of the target user, and the face image with the highest clarity can be determined according to the aforementioned method, and the face image with the highest clarity can be determined as the face image to be optimized for the target user. For scenarios involving multiple users, the above are only several feasible implementations. Other feasible implementations are not listed one by one in this application, and they can be set according to needs in actual applications.
[0065] As mentioned above, in order to improve the optimization efficiency of the image, in the embodiment of the present application, the existing RDN model is improved in advance, each 3*3 convolution in the existing RDN model is replaced with a hole transposed convolution, and after training processing, a super-resolution model is obtained. Correspondingly, in the optimization processing in step S104 and step S108, the hole transposed convolution is used to perform a preset processing on the first input image to obtain a processing result; wherein the first input image includes a face image or a corrected image or an output image of the previous layer of the hole device convolution.
[0066] The first input image is subjected to a preset process to obtain a processing result, which may include the following steps A2 to A10:
[0067] Step A2, using a preset sliding window matrix and a preset sliding step length to perform sliding window processing on the first input image to obtain a plurality of activation areas;
[0068] It is understandable that for different dilated transposed convolutions, the first input image may be different. Specifically, Figure 5 It can be seen from the structure of the super-resolution model shown that, in the order from left to right, in the optimization process in step S104, the first input image of the first dilated transposed convolution is the face image to be optimized, the first input image of the second dilated transposed convolution is the output image of the first dilated transposed convolution; the first input image of the third dilated transposed convolution is the output image of 1*1Covn; the first input image of the fourth dilated transposed convolution is the output image of Upscale. In the optimization process in step S108, the first input image of the first dilated transposed convolution is the corrected image, the first input image of the second dilated transposed convolution is the output image of the first dilated transposed convolution; the first input image of the third dilated transposed convolution is the output image of 1*1Covn; the first input image of the fourth dilated transposed convolution is the output image of Upscale.
[0069] Step A4, performing a first conversion process on each active area to obtain a target matrix;
[0070] The first conversion process may be an im2col conversion.
[0071] Step A6, performing a second conversion process on the convolution kernel of the dilated transposed convolution to obtain a target vector;
[0072] The second conversion process may be to sequentially read the data of each row in the convolution kernel and then rearrange it (eg, sequentially concatenate it).
[0073] Step A8, performing calculation processing according to the target matrix and the target vector to obtain a calculation result;
[0074] Specifically, the target matrix and the target vector are multiplied to obtain a calculation result.
[0075] Step A10, performing a third conversion process on the calculation result to obtain a processing result, and outputting the processing result.
[0076] Among them, the third conversion process can be col2im conversion.
[0077] In one embodiment, the preset sliding window matrix can be a 1*49 matrix (i.e., a row vector), the preset sliding step size is 1, and the convolution kernel of the hole transposed convolution is a 7*7 matrix. First, the preset sliding window matrix of 1*49 is used to perform sliding window processing on the first input image according to the sliding step size of 1 to obtain W activation areas; wherein W is a positive integer, and the value of W is related to the size of the input image. Then, the obtained W activation areas are processed by im2col to obtain a W*49 target matrix; thereafter, the 7*7 convolution kernel is subjected to a second conversion process to obtain a 49*1 target vector; finally, the W*49 target matrix is multiplied by the 49*1 target vector to obtain a calculation result; and the calculation result is subjected to col2im conversion processing to obtain the processing result of the first input image, and the processing result is output. Among them, the process of im2col conversion processing and the process of col2im conversion processing can refer to the existing conversion method, which will not be described in detail in this application. It can be understood that for different hole transposed convolutions, the processing results may be different.
[0078] Since the process of performing the third conversion processing on the convolution kernel to obtain the target vector does not require complex calculations, it only needs to read the data sequentially and then rearrange it; and the multiplication result of the target matrix and the target vector is the same as the multi-dimensional calculation result of the 3*3 convolution of the existing RDN model, but the multiplication of the target matrix and the target vector does not require other complex multi-dimensional calculations, which greatly reduces the inference time of the memory space and improves the computing efficiency.
[0079] Further, such as Figure 5 As shown, the super-resolution model includes an improved SFENet, RDBs, an improved DFF and an improved Up-Sampling Net; wherein the improved SFENet is used to perform shallow feature extraction processing on the input image to obtain a first feature map; RDBs is used to perform local feature extraction processing and local residual learning processing based on the first feature map to obtain multiple second feature maps; the improved DFF is used to perform global feature fusion processing on multiple second feature maps to obtain a third feature map; the improved Up-Sampling Net is used to upsample the third feature map to obtain a super-resolution image.
[0080] Furthermore, if Figure 5As shown, the improved SFENet includes a first dilated transposed convolution and a second dilated transposed convolution. Accordingly, the above-mentioned shallow feature extraction processing of the input image to obtain the first feature map may include: performing the aforementioned preset processing (i.e., steps A2 to A10) on the input image (i.e., the first input image) through the first dilated transposed convolution to obtain a first sub-feature map (i.e., the processing result, which can also be referred to as the first processing result for the sake of distinction); performing the aforementioned preset processing on the first sub-feature map (i.e., the first input image) through the second dilated transposed convolution to obtain the first feature map (i.e., the processing result, which can also be referred to as the second processing result for the sake of distinction);
[0081] like Figure 5 As shown, RDBs includes D RDB modules connected in sequence, where D is an integer greater than 1. Correspondingly, performing local feature extraction processing and local residual learning processing based on the first feature map to obtain multiple second feature maps may include: performing local feature extraction processing and local residual learning processing on the fourth input image through each RDB module to obtain D second feature maps. Among them, the D RDB modules correspond to D arrangement numbers, the fourth input image of the RDB module with the smallest arrangement number is the first feature map, and the fourth input image of the RDB module whose arrangement number is not the smallest is the second feature map output by the previous RDB module. The structure of each RDB module and the process of performing local feature extraction processing and local residual learning processing on the fourth input image can refer to the structure of the RDB module and the image processing method in the existing RDN model, which will not be repeated in this application.
[0082] like Figure 5 As shown, the improved DFF includes a Concat layer, a 1*1 Conv layer and a third hole transposed convolution. Accordingly, the above-mentioned global feature fusion processing of multiple second feature maps to obtain a third feature map may include: performing feature fusion processing on D second feature maps through the Concat layer to obtain a second sub-feature map; performing dimension transformation processing on the second sub-feature map through a 1*1 Conv layer to obtain a third sub-feature map; performing the aforementioned preset processing on the third sub-feature map (i.e., the first input image) through the third hole transposed convolution to obtain a third feature map (i.e., the processing result, which can also be referred to as the third processing result for the sake of distinction).
[0083] like Figure 5As shown, the improved Up-Sampling Net includes an Upscale layer and a fourth hole transposed convolution. Accordingly, the aforementioned upsampling of the third feature map to obtain a super-resolution image may include: upsampling the third feature map through the Upscale layer to obtain a fourth sub-feature map; performing the aforementioned preset processing on the fourth sub-feature map (i.e., the first input image) through the fourth hole transposed convolution to obtain a super-resolution image (i.e., the processing result, which may also be referred to as the fourth processing result for the sake of distinction).
[0084] Taking the optimization process in step S104 as an example, it may include: performing the aforementioned preset processing on the input face image (i.e., the first input image) through the first hole transposed convolution to obtain a first sub-feature map (i.e., the first processing result); performing the aforementioned preset processing on the first sub-feature map (i.e., the first input image) through the second hole transposed convolution to obtain a first feature map (i.e., the second processing result); performing local feature extraction processing and local residual learning processing based on the first feature map through D RDB modules to obtain D second feature maps; performing local feature extraction processing and local residual learning processing on the D second feature maps through the Concat layer. Perform feature fusion processing to obtain a second sub-feature map; perform dimension transformation processing on the second sub-feature map through a 1*1 Conv layer to obtain a third sub-feature map; perform the aforementioned preset processing on the third sub-feature map (i.e., the first input image) through a third hole transposed convolution to obtain a third feature map (i.e., the third processing result); perform upsampling processing on the third feature map through an Upscale layer to obtain a fourth sub-feature map; perform the aforementioned preset processing on the fourth sub-feature map (i.e., the first input image) through a fourth hole transposed convolution to obtain a first super-resolution image (i.e., the fourth processing result).
[0085] The optimization process in step S108 is similar to the optimization process in step S104, and the above description can be referred to. The difference is that the input corrected image (i.e., the first input image) is subjected to the aforementioned preset processing through the first hole transposed convolution to obtain the first sub-feature map; and the fourth sub-feature map (i.e., the first input image) is subjected to the aforementioned preset processing through the fourth hole transposed convolution to obtain the second super-resolution target optimized image (i.e., the fourth processing result).
[0086] Considering that in practical applications, due to factors such as shooting angle or artificial head twisting, the face in the face image is often in a side profile state, which is not conducive to subsequent related processing such as identity recognition processing and business handling. Based on this, in the embodiment of the present application, a correction model is also pre-trained, and the super-resolution model is combined with the correction model to obtain the final optimized target image. Among them, the structure of the correction model is as follows Figure 6 As shown, it includes: a three-dimensional reconstruction module, a first generation module and a second generation module;
[0087] Correspondingly, in the face correction process in step S106, the three-dimensional reconstruction module is used to perform three-dimensional face reconstruction on the second input image to obtain a first three-dimensional frontal face image; the first generation module is used to generate a two-dimensional side face image according to the first three-dimensional frontal face image; the second generation module is used to generate an output image according to the first three-dimensional frontal face image and the two-dimensional side face image;
[0088] Among them, if the face in the first super-resolution image is not in a frontal state in the first preset direction or the second preset direction, the second input image processed by the three-dimensional reconstruction module when performing three-dimensional face reconstruction includes the first super-resolution image, and the output image of the second generation module includes the corrected image; if the face in the first super-resolution image is not in a frontal state in both the first preset direction and the second preset direction, the second input image processed by the three-dimensional reconstruction module when performing three-dimensional face reconstruction is the first super-resolution image and the intermediate image corresponding to the first super-resolution image, and the output image of the second generation module is the intermediate image and the corrected image. In other words, when the face in the first super-resolution image is not in a frontal state in one of the first preset direction and the second preset direction, the correction model is used to perform a correction process on the input first super-resolution image, and the corresponding corrected image can be output. When the face in the first super-resolution image is not in a frontal state in the first preset direction and the second preset direction, it is necessary to perform two correction processes through the correction model, that is, firstly perform correction processing on the input first super-resolution image in the first preset direction to obtain an intermediate image; then perform correction processing on the intermediate image in the second preset direction to obtain a corrected image; or, first perform correction processing on the input first super-resolution image in the second preset direction to obtain an intermediate image; then perform correction processing on the intermediate image in the first preset direction to obtain a corrected image.
[0089] Further, such as Figure 7 The schematic diagram of the face correction process shown in the figure, the above three-dimensional face reconstruction process is performed on the second input image to obtain the first three-dimensional frontal face image, which may include the following steps B2 to B8:
[0090] Step B2, performing texture feature processing on the second input image to obtain a first texture feature;
[0091] Step B4, performing three-dimensional face reconstruction processing on the second input image to obtain a first three-dimensional side face model;
[0092] Step B6, performing a first rotation on the first three-dimensional side face model in a target direction to obtain a three-dimensional front face model; wherein the target direction includes a first preset direction or a second preset direction;
[0093] Step B8, fusing the first texture feature and the three-dimensional frontal face model to obtain a first three-dimensional frontal face image.
[0094] Optionally, 3DDFA_V2 is used to perform 3D face reconstruction processing on the second input image to obtain a 3D side face model. It can be understood that when the target direction is the first preset direction, that is, the y-axis direction in the three-dimensional space, if the face in the second input image is in the left face state, the first rotation is a right rotation along the y-axis; if the face in the second input image is in the right face state, the first rotation is a left rotation along the y-axis. When the target direction is the second preset direction, that is, the z-axis direction in the three-dimensional space, if the face in the second input image is in the left face state, the first rotation is a right rotation along the z-axis; if the face in the second input image is in the right face state, the first rotation is a left rotation along the z-axis.
[0095] Further, such as Figure 7 As shown, the above-mentioned generation of the two-dimensional side face image according to the first three-dimensional front face image may include the following steps C2 to C6:
[0096] Step C2, performing a second rotation on the first three-dimensional frontal face image in the target direction to obtain a first three-dimensional side face image in the target direction;
[0097] The second rotation may be a clockwise rotation or a rightward rotation.
[0098] Step C4, rendering the first three-dimensional side face image to obtain a two-dimensional rendered image;
[0099] Step C6, smoothing the two-dimensional rendered image to obtain a two-dimensional side face image.
[0100] Further, such as Figure 7 As shown, the above-mentioned generation of the output image according to the first three-dimensional frontal face image and the two-dimensional side face image may include the following steps D2 to D10:
[0101] Step D2, performing texture feature processing on the two-dimensional side face image to obtain a second texture feature;
[0102] Step D4, performing a second rotation on the three-dimensional frontal face model corresponding to the first three-dimensional frontal face image in a target direction to obtain a second three-dimensional side face model in the target direction;
[0103] The second rotation in step D4 is performed in the same manner as the second rotation in step C2; the second three-dimensional side face model may be the same as or different from the first three-dimensional side face model.
[0104] Step D6, fusing the second texture feature and the second three-dimensional side face model to obtain a second three-dimensional side face image;
[0105] Step D8, performing a third rotation on the second three-dimensional side face image in the target direction to obtain a second three-dimensional front face image;
[0106] The rotation direction of the third rotation and the second rotation can be the same or opposite. For example, the second rotation is a 90 degree rotation to the right along the target direction, and the third rotation can be a 90 degree rotation to the left along the target direction or a 270 degree rotation to the right along the target direction.
[0107] Step D10, rendering the second three-dimensional frontal face image to obtain an output image.
[0108] In a specific embodiment, taking the first super-resolution image in the profile state in the first preset direction and the second preset direction as an example, after the first super-resolution image is input into the correction model, the first super-resolution image is firstly processed with texture features by the three-dimensional reconstruction module to obtain the first texture features; and the first super-resolution image is processed with three-dimensional face reconstruction to obtain the first three-dimensional profile model; and the first three-dimensional profile model is first rotated in the first preset direction to obtain the three-dimensional frontal face model; the first texture features and the three-dimensional frontal face model are fused to obtain the first three-dimensional frontal face image. Then, the first three-dimensional frontal face image is second rotated in the first preset direction by the first generation module to obtain the first three-dimensional profile face image in the first preset direction; the first three-dimensional profile face image is rendered to obtain the two-dimensional rendered image; and the two-dimensional rendered image is smoothed to obtain the two-dimensional profile face image. Then, the texture feature processing of the two-dimensional side face image is performed through the second generation module to obtain the second texture feature; the three-dimensional front face model corresponding to the first three-dimensional front face image is rotated in the first preset direction for the second time to obtain the second three-dimensional side face model in the second preset direction; the second texture feature and the second three-dimensional side face model are fused to obtain the second three-dimensional side face image; and the second three-dimensional side face image is rotated in the second preset direction for the third time to obtain the second three-dimensional front face image; the second three-dimensional front face image is rendered to obtain an intermediate image and output the intermediate image. At this point, the face correction processing in the first preset direction is completed, and then based on the output intermediate image, the face correction processing in the second preset direction is performed according to the aforementioned process to obtain a corrected image and output the corrected image.
[0109] Thus, the correction model is used to perform face correction processing on the first super-resolution image to obtain a corrected image, which ensures that the face in the corrected image is in a frontal state in a preset direction, providing a guarantee for subsequent related processing. In addition, during the correction process, since a two-dimensional image is generated based on a three-dimensional image, high-dimensional image refinement is achieved in the process.
[0110] Taking into account that image texture may be lost during the face correction process, based on this, in one or more embodiments of the present application, step S106 may also include: post-processing the corrected image. Specifically, the corrected image is input into the neural rendering model for neural rendering processing, and a neural rendered image is output; the neural rendered image is input into the reconstruction model for reconstruction processing, and a reconstructed image is output. Among them, the neural rendering model can be a Unet model, and the reconstruction model can be a Gan model. The specific forms of the neural rendering model and the reconstruction model and the training process are not specifically limited in this application, and can be set by oneself according to needs in actual applications.
[0111] Corresponding to the above post-processing, step S108 may include: inputting the reconstructed image into the super-resolution model for optimization processing to obtain a target optimized image of the second super-resolution.
[0112] In one or more embodiments of the present application, after obtaining the target image in step S108, the method may further include: performing identity recognition processing on the corresponding target user according to the target optimized image; or, updating a specified image library according to the target optimized image, etc.
[0113] Wherein, performing identity recognition processing on the corresponding target user according to the target optimized image may include: performing comparison processing on the target optimized image and each face image in the specified face image library according to a preset face comparison algorithm; if the comparison is successful, obtaining the identity information of the target user according to the face image in the specified face image library that has been successfully compared. Wherein, the specified face image library may be an authoritative face image library, which includes real and valid face images of multiple users, and each face image is associated with the real and valid identity information of the corresponding user; when the target optimized image is successfully compared with a face image in the specified face image library, the associated identity information can be obtained according to the face image that has been successfully compared, and the obtained identity information is determined as the identity information of the target user. Wherein, the face comparison algorithm may be an Arcface face comparison algorithm, or other face comparison algorithms, which can be set according to needs, and this application does not make specific restrictions on this.
[0114] In the embodiment of the present application, the face image to be optimized is input into the super-resolution model for optimization processing to obtain a first super-resolution image, and when the face in the first super-resolution image meets the preset correction condition, the first super-resolution image is input into the correction model for face correction processing to obtain a correction image in a frontal face state in a preset direction; and the correction image is input into the super-resolution model for optimization processing again to obtain a second super-resolution target optimized image. Since the super-resolution model used in this process is obtained by optimizing the existing RDN model, compared with the existing RDN model, the complex multi-dimensional calculation processing of convolution is reduced, thereby improving the reasoning speed of the model, and thus improving the optimization efficiency of the image; at the same time, when the preset correction condition is met, the correction model is used to perform face correction processing, so that the face in the target optimized image is in a frontal face state in a preset direction, which provides guarantee and convenience for subsequent related processing based on the target optimized image; further, after obtaining the corrected image, the super-resolution model is used for optimization processing again, which avoids problems such as texture loss caused by the face correction process, and further ensures the image quality.
[0115] Corresponding to the image optimization method described above, based on the same technical concept, one or more embodiments of the present application also provide a method for training a correction model. Figure 8 A flowchart of a method for training a correction model provided in one or more embodiments of the present application is provided. Figure 8 The method can be executed by a training device for the correction model; the training device for the correction model can be set in a terminal device or in a server. The terminal device can be a mobile phone, a tablet computer, a desktop computer, a portable notebook, etc. The server can be an independent server or a server cluster composed of multiple servers. Figure 8 As shown, the method comprises the following steps:
[0116] Step S202, obtaining a plurality of training sample images; wherein the faces of people in the training sample images are in a side face state in a preset direction;
[0117] Specifically, the face in the training sample image is in a side face state in the first preset direction and / or the second preset direction; the label of the training sample image may include state information characterizing that the face is in a side face state in the first preset direction and / or the second preset direction.
[0118] Step S204, input the training sample image into the model to be trained for training processing to obtain a correction model; wherein the correction model is used to perform face correction processing on the image to be corrected that meets the preset correction conditions to obtain a corrected image; the face in the corrected image is in a frontal state in a preset direction.
[0119] Among them, the model to be trained includes a three-dimensional reconstruction module, a first generation module and a second generation module; in the training process, the three-dimensional reconstruction module is used to perform three-dimensional face reconstruction on the third input image to obtain a first three-dimensional frontal face image; the first generation module is used to generate a two-dimensional side face image based on the first three-dimensional frontal face image; the second generation module is used to generate an output image based on the first three-dimensional frontal face image and the two-dimensional side face image, and output the output image.
[0120] Wherein, if the face in the training sample image is in a side face state in the first preset direction or the second preset direction, the third input image processed by the 3D reconstruction module when performing 3D face reconstruction includes the training sample image, and the output image of the second generation module includes the correction image; if the face in the training sample image is in a side face state in both the first preset direction and the second preset direction, the third input image processed by the 3D reconstruction module when performing 3D face reconstruction is the training sample image and the intermediate image corresponding to the training sample image, and the output image of the second generation module is the intermediate image and the correction image. It can be understood that the training process is also a correction process for the training sample image, that is, when the face in the training sample image is not in a front face state in one of the first preset direction and the second preset direction, the training sample image is corrected once by the model to be trained, and the correction image corresponding to the training sample image is output. When the human face in the training sample image is not in a frontal state in both the first preset direction and the second preset direction, the model to be trained is subjected to two correction processes, that is, firstly, the input training sample image is corrected in the first preset direction to obtain an intermediate image; then, the intermediate image is corrected in the second preset direction to obtain a corrected image; or, first, the input training sample image is corrected in the second preset direction to obtain an intermediate image; then, the intermediate image is corrected in the first preset direction to obtain a corrected image.
[0121] Furthermore, the above-mentioned three-dimensional face reconstruction process, the process of generating a two-dimensional side face image, and the process of generating an output image can all be referred to the above-mentioned related descriptions, and the repeated parts will not be repeated here.
[0122] It should be pointed out that the training process can refer to the existing training process, and this application does not make specific limitations on this. The stopping condition of training can be that the number of training times reaches a preset number, or it can be the convergence of the loss value calculated based on the loss function. When the training stopping condition is the convergence of the loss value calculated based on the loss function, after each round of training, the corrected image output by the model to be trained can be input into the neural rendering model for neural rendering processing, and the neural rendering image can be output; and the neural rendering image can be input into the reconstruction model for reconstruction processing, and the reconstructed image can be output; the Euclidean distance between the three-dimensional frontal face image obtained by the three-dimensional reconstruction module and the reconstructed image is calculated, and the Euclidean distance is determined as the loss value.
[0123] In an embodiment of the present application, by acquiring multiple training sample images, and the faces in the training sample images are in a side face state in a preset direction, and training processing is performed based on the training sample images to obtain a correction model, the correction model can be used to perform face correction processing on the images to be corrected that meet the preset correction conditions to obtain a corrected image, so that the faces in the corrected image are in a front face state in the preset direction, which not only solves the side face problem in the image and realizes image optimization, but also provides guarantee and convenience for subsequent related processing.
[0124] Corresponding to the image optimization method described above, based on the same technical concept, one or more embodiments of the present application also provide an image optimization device. Fig. 9 A schematic diagram of the module composition of an image optimization device provided in one or more embodiments of the present application, such as Fig. 9 As shown, the device comprises:
[0125] An acquisition module 301 is used to acquire a face image to be optimized;
[0126] A first optimization module 302 is used to input the face image into a super-resolution model for optimization processing to obtain a first super-resolution image; the super-resolution model is obtained by optimizing the RDN model;
[0127] The correction module 303 is used for inputting the first super-resolution image into the correction model to perform face correction processing to obtain a corrected image if the face in the first super-resolution image meets the preset correction condition; the face in the corrected image is in a frontal state in a preset direction;
[0128] The second optimization module 304 is used to input the corrected image into the super-resolution model for optimization processing to obtain a second super-resolution target optimized image.
[0129] The image optimization device provided by the embodiment of the present application inputs the face image to be optimized into the super-resolution model for optimization processing to obtain a first super-resolution image, and when the face in the first super-resolution image meets the preset correction condition, the first super-resolution image is input into the correction model for face correction processing to obtain a correction image in a frontal face state in a preset direction; and the correction image is input into the super-resolution model for optimization processing again to obtain a second super-resolution target optimized image. Since the super-resolution model used in this process is obtained by optimizing the existing RDN model, compared with the existing RDN model, the complex multi-dimensional calculation processing of convolution is reduced, thereby improving the reasoning speed of the model, and thus improving the optimization efficiency of the image; at the same time, when the preset correction condition is met, the correction model is used to perform face correction processing, so that the face in the target optimized image is in a frontal face state in a preset direction, which provides guarantee and convenience for subsequent related processing based on the target optimized image; further, after obtaining the corrected image, the super-resolution model is used for optimization processing again, which avoids problems such as texture loss caused by the face correction process, and further ensures the image quality.
[0130] It should be noted that the embodiment of the image optimization device in the present application and the embodiment of the image optimization method in the present application are based on the same inventive concept, so the specific implementation of this embodiment can refer to the implementation of the corresponding image optimization method mentioned above, and the repeated parts will not be repeated.
[0131] Furthermore, corresponding to the training method of the correction model described above, based on the same technical concept, one or more embodiments of the present application also provide a training device for the correction model. Fig.10 A schematic diagram of the module composition of a training device for a correction model provided in one or more embodiments of the present application, such as Fig.10 As shown, the device comprises:
[0132] The acquisition module 401 is used to acquire a plurality of training sample images; the faces of people in the training sample images are in a side face state in a preset direction;
[0133] The training module 402 is used to input the training sample image into the model to be trained for training processing to obtain a correction model; wherein the correction model is used to perform face correction processing on the image to be corrected that meets the preset correction conditions and output a corrected image; the face in the corrected image is in a frontal state in the preset direction.
[0134] The training device of the correction model provided in the embodiment of the present application obtains multiple training sample images, and the faces in the training sample images are in a side face state in a preset direction, and performs training processing based on the training sample images to obtain the correction model, so that the correction model can be used to perform face correction processing on the to-be-corrected images that meet the preset correction conditions to obtain the corrected images, so that the faces in the corrected images are in a front face state in the preset direction, which not only solves the side face problem in the image and realizes the optimization of the image, but also provides guarantee and convenience for subsequent related processing.
[0135] It should be noted that the embodiment of the training device for the correction model in the present application and the embodiment of the training method for the correction model in the present application are based on the same inventive concept. Therefore, the specific implementation of this embodiment can refer to the implementation of the corresponding training method for the correction model mentioned above, and the repeated parts will not be repeated.
[0136] Furthermore, corresponding to the image optimization method described above, based on the same technical concept, one or more embodiments of the present application further provide an electronic device, which is used to execute the image optimization method described above. Fig.11 A schematic diagram of the structure of an electronic device provided for one or more embodiments of the present application.
[0137] like Fig.11 As shown, the electronic device may have relatively large differences due to different configurations or performances, and may include one or more processors 501 and memory 502, and the memory 502 may store one or more storage applications or data. Among them, the memory 502 can be a temporary storage or a permanent storage. The application stored in the memory 502 may include one or more modules (not shown in the figure), and each module may include a series of computer executable instructions in the electronic device. Furthermore, the processor 501 can be configured to communicate with the memory 502 to execute a series of computer executable instructions in the memory 502 on the electronic device. The electronic device may also include one or more power supplies 503, one or more wired or wireless network interfaces 504, one or more input and output interfaces 505, one or more keyboards 506, etc.
[0138] In a specific embodiment, the electronic device includes a memory and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer executable instructions for the electronic device, and the one or more programs configured to be executed by one or more processors include the following computer executable instructions:
[0139] Obtaining a face image to be optimized;
[0140] Inputting the face image into a super-resolution model for optimization processing to obtain a first super-resolution image; the super-resolution model is obtained by optimizing the RDN model;
[0141] If the face in the first super-resolution image meets the preset correction condition, the first super-resolution image is input into the correction model for face correction processing to obtain a corrected image; the face in the corrected image is in a frontal state in a preset direction;
[0142] The corrected image is input into the super-resolution model for optimization processing to obtain a second super-resolution target optimized image.
[0143] The electronic device provided by one or more embodiments of the present application inputs the face image to be optimized into the super-resolution model for optimization processing to obtain a first super-resolution image, and when the face in the first super-resolution image meets the preset correction condition, the first super-resolution image is input into the correction model for face correction processing to obtain a correction image in a frontal face state in a preset direction; and the correction image is input into the super-resolution model for optimization processing again to obtain a second super-resolution target optimized image. Since the super-resolution model used in this process is obtained by optimizing the existing RDN model, compared with the existing RDN model, the complex multi-dimensional calculation processing of convolution is reduced, thereby improving the reasoning speed of the model, thereby improving the optimization efficiency of the image; at the same time, when the preset correction condition is met, the correction model is used to perform face correction processing, so that the face in the target optimized image is in a frontal face state in a preset direction, which provides guarantee and convenience for subsequent related processing based on the target optimized image; further, after obtaining the corrected image, the super-resolution model is used for optimization processing again, avoiding problems such as texture loss caused by the face correction process, and further ensuring the image quality.
[0144] In another specific embodiment, the electronic device includes a memory and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer executable instructions for the electronic device, and the one or more programs are configured to be executed by one or more processors, including computer executable instructions for performing the following:
[0145] Acquire a plurality of training sample images; wherein the faces of people in the training sample images are in a profile state in a preset direction;
[0146] The training sample image is input into the model to be trained for training processing to obtain a correction model; wherein the correction model is used to perform face correction processing on the image to be corrected that meets the preset correction conditions to obtain a corrected image; the face in the corrected image is in a frontal state in the preset direction.
[0147] The electronic device provided in the embodiment of the present application obtains multiple training sample images, and the faces in the training sample images are in a side face state in a preset direction, and a correction model is obtained by training processing based on the training sample images. The correction model can be used to perform face correction processing on the images to be corrected that meet the preset correction conditions to obtain a corrected image, so that the faces in the corrected image are in a front face state in the preset direction. This not only solves the side face problem in the image and realizes image optimization, but also provides guarantee and convenience for subsequent related processing.
[0148] It should be noted that the embodiments of the electronic device in the present application and the embodiments of the image optimization method and the training method of the correction model in the present application are based on the same inventive concept. Therefore, the specific implementation of this embodiment can refer to the implementation of the aforementioned corresponding image optimization method and the training method of the correction model, and the repeated parts will not be repeated.
[0149] Furthermore, corresponding to the image optimization method described above, based on the same technical concept, one or more embodiments of the present application further provide a storage medium for storing computer executable instructions. In a specific embodiment, the storage medium may be a USB flash drive, an optical disk, a hard disk, etc. When the computer executable instructions stored in the storage medium are executed by the processor, the following process can be implemented:
[0150] Obtaining a face image to be optimized;
[0151] Inputting the face image into a super-resolution model for optimization processing to obtain a first super-resolution image; the super-resolution model is obtained by optimizing the RDN model;
[0152] If the face in the first super-resolution image meets the preset correction condition, the first super-resolution image is input into the correction model for face correction processing to obtain a corrected image; the face in the corrected image is in a frontal state in a preset direction;
[0153] The corrected image is input into the super-resolution model for optimization processing to obtain a second super-resolution target optimized image.
[0154] When the computer executable instructions stored in the storage medium provided by one or more embodiments of the present application are executed by the processor, the face image to be optimized is input into the super-resolution model for optimization processing to obtain a first super-resolution image, and when the face in the first super-resolution image meets the preset correction condition, the first super-resolution image is input into the correction model for face correction processing to obtain a corrected image in a frontal face state in a preset direction; and the corrected image is input into the super-resolution model for optimization processing again to obtain a second super-resolution target optimized image. Since the super-resolution model used in this process is obtained by optimizing the existing RDN model, compared with the existing RDN model, the complex multi-dimensional calculation processing of convolution is reduced, thereby improving the inference speed of the model, and thus improving the optimization efficiency of the image; at the same time, when the preset correction condition is met, the correction model is used to perform face correction processing, so that the face in the target optimized image is in a frontal face state in a preset direction, which provides guarantee and convenience for subsequent related processing based on the target optimized image; further, after obtaining the corrected image, the super-resolution model is used for optimization processing again, which avoids problems such as texture loss caused by the face correction process, and further ensures the image quality.
[0155] In another specific embodiment, the storage medium may be a USB flash drive, an optical disk, a hard disk, etc. When the computer executable instructions stored in the storage medium are executed by the processor, the following process can be implemented:
[0156] Acquire a plurality of training sample images; wherein the faces of people in the training sample images are in a profile state in a preset direction;
[0157] The training sample image is input into the model to be trained for training processing to obtain a correction model; wherein the correction model is used to perform face correction processing on the image to be corrected that meets the preset correction conditions to obtain a corrected image; the face in the corrected image is in a frontal state in the preset direction.
[0158] When the computer executable instructions stored in the storage medium provided by one or more embodiments of the present application are executed by the processor, multiple training sample images are obtained, and the faces in the training sample images are in a side face state in a preset direction, and a correction model is obtained by training processing based on the training sample images. The correction model can then be used to perform face correction processing on the images to be corrected that meet the preset correction conditions to obtain a corrected image, so that the faces in the corrected image are in a front face state in the preset direction. This not only solves the side face problem in the image and realizes image optimization, but also provides guarantee and convenience for subsequent related processing.
[0159] It should be noted that the embodiments of the storage medium in the present application and the embodiments of the image optimization method and the training method of the correction model in the present application are based on the same inventive concept. Therefore, the specific implementation of this embodiment can refer to the implementation of the aforementioned corresponding image optimization method and the training method of the correction model, and the repeated parts will not be repeated.
[0160] The above describes specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0161] In the 1990s, improvements to a technology could be clearly distinguished as hardware improvements (for example, improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the method flow). However, with the development of technology, many improvements to the method flow today can be regarded as direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement in a method flow cannot be implemented using a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask a chip manufacturer to design and produce a dedicated integrated circuit chip. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.
[0162] The controller can be implemented in any appropriate manner, for example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code manner, the controller can be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be regarded as structures within the hardware component. Or even, the devices for implementing various functions can be regarded as both software modules for implementing the method and structures within the hardware component.
[0163] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0164] For the convenience of description, the above devices are described in terms of functions and are divided into various units. Of course, when implementing the embodiments of the present application, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0165] Those skilled in the art will appreciate that one or more embodiments of the present application may be provided as methods, systems or computer program products. Therefore, one or more embodiments of the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0166] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0167] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0168] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0169] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0170] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0171] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0172] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0173] One or more embodiments of the present application may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. One or more embodiments of the present application may also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0174] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0175] The above description is only an embodiment of this document and is not intended to limit this document. For those skilled in the art, this document may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this document should be included in the scope of the claims of this document.
Claims
1. An image optimization method, characterized in that: include: Obtaining a face image to be optimized; Input the face image into the super-resolution model for optimization processing to obtain a first super-resolution image; the super-resolution model is obtained by replacing each 3*3 convolution in the RDN model with a dilated transposed convolution; in the optimization processing, the dilated transposed convolution is used to perform a preset processing on the first input image to obtain a processing result; the first input image includes the face image or the corrected image or the output image of the previous layer of the dilated transposed convolution; If the face in the first super-resolution image meets the preset correction condition, the first super-resolution image is input into the correction model for face correction processing to obtain a corrected image; the face in the corrected image is in a frontal state in a preset direction; The corrected image is input into the super-resolution model for optimization processing to obtain a second super-resolution target optimized image.
2. The method according to claim 1, characterized in that The first input image is processed by a preset process to obtain a processing result, including Using a preset sliding window matrix, and performing sliding window processing on the first input image according to a preset sliding step length, to obtain a plurality of activation areas; Performing a first conversion process on each of the activation areas to obtain a target matrix; Performing a second conversion process on the convolution kernel of the dilated transposed convolution to obtain a target vector; Perform calculation processing according to the target matrix and the target vector to obtain a calculation result; Perform a third conversion process on the calculation result to obtain a processing result, and output the processing result.
3. The method according to claim 1, characterized in that After inputting the face image into the super-resolution model for optimization processing to obtain the first super-resolution image, the method further includes: Determine whether the human face in the first super-resolution image is in a frontal state in both a first preset direction and a second preset direction; If not, it is determined that the human face in the first super-resolution image meets the preset correction condition.
4. The method according to claim 3, characterized in that The correction model includes a three-dimensional reconstruction module, a first generation module and a second generation module; In the face correction process, the three-dimensional reconstruction module is used to perform three-dimensional face reconstruction on the second input image to obtain a first three-dimensional frontal face image; the first generation module is used to generate a two-dimensional side face image according to the first three-dimensional frontal face image; the second generation module is used to generate an output image according to the first three-dimensional frontal face image and the two-dimensional side face image; Among them, if the face in the first super-resolution image is not in a frontal face state in the first preset direction or the second preset direction, the second input image processed by the 3D reconstruction module when performing 3D face reconstruction includes the first super-resolution image, and the output image of the second generation module includes the corrected image; if the face in the first super-resolution image is not in a frontal face state in both the first preset direction and the second preset direction, the second input image processed by the 3D reconstruction module when performing 3D face reconstruction is the first super-resolution image and the intermediate image corresponding to the first super-resolution image, and the output image of the second generation module is the intermediate image and the corrected image, respectively.
5. The method according to claim 4, characterized in that The step of performing three-dimensional face reconstruction on the second input image to obtain a first three-dimensional frontal face image includes: Performing texture feature processing on the second input image to obtain a first texture feature; Performing three-dimensional face reconstruction processing on the second input image to obtain a first three-dimensional side face model; Performing a first rotation on the first three-dimensional side face model in a target direction to obtain a three-dimensional front face model; wherein the target direction includes a first preset direction or a second preset direction; The first texture feature and the three-dimensional frontal face model are fused to obtain a first three-dimensional frontal face image.
6. The method according to claim 4, characterized in that The step of generating a two-dimensional side face image according to the first three-dimensional front face image comprises: Performing a second rotation on the first three-dimensional frontal face image in a target direction to obtain a first three-dimensional side face image in the target direction; the target direction includes the first preset direction or the second preset direction; Rendering the first three-dimensional side face image to obtain a two-dimensional rendered image; The two-dimensional rendered image is smoothed to obtain a two-dimensional side face image.
7. The method according to claim 4, characterized in that The step of generating an output image according to the first three-dimensional frontal face image and the two-dimensional side face image comprises: Performing texture feature processing on the two-dimensional side face image to obtain a second texture feature; Performing a second rotation on the three-dimensional frontal face model corresponding to the first three-dimensional frontal face image in a target direction to obtain a second three-dimensional side face model in the target direction; the target direction includes the first preset direction or the second preset direction; fusing the second texture feature and the second three-dimensional side face model to obtain a second three-dimensional side face image; Performing a third rotation on the second three-dimensional side face image in the target direction to obtain a second three-dimensional front face image; The second three-dimensional frontal face image is rendered to obtain an output image.
8. The method according to claim 1, characterized in that: After inputting the first super-resolution image into the correction model for face correction processing and outputting the corrected image, the method further comprises: Inputting the corrected image into a neural rendering model for neural rendering processing, and outputting a neural rendering image; Inputting the neural rendering image into a reconstruction model for reconstruction processing, and outputting a reconstructed image; The step of inputting the corrected image into the super-resolution model for optimization processing to obtain a target optimized image of a second super-resolution includes: inputting the reconstructed image into the super-resolution model for optimization processing to obtain a target optimized image of a second super-resolution.
9. A method for training a calibration model, characterized in that: include: Obtain multiple training sample images; The human face in the training sample image is in a profile state in a preset direction; The training sample image is input into the model to be trained for training processing to obtain a correction model; wherein the model to be trained includes a three-dimensional reconstruction module, a first generation module and a second generation module; during the training process, the three-dimensional reconstruction module is used to perform three-dimensional face reconstruction processing on the training sample image to obtain a first three-dimensional frontal face image; The first generation module is used to generate a two-dimensional side face image based on the first three-dimensional front face image; the second generation module is used to generate an output image based on the first three-dimensional front face image and the two-dimensional side face image, and output the output image; the correction model is used to perform face correction processing on the image to be corrected that meets the preset correction conditions to obtain a corrected image; the face in the corrected image is in a front face state in the preset direction.
10. The method according to claim 9, characterized in that If the human face in the training sample image is in a side face state in the first preset direction or the second preset direction, the output image of the second generation module includes a corrected image; if the human face in the training sample image is in a side face state in both the first preset direction and the second preset direction, the input images of the three-dimensional reconstruction module processed by the three-dimensional reconstruction module when performing three-dimensional face reconstruction are respectively the training sample image and the intermediate image corresponding to the training sample image, and the output images of the second generation module are respectively the intermediate image and the corrected image.
11. An image optimization device, characterized in that: include: An acquisition module, used for acquiring a face image to be optimized; A first optimization module is used to input the face image into the super-resolution model for optimization processing to obtain a first super-resolution image; the super-resolution model is obtained by replacing each 3*3 convolution in the RDN model with a dilated transposed convolution; in the optimization processing, the dilated transposed convolution is used to perform a preset processing on the first input image to obtain a processing result; the first input image includes the face image or the corrected image or the output image of the previous layer of the dilated transposed convolution; A correction module, configured to input the first super-resolution image into a correction model to perform face correction processing to obtain a corrected image if the face in the first super-resolution image meets a preset correction condition; the face in the corrected image is in a frontal state in a preset direction; The second optimization module is used to input the corrected image into the super-resolution model for optimization processing to obtain a second super-resolution target optimized image.
12. A training device for a calibration model, characterized in that: include: An acquisition module, used for acquiring multiple training sample images; The human face in the training sample image is in a profile state in a preset direction; A training module, used for inputting the training sample image into the model to be trained for training processing to obtain a correction model; wherein the model to be trained includes a three-dimensional reconstruction module, a first generation module and a second generation module; during the training processing, the three-dimensional reconstruction module is used for performing three-dimensional face reconstruction processing on the training sample image to obtain a first three-dimensional frontal face image; The first generation module is used to generate a two-dimensional side face image based on the first three-dimensional front face image; the second generation module is used to generate an output image based on the first three-dimensional front face image and the two-dimensional side face image, and output the output image; the correction model is used to perform face correction processing on the image to be corrected that meets the preset correction conditions, and output the corrected image; the face in the corrected image is in a front face state in the preset direction.
13. An electronic device, comprising: processor; as well as, A memory arranged to store computer executable instructions, the executable instructions being configured to be executed by the processor, the executable instructions comprising instructions for executing the steps in the method according to any one of claims 1 to 8, or the executable instructions comprising instructions for executing the steps in the method according to claims 9 to 10.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store computer-executable instructions, wherein the executable instructions enable a computer to execute the method according to any one of claims 1 to 8, or the executable instructions enable a computer to execute the method according to claims 9 to 10.
