LPSTGAN-based style migration method and system

By improving the CycleGAN network model, integrating the self-attention mechanism and AES module, and combining the WGAN-GP loss function, the LPSTGAN network is constructed, which solves the problem that the existing style migration method fails to make full use of image feature information, and achieves higher quality style migration images, which is especially suitable for the style migration of Chinese landscape paintings.

CN119809915APending Publication Date: 2025-04-11QILU UNIVERSITY OF TECHNOLOGY (SHANDONG ACADEMY OF SCIENCES)
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411626989.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-14
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

The existing style transfer method fails to fully utilize image feature information during the dataset training process, resulting in the problem of overflow and inaccurate migration of migrated images, and the style transfer effect of Chinese landscape painting is not ideal.

Method used

The style migration method based on LPSTGAN network is adopted, and the CycleGAN network model is improved, the self-attention mechanism module and the advanced encryption standard AES module are integrated, and the WGAN-GP loss function is combined to build the LPSTGAN network model to improve the processing capability and image quality of feature information.

Benefits of technology

While maintaining the texture of the content image, it effectively integrates style features, improving the subjective and objective evaluation of the structure and color of generated and migrated images, especially in the transfer of Chinese landscape painting styles.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119809915A_ABST
    Figure CN119809915A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of printing media image processing, and particularly provides a style migration method and system based on an LPSTGAN network. The method comprises the steps of obtaining a training data set and a test data set; the method comprises the following steps: constructing an LPSTGAN network model by improving a CycleGAN network model; a model training environment is configured, the LPSTGAN network model is deployed in the configured model training environment, preset parameters are set, the LPSTGAN network model is trained through the training data set, and the trained LPSTGAN network model is obtained; and a weight file of the trained LPSTGAN network model is called, comprehensive evaluation is carried out on the model through a test data set, and an evaluation result is obtained, the method can effectively fuse style features while maintaining content image textures, and subjective and objective evaluation on the generated migration image is improved in the aspects of structure and color.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of printed media image processing, and in particular to a style transfer method and system based on an LPSTGAN network. Background Art

[0002] Style transfer is the process of synthesizing the style features of one image with the content features of another image to generate a new transferred image. This process is not just a simple synthesis of images and an improvement in human vision. It has a wide range of applications in film and television image processing, media information dissemination, virtual reality, and artistic and cultural creation.

[0003] Style transfer is a classic and important research direction in computer vision. Currently, many meaningful and effective transfer methods have been developed. However, in the process of transfer, the information of feature images is not fully utilized during the training of data sets. The existing transfer methods only extract local features on two-dimensional feature images. Although they can produce good results for some images, the global utilization of image feature information is not sufficient, resulting in overflow and inaccurate transfer of the final transferred images, which greatly limits its scope of application. At the same time, most of the existing transfer methods are suitable for Western paintings, and the style transfer effect of Chinese landscape paintings is not ideal. Summary of the invention

[0004] In view of this, the present invention provides a style transfer method and system based on the LPSTGAN network, which is used to effectively integrate style features while maintaining the texture of the content image, and improve the subjective and objective evaluation of the generated transfer image in terms of structure and color.

[0005] In a first aspect, the present invention provides a style transfer method based on an LPSTGAN network, the method comprising:

[0006] Step 1: Select and preprocess the public style transfer dataset and the self-built style transfer dataset, divide the dataset, and obtain the training dataset and the test dataset;

[0007] Step 2: Construct the LPSTGAN network model by improving the CycleGAN network model;

[0008] Step 3: Configure the model training environment, deploy the LPSTGAN network model in the configured model training environment, set the preset parameters, train the LPSTGAN network model through the training data set, and obtain the trained LPSTGAN network model;

[0009] Step 4: Call the weight file of the trained LPSTGAN network model, conduct a comprehensive evaluation of the model through the test data set, and obtain the evaluation results.

[0010] Optionally, step 1 includes:

[0011] After obtaining public style transfer images and self-built style transfer images, preprocessing and annotating them, divide the preprocessed style transfer dataset into training dataset and test dataset in a ratio of 7:3, store them in the specified path, and add the corresponding paths of the training dataset and test dataset to the model yaml configuration file respectively.

