A non-matching image style transfer method based on generative adversarial network

By introducing an attention mechanism and an independent codec into the generative adversarial network, combined with ShapeNet and PerceptionNet, the problem of unclear details and edge shape changes in non-matching image style conversion is solved, achieving high-quality style conversion and suitable for a wide range of applications. scenarios, and provide data augmentation under data scarcity conditions.

CN112581550BActive Publication Date: 2024-10-29ZHEJIANG UNIV OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011391478.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-02
Publication Date
2024-10-29
Estimated Expiration
2040-12-02

AI Technical Summary

Technical Problem

Existing non-matching image style conversion algorithms have problems such as unclear image details, changes in edge shapes, and difficulty in training. Moreover, the style conversion algorithm based on matching data sets has a small application range and is difficult to obtain data.

Method used

A non-matching image style conversion method based on a generative adversarial network is adopted. By introducing an attention mechanism and an independent codec structure, combined with ShapeNet and PerceptionNet, the shape consistency loss and perceptual loss are used to ensure that the edge shape and high-level information of the generated image are consistent. property, and perform quality evaluation through the discriminator to realize the mutual game between the generator and the discriminator to improve performance.

Benefits of technology

It improves the quality of image conversion, adapts to a wider range of application scenarios, can achieve effective style conversion in the absence of mutually matching data, and provides support for medical diagnosis and data expansion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112581550B_ABST
    Figure CN112581550B_ABST
Patent Text Reader

Abstract

A non-matching image style transfer method based on a generative adversarial network comprises the following steps: 1) simultaneously inputting an image x belonging to style A a and the image x belonging to style B b Enter the style transfer neural network; 2) According to the source domain image, the network generator generates the corresponding target domain style image; 3) The source domain and the generated target domain images pass through the segmentation network and are constrained by shape consistency loss; 4) The source domain and the generated target domain images pass through the perception network and are constrained by the perception loss; 5) The discriminator judges the quality of the image generated by the generator; 6) Repeat steps 1) to 5) for a set number of times until the network converges. The present invention aims to use deep learning technology to achieve effective conversion of image styles in the absence of mutually matching image data. Through a carefully designed network structure, the quality of the converted image can be effectively improved and adapted to a wider range of application scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of generative adversarial networks in deep learning, introduces an attention mechanism, and is a method for realizing non-matching image style conversion. Background Art

[0002] In recent years, deep learning technology has attracted more and more attention from researchers and has been successfully applied in many practical applications. Deep learning algorithms attempt to learn high-level features from massive data, which makes deep learning surpass traditional machine learning. It can automatically extract data features through unsupervised or semi-supervised feature learning algorithms and hierarchical feature extraction. In contrast, traditional machine learning methods require manual design of features, which seriously increases the burden on users. It can be said that deep learning is a representation learning algorithm based on large-scale data in machine learning.

[0003] In recent years, the application of generative adversarial networks (GANs) has also been a hot research topic in the field of deep learning. Since 2014, people have conducted extensive research on GANs and proposed a large number of algorithms. GANs contain generators and discriminators in their structure, and the performance is improved through the mutual game between the two. GANs are widely used in image processing and computer vision, natural language processing, speech and audio, medicine, and data science.

[0004] Image style transfer is a new technology based on deep learning that has emerged in recent years. It has also developed rapidly along with the development of deep learning. Image style transfer belongs to the problem of texture transfer. In the classic method, some non-parametric methods are used for texture transfer, such as using some fixed methods for rendering. Traditional methods can only extract the underlying features, while convolutional neural networks can extract the high-level features of image features, making it feasible to separate image content from style.

[0005] In recent years, attention mechanisms have been a hot research topic in both natural language processing and computer vision. Many scholars have proposed several attention mechanisms to improve the performance of models in related tasks. The basic idea of ​​the attention mechanism in computer vision is to make the model learn to pay attention, that is, to ignore irrelevant information and focus on key information.

[0006] From the current research status of related fields, the current style transfer algorithms are mainly divided into two categories, one is the style transfer algorithm based on matching data, and the other is the style transfer algorithm based on non-matching data. Specifically, data matching means that from the perspective of content, the two images have consistent content attributes, but from the perspective of style, the two belong to different style domains. For example, two images of summer and winter scenery corresponding to the same location, and then these two images are input in pairs during training. Conversely, data non-matching means that there is no need to require strict matching of data before pairing them into the network, and the input images can be from two different domains. According to current research results, the algorithm based on matching data sets has better experimental results, but the scarcity of matching data sets and the difficulty of obtaining them are also issues that cannot be ignored. This also leads to a small application range of style transfer algorithms based on matching data sets, which has also prompted style transfer algorithms based on non-matching data to become the focus of research for many researchers. The current non-matching data algorithms have problems such as unclear image details, changes in edge shapes, and difficulty in training. The present invention utilizes a codec to split and reassemble images, retains the split content encoding, and introduces an attention mechanism to enable the network to focus on detailed information in important areas, thereby solving the above-mentioned related problems. Summary of the invention

