Color migration method of double attention mechanism module optimization generative adversarial network
By introducing a dual attention mechanism module into the generative adversarial network, the problem of difficulty in extracting the features of multiple foreground objects in the color style transfer of the generative adversarial network is solved, and better color distribution and visual effects are achieved.
Patent Information
- Application Number
- CN202410736565.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-07
- Publication Date
- 2024-10-11
AI Technical Summary
When the generative adversarial network performs color style transfer, it is difficult to effectively extract the features of multiple foreground objects, causing the object boundary details of the generated image to be distorted or destroyed.
The dual attention mechanism module is used to optimize the generative adversarial network. By introducing the dual attention mechanism module in the encoder and decoder, combined with the skip connection and recolor module, the color style features are extracted and transferred to ensure the feature extraction and accuracy of each object. Accuracy of color distribution.
The semantic feature extraction capability of the generative adversarial network in color style transfer is improved. The color distribution of the generated image is more uniform, the visual effect is better, and the destruction of object boundary details is avoided.
Smart Images

Figure CN118762092A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of computer graphics and artificial intelligence, and in particular, to a color migration method of a generative adversarial network by optimizing a dual attention mechanism module. Background Art
[0002] Color style transfer is an important task in computer graphics. Its processing process mainly involves transferring the color features of the target color style image to the input image through an algorithm model to enhance the expressiveness of the input image. Since some images, such as landscapes, contain objects of different colors (such as flowers, trees, etc.), ensuring that the colors of these objects are more harmonious after adjustment is a major challenge in the color style transfer task.
[0003] The Generative Adversarial Network (GAN) model is one of the deep learning network models, which is widely used in image content generation. The network model can be trained with a large amount of data and then has the ability to generate a specific style for the input image. However, when the Generative Adversarial Network is used for color style transfer tasks in different scenes, it may not be able to adjust the color of each object in the image to the best effect when facing a scene containing multiple objects. Therefore, the Generative Adversarial Network needs to be optimized to a certain extent to meet the needs of specific scenes.
[0004] The attention mechanism is an algorithmic strategy for optimizing feature extraction. Its main function is to further extract the features of the target object in the image. By improving the attention mechanism, it is helpful to extract higher quality features from the image. Therefore, applying the new attention mechanism module to the image color style transfer model is conducive to generating a better visual effect image.
[0005] At present, the image color style transfer algorithm model has been widely used in actual products. It can not only enhance the expressiveness of film and television works, but also adjust the color of personal photos. However, the technical problem is that the traditional algorithm that can only extract low-quality features may cause the details of the image objects to be destroyed during the color adjustment process. Furthermore, the difficulty lies in that when performing color style transfer operations on scene images such as landscapes, if there are many foreground objects in the image, it is necessary to improve the generative adversarial network (GAN) to extract the features of each object well, otherwise it is easy to cause the generated target color generation map to have details such as object boundaries distorted or destroyed. Therefore, it is necessary to use a color style transfer model containing an attention mechanism module for color adjustment tasks.
[0006] The significance of solving the above problems is to optimize the generative adversarial network through the dual attention mechanism module to improve the ability to obtain semantic features, thereby helping to generate better and more expressive renderings. Summary of the invention
[0007] The present invention provides a color transfer method for a generative adversarial network by optimizing a dual attention mechanism module, which solves the technical problem that when a color style transfer operation is performed on scene images such as landscape images, if there are many foreground objects in the image, it is difficult for a generative adversarial network (GAN) to extract the features of each object well, resulting in distortion or destruction of details such as object boundaries in the generated target color generation image.
[0008] The technical solution of the present invention is as follows:
[0009] The present invention discloses a color migration method for optimizing a generative adversarial network through a dual attention mechanism module. The method adopts a recolored histogram feature generative adversarial network as a basic model. The basic model includes an encoder, a decoder, a jump connection module and a recoloring module. The method includes the following steps: receiving an input image through an encoder, and performing feature extraction and downsampling operations on the image, and each encoding block in the encoder includes a dual attention mechanism module; receiving feature maps output by the encoder and the jump connection module through a decoder, and performing feature extraction and upsampling operations on these feature maps; through a jump connection module, not only is it used to transmit the feature map generated by the encoder to the decoder, but it is also used to combine the extracted color style features with the feature map output by the encoder, thereby generating a new feature map with target color style features; and through a recoloring module, it is mainly used to process the feature maps output from the decoder and the jump connection module, and at the same time, color feature migration and upsampling operations are performed on these feature maps.
[0010] Optionally, in the above-mentioned color migration method of optimizing the generative adversarial network through the dual attention mechanism module, the encoder is composed of multiple encoding blocks, wherein the first encoding block in the encoder is used to receive the input image, and the last encoding block outputs a feature map corresponding to the image, and inputs the feature map to the decoder; and the feature map generated by each encoding block is passed to the encoding block of the next layer; at the same time, the feature map output by the encoding block is also transmitted to the jump connection module.
[0011] Optionally, in the above-mentioned color migration method of generating an adversarial network through dual attention optimization, the encoding block includes a convolutional layer, a convolutional module and a dual attention mechanism module, and the convolutional module is mainly composed of a convolutional layer, an instance normalization layer, and an activation function layer.
[0012] Optionally, in the above-mentioned color migration method of optimizing the generative adversarial network through the dual attention mechanism module, the algorithm flow of the encoding block is: after the input data enters the encoding block, it first enters a convolution layer Conv1 for feature extraction operation, and the feature map output by the convolution layer Conv1 will be used for subsequent feature optimization operations; at the same time, the input data of the encoding block will also be input into the convolution module ConvBlock1 for feature extraction, and the convolution module ConvBlock1 will output a feature map F after the feature extraction operation; the feature map F is input into the dual attention mechanism module, in which the feature map F is transformed into a query value query, a key value key and a content value value through a transformation operation; then, the query value query and the key value are key will be transformed to generate a feature map f1 for attention operation; the transformation operation here includes matrix multiplication, Softmax and other operations; then, the feature map f1 will be used for attention operation with the content value value to generate the attention feature map f2; the attention operation here mainly includes batch matrix multiplication and other operations; in order to further use the attention mechanism to extract the features of objects in the image data, the attention mechanism operation is further used to perform feature extraction operations on the obtained attention feature map f2; the specific method is to use the content value value and the attention feature map f2 for weighted averaging operation, and the feature map f' obtained after weighted averaging is then used for attention operation with the feature map f1. The process is described by the following formula:
[0013] f' = α╳value+ β╳f2Formula 1
[0014] f3 = attent ( f1, f' ) Formula 2
[0015] Wherein, in formula 1, f' is the feature map obtained by weighted average operation of content value and attention feature map f2; α and β are coefficients, and both of them have values 0 to 1, α+β=1; in formula 2, f3 is the attention feature map obtained by performing attention operation on feature map f1 and feature map f'; attent(·) represents the attention operation;
[0016] Next, the attention feature map f3 and the feature map F are subjected to feature optimization operations to obtain the optimized feature map f4. The specific operation of feature optimization is shown in the following formula:
[0017] f4 = γ╳f3+ F formula 3
[0018] In Formula 3, f4 is the feature map obtained after feature optimization; γ is a coefficient, ranging from 0 to 1;
[0019] Then the optimized feature map f4 is processed by the convolution module ConvBlock2 for feature extraction, and the feature map output by the convolution module ConvBlock2 is It will be added to the feature map output by the convolution layer Conv1; finally, the feature map obtained by the addition operation It will be transmitted to the convolution layer Conv2 for feature extraction and downsampling operations. The feature map output by the convolution layer Conv2 is the final output feature map of the encoding block.
[0020] Optionally, in the above-mentioned color migration method for optimizing the generative adversarial network through the dual attention mechanism module, the decoder is composed of multiple decoding blocks, wherein the first decoding block in the decoder receives the feature map output by the encoder and the jump connection module; the last decoding block performs an upsampling operation on the received feature map, and generates a corresponding feature map and a generated map; in addition, each decoding block receives the feature map output by the decoding block of the previous layer; at the same time, each decoding block also receives the corresponding feature map output from the jump connection module; finally, after each decoding block completes the feature extraction and upsampling operations on the feature map, the output feature map is transmitted to the decoding block of the next layer.
[0021] Optionally, in the above-mentioned color migration method for optimizing the generative adversarial network through the dual attention mechanism module, the jump connection module is mainly composed of two parts: a potential feature extraction part and a style feature extraction part, wherein, in the potential feature extraction part, the feature maps output by the third, fourth, fifth and sixth layer encoding blocks of the encoder will be used to obtain the potential features in the feature maps through operations such as transformation; when the potential features in the feature maps are extracted, the potential features of the feature maps output by the third, fourth, fifth and sixth layer encoding blocks in the encoder will be transmitted to the fourth, third, second and first layer decoding blocks in the decoder respectively; in the style feature extraction part, one On the one hand, the model extracts the histogram features of color style from the target style map; these color style features will undergo linear transformation and other operations to form convolution kernels; on the other hand, this part receives the feature maps output by the first and second layer encoding blocks in the encoder, and then uses these feature maps to perform convolution operations with the convolution kernels formed by the color style features, thereby generating new style feature maps; finally, the new style feature map and noise data will be passed to the generation block corresponding to the recoloring module, and the style feature map generated by the output feature maps of the first and second layer encoding blocks in the encoder will be transmitted to the second and first layer generation blocks of the recoloring module respectively.
[0022] Optionally, in the above-mentioned color migration method for optimizing a generative adversarial network through a dual attention mechanism module, the recoloring module includes: a first generation block, for receiving a feature map output from a decoder and a jump connection module, and outputting a processed feature map; and a second generation block, for receiving a feature map output from a previous generation block and a jump connection module, and outputting image data with a target color style.
[0023] According to the technical solution of the present invention, the beneficial effects produced are:
[0024] The present invention proposes a new dual attention mechanism module that can extract high-quality semantic features of objects, so that the deep learning model can better extract the features of objects; the present invention proposes a new deep learning model for color style transfer, which is based on a generative adversarial network and includes a newly proposed dual attention mechanism module, which can make the color distribution in the generated image more hierarchical and have better visual effects in the image color transfer task. The model proposed by the present invention can complete the color style transfer task with a small amount of calculation, and the generated image output by it can achieve good visual effects; in addition, the model can be used as a basic model to provide a basis for further in-depth research on the color style transfer task.
[0025] In order to better understand and illustrate the concept, working principle and effect of the present invention, the present invention is described in detail below through specific embodiments in conjunction with the accompanying drawings: BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the specific implementation of the present invention or the technical solution in the prior art, the drawings required for use in the specific implementation or the description of the prior art are briefly introduced below.
[0027] Figure 1 It is a model structure diagram of the color migration method of the present invention that optimizes the generation of adversarial networks through a dual attention mechanism module;
[0028] Figure 2 It is an algorithm flow chart of the coding block of the method of the present invention;
[0029] Figure 3 It shows the original image of the input image used for the color migration operation, the color style migration effect diagram output by the ReHistoGAN model, and the color style migration effect diagram generated by the method of the present invention. DETAILED DESCRIPTION
[0030] In order to make the purpose, technical method and advantages of the present invention clearer, the present invention is further described in detail below in conjunction with the accompanying drawings and specific examples. These examples are only illustrative and not limiting of the present invention.
[0031] The main goal of this invention is to build a new dual attention mechanism module to optimize the Generative Adversarial Networks (GAN), thereby improving the generation effect of the color style transfer task.
[0032] The color migration method of the invention optimizes the generative adversarial network through the dual attention mechanism module, adopts the recoloring histogram feature generative adversarial network (Recoloring-HistoGAN, ReHistoGAN) as the basic model, which is composed of an encoder, a decoder, a jump connection module and a recoloring module, and can achieve good results in the color style migration task. In this model, the encoder mainly performs feature extraction and downsampling operations on the input image, and each encoding block contains the newly proposed dual attention mechanism module. The decoder mainly receives feature maps from the encoder and the jump connection module, and performs upsampling operations and further feature extraction operations on these feature maps. The jump connection module is not only used to transmit the feature map generated by the encoder to the decoder, but also used to combine the extracted color style features with the feature map output by the encoder, thereby generating a new feature map with target color style features. The recoloring module is mainly used to process the feature maps output from the decoder and the jump connection module, and at the same time performs color feature migration and upsampling operations on these feature maps.
[0033] See also Figure 1 The color migration method of the present invention optimizes the generative adversarial network through a dual attention mechanism module, and adopts the recoloring histogram feature generative adversarial network (Recoloring-HistoGAN, ReHistoGAN) as the basic model. The basic model mainly includes an encoder, a decoder, a convolutional layer, a skip connection module, and a recoloring module.
[0034] The data processing flow of the model network of the method of the present invention is as follows: First, the input image ( Figure 1The input image in the image is passed through the encoder for feature extraction; in the encoder, each layer of encoding blocks performs downsampling and feature extraction operations, and after the operations, each layer of encoding blocks outputs feature maps. These feature maps are transmitted to the skip connection module and the next layer of encoding blocks, and the last layer of encoding blocks transmits the feature maps generated by them to the first layer of decoding blocks of the decoder. In the decoder, each layer of decoding blocks performs upsampling and feature extraction operations, and after these operations, the decoding blocks output feature maps. Furthermore, each layer of decoding blocks receives feature maps generated from the skip connection module and the previous layer of decoding blocks, and transmits the generated feature maps to the next layer of decoding blocks. The feature maps generated by the last layer of decoding blocks are transmitted to a convolutional layer. The convolutional layer adjusts the size of the feature map and transmits the output feature map to the recoloring module. The recoloring module receives the feature maps generated by the convolutional layer, as well as the noise data and color style features transmitted from the skip connection module. Finally, after the operation, the recoloring module outputs a generated map containing the target color style.
[0035] The skip connection module of the model network can be divided into two main parts: latent feature extraction and style feature extraction. In the latent feature extraction part, the module receives the feature map output from the encoding block in the encoder, then extracts the latent features of the objects in the image, and then transmits the feature map containing the latent features to the corresponding decoding block in the decoder. In the style feature extraction part, the module receives the feature map output by the encoding block in the encoder on the one hand, and obtains the color style features of the target color style image on the other hand. Then, the module combines the feature map obtained from the encoding block with the color style features of the color style image to form a style feature. Finally, these style features and noise data will be transmitted to the recoloring module for color style transfer operation.
[0036] The following is a more detailed introduction to each part of the model network of the present invention:
[0037] The encoder is a very important part of the model. Its function is to receive the input image and perform feature extraction and downsampling operations on the image. The encoder consists of multiple encoding blocks. The first encoding block is used to receive the input image, and the last encoding block outputs the feature map corresponding to the image and inputs the feature map to the decoder. The feature map generated by each encoding block will be passed to the encoding block of the next layer; at the same time, the feature map output by the encoding block will also be transmitted to the jump connection module.
[0038] The encoder is mainly composed of 6 layers of encoding blocks connected in sequence. In each encoding block, the input feature map or image will be input into a convolution layer and a convolution module for feature extraction. More specifically, the convolution module contains a convolution layer, an instance normalization layer, and an activation function layer. The feature map generated by this convolution module will be input into the dual attention mechanism module for further feature extraction, and the output of the attention mechanism module will be input into another convolution module for processing and output feature map Then, the feature map It will be added to the feature map generated by the first convolutional layer to perform feature fusion and generate a feature map Finally, the feature map It will be input to a convolutional layer for receiving and downsampling. Among them, the 6 layers of sequentially connected encoding blocks are as follows: the first layer encoding block receives the input image and outputs a feature map of 1 / 2 the size of the original image after operation processing; the second layer encoding block receives the feature map output from the first layer encoding block and outputs a feature map of 1 / 4 the size of the original image after operation processing; the third layer encoding block receives the feature map output from the second layer encoding block and outputs a feature map of 1 / 8 the size of the original image after operation processing; the fourth layer encoding block receives the feature map generated from the third layer encoding block and outputs a feature map of 1 / 16 the size of the original image after operation processing; the fifth layer encoding block receives the feature map generated from the fourth layer encoding block and outputs a feature map of 1 / 32 the size of the original image after operation processing; the sixth layer encoding block receives the feature map generated from the fifth layer encoding block and outputs a feature map of 1 / 64 the size of the original image after operation processing.
[0039] The encoding block including the newly proposed dual attention mechanism module in the present invention includes a convolution layer, a convolution module and a dual attention mechanism module, wherein the convolution module is mainly composed of a convolution layer, an instance normalization layer, and an activation function layer, such as Figure 2 As shown in . In the encoder, the input data of the first layer coding block is image data, while the input data of the second, third, fourth, fifth, and sixth layer coding blocks are all feature maps. Figure 2As shown in the figure, after the input data enters the encoding block, it first enters a convolution layer Conv1 for feature extraction. The feature map output by the convolution layer Conv1 will be used for subsequent feature optimization operations. At the same time, the input data of the encoding block will also be input into the convolution module ConvBlock1 for feature extraction. After the feature extraction operation, the convolution module ConvBlock1 will output the feature map F. The feature map F will be input into the dual attention mechanism module, in which the feature map F is transformed into the query value query, the key value key and the content value value. Then, the query value query and the key value key will be transformed to generate the feature map f1 for attention operation. The transformation operation here includes matrix multiplication, Softmax and other operations. Next, the feature map f1 will perform attention operation with the content value value to generate the attention feature map f2. The attention operation here mainly includes batch matrix multiplication and other operations. In order to further use the attention mechanism to extract the features of objects in the image data, the attention mechanism operation is further used to perform feature extraction operation on the obtained attention feature map f2. The specific method is to use the content value value and the attention feature map f2 to perform a weighted average operation, and then perform an attention operation on the feature map f' obtained after the weighted average with the feature map f1. The process is described by the following formula:
[0040] f' = α╳value+ β╳f2Formula 1
[0041] f3 = attent ( f1, f' ) Formula 2
[0042] Among them, in formula 1, f' is the feature map obtained by weighted average operation of content value and attention feature map f2; α and β are coefficients, and both of them have values 0 to 1, α+β=1. In formula 2, f3 is the attention feature map obtained by performing attention operation on feature map f1 and feature map f'; attent(·) represents the attention operation.
[0043] Next, the attention feature map f3 will be optimized with the feature map F to obtain the optimized feature map f4. The specific operation of feature optimization is shown in the following formula:
[0044] f4 = γ╳f3+ F formula 3
[0045] In Formula 3, f4 is the feature map obtained after feature optimization; γ is a coefficient, and its value ranges from 0 to 1.
[0046] Then the optimized feature map f4 will be processed by the convolution module ConvBlock2 for feature extraction, and the feature map output by ConvBlock2 It will be added to the feature map output by the convolution layer Conv1. Finally, the feature map obtained by the addition operation It will be sent to the convolutional layer Conv2 for feature extraction and downsampling. The feature map output by the convolutional layer Conv2 is the final output feature map of the encoding block.
[0047] The decoder is mainly used to receive the feature maps output by the encoder and the jump connection module, and perform feature extraction and upsampling operations on these feature maps. The decoder consists of multiple decoding blocks, among which the first decoding block receives the feature maps output by the encoder and the jump connection module; the last decoding block performs upsampling operations on the received feature maps and generates corresponding feature maps and generated maps. In addition, each decoding block receives the feature maps output by the decoding block of the previous layer; at the same time, each decoding block also receives the corresponding feature maps output from the jump connection module. Finally, after each decoding block completes the feature extraction and upsampling operations on the feature map, it transmits the output feature map to the decoding block of the next layer.
[0048] The decoder mainly consists of 4 layers of sequentially connected decoding blocks: In each decoding block, the feature maps from the encoder and the skip connection module are input into a convolution module for feature extraction. After the feature extraction operation is completed, the output results of the above-mentioned convolution modules that process different feature maps are concatenated together and input into the next convolution module for further feature extraction, thereby generating a feature map. The feature map from the encoder is processed by a convolutional layer and the output feature map is combined with the feature map Add, and input the generated feature map into the next convolution module, which will output the feature map Next, the feature map It will enter two branches for different processing operations. In one branch, the feature map Will be directly passed to the upsampling layer for upsampling operation; in another branch, the feature map It will first be input into a convolutional layer for feature extraction, and then the output of the feature extraction will be added to the color feature map, and the result of the addition will be input into the upsampling layer for upsampling. The convolution module in the decoding block includes a convolutional layer and an activation function layer in sequence. Among them, the 4 layers of decoding blocks connected in sequence are as follows: the first layer decoding block receives the feature maps output from the encoder and the jump connection module respectively, and outputs the feature map of the original image size 1 / 32 after operation processing; 3. The second layer decoding block receives the feature maps output from the first layer decoding block and the jump connection module respectively, and outputs the feature map of the original image size 1 / 16 after operation processing; 4. The third layer decoding block receives the feature maps output from the second layer decoding block and the jump connection module respectively, and outputs the feature map of the original image size 1 / 8 after operation processing; 5. The fourth layer decoding block receives the feature maps output from the third layer decoding block and the jump connection module respectively, and outputs the feature map of the original image size 1 / 4 and the generated image after operation processing.
[0049] The jump connection module mainly consists of two parts: the latent feature extraction part and the style feature extraction part. In the latent feature extraction part, it will obtain the feature maps output by the third, fourth, fifth and sixth layer encoding blocks in the encoder respectively, and then pass each feature map to the corresponding decoding block in the decoder. In the style feature extraction part, on the one hand, it extracts the histogram features of the color style from the target style map; on the other hand, it receives the feature maps output by the first and second layer encoding blocks in the encoder, and fuses the feature maps of the encoding blocks with the color style feature maps through operations such as convolution to form a new style feature map. Finally, the new style feature map and noise data will be passed to the generation block corresponding to the recoloring module.
[0050] In the latent feature extraction part, the feature maps output by the third, fourth, fifth and sixth layer encoding blocks in the encoder are used to obtain the latent features in the feature maps through transformation and other operations. After the latent features in the feature maps are extracted, the latent features belonging to the feature maps output by the third, fourth, fifth and sixth layer encoding blocks in the encoder are transmitted to the fourth, third, second and first layer decoding blocks in the decoder respectively.
[0051] In the style feature extraction part, there are two main aspects. On the one hand, the model extracts the histogram features of the color style from the target style map. These color style features will undergo linear transformation and other operations to form convolution kernels. On the other hand, this part receives the feature maps output by the first and second layer encoding blocks in the encoder respectively, and then uses these feature maps to perform convolution operations with the convolution kernels formed by the color style features, thereby generating new style feature maps. Finally, these newly generated style feature maps are transmitted to the recoloring module together with the noise data. It should be noted that the style feature maps generated by the output feature maps of the first and second layer encoding blocks in the encoder will be transmitted to the second and first layer generation blocks of the recoloring module respectively.
[0052] The recolorization module is mainly used to process the feature maps output from the decoder and the jump connection module, and perform color feature migration and upsampling operations on these feature maps. The module consists of two generation blocks: the first generation block receives the feature maps output from the decoder and the jump connection module, and outputs the processed feature maps; the second generation block receives the feature maps output from the previous generation block and the jump connection module, and outputs image data with the target color style.
[0053] Specifically, the recoloring module is mainly composed of two layers of sequentially connected generation blocks. In each generation block, the feature map output by the decoder or the previous generation block is first input to the upsampling layer for upsampling operation to generate a feature map. Feature Map The first feature transfer module is used as an example. First, the noise data and color style features of the jump connection module are linearly transformed by the linear transformation layer. The color style features after linear transformation are transformed to form a convolution kernel. The convolution kernel is used to combine with the feature map. After the convolution operation, the feature map will be output. Feature Map It is added to the noise data output by the linear transformation layer and processed by the activation function layer to generate the feature map output by the feature migration module. After the above operation is completed in the first feature migration module, the feature map output by the first feature migration module will be input into the second feature migration module, and the above operation will be repeated. The second feature migration module will receive the feature map generated by the first feature migration module, complete the feature migration process, and then output the feature map. Then, the feature map The RGB information data and color style features from the jump connection module will be input into the RGB conversion layer to generate the corresponding RGB image data. The two layers of sequentially connected generation blocks are as follows: the first layer generation block receives the feature map output by the jump connection module, and receives the feature map output from the decoder and processed by a layer of convolution. The generation block operates on the feature map and outputs a feature map of 1 / 2 the size of the original image; the second layer generation block receives the feature map output by the first layer generation block and the jump connection module, and operates on the feature map and outputs the generated image data of the same size as the original image.
[0054] The present invention proposes a new dual attention mechanism module, and the module can be used to optimize the recoloring histogram feature generation adversarial network (Recoloring-HistoGAN, ReHistoGAN), and generate high-quality generated graphs. The present invention also proposes a deep learning model including the above dual attention mechanism module. The model mainly includes four modules: encoder (Encoder), decoder (Decoder), skip connection module (Skip connection module), recoloring module (Recoloring module). Among them, the dual attention mechanism module mentioned in the present invention is mainly included in each encoding block of the encoder. The dual attention mechanism module in each encoding block helps the encoder to extract high-quality features, so that the optimized ReHistoGAN can generate a rendering with better visual effects.
[0055] In order to test the performance of the network of the method of the present invention, an image containing a landscape is used to test the method of the present invention. Experiments have shown that the color style image generated by the method of the present invention has a better visual effect than the color style image generated by using only ReHistoGAN, because the high-quality features are extracted by using the dual attention mechanism module. Figure 3 As shown in the figure, it can be seen that in the rendering produced by ReHistoGAN, the color rendering is unevenly distributed, which makes the overall visual effect poor. In contrast, in the rendering produced by the method of the present invention, the color distribution is uniform, and the visual effect is better.
[0056] The above description is the best embodiment based on the concept and working principle of the invention. The above embodiment should not be understood as limiting the protection scope of the present claims, and other implementations and combinations of implementations according to the concept of the present invention belong to the protection scope of the present invention.
Claims
1. A color migration method for optimizing a generative adversarial network by using a dual attention mechanism module, characterized in that: The method adopts a recoloring histogram feature generation adversarial network as a basic model, the basic model includes an encoder, a decoder, a skip connection module and a recoloring module, and the method includes the following steps: An input image is received through the encoder, and feature extraction and downsampling operations are performed on the image, wherein each encoding block in the encoder includes a newly proposed dual attention mechanism module; receiving, through the decoder, feature maps output by the encoder and the skip connection module, and performing feature extraction and upsampling operations on the feature maps; Transmitting the feature map generated by the encoder to the decoder through the skip connection module, and combining the extracted color style features with the feature map output by the encoder to generate a new feature map having target color style features; and The feature maps output from the decoder and the skip connection module are processed by the recoloring module, and color feature migration and upsampling operations are performed on the feature maps.
2. The color migration method of optimizing the generative adversarial network by the dual attention mechanism module according to claim 1, characterized in that: in, The encoder is composed of multiple encoding blocks, wherein the first encoding block in the encoder is used to receive an input image, the last encoding block outputs a feature map corresponding to the image, and inputs the feature map to the decoder, and the feature map generated by each encoding block is passed to the encoding block of the next layer; at the same time, the feature map output by the encoding block is also transmitted to the jump connection module.
3. The color migration method of optimizing the generative adversarial network by the dual attention mechanism module according to claim 1, characterized in that: The encoding block includes a convolution layer, a convolution module and a dual attention mechanism module. The convolution module is mainly composed of a convolution layer, an instance normalization layer and an activation function layer.
4. The color migration method of optimizing the generative adversarial network by dual attention mechanism module according to claim 3, characterized in that: The algorithm flow of the encoding block is as follows: after the input data enters the encoding block, it first enters a convolution layer Conv1 for feature extraction operation, and the feature map output by the convolution layer Conv1 will be used for subsequent feature optimization operations; at the same time, the input data of the encoding block will also be input into the convolution module ConvBlock1 for feature extraction, and the convolution module ConvBlock1 will output a feature map F after the feature extraction operation; the feature map F is input into the dual attention mechanism module, in which the feature map F is transformed into a query value query, a key value key and a content value value through a transformation operation; then, the query value query and the key value key will be transformed to generate a feature map f1 for attention operation; then, the feature map f1 will perform an attention operation with the content value value to generate an attention feature map f2; in order to further use the attention mechanism to extract the features of objects in the image data, the attention mechanism operation is further used to perform a feature extraction operation on the obtained attention feature map f2. The specific method is to use the content value value and the attention feature map f2 to perform a weighted average operation, and then perform an attention operation on the feature map f' obtained after the weighted average with the feature map f1. The process is described by the following formula: f' = α╳value+ β╳f2Formula 1 f3 = attent ( f1, f' ) Formula 2 Wherein, in formula 1, f' is the feature map obtained by weighted averaging the content value value and the attention feature map f2; α and β are coefficients, and both of them are between 0 and 1, α+β=1; in formula 2, f3 is the attention feature map obtained by performing attention operation on the feature map f1 and the feature map f'; attent(·) represents the attention operation; Next, the attention feature map f3 and the feature map F are subjected to feature optimization operations to obtain the optimized feature map f4. The specific operation of feature optimization is shown in the following formula: f4 = γ╳f3+ F formula 3 In Formula 3, f4 is the feature map obtained after feature optimization; γ is a coefficient, ranging from 0 to 1; The optimized feature map f4 is then processed by the convolution module ConvBlock2 for feature extraction, and the feature map output by the convolution module ConvBlock2 is It will be added to the feature map output by the convolution layer Conv1; finally, the feature map obtained by the addition operation It will be transmitted to the convolution layer Conv2 for feature extraction and downsampling operations. The feature map output by the convolution layer Conv2 is the final output feature map of the encoding block.
5. The color migration method of optimizing the generative adversarial network by the dual attention mechanism model according to claim 1, characterized in that: The decoder is composed of multiple decoding blocks, wherein the first decoding block in the decoder receives the feature map output by the encoder and the jump connection module; the last decoding block performs upsampling operation on the received feature map and generates a corresponding feature map and a generated map; in addition, each decoding block receives the feature map output by the decoding block of the previous layer; at the same time, each decoding block also receives the corresponding feature map output from the jump connection module; finally, after each decoding block completes feature extraction and upsampling operations on the feature map, it transmits the output feature map to the decoding block of the next layer.
6. The color migration method of optimizing a generative adversarial network by a dual attention mechanism module according to claim 1, characterized in that: The jump connection module comprises: Extracting the potential feature part, the feature maps output by the third, fourth, fifth and sixth layer encoding blocks in the encoder will be used to obtain the potential features in the feature maps through operations such as transformation. After the potential features in the feature maps are extracted, the potential features of the feature maps output by the third, fourth, fifth and sixth layer encoding blocks in the encoder will be transmitted to the fourth, third, second and first layer decoding blocks in the decoder respectively; The style feature extraction part has two main aspects: on the one hand, the model extracts the histogram features of the color style from the target style map, and these color style features will undergo linear transformation and other operations to form a convolution kernel; on the other hand, this part receives the feature maps output by the first and second layer encoding blocks in the encoder respectively, and then uses these feature maps to perform convolution operations with the convolution kernels formed by the color style features, thereby generating new style feature maps; finally, these newly generated style feature maps are transmitted to the recoloring module together with the noise data; it should be noted that the style feature maps generated by the output feature maps of the first and second layer encoding blocks in the encoder will be transmitted to the second and first layer generation blocks of the recoloring module respectively.
7. The color migration method of generating adversarial networks by dual attention optimization according to claim 1, characterized in that The recoloring module comprises: a first generation block, configured to receive the feature map output from the decoder and the skip connection module, and output a processed feature map; and The second generation block is used to receive the feature map output from the previous generation block and the jump connection module, and output image data with a target color style.