[0012] Optionally, the step 2 includes:

[0013] Step 21, integrate the self-attention mechanism module SDPA into the backbone network of the CycleGAN network model. The attention mechanism module SDPA performs feature aggregation operations to enhance feature expression capabilities. The attention mechanism module uses dot product calculations, scaling operations, Softmax conversions, and weighted sum operations, combined with the attention mechanism, to improve the model's ability to process feature information.

[0014] Step 22, replacing the residual network module of the CycleGAN network model with an Advanced Encryption Standard (AES) module to extract feature information;

[0015] Step 23: Use WGAN-GP as the loss function of the network model, and its expression is:

[0016]

[0017] Among them, P r and P g Represents two data distributions, and both are Π(P r , P g ), when r belongs to the joint distribution, the true data x and generated data y will be sampled from r, and ||xy|| represents the error between the true data and the generated data.

[0018] Optionally, the step 21 includes:

[0019] The self-attention mechanism module SDPA combines information retrieval, dimensionality scaling, and attention allocation theories to enhance feature expression, processing capabilities, and computing speed. When processing input features, information retrieval is applied first, then dimensionality scaling, and finally attention allocation. The specific implementation steps include:

[0020] (1) Multi-Head Attention: In order to capture information in different representation subspaces, a multi-head attention mechanism is used to split the query, key, and value matrices into multiple heads. After performing the above process independently, the results are merged to increase the expressiveness of the model.

[0021] (2) Dot-Product calculation: First, for each query vector q i With all key vectors k j Calculate the dot product to generate the original matching score matrix S, that is,

[0022] (3) Scaling operation: Divide the above matching score by d k , to complete the scaling operation and ensure numerical stability, d k is the dimension of the key vector;

[0023] (4) Softmax transformation: Apply the softmax function to the scaled scores to convert them into a probability distribution that reflects the importance of each value relative to the query;

[0024] (5) Weighted sum operation: Use the obtained probability distribution to perform weighted summation on the value matrix V to generate the final context vector C, which is the output of each query position.

[0025] Optionally, the step 22 includes:

[0026] Step 211, global average pooling, directly performing average pooling on the entire feature map, by averaging the feature values ​​of each channel to generate a converged feature value corresponding to each channel; the final converged feature vector represents the global information of the entire feature map;

[0027] Step 212, spatial and channel reconstruction convolution SCConv, using two different modules spatial reconstruction unit SRU and channel reconstruction unit CRU to reduce redundancy in feature mapping;

[0028] Step 213, diffusion constraint, erosion and blurring operations are performed on the generated migration image and the real migration image, and then the ink washing losses of the two are calculated.

[0029] Optionally, the step 3 includes:

[0030] Configure the LPSTGAN network model training environment, read the training data set and test data set through the yaml file, train the LPSTGAN network model, and continuously optimize the loss function of the LPSTGAN network model during the training process until the training converges; conduct a comprehensive evaluation through the test data set, and use visual information fidelity VIF and chromaticity score CF to measure the performance; visual information fidelity VIF is used to measure the image similarity between the generated migration image and the content image; chromaticity score CF is used to reflect the vividness of the generated migration image.

[0031] In a second aspect, the present invention provides a style transfer system based on an LPSTGAN network, wherein the system is implemented by the style transfer method based on an LPSTGAN network described in the first aspect, and the system comprises:

[0032] The data acquisition module is used to select and preprocess the public style migration dataset and the self-built style migration dataset, divide the dataset, and obtain the training dataset and the test dataset;

[0033] The network model building module is used to build the LPSTGAN network model by improving the CycleGAN network model;

[0034] Training environment configuration module, used to configure the model training environment;

[0035] The training and verification module is used to deploy the LPSTGAN network model in the configured model training environment, set preset parameters, train the LPSTGAN network model through the training data set, and obtain the trained LPSTGAN network model; call the weight file of the trained LPSTGAN network model, and comprehensively evaluate the model through the test data set to obtain the evaluation results.