[0007] In order to overcome the shortcomings of the prior art, the present invention provides a non-matching image style transfer method based on a generative adversarial network. In the absence of mutually matching image data, deep learning technology is used to effectively transfer the style of the image. Through a carefully designed network structure, the quality of the converted image can be effectively improved and adapted to a wider range of application scenarios.

[0008] The technical solution adopted by the present invention to solve the technical problem is:

[0009] A non-matching image style transfer method based on a generative adversarial network, the method comprising the following steps:

[0010] 1) Input image x belonging to style A at the same time a and the image x belonging to style B b Enter the style transfer neural network, which is a generative adversarial network that includes a generator and a discriminator;

[0011] 2) Based on the image in the source domain, the style conversion neural network generates the image in the target domain, and converts the A style image x a As the source domain, the conversion generates the target domain B style image x a2b , the B style image x b As the source domain, the conversion generates the target domain A style image x b2a ;

[0012] 3) The image in the source domain and the image in the target domain generated by the conversion are passed through a segmentation network, which is named ShapeNet in the present invention. The generated image is constrained using shape consistency loss to ensure that the image in the source domain and the generated converted target domain image have the same edge shape;

[0013] 4) The source domain image and the converted target domain image are passed through a perception network, which is named PerceptionNet in the present invention, and the generated image is constrained using a perception loss to ensure that the source domain image and the converted target domain image have high-level information consistency;

[0014] 5) The discriminator judges the quality of the images generated by the generator and distinguishes whether the images input to the discriminator are real images or fake images generated by the network.

[0015] 6) Repeat steps 1) to 5) for a set number of times, and the generator and the discriminator will continue to compete with each other to improve performance together until the network converges. At this point, the quality of the image generated by the generator is high enough, and the discriminator cannot distinguish whether the image generated by the generator is a fake image generated by the network generator.

[0016] Furthermore, the style transfer neural network fully learns how to encode images into content encoding and style encoding by using independent codec structures corresponding to different styles; the style transfer neural network includes two sets of generators and discriminators, which generate and discriminate images for source domain images and target domain images respectively.

[0017] For each group of generators, it contains the structure of encoder and decoder. The encoder encodes the image, which contains two encoder structures: content encoder, which encodes the content features of the image and generates content encoding; style encoder, which encodes the style features of the image and generates style encoding; decoder decodes the encoding completed by the encoder, merges the content encoding with the style encoding, and synthesizes the corresponding target domain style image. The encoder learns the distribution characteristics of a specific style, so paired matching data is not required for training, which reduces the difficulty of data collection.

[0018] Furthermore, an attention mechanism is introduced to visualize the features extracted by the convolutional network to form a heat map. Based on the heat map, the neural network is taught to focus on important areas.

[0019] The attention mechanism is introduced in both the generator and the discriminator. Assume that the number of channels of the feature map extracted by a certain layer of the neural network is n, corresponding to n feature maps. The introduced attention mechanism is: calculate the weight representing the importance of the feature map of each channel, and the sum of all weights is 1. The weight corresponding to each channel and the feature map are weighted and summed to form a heat map, and the feature visualization result of the convolutional network is obtained. The attention mechanism enables the network to teach the neural network to focus on important areas, improve the detailed information and the overall imaging quality.

[0020] Furthermore, a trained segmentation network is introduced to ensure the consistency of edge shapes.

[0021] The segmentation network structure used is Feature Pyramid Networks, which is trained using a segmentation dataset with real labels. After testing, it can segment the edge information of the image very well.

[0022] The perception network and perception loss are introduced to ensure the consistency of high-level information.

[0023] The perception network can use pre-trained VGG or ResNet, and use the pre-trained network to extract image features.

[0024] The perceptual loss minimizes the difference between the source domain image and the converted target domain image at the feature level. When completing the style transfer task in GAN, due to the universality of the backpropagation distribution, it has the advantages of fast training speed, good convergence effect, and consistent high-frequency detail information.

