Image high-quality harmonization model training and device
Through the image high-quality harmonization model training method, the generative adversarial network is used to fuse multi-scale image features and face prior features, which solves the problem of forgery trace repair during the expression migration process, improves the attack capability of face attack materials, and achieves Generation of high-quality images and efficient attacks on face recognition algorithms.
Patent Information
- Application Number
- PCT/CN2023/141798
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-03-10
- Filing Date
- 2023-12-26
- Publication Date
- 2024-09-19
AI Technical Summary
Existing face activation attack material generation methods are difficult to repair forgery traces during the expression migration process, resulting in low quality of generated images and inability to effectively attack face recognition algorithms.
Using the image high-quality harmonization model training method, through the generative adversarial network including the discriminant network and the generative network, multi-scale image features are extracted and fused with face prior features, decoded to generate high-quality reconstructed images, repair traces of forgery, and improve the accuracy of attack materials. Attack rate.
Through multi-scale feature fusion and weighting, high-fidelity high-definition images are restored, enhancing the attack capabilities of face attack materials, and effectively breaking through the gap in face recognition algorithms.
Smart Images

Figure CN2023141798_19092024_PF_FP_ABST
Abstract
Description
A high-quality image harmonization model training and device Technical Field
[0001] The embodiments of this specification relate to an image processing method, and more particularly to a method for high-quality image harmonization. Background Art
[0002] Mobile phones have become an essential communication tool for everyone today. With the development of technology, the way of using mobile phones for identity authentication has evolved from passwords to fingerprints to faces, and the security of mobile phones and other devices is also facing challenges from all aspects.
[0003] IIFAA biometric attack detection requires intelligent generation of sufficiently realistic facial attack materials to conduct security assessments of mobile phone authentication functions, ensuring the completeness and effectiveness of facial security assessments. This attack method must be universal, demonstrating stable attack power across various mobile phone black box tests. It must also have a high attack rate, effectively narrowing the gap in facial recognition algorithms between different mobile phone manufacturers under test. Furthermore, this attack method must be intelligently generated through an algorithm, distinct from physical generation or common Photoshop methods, to enhance model interpretability.
[0004] Among the current mainstream methods for generating face animation attack materials, some, such as the FOMM algorithm, generate attack materials based on 2D keypoint expression migration. However, during the attack process, mainstream face recognition algorithms require a high resolution to achieve the desired high attack rate.
[0005] In view of this, we hope to obtain a method for high-quality image harmonization, which can repair the forgery traces produced during the expression migration process and improve the quality of the generated image, so that the obtained face attack material can effectively attack the face recognition algorithm.
[0006] Summary of the Invention
[0007] One of the purposes of the embodiments of this specification is to provide a high-quality image harmonization model training method, which can improve the quality of images, such as the quality of generated images obtained by expression migration, and repair the forgery traces produced during the expression migration process, so that the obtained face attack materials have a higher attack rate.
[0008] According to the above purpose, the embodiment of this specification proposes a method for training a high-quality image harmonization model, wherein the high-quality harmonization model is a generative adversarial network, including a discriminant network and a generative network, and the generative network includes an encoder, a fusion module and a decoder. The method includes: obtaining a high-quality sample image; converting the high-quality sample image into a low-quality sample image; inputting the low-quality sample image into the generative network, and extracting the multi-scale image features of the low-quality sample image through the encoder; fusing the multi-scale image features and the pre-acquired face prior features through the fusion module to obtain fused features; decoding the fused features through the decoder to obtain a high-quality reconstructed image corresponding to the low-quality sample image; calculating the generation loss based on the high-quality reconstructed image and the high-quality sample image; using the discriminant network to determine whether the high-quality reconstructed image is the high-quality sample image; calculating the discrimination loss based on the discrimination result of the discriminant network; training the discriminant network with the goal of minimizing the discrimination loss; training the generative network with the goal of minimizing the generation loss.
[0009] In the embodiments of this specification, extracting multi-scale image features can obtain feature information of the image from various aspects. Then, by fusing prior facial features, it is possible to express image features more comprehensively and accurately, thereby decoding and restoring highly realistic and high-quality image data, and repairing the forgery traces produced during the expression migration process, so that the obtained facial attack material can effectively attack the face recognition algorithm.
[0010] Furthermore, in an embodiment of the present specification, the facial prior features include multi-scale facial features; the multi-scale image features and the pre-acquired facial prior features are fused through the fusion module, specifically including: for each scale, fusing the image features of that scale with the facial features of that scale.
[0011] Furthermore, in an embodiment of the present specification, the encoder extracts multi-scale image features of the low-quality sample image, specifically including: for each scale, extracting the image features of the low-quality sample image at that scale and the weights corresponding to the image features at that scale through the encoder, the weights being used to characterize the importance of the image features at that scale for decoding to obtain a high-quality reconstructed image; fusing the image features of the scale with the facial features of the scale, specifically including: splicing the image features of the scale and the facial features of the scale to obtain spliced features; and weighting the spliced features by the weights corresponding to the image features of the scale to obtain the fused features of the scale.
[0012] When performing feature fusion, weights are introduced to represent the feature expression contribution values of different feature dimensions at each scale. For example, color information can better express image features, so it is assigned a higher weight; these weights constitute the latent vector c, which acts as a regulator to edit the contribution value of each feature dimension, strengthening the influence of important feature information and weakening the effect of insignificant feature information, so that the fused features can more accurately and comprehensively represent the image, thereby restoring a more realistic high-definition image.
[0013] Furthermore, in the embodiments of this specification, a fusion module constructed using the generative network of the styleGAN2 network is used to pre-acquire prior facial features.
[0014] Furthermore, in the embodiment of this specification, with the goal of minimizing the generation loss, training the generation network specifically includes: with the goal of minimizing the generation loss, training the encoder and decoder of the generation network.
[0015] Furthermore, in an embodiment of the present specification, calculating the generation loss based on the high-quality reconstructed image and the high-quality sample image specifically includes: in the spatial domain, based on the high-quality reconstructed image and the high-quality sample image, calculating the spatial mean square error loss of the two, and using it as the generation loss.
[0016] Furthermore, calculating the generation loss based on the high-quality reconstructed image and the high-quality sample image specifically includes: in the spatial domain, calculating the spatial mean square error loss of the high-quality reconstructed image and the high-quality sample image based on the high-quality reconstructed image and the high-quality sample image; in the frequency domain, transforming the high-quality reconstructed image and the high-quality sample image and performing corresponding inverse transformations, and calculating the frequency domain mean square error loss of the high-quality reconstructed image and the high-quality sample image based on the transformed high-quality reconstructed image and the transformed high-quality sample image; in the feature space, calculating the feature mean square error loss of the high-quality reconstructed image and the high-quality sample image based on their feature mappings; and weightedly fusing the spatial mean square error loss, frequency domain mean square error loss and feature mean square error loss as the generation loss.
[0017] Another purpose of the embodiments of this specification is to provide a method for improving the quality of biological images. This method improves the quality of biological images, for example, it can repair the forgery traces produced during the migration of expression, improve the quality of images in face attack materials, and thus can be effectively used to attack face recognition algorithms.
[0018] In accordance with the above-mentioned purpose, an embodiment of the present specification provides a method for improving the quality of biological images, the method comprising: obtaining a low-quality original biological image to be processed; inputting the low-quality original biological image into a generation network of a pre-trained high-quality harmonization model to obtain a high-quality image, wherein the high-quality harmonization model is trained using the image high-quality harmonization model training method described above.
[0019] Another purpose of the embodiments of this specification is to provide a high-quality image harmonization model training device, which can improve the quality of the image, such as improving the quality of the generated image obtained by expression migration, repairing the forgery traces produced during the expression migration process, so that the obtained face attack material has a higher attack rate.
[0020] According to the above purpose, an embodiment of this specification provides an image high-quality harmonization model training device, which includes: a sample processing module for obtaining high-quality sample images and converting the high-quality sample images into low-quality sample images; a generation module for inputting the low-quality sample images into the generation network, and extracting the multi-scale image features of the low-quality sample images through the encoder; fusing the multi-scale image features and the pre-acquired face prior features through the fusion module to obtain fused features; decoding the fused features through the decoder to obtain a high-quality reconstructed image corresponding to the low-quality sample image; a training module for calculating the generation loss based on the high-quality reconstructed image and the high-quality sample image; using the discriminant network to determine whether the high-quality reconstructed image is the high-quality sample image; calculating the discriminant loss based on the discrimination result of the discriminant network; training the discriminant network with the goal of minimizing the discriminant loss; and training the generation network with the goal of minimizing the generation loss.
[0021] Furthermore, in an embodiment of the present specification, the facial prior features include multi-scale facial features; the generation module fuses the multi-scale image features and the pre-acquired facial prior features through the fusion module, specifically including: for each scale, fusing the image features of that scale with the facial features of that scale.
[0022] Furthermore, in an embodiment of the present specification, the generation module extracts, for each scale, the image features of the low-quality sample image at the scale and the weights corresponding to the image features at the scale through the encoder, and the weights are used to characterize the importance of the image features at the scale for decoding to obtain a high-quality reconstructed image; the generation module fuses the image features of the scale with the facial features of the scale, specifically including: splicing the image features of the scale and the facial features of the scale to obtain spliced features; and weighting the spliced features by the weights corresponding to the image features of the scale to obtain the fused features of the scale.
[0023] Furthermore, in the embodiments of this specification, a fusion module constructed using the generative network of the styleGAN2 network is used to pre-acquire prior facial features.
[0024] Furthermore, in the embodiment of this specification, the training module trains the encoder and decoder of the generation network with the goal of minimizing the generation loss.
[0025] Furthermore, in an embodiment of the present specification, the training module calculates the spatial mean square error loss of the high-quality reconstructed image and the high-quality sample image in the spatial domain, and uses it as the generation loss.
[0026] Furthermore, in an embodiment of the present specification, the training module calculates the spatial mean square error loss of the high-quality reconstructed image and the high-quality sample image in the spatial domain; the training module transforms the high-quality reconstructed image and the high-quality sample image and performs corresponding inverse transformations in the frequency domain, and calculates the frequency domain mean square error loss of the high-quality reconstructed image and the high-quality sample image after transformation; the training module calculates the feature mean square error loss of the high-quality reconstructed image and the high-quality sample image in the feature space based on the feature mapping of the high-quality reconstructed image and the high-quality sample image; the training module weightedly fuses the spatial mean square error loss, frequency domain mean square error loss and feature mean square error loss as the generated loss.
[0027] Another purpose of the embodiments of this specification is to provide a device for improving the quality of biological images, which can repair the forgery traces produced during the expression migration process, improve the quality of images in face attack materials, and thus effectively attack face recognition algorithms.
[0028] In accordance with the above-mentioned purpose, an embodiment of the present specification provides a device for improving the quality of biological images, the device comprising: an acquisition module for acquiring low-quality original biological images to be processed; an image processing module for inputting the low-quality original biological images into a generation network of a pre-trained high-quality harmonization model to obtain high-quality images, wherein the high-quality harmonization model is trained using the image high-quality harmonization model training method described above.
[0029] Another object of an embodiment of this specification is to provide a computer-readable storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the image high-quality and harmonized model training method described above are implemented.
[0030] Another object of an embodiment of the present specification is to provide an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the image high-quality and harmonized model training method as described above are implemented.
[0031] The high-quality image harmonization model training method described in the embodiments of this specification has the following beneficial effects: the extracted multi-scale image features can obtain feature information of the image from all aspects, and then by fusing the facial prior features, the image features can be expressed more comprehensively and accurately, thereby decoding and restoring high-fidelity and high-quality image data, and can repair the forgery traces produced during the expression migration process, so that the obtained facial attack materials can effectively attack the face recognition algorithm.
[0032] When performing feature fusion, weights are introduced to represent the feature expression contribution values of different feature dimensions at each scale; these weights constitute the latent vector c, which acts as a regulator to edit the contribution value of each feature dimension, strengthen the influence of important feature information, and weaken the effect of insignificant feature information, so that the fused features can more accurately and comprehensively represent the image, thereby restoring a more realistic high-definition image. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] FIG1 exemplarily shows the steps of a method for using an image high-quality harmonization model according to an embodiment of this specification, performed in one implementation manner.
[0034] FIG2 exemplarily shows a flowchart of a method for training a high-quality image harmonization model according to an embodiment of this specification in one implementation manner.
[0035] FIG3 exemplarily shows the steps performed by the fusion module in the image high-quality harmonization model according to an embodiment of this specification under one implementation manner.
[0036] FIG4 exemplarily shows a flow chart of a method for improving the quality of biological images described in an embodiment of this specification in one implementation manner.
[0037] FIG5 exemplarily shows a structural diagram of an image high-quality harmonization model training device according to an embodiment of this specification in one implementation manner.
[0038] FIG6 exemplarily shows a schematic structural diagram of an apparatus for improving the quality of biological images according to an embodiment of this specification, in one implementation manner. DETAILED DESCRIPTION
[0039] The method and apparatus for training and using a high-quality image harmonization model according to the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. However, such detailed description does not constitute a limitation to the present invention.
[0040] FIG1 exemplarily shows the steps of a method for using an image high-quality harmonization model according to an embodiment of this specification, performed in one implementation manner.
[0041] As shown in Figure 1, in one embodiment, the low-quality sample image obtained after the expression migration is completed is input into the generative network of the image high-quality harmonization model, and the multi-scale image features and the weights corresponding to the image features at each scale are first extracted by the encoder. These weights constitute the latent vector c, which is used to characterize the importance of the image features at each scale for decoding to obtain a high-quality reconstructed image; then the generative network of the styleGAN2 network is used to pre-acquire the facial prior features, and the image features are fused with the facial prior features at each scale, and the latent vector c is used for weighting to obtain the fused features at each scale; the fused features are then input into the decoder for decoding to obtain a high-quality reconstructed image, thereby obtaining a highly realistic and harmonized face activation image for attack testing of the face recognition algorithm.
[0042] In one embodiment of the present specification, a method for training a high-quality image harmonization model is proposed. FIG2 exemplarily shows a flow chart of the method for training a high-quality image harmonization model according to an embodiment of the present specification in one embodiment.
[0043] As shown in FIG2 , the high-quality harmonization model is a generative adversarial network, including a discriminative network and a generative network. The generative network includes an encoder, a fusion module, and a decoder. The specific method includes steps 100 to 116 .
[0044] 100: Get high-quality sample images.
[0045] In one embodiment, facial images are used as sample images for model training to facilitate the illustration of the solution. However, the methods and apparatus provided in the embodiments of this specification are not limited to the field of facial images. The high-quality sample images can be obtained from publicly available datasets or collected using image acquisition equipment.
[0046] 102: Convert the high-quality sample image into a low-quality sample image.
[0047] The process of converting a high-quality sample image into a low-quality sample image can be considered an image blurring process, employing an image blurring algorithm from image processing methods. Since an image is composed of a number of pixels, the number and value of these pixels determine the user's perception of the image. Image blurring can be understood as reducing the difference between adjacent pixel values, thereby weakening the image's edges and details.
[0048] In some more specific embodiments, mean blur, median blur and Gaussian blur may be used to perform image blurring processing, thereby converting a high-quality sample image into a low-quality sample image.
[0049] 104: Input the low-quality sample image into the generative network, and extract the multi-scale image features of the low-quality sample image through the encoder.
[0050] The encoder can be a general feature extraction network that can extract image features at different feature dimensions at various resolutions (i.e., at various scales). In some specific embodiments, similar network models such as Unet, ShuffleNet, and RRDBnet can be used as image feature encoders. Of course, in other embodiments, Transformer can also be used for image feature encoding.
[0051] Multi-scale image features can represent, for example, the characteristics of a single eye or the entire face; different feature dimensions can include, for example, texture and color; and multi-scale refers to multiple different resolutions. By extracting multi-scale image features from sample images, this implementation can comprehensively and accurately capture all aspects of image detail and overall information, facilitating improved fidelity in subsequent high-quality image reconstruction.
[0052] 106: The multi-scale image features and the pre-acquired face prior features are fused through the fusion module to obtain fused features.
[0053] Facial prior features can be learned by training a general feature extraction network on a large number of existing face databases. They represent the natural attributes of the face. In other words, facial prior features represent the inherent commonalities of facial structure. They are generally divided into geometric face priors and face reference images. Geometric face priors include features such as facial feature proportions, facial key points, and facial heatmaps. Face reference images are selected from the database to select identical or similar faces as references for face restoration.
[0054] In some embodiments, a fusion module constructed using the generative network of the styleGAN2 network may be used to pre-acquire prior facial features.
[0055] In the embodiments of this specification, the generative network part of the styleGAN2 network is used. The styleGAN2 network has been pre-trained and has strong feature representation capabilities. It can obtain prior facial features by learning big facial data in order to receive multi-scale image features extracted and sent by the encoder and perform feature fusion.
[0056] In some embodiments, the facial prior features include multi-scale facial features; the multi-scale image features and the pre-acquired facial prior features are fused through a fusion module, specifically including: for each scale, fusing the image features of that scale with the facial features of that scale.
[0057] In some more specific embodiments, multi-scale image features of low-quality sample images are extracted through an encoder, specifically including: for each scale, extracting through an encoder the image features of the low-quality sample image at that scale and the weights corresponding to the image features at that scale, the weights being used to characterize the importance of the image features at that scale for decoding to obtain a high-quality reconstructed image; fusing the image features at that scale with the facial features at that scale, specifically including: splicing the image features at that scale and the facial features at that scale to obtain spliced features; weighting the spliced features by the weights corresponding to the image features at that scale to obtain the fused features at that scale.
[0058] FIG3 exemplarily shows the steps performed by the fusion module in the image high-quality harmonization model according to an embodiment of this specification under one implementation manner.
[0059] As shown in Figure 3, E0, E1, E2, and E3 represent image features at different scales; S0, S1, S2, S3, and S4 represent facial features at different scales; V0, V1, V2, V3, and V4 represent the corresponding weights, which constitute the latent vector c; Win and Hin represent the width and height of the image, i.e., scale information. The input is a low-quality sample image, from which the encoder extracts multi-scale image features E0, E1, E2, and E3. These are concatenated with the facial features S0, S1, S2, and S3 at the corresponding scales. The concatenated features are then weighted using the weights V0, V1, V2, and V3 corresponding to the image features at each scale, resulting in a fused feature S4. This is then weighted using the corresponding weight V4 and fed into the decoder for decoding, outputting a high-quality reconstructed image.
[0060] In the embodiments of this specification, when performing feature fusion, weights are introduced to represent the feature expression contribution values of different feature dimensions at each scale. For example, color information can better express image features, so it is assigned a higher weight; these weights constitute a latent vector c, which acts as a regulator to edit the contribution values of each feature dimension, strengthen the influence of important feature information, and weaken the effect of insignificant feature information, so that the fused features can more accurately and comprehensively represent the image, thereby restoring a more realistic high-definition image.
[0061] It should be noted that, assuming that the size of the multi-scale image features and the face prior features are both the length C of the latent vector, the size of the fused features obtained by splicing and weighting the two becomes 2C. In order to adapt to the scale specified by the model and ensure the normal operation of the model, the fused features can be reduced in dimension so that the size of the fused features is reduced to C.
[0062] 108: Decode the fused features through a decoder to obtain a high-quality reconstructed image corresponding to the low-quality sample image.
[0063] In some implementations, the decoder can be a general image generation network. In some specific embodiments, a ResNet combined with downsampling or deconvolution can be used for decoding, fully utilizing the acquired features to restore the sample image from feature space to pixel space, thereby obtaining a high-quality restored image. Of course, in other embodiments, a Transformer can also be used for image feature decoding.
[0064] 110: Calculate the generation loss based on the high-quality reconstructed image and the high-quality sample image.
[0065] The generation loss can reflect the similarity between the high-quality reconstructed image generated by the image high-quality harmonization model and the original high-quality sample image. The larger the generation loss, the greater the gap between the two; the smaller the generation loss, the more similar the two are.
[0066] In some embodiments, in the spatial domain, a spatial mean square error loss between the high-quality reconstructed image and the high-quality sample image is calculated and used as the generation loss.
[0067] The generation loss can be expressed as the square of the pixel-by-pixel difference between the high-quality reconstructed image and the high-quality sample image:
[0068] in, represents the spatial mean square error loss; r represents the number of images, W and H represent the width and height of the high-quality reconstructed image or high-quality sample image, respectively, and the three can be regarded as constants; x and y are the horizontal and vertical coordinates of the pixel point; Represents a high-quality sample image; I LR Represents a low-quality sample image; Represents a low-quality sample image I LR The corresponding high-quality reconstructed image; θ σ are model parameters.
[0069] In the process of training the high-quality image harmonization model, the calculation of the spatial mean square error loss should at least be included to train the generative network as the generation loss.
[0070] In some other embodiments, calculating the generation loss based on the high-quality reconstructed image and the high-quality sample image specifically includes: in the spatial domain, calculating the spatial mean square error loss of the high-quality reconstructed image and the high-quality sample image based on the high-quality reconstructed image and the high-quality sample image; in the frequency domain, transforming the high-quality reconstructed image and the high-quality sample image and performing the corresponding inverse transformation, and calculating the frequency domain mean square error loss of the high-quality reconstructed image and the high-quality sample image based on the transformed high-quality reconstructed image and the transformed high-quality sample image; in the feature space, calculating the feature mean square error loss of the high-quality reconstructed image and the high-quality sample image based on their feature mapping; and weightedly fusing the spatial mean square error loss, the frequency domain mean square error loss and the feature mean square error loss as the generation loss.
[0071] In some more specific embodiments, the high-quality reconstructed image and the high-quality sample image are subjected to a discrete cosine transform (DCT) and a corresponding inverse transform in the frequency domain, and the frequency-domain mean square error loss between the two images is calculated based on the transformed images. More specifically, the use of a secondary DCT transform and a corresponding inverse transform ensures the similarity between the high-quality reconstructed image and the high-quality sample image in the frequency domain, thereby improving the model training quality and image generation quality.
[0072] Of course, in other more specific implementations, in the frequency domain, the high-quality reconstructed image and the high-quality sample image can be Fourier transformed and inversely transformed respectively, and then the frequency domain mean square error loss of the two can be calculated based on the transformed images.
[0073] In some more specific embodiments, a pre-trained VGG model is used to perform feature mapping on the high-quality reconstructed image and the high-quality sample image. The high-quality reconstructed image and the high-quality sample image are respectively input into the VGG model, and the feature map of a certain layer in the output results of the two are extracted and compared pixel by pixel to obtain the feature mean square error loss. This ensures that the high-quality reconstructed image and the high-quality sample image have a certain degree of similarity in the feature space.
[0074] It should be noted that during the model training process, the weight of each loss can be adjusted by observing the impact of the above three losses on the model training effect, so as to continuously update the generation loss, so that the generation loss can better reflect the high quality of the image and the ability of the harmonized model to generate high-quality reconstructed images, thereby accelerating the training efficiency.
[0075] 112: Use a discriminant network to determine whether a high-quality reconstructed image is a high-quality sample image.
[0076] 114: Calculate the discrimination loss based on the discrimination results of the discriminant network.
[0077] In some embodiments, the discriminative loss is calculated as follows:
[0078] in, represents the discrimination loss; I LR Represents a low-quality sample image; Represents a low-quality sample image I LR The corresponding high-quality reconstructed image; is the discrimination result of the discriminant network for high-quality reconstructed images; θ D and θ G is a model parameter; n is the sequence number of the high-quality reconstructed image, and N is the number of high-quality reconstructed images.
[0079] 116: With the goal of minimizing the discriminative loss, train the discriminative network; with the goal of minimizing the generative loss, train the generative network.
[0080] In some embodiments, the encoder and decoder of the generative network are trained with the goal of minimizing the generation loss.
[0081] It should be noted that in the high-quality image harmonization model described in the embodiments of this specification, the generative network of styleGAN2 used to constitute the fusion module is pre-trained and is used to obtain the prior features of the face. The prior features of the face will not change after they are obtained. Therefore, the parameters in the fusion module do not participate in the update during the model training process.
[0082] In some more specific embodiments, in the frequency domain, the high-quality reconstructed image and the high-quality sample image are subjected to discrete cosine transform (DCT) and the corresponding inverse transform, and the frequency domain mean square error loss between the two images is calculated based on the transformed images. More specifically, a secondary DCT transform and the corresponding inverse transform are used.
[0083] The DCT transform converts blocks of original image information into sets of coefficients representing different frequency components. This allows for appropriate allocation of memory based on the concentration of signals within the frequency domain, such as allocating more bits to areas with high signal concentration and fewer bits to less important areas. Furthermore, because images are two-dimensional, the DCT secondary transform is more appropriate and more commonly used than the DCT primary transform.
[0084] In some embodiments, the high-quality reconstructed image and the high-quality sample image are collectively referred to as a facial image. A DCT secondary transform is performed on these images to obtain coefficient sets representing different frequency components in the frequency domain. Each coefficient set is then subjected to an inverse DCT secondary transform to obtain a corresponding image set representing different frequency components in the spatial domain. According to this method, the high-quality reconstructed image and the high-quality sample image are subjected to a DCT secondary transform and the corresponding inverse transform, respectively, and the frequency domain mean square error loss DCTLoss between the two is calculated according to the following formula:
[0085] Among them, D -1 (D(I HR )) x,y It is the data obtained by performing DCT secondary transformation and corresponding inverse transformation on high-quality sample images; It is the data obtained by performing DCT secondary transformation and corresponding inverse transformation on the high-quality reconstructed image; HR Represents a high-quality sample image; I LR Represents a low-quality sample image; Represents a low-quality sample image I LR The corresponding high-quality reconstructed image; θ c are model parameters; W and H represent the width and height of the high-quality reconstructed image or high-quality sample image, respectively.
[0086] By calculating the mean square error loss in the frequency domain, the similarity between the high-quality reconstructed image and the high-quality sample image in the frequency domain is ensured, thereby improving the training quality of the model and the image generation quality.
[0087] In some more specific embodiments, a pre-trained VGG model is used to perform feature mapping on the high-quality reconstructed image and the high-quality sample image, and the feature mean square error loss of the two is calculated. The high-quality reconstructed image and the high-quality sample image are respectively input into the VGG model, and the feature map of a certain layer in the output results of the two is extracted and compared pixel by pixel, as shown in the following formula:
[0088] in, represents the feature mean square error loss; φ i,j Represents the feature map of the jth convolution before the i-th maximum pooling layer in the VGG model, W i,j and H i,j I represents the width and height of the feature map corresponding to the high-quality reconstructed image or high-quality sample image respectively; HR Represents a high-quality sample image; I LR Represents a low-quality sample image; Represents a low-quality sample image I LR The corresponding high-quality reconstructed image; θ c are model parameters.
[0089] By calculating the feature mean square error loss, the high-quality reconstructed image and the high-quality sample image also have a certain degree of similarity in the feature space.
[0090] The embodiments of this specification extract multi-scale image features, which can obtain feature information of the image from various aspects. By fusing the prior features of the face, the image features can be expressed more comprehensively and accurately, thereby decoding and restoring high-fidelity, high-quality image data. It can also repair the forgery traces produced during the expression migration process, so that the obtained face attack materials can effectively attack the face recognition algorithm. When performing feature fusion, weights are introduced to represent the feature expression contribution value of different feature dimensions at each scale. The weights act as regulators, strengthening the influence of important feature information and weakening the effect of insignificant feature information, so that the fused features can more accurately and comprehensively represent the image, thereby restoring a more realistic high-definition image.
[0091] In another embodiment of the present specification, a method for improving the quality of biological images is proposed. FIG4 exemplarily shows a flow chart of the method for improving the quality of biological images described in an embodiment of the present specification in one implementation manner.
[0092] As shown in Figure 4, the method specifically includes: 200: obtaining a low-quality original biological image to be processed; 202: inputting the low-quality original biological image into the generation network of a pre-trained high-quality harmonization model to obtain a high-quality image, and the high-quality harmonization model is trained using the image high-quality harmonization model training method described above.
[0093] When obtaining low-quality original biological images to be processed, you can directly input the images by installing a local image acquisition device, or you can retrieve the images from a remote image acquisition device in the cloud, or retrieve a pre-prepared image set from the cloud directly as model input.
[0094] The generative network of the high-quality harmonization model trained in the embodiments of this specification can be used to restore image quality after expression migration. By extracting multi-scale image features and fusing them with facial prior features through pre-trained weights, high-quality images are generated and traces of expression forgery are repaired.
[0095] In one embodiment of the present specification, a high-quality image harmonization model training device is proposed. FIG5 exemplarily shows a structural diagram of the high-quality image harmonization model training device described in the embodiment of the present specification under one implementation manner.
[0096] As shown in Figure 5, the device includes: a sample processing module 30, which is used to obtain a high-quality sample image and convert the high-quality sample image into a low-quality sample image; a generation module 32, which is used to input the low-quality sample image into the generation network and extract the multi-scale image features of the low-quality sample image through the encoder; the multi-scale image features and the pre-acquired face prior features are fused through the fusion module to obtain the fused features; the fused features are decoded through the decoder to obtain a high-quality reconstructed image corresponding to the low-quality sample image; a training module 34, which is used to calculate the generation loss based on the high-quality reconstructed image and the high-quality sample image; a discriminant network is used to determine whether the high-quality reconstructed image is a high-quality sample image; the discriminant loss is calculated based on the discrimination result of the discriminant network; the discriminant network is trained with the goal of minimizing the discriminant loss; and the generation network is trained with the goal of minimizing the generation loss.
[0097] In the sample processing module, high-quality sample images can come from publicly available datasets that can be directly obtained, or they can be collected by image acquisition equipment.
[0098] The process of converting a high-quality sample image into a low-quality sample image can be considered an image blurring process, employing an image blurring algorithm from image processing methods. Since an image is composed of a number of pixels, the number and value of these pixels determine the perceived quality of the image to the user. Image blurring can be understood as reducing the difference between adjacent pixel values, thereby weakening the image's edges and details. In more specific embodiments, mean blurring, median blurring, and Gaussian blurring can be employed to perform image blurring, thereby converting a high-quality sample image into a low-quality sample image.
[0099] In the generation module, the encoder can be a general feature extraction network that can extract image features at different feature dimensions at various resolutions (i.e., at various scales). In some specific embodiments, similar network models such as Unet, ShuffleNet, and RRDBnet can be used as image feature encoders. Of course, in other embodiments, Transformer can also be used for image feature encoding.
[0100] Multi-scale image features can represent, for example, the characteristics of a single eye or the entire face; different feature dimensions can include, for example, texture and color; and multi-scale refers to multiple different resolutions. By extracting multi-scale image features from sample images, this implementation can comprehensively and accurately capture all aspects of image detail and overall information, facilitating improved fidelity in subsequent high-quality image reconstruction.
[0101] Facial prior features can be learned by training a general feature extraction network on a large number of existing face databases. They represent the natural attributes of the face. In other words, facial prior features represent the inherent commonalities of facial structure. They are generally divided into geometric face priors and face reference images. Geometric face priors include features such as facial feature proportions, facial key points, and facial heatmaps. Face reference images are selected from the database to select identical or similar faces as references for face restoration.
[0102] In some embodiments, a fusion module constructed using the generative network of the styleGAN2 network may be used to pre-acquire prior facial features.
[0103] In the embodiments of this specification, the generative network part of the styleGAN2 network is used. The styleGAN2 network has been pre-trained and has strong feature representation capabilities. It can obtain prior facial features by learning big facial data in order to receive multi-scale image features extracted and sent by the encoder and perform feature fusion.
[0104] In some embodiments, the facial prior features include multi-scale facial features; the multi-scale image features and the pre-acquired facial prior features are fused through a fusion module, specifically including: for each scale, fusing the image features of that scale with the facial features of that scale.
[0105] In some more specific embodiments, multi-scale image features of low-quality sample images are extracted through an encoder, specifically including: for each scale, extracting through an encoder the image features of the low-quality sample image at that scale and the weights corresponding to the image features at that scale, the weights being used to characterize the importance of the image features at that scale for decoding to obtain a high-quality reconstructed image; fusing the image features at that scale with the facial features at that scale, specifically including: splicing the image features at that scale and the facial features at that scale to obtain spliced features; weighting the spliced features by the weights corresponding to the image features at that scale to obtain the fused features at that scale.
[0106] In the embodiments of this specification, when performing feature fusion, weights are introduced to represent the feature expression contribution values of different feature dimensions at each scale. For example, color information can better express image features, so it is assigned a higher weight; these weights constitute a latent vector c, which acts as a regulator to edit the contribution values of each feature dimension, strengthen the influence of important feature information, and weaken the effect of insignificant feature information, so that the fused features can more accurately and comprehensively represent the image, thereby restoring a more realistic high-definition image.
[0107] In some implementations, the decoder can be a general image generation network. In some specific embodiments, a ResNet combined with downsampling or deconvolution can be used for decoding, fully utilizing the acquired features to restore the sample image from feature space to pixel space, thereby obtaining a high-quality restored image. Of course, in other embodiments, a Transformer can also be used for image feature decoding.
[0108] In the training module, the generation loss can reflect the degree of similarity between the high-quality reconstructed image generated by the image high-quality harmonization model and the original high-quality sample image. The larger the generation loss, the greater the gap between the two; the smaller the generation loss, the more similar the two are.
[0109] In some embodiments, in the spatial domain, a spatial mean square error loss between the high-quality reconstructed image and the high-quality sample image is calculated and used as the generation loss.
[0110] The generation loss can be expressed as the square of the pixel-by-pixel difference between the high-quality reconstructed image and the high-quality sample image:
[0111] in, represents the spatial mean square error loss; r represents the number of images, W and H represent the width and height of the high-quality reconstructed image or high-quality sample image, respectively, and the three can be regarded as constants; x and y are the horizontal and vertical coordinates of the pixel point; Represents a high-quality sample image; I LR Represents a low-quality sample image; represents the high-quality reconstructed image corresponding to the low-quality sample image; θ σ are model parameters.
[0112] In the process of training the high-quality image harmonization model, the calculation of the spatial mean square error loss should at least be included to train the generative network as the generation loss.
[0113] In some other embodiments, calculating the generation loss based on the high-quality reconstructed image and the high-quality sample image specifically includes: in the spatial domain, calculating the spatial mean square error loss of the high-quality reconstructed image and the high-quality sample image based on the high-quality reconstructed image and the high-quality sample image; in the frequency domain, transforming the high-quality reconstructed image and the high-quality sample image and performing the corresponding inverse transformation, and calculating the frequency domain mean square error loss of the high-quality reconstructed image and the high-quality sample image based on the transformed high-quality reconstructed image and the transformed high-quality sample image; in the feature space, calculating the feature mean square error loss of the high-quality reconstructed image and the high-quality sample image based on their feature mapping; and weightedly fusing the spatial mean square error loss, the frequency domain mean square error loss and the feature mean square error loss as the generation loss.
[0114] In some more specific embodiments, in the frequency domain, the high-quality reconstructed image and the high-quality sample image are subjected to discrete cosine transform (DCT) and the corresponding inverse transform, and the frequency domain mean square error loss between the two images is calculated based on the transformed images. More specifically, a secondary DCT transform and the corresponding inverse transform are used.
[0115] The DCT transform converts blocks of original image information into sets of coefficients representing different frequency components. This allows for appropriate allocation of memory based on the concentration of signals within the frequency domain, such as allocating more bits to areas with high signal concentration and fewer bits to less important areas. Furthermore, because images are two-dimensional, the DCT secondary transform is more appropriate and more commonly used than the DCT primary transform.
[0116] In some embodiments, the high-quality reconstructed image and the high-quality sample image are collectively referred to as a facial image. A DCT secondary transform is performed on these images to obtain coefficient sets representing different frequency components in the frequency domain. Each coefficient set is then subjected to an inverse DCT secondary transform to obtain a corresponding image set representing different frequency components in the spatial domain. According to this method, the high-quality reconstructed image and the high-quality sample image are subjected to a DCT secondary transform and the corresponding inverse transform, respectively, and the frequency domain mean square error loss DCTLoss between the two is calculated according to the following formula:
[0117] Among them, D -1 (D(I HR )) x,y It is the data obtained by performing DCT secondary transformation and corresponding inverse transformation on high-quality sample images; It is the data obtained by performing DCT secondary transformation and corresponding inverse transformation on the high-quality reconstructed image; HR Represents a high-quality sample image; I LR Represents a low-quality sample image; Represents a low-quality sample image I LR The corresponding high-quality reconstructed image; θ c are model parameters; W and H represent the width and height of the high-quality reconstructed image or high-quality sample image, respectively.
[0118] By calculating the mean square error loss in the frequency domain, the similarity between the high-quality reconstructed image and the high-quality sample image in the frequency domain is ensured, thereby improving the training quality of the model and the image generation quality.
[0119] Of course, in other more specific implementations, in the frequency domain, the high-quality reconstructed image and the high-quality sample image can be Fourier transformed and inversely transformed respectively, and then the frequency domain mean square error loss of the two can be calculated based on the transformed images.
[0120] In some more specific embodiments, a pre-trained VGG model is used to perform feature mapping on the high-quality reconstructed image and the high-quality sample image, and the feature mean square error loss of the two is calculated. The high-quality reconstructed image and the high-quality sample image are respectively input into the VGG model, and the feature map of a certain layer in the output results of the two is extracted and compared pixel by pixel, as shown in the following formula:
[0121] in, represents the feature mean square error loss; φ i,j Represents the feature map of the jth convolution before the i-th maximum pooling layer in the VGG model, W i,j and H i,jI represents the width and height of the feature map corresponding to the high-quality reconstructed image or high-quality sample image respectively; HR Represents a high-quality sample image; I LR Represents a low-quality sample image; Represents a low-quality sample image I LR The corresponding high-quality reconstructed image; θ c are model parameters.
[0122] By calculating the feature mean square error loss, the high-quality reconstructed image and the high-quality sample image also have a certain degree of similarity in the feature space.
[0123] It should be noted that during the model training process, the weight of each loss can be adjusted by observing the impact of the above three losses on the model training effect, so as to continuously update the generation loss, so that the generation loss can better reflect the high quality of the image and the ability of the harmonized model to generate high-quality reconstructed images, thereby accelerating the training efficiency.
[0124] In some embodiments, the discriminative loss is calculated as follows:
[0125] in, represents the discrimination loss; I LR Represents a low-quality sample image; Represents the high-quality reconstructed image corresponding to the low-quality sample image; is the discrimination result of the discriminant network for high-quality reconstructed images; θ D and θ G is a model parameter; n is the sequence number of the high-quality reconstructed image, and N is the number of high-quality reconstructed images.
[0126] In some embodiments, the encoder and decoder of the generative network are trained with the goal of minimizing the generation loss.
[0127] It should be noted that in the high-quality image harmonization model described in the embodiments of this specification, the generative network of styleGAN2 used to constitute the fusion module is pre-trained and is used to obtain the prior features of the face. The prior features of the face will not change after they are obtained. Therefore, the parameters in the fusion module do not participate in the update during the model training process.
[0128] In another embodiment of the present specification, a device for improving the quality of biological images is proposed. FIG6 exemplarily shows a structural diagram of the device for improving the quality of biological images described in an embodiment of the present specification in one implementation manner.
[0129] As shown in Figure 6, the device includes: an acquisition module 40 for acquiring low-quality original biological images to be processed; an image processing module 42 for inputting low-quality original biological images into a generation network of a pre-trained high-quality harmonization model to obtain high-quality images, and the high-quality harmonization model is trained using the image high-quality harmonization model training method described above.
[0130] When obtaining low-quality original biological images to be processed, you can directly input the images by installing a local image acquisition device, or you can retrieve the images from a remote image acquisition device in the cloud, or retrieve a pre-prepared image set from the cloud directly as model input.
[0131] The generative network of the high-quality harmonization model trained in the embodiments of this specification can be used to restore image quality after expression migration. By extracting multi-scale image features and fusing them with facial prior features through pre-trained weights, high-quality images are generated and traces of expression forgery are repaired.
[0132] In one embodiment of the present specification, a computer-readable storage medium is further proposed, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the image high-quality and harmonized model training method described above are implemented.
[0133] In one embodiment of the present specification, an electronic device is also proposed, comprising a memory, a processor, and a computer program stored in the memory and runnable on the processor, wherein when the processor executes the program, the steps of the image high-quality and harmonized model training method described above are implemented.
[0134] The foregoing description of this specification describes specific embodiments. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that described in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order shown or the sequential order to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0135] It should be noted that the above examples are merely specific embodiments of the present invention. Obviously, the present invention is not limited to the above examples, and many similar variations are possible. All variations directly derived from or associating with the present invention by those skilled in the art are intended to fall within the scope of protection of the present invention.
Claims
1. A method for training a high-quality image harmonization model, wherein the high-quality harmonization model is a generative adversarial network, including a discriminant network and a generative network, wherein the generative network includes an encoder, a fusion module and a decoder, and the method comprises: Acquire high-quality sample images; Converting the high-quality sample image into a low-quality sample image; Inputting the low-quality sample image into the generation network, and extracting multi-scale image features of the low-quality sample image through the encoder; The multi-scale image features and the pre-acquired human face prior features are fused by the fusion module to obtain fused features; Decoding the fused features by the decoder to obtain a high-quality reconstructed image corresponding to the low-quality sample image; A loss is calculated based on the high-quality reconstructed image and the high-quality sample image; Using the discriminant network to determine whether the high-quality reconstructed image is the high-quality sample image; Calculate the discrimination loss according to the discrimination result of the discrimination network; Training the discriminative network with the goal of minimizing the discriminative loss; The generation network is trained with the goal of minimizing the generation loss.
2. The high-quality image harmonization model training method according to claim 1, wherein the facial prior features include multi-scale facial features; The multi-scale image features and the pre-acquired human face prior features are fused by the fusion module, specifically including: For each scale, the image features of that scale are fused with the face features of that scale.
3. The image high-quality harmonization model training method according to claim 2, wherein the encoder extracts multi-scale image features of the low-quality sample image, specifically comprising: For each scale, the encoder extracts image features of the low-quality sample image at the scale and weights corresponding to the image features at the scale, wherein the weights are used to represent the importance of the image features at the scale for decoding to obtain a high-quality reconstructed image; The image features of the scale are integrated with the face features of the scale, specifically including: Splicing the image features of the scale and the face features of the scale to obtain splicing features; The splicing features are weighted by the weights corresponding to the image features of the scale to obtain the fusion features of the scale.
4. The high-quality image harmonization model training method as described in claim 1, wherein a fusion module constructed by a generative network of the styleGAN2 network is used to pre-acquire facial prior features.
5. The image high-quality and harmonized model training method according to claim 1, wherein the training of the generation network specifically comprises: The encoder and decoder of the generative network are trained with the goal of minimizing the generation loss.
6. The image high-quality harmonization model training method according to claim 1, wherein the loss is calculated based on the high-quality reconstructed image and the high-quality sample image and specifically comprises: In the spatial domain, based on the high-quality reconstructed image and the high-quality sample image, a spatial mean square error loss of the two is calculated and used as the generation loss.
7. The image high-quality harmonization model training method according to claim 1, wherein the loss is calculated based on the high-quality reconstructed image and the high-quality sample image and specifically comprises: In the spatial domain, according to the high-quality reconstructed image and the high-quality sample image, a spatial mean square error loss of the two is calculated; In the frequency domain, the high-quality reconstructed image and the high-quality sample image are both transformed and inversely transformed accordingly, and the frequency domain mean square error loss of the transformed high-quality reconstructed image and the transformed high-quality sample image is calculated according to the transformed high-quality reconstructed image and the transformed high-quality sample image; In the feature space, according to the feature mapping of the high-quality reconstructed image and the high-quality sample image, the feature mean square error loss of the two is calculated; The spatial domain mean square error loss, the frequency domain mean square error loss and the feature mean square error loss are weighted and fused to serve as the generation loss.
8. A method for improving the quality of biological images, the method comprising: Obtaining low-quality raw biological images to be processed; The low-quality original biological image is input into a generation network of a pre-trained high-quality harmonization model to obtain a high-quality image, wherein the high-quality harmonization model is trained using the method described in any one of claims 1 to 7.
9. A high-quality image harmonization model training device, the device comprising: A sample processing module, used for acquiring a high-quality sample image and converting the high-quality sample image into a low-quality sample image; A generation module is used to input the low-quality sample image into a generation network, extract multi-scale image features of the low-quality sample image through an encoder; fuse the multi-scale image features with pre-acquired human face prior features through a fusion module to obtain fused features; and decode the fused features through a decoder to obtain a high-quality reconstructed image corresponding to the low-quality sample image; A training module, used for calculating a generation loss based on the high-quality reconstructed image and the high-quality sample image; Using a discriminant network to determine whether the high-quality reconstructed image is the high-quality sample image; Calculate the discrimination loss according to the discrimination result of the discrimination network; Training the discriminative network with the goal of minimizing the discriminative loss; The generation network is trained with the goal of minimizing the generation loss.
10. The high-quality image harmonization model training device according to claim 9, wherein the facial prior features include multi-scale facial features; The generation module fuses the multi-scale image features and the pre-acquired human face prior features through the fusion module, specifically including: For each scale, the image features of that scale are fused with the face features of that scale.
11. The image high quality and harmonization model training device according to claim 10, The generation module extracts, for each scale, image features of the low-quality sample image at the scale and weights corresponding to the image features at the scale through the encoder, wherein the weights are used to represent the importance of the image features at the scale for decoding to obtain a high-quality reconstructed image; The generation module fuses the image features of the scale with the face features of the scale, specifically including: Splicing the image features of the scale and the face features of the scale to obtain splicing features; The splicing features are weighted by the weights corresponding to the image features of the scale to obtain the fusion features of the scale.
12. The high-quality image harmonization model training device as described in claim 9 uses a fusion module constructed by a generative network of a styleGAN2 network to pre-acquire a priori features of the face.
13. The image high quality and harmonization model training device according to claim 9, The training module trains the encoder and decoder of the generation network with the goal of minimizing the generation loss.
14. The image high quality and harmonization model training device according to claim 9, The training module calculates the spatial mean square error loss of the high-quality reconstructed image and the high-quality sample image in the spatial domain, and uses the spatial mean square error loss as the generation loss.
15. The image high quality and harmonization model training device according to claim 9, The training module calculates the spatial mean square error loss of the high-quality reconstructed image and the high-quality sample image in the spatial domain; The training module transforms the high-quality reconstructed image and the high-quality sample image in the frequency domain and performs corresponding inverse transformation, and calculates the frequency domain mean square error loss of the high-quality reconstructed image and the high-quality sample image after the transformation according to the transformed high-quality sample image; The training module calculates the feature mean square error loss of the high-quality reconstructed image and the high-quality sample image in the feature space according to the feature mapping of the high-quality reconstructed image and the high-quality sample image; The training module weightedly fuses the spatial domain mean square error loss, the frequency domain mean square error loss and the feature mean square error loss as the generation loss.
16. A device for improving the quality of biological images, the device comprising: An acquisition module, used for acquiring low-quality original biological images to be processed; An image processing module is used to input the low-quality original biological image into a generation network of a pre-trained high-quality harmonization model to obtain a high-quality image, wherein the high-quality harmonization model is trained using the method described in any one of claims 1 to 7.
17. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Generative adversarial network construction method and device, and image reconstruction method and device
CN109544450A
Super-division model training and face recognition method and device, medium and electronic equipment
CN113191495A
Image high-quality harmonious model training method and device
CN116452435A
Super resolution using a generative adversarial network
US20180075581A1
Cited By
Lightweight social platform image restoration method and system based on dual-branch frequency and space fusion, and readable storage medium
CN119599915A
Video quality evaluation method and system based on space-frequency combination and time sequence interaction
CN121397207A
Priori knowledge guided dual-domain feature network multi-modal image fusion method and system
CN122222836A
Prior knowledge guided dual-domain feature network multi-modal image fusion method and system
CN122222836B