[0036] In a third aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium includes a stored program, wherein when the program is running, the device where the computer-readable storage medium is located is controlled to execute the style transfer method based on the LPSTGAN network in the first aspect or any possible implementation of the first aspect.

[0037] In a fourth aspect, an embodiment of the present invention provides an electronic device, comprising: one or more processors; a memory; and one or more computer programs, wherein the one or more computer programs are stored in the memory, and the one or more computer programs include instructions, which, when executed by the device, enable the device to perform the style transfer method based on the LPSTGAN network in the first aspect or any possible implementation of the first aspect.

[0038] In the technical solution provided by the present invention, the method includes selecting and preprocessing a public style transfer data set and a self-built style transfer data set, and dividing the data set to obtain a training data set and a test data set; constructing an LPSTGAN network model by improving the CycleGAN network model; configuring a model training environment, and deploying the LPSTGAN network model in the configured model training environment, setting preset parameters, training the LPSTGAN network model through the training data set, and obtaining a trained LPSTGAN network model; calling the weight file of the trained LPSTGAN network model, and comprehensively evaluating the model through the test data set to obtain an evaluation result. The method can effectively integrate style features while maintaining the texture of the content image, and improves the subjective and objective evaluation of the generated migration image in terms of structure and color. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0040] Figure 1 A flowchart of a style transfer method based on an LPSTGAN network provided in an embodiment of the present invention;

[0041] Figure 2 A schematic diagram of the LPSTGAN network architecture provided by an embodiment of the present invention;

[0042] Figure 3 A schematic diagram of a self-attention mechanism module provided by an embodiment of the present invention;

[0043] Figure 4 A schematic diagram of the structure of the spatial and channel reconstruction convolution feature representation provided by an embodiment of the present invention;

[0044] Figure 5 A schematic diagram of a style transfer system based on an LPSTGAN network provided by an embodiment of the present invention;

[0045] Figure 6 A schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0046] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0047] It should be clear that the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0048] The terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. The singular forms "a", "said" and "the" used in the embodiments of the present invention are also intended to include plural forms, unless the context clearly indicates other meanings.

[0049] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.

[0050] The word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to determining" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)", depending on the context.

[0051] Figure 1 A flow chart of a style transfer method based on an LPSTGAN network provided in an embodiment of the present invention, such as Figure 1 As shown, the method includes:

[0052] Step 1: Select and preprocess the public style transfer dataset and the self-built style transfer dataset, divide the dataset, and obtain the training dataset and the test dataset.

[0053] In the embodiment of the present invention, step 1 includes:

[0054] After obtaining public style transfer images and self-built style transfer images, preprocessing and annotating them, divide the preprocessed style transfer dataset into training dataset and test dataset in a ratio of 7:3, store them in the specified path, and add the corresponding paths of the training dataset and test dataset to the model yaml configuration file respectively.

[0055] In the embodiment of the present invention, the public style transfer images and the self-built style transfer images include nearly 80,000 content images and 20,000 style images. The sizes of the public style transfer images and the self-built style transfer images are unified to 256×256, and color enhancement is performed.

[0056] Step 2: Build the LPSTGAN network model by improving the CycleGAN network model.

[0057] In the embodiment of the present invention, Figure 2 As shown in the figure, the LPSTGAN network model is trained by the preprocessed style transfer image, and the loss function of the LPSTGAN network model is continuously optimized during the training process to improve the accuracy of the style transfer image. The end-to-end LPSTGAN network generator model created by the CycleGAN framework integrates multiple key modules: the image enhancement module ReflectionPad is a mirror filling layer, which fills the mirror content of three pixel matrices around the image; the AES module replaces the original residual network as an encoder to give the extracted features a global view; the spatial and channel reconstruction convolution SCConv is a spatial and channel reconstruction convolution operation to improve the model's computing speed; the transposed convolution module ConvTranspose module is a deconvolution operation; InstanceNorm normalization + Relu activation function and Tanh activation function are used; the dotted line part is to fuse the low-level features obtained after convolution in the model with the high-level features at the same resolution, so that the utilization rate of feature information in each layer of the model is improved.

[0058] In the embodiment of the present invention, step 2 includes:

[0059] Step 21, integrate the self-attention mechanism module SDPA into the backbone network of the CycleGAN network model. The attention mechanism module SDPA performs feature aggregation operations to enhance feature expression capabilities. The attention mechanism module uses dot product calculations, scaling operations, Softmax conversions, and weighted sum operations, combined with the attention mechanism, to improve the model's ability to process feature information.

[0060] Step 22, replacing the residual network module of the CycleGAN network model with an Advanced Encryption Standard (AES) module to extract feature information;

[0061] The use of the AES module makes up for the deficiency that the original residual can only extract features locally, and aims to extract features globally in the convolutional network with multi-scale invariance. It replaces the residual network module of the CycleGAN network model to improve the style transfer model's extraction of feature information in the style transfer process, and can reduce the number of model parameters and computational complexity, thereby improving the quality of the generated images.

[0062] Step 23: Use WGAN-GP as the loss function of the network model, and its expression is:

[0063]

[0064] Among them, P r and P g Represents two data distributions, and both are Π(P r , P g ), when r belongs to the joint distribution, the true data x and generated data y will be sampled from r, and ||xy|| represents the error between the true data and the generated data.

[0065] In the embodiment of the present invention, Figure 3 As shown, step 21 includes:

[0066] The self-attention mechanism module SDPA combines information retrieval, dimensionality scaling and attention allocation theory to enhance feature expression, processing capabilities and computing speed; when processing input features, information retrieval is applied first, then dimensionality scaling is applied, and finally attention allocation is applied; this combination enables SDPA to more effectively highlight important features when processing complex scenes. The application of this attention mechanism can more finely adjust the network's ability to capture different features, improving the model's expressiveness and ability to understand complex patterns. Its specific implementation steps include:

[0067] (1) Multi-Head Attention: In order to capture information in different representation subspaces, a multi-head attention mechanism is used to split the query, key, and value matrices into multiple heads. After performing the above process independently, the results are merged to increase the expressiveness of the model.

[0068] (2) Dot-Product calculation: First, for each query vector q i With all key vectors k j Calculate the dot product to generate the original matching score matrix S, that is,

[0069] (3) Scaling operation: Divide the above matching score by d k , to complete the scaling operation and ensure numerical stability, d kis the dimension of the key vector;

[0070] (4) Softmax transformation: Apply the softmax function to the scaled scores to convert them into a probability distribution that reflects the importance of each value relative to the query;

[0071] (5) Weighted sum operation: Use the obtained probability distribution to perform weighted summation on the value matrix V to generate the final context vector C, which is the output of each query position.

[0072] In the embodiment of the present invention, step 22 includes:

[0073] Step 211, global average pooling, to achieve global extraction of feature information: Global average pooling is a pooling operation that aggregates the information of the entire feature map. It does not set the pooling window size, but directly averages the entire feature map, and generates a converged feature value corresponding to each channel by averaging the feature values ​​of each channel; the final converged feature vector represents the global information of the entire feature map, which can better preserve the overall features and spatial information of the original image, and has a lower risk of overfitting;

[0074] Step 212, spatial and channel reconstruction convolution SCConv, using two different modules spatial reconstruction unit SRU and channel reconstruction unit CRU to reduce redundancy in feature mapping;

[0075] SCConv can reduce computational costs and model storage, while improving the performance of the LPSTGAN network model by reducing the spatial and channel redundancy that is widely present in standard convolutions, achieving considerable performance expansion while reducing a large amount of computational load.

[0076] In the embodiment of the present invention, Figure 4 As shown in the figure, the spatial and channel reconstruction convolution SCConv optimizes the convolution network through the spatial and channel reconstruction convolution strategy. This technology is placed in a sequential manner through two key steps: spatial reconstruction and channel reconstruction. Specifically, for the intermediate input feature X in the bottleneck residual block, the spatial refinement feature Xw is first obtained through the SRU operation, and then the channel refinement feature Y is obtained using the CRU operation. The spatial redundancy and channel redundancy between features are utilized in the SCConv module and integrated into the LPSTGAN network architecture to reduce the redundancy between intermediate feature maps and enhance the feature representation of convolution.