[0025] The beneficial effects of the present invention are as follows: through the present invention, only one style image is needed to obtain corresponding images of multiple styles. It is conducive to building a medical diagnosis assistance system, and assisting doctors to make more accurate clinical judgments through multi-style images. At the same time, under the premise of scarcity of medical image data, the present invention can also be used as a data expansion, which can provide researchers in related research fields with more data for algorithm research and promote the overall development of the industry. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 Schematic diagram of the main structure of a non-matching image style transfer method based on generative adversarial network.

[0027] Figure 2 Schematic diagram of the structure of the generator in the style transfer neural network in a non-matching image style transfer method based on a generative adversarial network.

[0028] Figure 3 Schematic diagram of the structure of the discriminator in the style transfer neural network in a non-matching image style transfer method based on a generative adversarial network. DETAILED DESCRIPTION

[0029] The present invention will be further described below in conjunction with the accompanying drawings.

[0030] Reference Figure 1 to Figure 3 , a non-matching image style transfer method based on generative adversarial networks, the two style images that need to be converted to each other are named x a With x b , the following describes in detail the image x in the style of source domain A. a Transformed to the target domain B style image x a2b Process, from the source domain B style image x b Transformed to the target domain A style image x b2a The process is similar. a After passing through a style transfer neural network based on GAN architecture, an image is generated, which has image x a The content of the image x b style, named x a2b .

[0031] Furthermore, in some specific image style conversion tasks, such as converting horses to zebras and modality conversion of magnetic resonance imaging, the edge structure of the source domain image and the target domain image must be consistent. Therefore, ShapeNet is introduced, which is a trained segmentation network based on the Feature Pyramid Networks architecture. a and the generated target domain image x a2b Input ShapeNet to obtain the segmentation results of the two, and constrain the segmentation results of the two through the loss function to ensure that the source domain image x a and the generated target domain image x a2b Have the same structural edge shape.

[0032] Furthermore, the features extracted by the convolutional neural network can be used as part of the objective function. By comparing the feature values ​​of the source domain image after the convolutional neural network with the feature values ​​of the target domain image after the convolutional neural network, the source domain image and the target domain image are semantically more similar. Therefore, PerceptionNet is introduced to convert the source domain image x a and the generated target domain image x a2b Input into a pre-trained PerceptionNet, which can be a feature extraction network such as VGG or ResNet. In the latent space, an image can be split into two components: image content and image style. The extracted features are constrained accordingly using perceptual loss. In the formula, j is the pixel position corresponding to the image. is the nonlinear function representation of the feature extraction network, H and W are the height and width of the image respectively. Through the perception network, the source domain image x a and the generated target domain image x a2b They should have similar image semantic content to improve the quality of image generation.

[0033] Reference Figure 2 ,The style transfer neural network consists of two parts: generator and discriminator. Figure 2 The architecture design of the generator. The generator contains an encoder and a decoder. The encoder is responsible for decomposing the image information into content coding and style coding. The above coding operations are completed by content encoders and style encoders with different designs respectively. The decoder is responsible for fusing the content coding and style coding obtained by the above encoders to synthesize the corresponding target domain style image. Specifically, a.encoder represents the encoder that encodes the A style image, and a.decoder represents the decoder that decodes the A style image. b.encoder represents the encoder that encodes the B style image, and b.decoder represents the decoder that decodes the B style image.

[0034] The input network has A style image x a With B style image x b , x a After the encoder, it is decomposed into style code s a With content encoding c a Two parts, representing the A style image x a Corresponding style code and content code. a With content encoding c a As input, it is input to the decoder, and the decoder converts s a With c a Fusion, generating a The corresponding reconstructed image x a_recon , constrained by the L1 loss function to ensure that the reconstructed image is consistent with the input.

[0035] Furthermore, L1 loss is also called minimizing the Least Absolute Error.

[0036] Similarly, x b After the encoder, it is decomposed into style code s b With content encoding c b Two parts, representing the B style image x b The corresponding style encoding and content encoding are reconstructed to obtain the reconstructed image x b_recon .

[0037] Through the above learning and training, the two sets of codecs learned to convert A style image x and B style image x respectively. b Perform disassembly and synthesis operations.

[0038] Next, x a The corresponding content code c a With x b The corresponding style code s b Combine and input the decoder b.decoder corresponding to the B style to generate a The converted image x with style B ab . Because x ab At this time, it is A style image x a The content of B plus the style image x b style, so x ab Perform the encoding operation again to generate c a_recon With s b_recon .