[0077] Step 213, diffusion constraint, erosion and blurring operations are performed on the generated migration image and the real migration image, and then the ink washing losses of the two are calculated.

[0078] The erosion operation can remove interfering pixels and discrete boundary points in the image. The blur operation reduces the details and sharpness in the picture and weakens the contrast between the target and the background, making the picture softer and more natural.

[0079] Step 3: Configure the model training environment and deploy the LPSTGAN network model in the configured model training environment. Set the preset parameters and train the LPSTGAN network model through the training data set to obtain the trained LPSTGAN network model.

[0080] In the embodiment of the present invention, step 3 includes:

[0081] Configure the LPSTGAN network model training environment, read the training data set and test data set through the yaml file, train the LPSTGAN network model, and continuously optimize the loss function of the LPSTGAN network model during the training process until the training converges; conduct a comprehensive evaluation through the test data set, and use visual information fidelity VIF and chromaticity score CF to measure the performance; visual information fidelity VIF is used to measure the image similarity between the generated migration image and the content image; chromaticity score CF is used to reflect the vividness of the generated migration image.

[0082] Peak signal-to-noise ratio (PSNR), mean square error (MSE), structural similarity (SSIM), and learning perceptual image similarity (LPIPS) are also used as references.

[0083] In the embodiment of the present invention, configuring the model training environment includes installing relevant software and libraries, setting hardware parameter configuration, and ensuring basic software and hardware configuration such as all dependencies. For example, torchvision is used for image operations and must be compatible with the PyTorch version; numpy is used for efficient numerical calculations; opencv-python is used for image processing; matplotlib is used for drawing charts and image display; Pillow is an image processing library, etc.

[0084] Step 4: Call the weight file of the trained LPSTGAN network model, conduct a comprehensive evaluation of the model through the test data set, and obtain the evaluation results.

[0085] In the embodiment of the present invention, the evaluation includes visualization analysis, migration content accuracy evaluation, network complexity evaluation and migration speed evaluation.

[0086] In the embodiment of the present invention, step 4 includes:

[0087] After setting up the data path configuration, preset parameters (training rounds, batches, and defect categories, etc.), logging and monitoring, backup and version control, and security and permissions, the test dataset is read through the yaml file to comprehensively evaluate the LPSTGAN network model. We mainly use visual information fidelity (VIF) and color score (CF) to measure the performance of these methods. VIF measures the image similarity between the generated migration image and the content image, and has a higher consistency with subjective vision. CF reflects the vividness of the generated migration image. Peak signal-to-noise ratio (PSNR), mean square error (MSE), structural similarity (SSIM), and learning perceptual image similarity (LPIPS) are also used as references.

[0088] Figure 5 A schematic diagram of a style transfer system based on an LPSTGAN network provided in an embodiment of the present invention, wherein the system is implemented by the above-mentioned style transfer method based on the LPSTGAN network, such as Figure 5 As shown, the system includes:

[0089] Data acquisition module 1, network model construction module 2, training environment configuration module 3 and training and verification module 4; data acquisition module 1 is connected to network model construction module 2, network model construction module 2 is connected to training environment configuration module 3, and training environment configuration module 3 is connected to training and verification module 4.

[0090] The data acquisition module 1 is used to select and preprocess the public style transfer data set and the self-built style transfer data set, and divide the data set to obtain the training data set and the test data set; the network model construction module 2 is used to build the LPSTGAN network model by improving the CycleGAN network model; the training environment configuration module 3 is used to configure the model training environment; the training and verification module 4 is used to deploy the LPSTGAN network model in the configured model training environment, set preset parameters, train the LPSTGAN network model through the training data set, and obtain the trained LPSTGAN network model; call the weight file of the trained LPSTGAN network model, comprehensively evaluate the model through the test data set, and obtain the evaluation result.

[0091] In an embodiment of the present invention, the loss function of the LPSTGAN network model is continuously optimized during the training process to improve the accuracy of style transfer; the end-to-end LPSTGAN network model created by the CycleGAN framework has a streamlined network structure, so that it can be better deployed and run on detection devices with limited computing power, thereby performing style transfer on content images and style images, and improving the accuracy and speed of style transfer.