[0039] Furthermore, c a_recon With the source domain image x a Split out c a Constrained by the loss function, so that c a_recon With c a Keep it consistent. b_recon With the real image x b Split out s b Constrain the loss function so that s b_recon With s b Basically the same. Here the loss function can be L1 loss or L2 loss.

[0040] Finally, c a_recon With s a Input the decoder a.decoder corresponding to style A to decode and complete x a —>x ab —>x aba The circular transformation process converts x a With x aba The ring consistency loss function is used to constrain x aba With x a Keep it consistent. Here, the loss function can be L1 loss or L2 loss.

[0041] Reference Figure 3 , the figure shows the architecture design of the discriminator. a With B style image x b They are disassembled and expressed as c a 、c b、s a With s b . Then c a With s b Perform combined decoding to generate image x ab , c b With s a Perform combined decoding to generate image x ba The discriminator is ab With x ba It determines whether it is a fake image generated by the generator and gives a score based on the judgment result. When the discriminator believes that the input image is a fake image generated by the generator, the score value is 0, otherwise it is 1.

[0042] After the above steps are repeated for a set number of times, the generator and the discriminator compete with each other and make progress together. The final generator has powerful performance and can generate a very realistic conversion image of the style based on a reference image of another style.

[0043] The above describes the embodiments of the present invention through specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific examples, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.

[0044] It should be noted that the diagrams provided in the above embodiments are only used to illustrate the basic concept of the present invention in a schematic manner, and thus the diagrams only show components related to the present invention rather than being drawn according to the number of components in actual implementation. The number and proportion of each component in actual implementation can be changed at will.

Claims

1. A non-matching image style transfer method based on a generative adversarial network, characterized by: The method comprises the following steps: 1) Input image x belonging to style A at the same time a and the image x belonging to style B b Enter the style transfer neural network, which is a generative adversarial network that includes a generator and a discriminator; 2) Based on the image in the source domain, the style conversion neural network generates the image in the target domain, and converts the A style image x a As the source domain, the conversion generates the target domain B style image x a2b , the B style image x b As the source domain, the conversion generates the target domain A style image x b2a ; 3) The source domain image and the converted target domain image are passed through the segmentation network, and the generated image is constrained using shape consistency loss to ensure that the source domain image and the converted target domain image have the same edge shape; 4) The source domain image and the converted target domain image are passed through the perception network, and the generated image is constrained using the perception loss to ensure that the source domain image and the converted target domain image have high-level information consistency; 5) The discriminator evaluates the quality of the images generated by the generator and distinguishes whether the images input to the discriminator are real images or fake images generated by the network; 6) Repeat steps 1) to 5) for a set number of times, and the generator and the discriminator will continue to compete with each other to improve the performance together until the network converges; The style transfer neural network fully learns how to encode images into content encoding and style encoding by using independent codec structures corresponding to different styles; the style transfer neural network includes two sets of generators and discriminators, which generate and discriminate images for source domain images and target domain images respectively; For each group of generators, it includes the structure of an encoder and a decoder. The encoder performs encoding operations on the image, which includes two encoder structures: a content encoder, which encodes the content features of the image and generates content coding; a style encoder, which encodes the style features of the image and generates style coding; the decoder decodes the coding completed by the encoder, merges the content coding with the style coding, and synthesizes the corresponding target domain style image.

2. The non-matching image style transfer method based on a generative adversarial network according to claim 1, characterized in that: An attention mechanism is introduced to visualize the features extracted by the convolutional network to form a heat map. Based on the heat map, the neural network is taught to focus on important areas.

3. The non-matching image style transfer method based on a generative adversarial network as claimed in claim 2, characterized in that: The attention mechanism is introduced in both the generator and the discriminator. Assume that the number of channels of the feature map extracted by a certain layer of the neural network is n, and the corresponding n feature maps are represented by f1, f2…f n The introduced attention mechanism is: the weight representing the importance of the feature map of each channel is calculated, using w1, w2…w n Indicates that the sum of all weights is 1, that is The weight corresponding to each channel is weighted and summed with the feature map to form a heat map, and the feature visualization result of the convolutional network is obtained, that is, 4. The non-matching image style transfer method based on a generative adversarial network according to claim 1, characterized in that: The perception network can use pre-trained VGG or ResNet, and use the pre-trained network to extract image features.

5. The non-matching image style transfer method based on a generative adversarial network according to claim 1, characterized in that: The perceptual loss minimizes the difference in feature level between the source domain image and the converted target domain image.

Citation Information

Patent Citations

  • Multi-domain image style migration method based on generative adversarial network

    CN110310221A

  • Style migration model and method for specific relevant region of garment image

    CN112017301A