[0092] The present invention aims to improve the accuracy and efficiency of style transfer, while realizing the style transfer of Chinese landscape painting features. In order to enhance the network's ability to recognize important features, the present invention introduces an attention mechanism module SDPA into the backbone network of the CycleGAN network model; in order to improve computational efficiency and reduce the number of model parameters, the present invention replaces the original residual network with an AES module of a globally connected residual network; in order to improve the realism of style transfer of Chinese landscape painting features, diffusion constraints are introduced; finally, in order to optimize the accuracy of target positioning and regression loss, the present invention applies the WGAN-GP loss function. The present invention can not only improve the speed and accuracy of style transfer, but also reduce the computational burden, making the model suitable for running on resource-constrained devices. Compared with other algorithms, the present invention increases the fidelity of visual information and image similarity, and also optimizes the efficiency and accuracy of the entire detection process.

[0093] Each step of the embodiment of the present invention may be performed by an electronic device, which includes but is not limited to a mobile phone, a tablet computer, a portable PC, a desktop computer, etc.

[0094] In the technical solution provided by the present invention, the method includes selecting and preprocessing a public style transfer data set and a self-built style transfer data set, and dividing the data set to obtain a training data set and a test data set; constructing an LPSTGAN network model by improving the CycleGAN network model; configuring a model training environment, and deploying the LPSTGAN network model in the configured model training environment, setting preset parameters, training the LPSTGAN network model through the training data set, and obtaining a trained LPSTGAN network model; calling the weight file of the trained LPSTGAN network model, and comprehensively evaluating the model through the test data set to obtain an evaluation result. The method can effectively integrate style features while maintaining the texture of the content image, and improves the subjective and objective evaluation of the generated migration image in terms of structure and color.

[0095] An embodiment of the present invention provides a computer-readable storage medium, which includes a stored program, wherein when the program is running, the electronic device where the computer-readable storage medium is located is controlled to execute the above-mentioned embodiment of the style transfer method based on the LPSTGAN network.

[0096] Figure 6 A schematic diagram of an electronic device provided by an embodiment of the present invention, such as Figure 6 As shown, the electronic device 21 includes: a processor 211, a memory 212, and a computer program 213 stored in the memory 212 and executable on the processor 211. When the computer program 213 is executed by the processor 211, the style transfer method based on the LPSTGAN network in the embodiment is implemented. To avoid repetition, they are not described one by one here.

[0097] The electronic device 21 includes, but is not limited to, a processor 211 and a memory 212. Those skilled in the art will appreciate that Figure 6 It is only an example of the electronic device 21 and does not constitute a limitation of the electronic device 21. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device may also include input and output devices, network access devices, buses, etc.

[0098] The processor 211 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0099] The memory 212 may be an internal storage unit of the electronic device 21, such as a hard disk or memory of the electronic device 21. The memory 212 may also be an external storage device of the electronic device 21, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 21. Further, the memory 212 may also include both an internal storage unit of the electronic device 21 and an external storage device. The memory 212 is used to store computer programs and other programs and data required by network devices. The memory 212 may also be used to temporarily store data that has been output or is to be output.

[0100] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0101] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A style transfer method based on LPSTGAN network, characterized in that: The method comprises: Step 1: Select and preprocess the public style transfer dataset and the self-built style transfer dataset, divide the dataset, and obtain the training dataset and the test dataset; Step 2: Construct the LPSTGAN network model by improving the CycleGAN network model; Step 3: Configure the model training environment, deploy the LPSTGAN network model in the configured model training environment, set the preset parameters, train the LPSTGAN network model through the training data set, and obtain the trained LPSTGAN network model; Step 4: Call the weight file of the trained LPSTGAN network model, conduct a comprehensive evaluation of the model through the test data set, and obtain the evaluation results.

2. The method according to claim 1, characterized in that The step 1 comprises: After obtaining public style transfer images and self-built style transfer images, preprocessing and annotating them, divide the preprocessed style transfer dataset into training dataset and test dataset in a ratio of 7:3, store them in the specified path, and add the corresponding paths of the training dataset and test dataset to the model yaml configuration file respectively.

3. The method according to claim 1, characterized in that The step 2 comprises: Step 21, integrate the self-attention mechanism module SDPA into the backbone network of the CycleGAN network model. The attention mechanism module SDPA performs feature aggregation operations to enhance feature expression capabilities. The attention mechanism module uses dot product calculations, scaling operations, Softmax conversions, and weighted sum operations, combined with the attention mechanism, to improve the model's ability to process feature information. Step 22, replacing the residual network module of the CycleGAN network model with an Advanced Encryption Standard (AES) module to extract feature information; Step 23: Use WGAN-GP as the loss function of the network model, and its expression is: Among them, P r and P g Represents two data distributions, and both are Π(P r , P g ), when r belongs to the joint distribution, the true data x and generated data y will be sampled from r, and ||xy|| represents the error between the true data and the generated data.

4. The method according to claim 1, characterized in that The step 21 comprises: The self-attention mechanism module SDPA combines information retrieval, dimensionality scaling, and attention allocation theories to enhance feature expression, processing capabilities, and computing speed. When processing input features, information retrieval is applied first, then dimensionality scaling, and finally attention allocation. The specific implementation steps include: (1) Multi-Head Attention: In order to capture information in different representation subspaces, a multi-head attention mechanism is used to split the query, key, and value matrices into multiple heads. After performing the above process independently, the results are merged to increase the expressiveness of the model. (2) Dot-Product calculation: First, for each query vector q i With all key vectors k j Calculate the dot product to generate the original matching score matrix S, that is, (3) Scaling operation: Divide the above matching score by d k , to complete the scaling operation and ensure numerical stability, d k is the dimension of the key vector; (4) Softmax transformation: Apply the softmax function to the scaled scores to convert them into a probability distribution that reflects the importance of each value relative to the query; (5) Weighted sum operation: Use the obtained probability distribution to perform weighted summation on the value matrix V to generate the final context vector C, which is the output of each query position.

5. The method according to claim 1, characterized in that The step 22 comprises: Step 211, global average pooling, directly performing average pooling on the entire feature map, by averaging the feature values ​​of each channel to generate a converged feature value corresponding to each channel; the final converged feature vector represents the global information of the entire feature map; Step 212, spatial and channel reconstruction convolution SCConv, using two different modules spatial reconstruction unit SRU and channel reconstruction unit CRU to reduce redundancy in feature mapping; Step 213, diffusion constraint, erosion and blurring operations are performed on the generated migration image and the real migration image, and then the ink washing losses of the two are calculated.

6. The method according to claim 1, characterized in that The step 3 comprises: Configure the LPSTGAN network model training environment, read the training data set and test data set through the yaml file, train the LPSTGAN network model, and continuously optimize the loss function of the LPSTGAN network model during the training process until the training converges; conduct a comprehensive evaluation through the test data set, and use visual information fidelity VIF and chromaticity score CF to measure the performance; visual information fidelity VIF is used to measure the image similarity between the generated migration image and the content image; chromaticity score CF is used to reflect the vividness of the generated migration image.

7. A style transfer system based on LPSTGAN network, characterized in that: The system is implemented by the style transfer method based on the LPSTGAN network according to claim 1, and the system includes: The data acquisition module is used to select and preprocess the public style migration dataset and the self-built style migration dataset, divide the dataset, and obtain the training dataset and the test dataset; The network model building module is used to build the LPSTGAN network model by improving the CycleGAN network model; Training environment configuration module, used to configure the model training environment; The training and verification module is used to deploy the LPSTGAN network model in the configured model training environment, set preset parameters, train the LPSTGAN network model through the training data set, and obtain the trained LPSTGAN network model; call the weight file of the trained LPSTGAN network model, and comprehensively evaluate the model through the test data set to obtain the evaluation results.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the style transfer method based on the LPSTGAN network according to any one of claims 1 to 6.

9. An electronic device, characterized in that: include: one or more processors; Memory; And one or more computer programs, wherein the one or more computer programs are stored in the memory, and the one or more computer programs include instructions, which, when executed by the device, enable the device to perform the style transfer method based on the LPSTGAN network as described in any one of claims 1 to 6.