Image style migration and model training method, device and equipment

By performing content feature extraction, style feature extraction and multi-level feature fusion on images, combined with diffusion network processing, the problem of insufficient image quality after image style migration is solved, and higher content and style consistency and accuracy are achieved.

CN118657656APending Publication Date: 2024-09-17BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410813766.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-21
Publication Date
2024-09-17

AI Technical Summary

Technical Problem

In the existing technology, there is room for improvement in image quality after image style migration, and it is difficult to maintain the consistency of content and style features.

Method used

By extracting content features from the original image and extracting style features from the style image, and fusion processing of multiple levels of image features, combined with the diffusion network, diffusion processing of content features, style features and control features is performed, and finally the style is generated through decoding processing Image after migration.

Benefits of technology

It improves the quality of the image after style transfer, ensures that its content is consistent with the original image and the style is consistent with the style image, and enhances the feature representation ability and accuracy after transfer.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118657656A
    Figure CN118657656A
Patent Text Reader

Abstract

The invention provides an image generation and model training method, device and equipment, and relates to the technical field of artificial intelligence, in particular to the technical fields of computer vision, deep learning and the like. The image generation method comprises the following steps: performing content feature extraction processing on an original image to obtain content features of the original image; performing style feature extraction processing on the style image to obtain style features of the style image; performing fusion processing on the image features of the plurality of layers of the original image to obtain control features; performing diffusion processing on the content features, the style features and the control features to obtain features after migration; carrying out decoding processing on the migrated features to obtain a style migrated image; the content of the image after style migration is consistent with that of the original image, and the style of the image after style migration is consistent with that of the style image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence technology, specifically to technical fields such as computer vision and deep learning, and in particular to an image style transfer and model training method, device and equipment. Background Art

[0002] The image style transfer task builds connections between images and has important application value in the fields of generative artificial intelligence, multimodal large models, etc. In the image style transfer task based on image guidance, the user inputs an original image and a style image. The model needs to generate a style-transferred image based on the original image and style image input by the user. The image content needs to be consistent with the original image content and have the style characteristics of the style image.

[0003] How to improve the quality of images after style transfer is a problem that needs to be solved. Summary of the invention

[0004] The present invention provides an image style transfer and model training method, device and equipment.

[0005] According to one aspect of the present disclosure, there is provided an image style migration method, comprising: performing content feature extraction processing on an original image to obtain content features of the original image; performing style feature extraction processing on a style image to obtain style features of the style image; performing fusion processing on multiple levels of image features of the original image to obtain control features; performing diffusion processing on the content features, the style features and the control features to obtain migrated features; performing decoding processing on the migrated features to obtain a style-migrated image; the content of the style-migrated image is consistent with that of the original image, and the style is consistent with that of the style image.

[0006] According to another aspect of the present disclosure, a method for training an image style transfer model is provided, wherein the image style transfer model comprises: a diffusion network, and the method comprises: performing content feature extraction processing on an original image sample to obtain a content feature of the original image sample; performing style feature extraction processing on a style image sample to obtain a style feature of the style image sample; performing fusion processing on image features of multiple levels of the original image sample to obtain a control feature; using the diffusion network, performing diffusion processing on the content feature, the style feature and the control feature to obtain a post-migration feature; performing decoding processing on the post-migration feature to obtain a predicted image; constructing a loss function based on the predicted image and the true value image; and adjusting the model parameters of the diffusion network based on the loss function.

[0007] According to another aspect of the present disclosure, there is provided an image style migration device, comprising: a content feature extraction module, configured to perform content feature extraction processing on an original image to obtain content features of the original image; a style feature extraction module, configured to perform style feature extraction processing on a style image to obtain style features of the style image; a fusion module, configured to perform fusion processing on multiple levels of image features of the original image to obtain control features; a diffusion module, configured to perform diffusion processing on the content features, the style features and the control features to obtain migrated features; a decoding module, configured to perform decoding processing on the migrated features to obtain a style-migrated image; the content of the style-migrated image is consistent with that of the original image, and the style is consistent with that of the style image.

[0008] According to another aspect of the present disclosure, there is provided an image style transfer model training device, the image style transfer model comprising: a diffusion network, the device comprising: a content feature extraction module, used to perform content feature extraction processing on an original image sample to obtain a content feature of the original image sample; a style feature extraction module, used to perform style feature extraction processing on a style image sample to obtain a style feature of the style image sample; a fusion module, used to perform fusion processing on multiple levels of image features of the original image sample to obtain a control feature; a diffusion module, used to use the diffusion network to perform diffusion processing on the content feature, the style feature and the control feature to obtain a post-migration feature; a decoding module, used to perform decoding processing on the post-migration feature to obtain a predicted image; a construction module, used to construct a loss function based on the predicted image and the true value image; and an adjustment module, used to adjust the model parameters of the diffusion network based on the loss function.

[0009] According to another aspect of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any method as described in any of the above aspects.

[0010] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute any one of the methods according to any one of the above aspects.

[0011] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the computer program implements any one of the methods described in any one of the above aspects.

[0012] According to the technical solution disclosed in the present invention, the quality of the image after style transfer can be improved.

[0013] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.

[0015] Figure 1 is a schematic diagram according to a first embodiment of the present disclosure;

[0016] Figure 2 is a schematic diagram of an application scenario for implementing the image style transfer method of an embodiment of the present disclosure;

[0017] Figure 3 is a schematic diagram of an image style transfer process based on an image style transfer model provided according to an embodiment of the present disclosure;

[0018] Figure 4 is a schematic diagram according to a second embodiment of the present disclosure;

[0019] Figure 5 is a schematic diagram according to a third embodiment of the present disclosure;

[0020] Figure 6 is a schematic diagram according to a fourth embodiment of the present disclosure;

[0021] Figure 7 is a schematic diagram according to a fifth embodiment of the present disclosure;

[0022] Figure 8 It is a schematic diagram of an electronic device used to implement the image style transfer method of an embodiment of the present disclosure. DETAILED DESCRIPTION

[0023] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0024] There are some image style transfer methods in the related technology, but there is a problem that the quality of the generated images needs to be improved.

[0025] In order to improve the quality of images after style transfer, the present disclosure provides the following embodiments.

[0026] Figure 1 is a schematic diagram according to the first embodiment of the present disclosure. This embodiment provides an image style transfer method, the method comprising:

[0027] 101. Perform content feature extraction processing on an original image to obtain content features of the original image.

[0028] 102. Perform style feature extraction processing on the style image to obtain style features of the style image.

[0029] 103. Perform fusion processing on the original control features of multiple levels of the original image to obtain target control features.

[0030] 104. Perform diffusion processing on the content feature, the style feature and the target control feature to obtain a post-migration feature.

[0031] 105. Decode the migrated features to obtain a style-migrated image; the content of the style-migrated image is consistent with the original image, and the style is consistent with the style image.

[0032] Among them, the original image and the style image are known images, such as images input by the user.

[0033] Content features are used to characterize the content of the original image, and the corresponding acquisition process is called content feature extraction processing.

[0034] Style features are used to characterize the style of a style image, and the corresponding acquisition process is called style feature extraction.

[0035] Images can be described by content and style. Content is used to describe the overall information of the image, and style is used to describe the detailed information of the image.

[0036] Generally, content refers to the semantic information of an image, that is, the objects contained in the image and their locations; it can be described by grayscale values, object contours, etc. Style, usually refers to information such as brushstrokes, colors, textures, etc., which is more abstract information; style can be described by mathematical formulas, such as the Gram matrix.

[0037] Image features can be divided into multiple levels, for example, high-level features, middle-level features and low-level features. Specifically, high-level features are, for example, semantic features, middle-level features are, for example, depth features, and low-level features are, for example, edge features.

[0038] For the original image, multiple layers of images of the original image can be fused to obtain control features.

[0039] Fusion processing refers to fusing multiple information into one information, such as direct addition, weighted addition, concatenation, etc.

[0040] After obtaining the content features, style features and control features, these three features can be diffused to obtain the migrated features.

[0041] Diffusion processing is a processing process based on the diffusion concept, which includes two processes: forward diffusion and reverse diffusion. Forward diffusion is to continuously increase noise, and reverse diffusion is to continuously remove noise. Through diffusion processing, post-migration features with stronger representation capabilities can be obtained.

[0042] After obtaining the migrated features, they are decoded to obtain a style-migrated image. The content of the style-migrated image is consistent with the original image, and the style is consistent with the style image.

[0043] In this embodiment, the content features, style features and control features are diffused to obtain the post-migration features. The diffusion process can improve the representation ability of the post-migration features, thereby improving the quality of the image after style transfer. Specifically, the accuracy of the image after style transfer is improved, that is, the content consistency of the image after style transfer is stronger than that of the original image, and the style consistency with the style image is stronger. In addition, the diffusion process refers to the control features, and the control features are obtained based on image features at multiple levels. In this way, the image style transfer process can be fine-grained controlled. Due to the finer control, the accuracy of the image after style transfer is further improved, thereby improving the quality requirements for accuracy and better meeting the desired style transfer effect.

[0044] In order to better understand the embodiments of the present disclosure, application scenarios to which the embodiments of the present disclosure can be applied are described.

[0045] Figure 2 It is a schematic diagram of an application scenario for implementing the image style transfer method of an embodiment of the present disclosure.

[0046] like Figure 2 As shown, the image generation system includes: a user terminal 201 and a server 202. The user terminal can be a desktop computer, a mobile phone, a tablet computer, a laptop computer, a smart wearable device, etc. The server can be a local server or a cloud server, and can be a single server or a server cluster. The user terminal and the server can communicate via a wired network and / or a wireless network.

[0047] like Figure 2As shown, the user can use the user terminal to upload the image to be processed, including the original image and the style image, and the original image and the style image are transmitted to the server. The server uses the image style transfer system deployed thereon to perform image style transfer processing. Specifically, the image style transfer system uses a pre-trained image style transfer model to process the input original image and style image, and the output is the style transferred image. Afterwards, the style transferred image can be transmitted to the user terminal and displayed to the user by the user terminal. The above takes the image style transfer processing performed by the server-side image style transfer system as an example. It can be understood that if the user terminal has the corresponding capabilities locally, the image style transfer processing can also be performed locally on the user terminal.

[0048] Figure 3 It is a schematic diagram of an image style transfer process based on an image style transfer model provided according to an embodiment of the present disclosure.

[0049] like Figure 3 As shown, the image style transfer model includes: a content feature extraction network 301, a style feature extraction network 302, a style adaptation network 303, a diffusion network 304 and a decoding network 305.

[0050] The original image is input into the content feature extraction network 301, and the output is the content feature f of the original image. c ; Input the style image into the style feature extraction network 302, and the output is the style feature f of the style image s ; Input the original image into the style adaptation network 303, and the output is the control feature f a ; Input the content features, style features and control features into the diffusion network 304, and the output is the migrated features; input the migrated features into the decoding network 305, and the output is the style migrated image.

[0051] Furthermore, the content feature extraction network 301 may include an encoder and a content refinement layer, and the encoder may be a variational auto-encoder (VAE) encoder. The encoder encodes the original image into a latent variable Z c , the content refinement layer has a significant impact on the latent variable Z c After processing, we get the feature Z that retains the content information but removes the style information r ; Then the feature Z r With time step feature Z t After splicing, we get the content feature f c Among them, for the diffusion network, its input includes time step features, and the time step features are obtained after embedding the time step.

[0052] The style feature extraction network 302 may include: a feature extraction network and an embedding network. The feature extraction network may be a VGG network, which was developed in the Visual Geometry Group laboratory and is a convolutional neural network (CNN). The embedding network may be a multilayer perceptron (MLP). The feature extraction network extracts features of the style image, and the multilayer perceptron converts the features obtained by the feature extraction network into an embedding, and then the embedding is concatenated with the time step feature (time step embedding) to obtain the style feature f s .

[0053] The style adaptation network 303 may include multiple levels of extractors. For example, three levels may be used to set three extractors to extract features of the three levels respectively, and then three embedding layers may be used to convert the extracted features into embedded features, and the obtained embedded features may be used as image features of the multiple levels. Figure 3 As shown, the multiple levels of image features are semantic features, depth features and edge features.

[0054] Afterwards, a fusion layer is used to perform fusion processing on the image features at multiple levels. In this embodiment, the fusion processing is specifically weighted summation.

[0055] That is, the image features at multiple levels can be weighted and summed according to the weights input by the user to obtain the control feature f a .

[0056] After the content features, style features and control features are obtained, they are used as inputs of the diffusion network 304, and the output is the post-transfer features. The diffusion network may be a Stable Diffusion model.

[0057] The transferred features are input into the decoding network 305, and the output is the style-transferred image. The decoding network 305 may specifically be a VAE decoder.

[0058] In this way, through the above process, a style-transferred image is obtained based on the original image and the style image.

[0059] In combination with the above application scenarios, the present disclosure also provides the following embodiments.

[0060] Figure 4 is a schematic diagram according to the second embodiment of the present disclosure. This embodiment provides an image style transfer method, the method comprising:

[0061] 401. Use a pre-trained content feature extraction network to perform content feature extraction processing on an original image to obtain content features of the original image.

[0062] 402. Use a pre-trained style feature extraction network to perform style feature extraction processing on the style image to obtain style features of the style image.

[0063] 403. Use a pre-trained style adaptation network to extract multiple levels of image features of the original image; perform weighted sum processing on the multiple levels of image features based on weights input by the user to obtain control features.

[0064] Among them, the style adaptation network may include multiple feature extractors, each feature extractor may include a deep learning model and an embedding layer, and each feature extractor may obtain a level of image features, so that multiple levels of image features can be obtained.

[0065] After obtaining the image features at multiple levels, the weights input by the user can be used to perform weighted sum processing on the image features at multiple levels to obtain the control features.

[0066] Taking three levels of image features as an example, the calculation formula can be:

[0067] F a =k1*F1+k2*F2+k3*F3.

[0068] F a is the control feature, F1~F3 are three levels of image features, and k1~k3 are three weights input by the user.

[0069] In this embodiment, a weighted summation process is performed on image features at multiple levels based on weights input by the user to obtain control features, so that the user can perform fine-grained control over image features at different levels, thereby improving the accuracy of the image after style transfer.

[0070] 404. Use a pre-trained diffusion network to perform diffusion processing on the content feature, the style feature, and the control feature to obtain a migrated feature.

[0071] 405. Use a pre-trained decoding network to decode the migrated features to obtain a style-migrated image; the content of the style-migrated image is consistent with the original image, and the style is consistent with the style image.

[0072] The above-mentioned content feature extraction network, style feature extraction network, diffusion network and decoding network are all deep learning models.

[0073] In this embodiment, a pre-trained model is used to perform corresponding content feature extraction, style feature extraction, diffusion processing, and decoding processing, and the excellent performance of the deep learning model can be utilized to improve the accuracy of the image after style transfer.

[0074] For the training process of the above models, please refer to the following embodiments.

[0075] Figure 5 is a schematic diagram according to the third embodiment of the present disclosure. This embodiment provides a method for training an image style transfer model. The image style transfer model includes: a diffusion network, such as Figure 5 As shown, the method includes:

[0076] 501. Perform content feature extraction processing on an original image sample to obtain content features of the original image sample.

[0077] 502. Perform style feature extraction processing on the style image sample to obtain the style feature of the style image sample.

[0078] 503. Perform fusion processing on the image features of multiple levels of the original image sample to obtain control features.

[0079] 504. Use the diffusion network to perform diffusion processing on the content feature, the style feature, and the control feature to obtain a migrated feature.

[0080] 505. Decode the migrated features to obtain a predicted image.

[0081] 506. Construct a target loss function based on the predicted image and the true value image.

[0082] 507. Adjust model parameters of the diffusion network based on the target loss function.

[0083] The original image samples and style image samples are training samples and can come from existing data sets. The true value image can be obtained by artificial annotation or other means, and the content of the true value image is consistent with the original image sample content, and the style is consistent with the style image sample.

[0084] The above-mentioned diffusion network can be trained based on a pre-trained model, that is, the initial parameters of the diffusion network are the trained model parameters of the pre-trained diffusion network (such as the Stable Diffusion model), which can reduce the required sample size and reduce the training and deployment costs.

[0085] In addition, when adjusting the model parameters of the diffusion network, the parameters of other models can be kept unchanged, so that the diffusion network can be obtained more quickly and the model training efficiency can be improved.

[0086] In this embodiment, the content features, style features and control features are diffused to obtain the post-migration features. The diffusion process can improve the representation ability of the post-migration features, thereby improving the accuracy of the image style transfer model, and thereby improving the quality of the image after style transfer based on the model. Specifically, the accuracy of the image after style transfer is improved, that is, the content consistency of the image after style transfer is stronger than that of the original image, and the style consistency with the style image is stronger. In addition, the diffusion process refers to the control features, and the control features are obtained based on image features at multiple levels. In this way, the image style transfer process can be fine-grainedly controlled. Due to the finer control, the accuracy of the image after style transfer is further improved, thereby improving the quality requirements for accuracy and better meeting the desired style transfer effect.

[0087] In some embodiments, the image style transfer model further includes: a content feature extraction network;

[0088] The performing content feature extraction processing on the original image sample to obtain the content feature of the original image sample includes: using the content feature extraction network to perform content feature extraction processing on the original image sample to obtain the content feature of the original image sample.

[0089] In some embodiments, the image style transfer model further includes: a style feature extraction network;

[0090] The performing style feature extraction processing on the style image sample to obtain the style feature of the style image sample includes: using the style feature extraction network to perform style feature extraction processing on the style image sample to obtain the style feature of the style image sample.

[0091] In some embodiments, the image style transfer model further includes: a decoding network;

[0092] The decoding process of the migrated features to obtain a predicted image includes: using the decoding network to decode the migrated features to obtain a predicted image.

[0093] In this embodiment, by acquiring content features, style features and predicted images through the model, relevant information can be obtained simply and efficiently, thereby improving training efficiency.

[0094] In some embodiments, the image style transfer model further includes: a style adaptation network, wherein the fusion processing of the image features of multiple levels of the original image sample to obtain the control features includes:

[0095] Using the style adaptation network, extracting multiple levels of image features of the original image;

[0096] Based on the weights corresponding to the true value images, weighted sum processing is performed on the image features of the multiple levels to obtain control features.

[0097] In this embodiment, by performing weighted summation processing on image features at multiple levels through weights, fine-grained image level information control can be achieved, thereby improving the accuracy of the image style transfer model.

[0098] In addition, the style adaptation network can be trained separately, and the model parameters of other models can be fixed during separate training.

[0099] In some embodiments, the target loss function is a loss function of the diffusion network training phase, and the method may further include:

[0100] In the training phase of the style adaptation network, the model parameters of the content extraction model, the style feature extraction, the decoder and the diffusion network are fixed, and the model parameters of the style adaptation network are adjusted based on the loss function of the style adaptation network training phase.

[0101] For example, in the training phase of the style adaptation network, Figure 3 The model structure shown in the figure includes the original image samples and style image samples in the training stage. Figure 3 The structure shown in the figure obtains the predicted image of the training stage, and then uses the predicted image and the corresponding true value image to construct the loss function of the training stage. After that, the model parameters of the style adaptation network are adjusted using the loss function, while the model parameters of other models (content feature extraction network, style feature extraction network, diffusion network) are fixed, thereby realizing the separate training of the style adaptation network.

[0102] In this embodiment, by separately training the style adaptation network, it is helpful to learn the alignment between multi-level style information and inherent knowledge in the diffusion network, thereby improving the feature extraction effect of the style adaptation network, and can extract more accurate multi-level image features; in addition, by separately training the style adaptation network, the lightweight, plug-and-play and composability of the style adaptation network can be achieved, thereby improving the flexibility of the image style transfer process.

[0103] Figure 6 This is a schematic diagram according to the fourth embodiment of the present disclosure. This embodiment provides an image style migration device, the device 600 includes: a content feature extraction module 601, a style feature extraction module 602, a fusion module 603, a diffusion module 604 and a decoding module 605.

[0104] The content feature extraction module 601 is used to perform content feature extraction processing on the original image to obtain the content features of the original image; the style feature extraction module 602 is used to perform style feature extraction processing on the style image to obtain the style features of the style image; the fusion module 603 is used to perform fusion processing on multiple levels of image features of the original image to obtain control features; the diffusion module 604 is used to perform diffusion processing on the content features, the style features and the control features to obtain migrated features; the decoding module 605 is used to perform decoding processing on the migrated features to obtain a style-migrated image; the content of the style-migrated image is consistent with the original image, and the style is consistent with the style image.

[0105] In this embodiment, the content features, style features and control features are diffused to obtain the post-migration features. The diffusion process can improve the representation ability of the post-migration features, thereby improving the quality of the image after style transfer. Specifically, the accuracy of the image after style transfer is improved, that is, the content consistency of the image after style transfer is stronger than that of the original image, and the style consistency with the style image is stronger. In addition, the diffusion process refers to the control features, and the control features are obtained based on image features at multiple levels. In this way, the image style transfer process can be fine-grained controlled. Due to the finer control, the accuracy of the image after style transfer is further improved, thereby improving the quality requirements for accuracy and better meeting the desired style transfer effect.

[0106] In some embodiments, the fusion module 603 is further used to: use a pre-trained style adaptation network to extract multiple levels of image features of the original image; and perform weighted summation processing on the multiple levels of image features based on weights input by the user to obtain control features.

[0107] In this embodiment, a weighted summation process is performed on image features at multiple levels based on weights input by the user to obtain control features, so that the user can perform fine-grained control over image features at different levels, thereby improving the accuracy of the image after style transfer.

[0108] In some embodiments, the content feature extraction module 601 is further used to: use a pre-trained content feature extraction network to perform content feature extraction processing on the original image to obtain the content features of the original image.

[0109] In some embodiments, the style feature extraction module 602 is further used to: use a pre-trained style feature extraction network to perform style feature extraction processing on the style image to obtain the style features of the style image.

[0110] In some embodiments, the diffusion module 604 is further used to: use a pre-trained diffusion network to perform diffusion processing on the content feature, the style feature and the control feature to obtain a migrated feature.

[0111] In some embodiments, the decoding module 605 is further used to: use a pre-trained decoder to perform diffusion processing on the content feature, the style feature and the control feature to obtain a migrated feature.

[0112] In this embodiment, a pre-trained model is used to perform corresponding content feature extraction, style feature extraction, diffusion processing, and decoding processing, and the excellent performance of the deep learning model can be utilized to improve the accuracy of the image after style transfer.

[0113] Figure 7 700 includes: a content feature extraction module 701, a style feature extraction module 702, a fusion module 703, a diffusion module 704, a decoding module 705, a construction module 706 and an adjustment module 707.

[0114] The content feature extraction module 701 is used to perform content feature extraction processing on the original image sample to obtain the content feature of the original image sample; the style feature extraction module 702 is used to perform style feature extraction processing on the style image sample to obtain the style feature of the style image sample; the fusion module 703 is used to perform fusion processing on multiple levels of image features of the original image sample to obtain the control feature; the diffusion module 704 is used to use the diffusion network to perform diffusion processing on the content feature, the style feature and the control feature to obtain the migrated feature; the decoding module 705 is used to decode the migrated feature to obtain the predicted image; the construction module 706 is used to construct a loss function based on the predicted image and the true value image; the adjustment module 707 is used to adjust the model parameters of the diffusion network based on the loss function.

[0115] In this embodiment, the content features, style features and control features are diffused to obtain the post-migration features. The diffusion process can improve the representation ability of the post-migration features, thereby improving the accuracy of the image style transfer model, and thereby improving the quality of the image after style transfer based on the model. Specifically, the accuracy of the image after style transfer is improved, that is, the content consistency of the image after style transfer is stronger than that of the original image, and the style consistency with the style image is stronger. In addition, the diffusion process refers to the control features, and the control features are obtained based on image features at multiple levels. In this way, the image style transfer process can be fine-grainedly controlled. Due to the finer control, the accuracy of the image after style transfer is further improved, thereby improving the quality requirements for accuracy and better meeting the desired style transfer effect.

[0116] In some embodiments, the image style transfer model further includes: a content feature extraction network; the content feature extraction module is further used to: use the content feature extraction network to perform content feature extraction processing on the original image sample to obtain the content features of the original image sample.

[0117] In some embodiments, the image style transfer model further includes: a style feature extraction network; the style feature extraction module is further used to: use the style feature extraction network to perform style feature extraction processing on the style image sample to obtain the style features of the style image sample.

[0118] In some embodiments, the image style transfer model further includes: a decoding network; and the decoding module is further used to: use the decoding network to decode the transferred features to obtain a predicted image.

[0119] In this embodiment, by acquiring content features, style features and predicted images through the model, relevant information can be obtained simply and efficiently, thereby improving training efficiency.

[0120] In some embodiments, the image style transfer model also includes: a style adaptation network, and the fusion module is further used to: use the style adaptation network to extract multiple levels of image features of the original image; based on the weights corresponding to the true value image, perform weighted sum processing on the multiple levels of image features to obtain control features.

[0121] In this embodiment, by performing weighted summation processing on image features at multiple levels through weights, fine-grained image level information control can be achieved, thereby improving the accuracy of the image style transfer model.

[0122] In some embodiments, the loss function is the loss function of the diffusion network training phase, and the device further includes: an adaptation module, which is used to fix the model parameters of the content extraction model, the style feature extraction, the decoder and the diffusion network during the training phase of the style adaptation network, and adjust the model parameters of the style adaptation network based on the loss function of the style adaptation network training phase.

[0123] In this embodiment, by separately training the style adaptation network, it is helpful to learn the alignment between multi-level style information and inherent knowledge in the diffusion network, thereby improving the feature extraction effect of the style adaptation network, and can extract more accurate multi-level image features; in addition, by separately training the style adaptation network, the lightweight, plug-and-play and composability of the style adaptation network can be achieved, thereby improving the flexibility of the image style transfer process.

[0124] It can be understood that in the embodiments of the present disclosure, the same or similar contents in different embodiments can be referenced to each other.

[0125] It can be understood that the “first”, “second”, etc. in the embodiments of the present disclosure are only used for distinction and do not indicate the degree of importance, time sequence, etc.

[0126] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0127] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.

[0128] Figure 8 A schematic block diagram of an example electronic device 800 that can be used to implement an embodiment of the present disclosure is shown. The electronic device 800 is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, servers, blade servers, mainframe computers, and other suitable computers. The electronic device 800 can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0129] like Figure 8As shown, the electronic device 800 includes a computing unit 801, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 802 or a computer program loaded from a storage unit 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the electronic device 800 can also be stored. The computing unit 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.

[0130] Multiple components in the electronic device 800 are connected to the I / O interface 805, including: an input unit 806, such as a keyboard, a mouse, etc.; an output unit 807, such as various types of displays, speakers, etc.; a storage unit 808, such as a disk, an optical disk, etc.; and a communication unit 809, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 809 allows the electronic device 800 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0131] The computing unit 801 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 801 performs the various methods and processes described above, such as the image style transfer method and the image style transfer model training method. For example, in some embodiments, the image style transfer method or the image style transfer model training method may be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 808. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 800 via the ROM 802 and / or the communication unit 809. When the computer program is loaded into the RAM 803 and executed by the computing unit 801, one or more steps of the image style transfer method or the image style transfer model training method described above may be performed. Alternatively, in other embodiments, the computing unit 801 may be configured to execute the image style transfer method or the image style transfer model training method in any other appropriate manner (for example, by means of firmware).

[0132] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0133] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0134] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0135] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0136] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0137] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services ("Virtual Private Server", or "VPS" for short). The server may also be a server of a distributed system, or a server combined with a blockchain.

[0138] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0139] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A method for image style transfer, include: Performing content feature extraction processing on the original image to obtain content features of the original image; Performing style feature extraction processing on the style image to obtain style features of the style image; Performing fusion processing on the image features of multiple levels of the original image to obtain control features; Performing diffusion processing on the content feature, the style feature and the control feature to obtain a post-migration feature; The migrated features are decoded to obtain a style-migrated image; the content of the style-migrated image is consistent with the original image, and the style is consistent with the style image.

2. The method according to claim 1, in, The fusing of the image features at multiple levels of the original image to obtain the control features includes: Using a pre-trained style adaptation network to extract multiple levels of image features of the original image; Based on the weights input by the user, weighted sum processing is performed on the image features of the multiple levels to obtain the control features.

3. The method according to claim 1, in, The performing content feature extraction processing on the original image to obtain the content feature of the original image includes: A pre-trained content feature extraction network is used to perform content feature extraction processing on the original image to obtain the content features of the original image.

4. The method according to claim 1, in, The performing style feature extraction processing on the style image to obtain the style feature of the style image includes: A pre-trained style feature extraction network is used to perform style feature extraction processing on the style image to obtain style features of the style image.

5. The method according to claim 1, in, The step of performing diffusion processing on the content feature, the style feature and the control feature to obtain a post-migration feature includes: A pre-trained diffusion network is used to perform diffusion processing on the content feature, the style feature and the control feature to obtain a migrated feature.

6. The method according to claim 1, in, The decoding process of the transferred features to obtain a style-transferred image includes: A pre-trained decoding network is used to perform diffusion processing on the content features, the style features and the control features to obtain post-migration features.

7. A method for training an image style transfer model, wherein the image style transfer model include: Diffusion network, the method comprising: Performing content feature extraction processing on the original image sample to obtain the content feature of the original image sample; Performing style feature extraction processing on the style image sample to obtain the style feature of the style image sample; Performing fusion processing on the image features of multiple levels of the original image sample to obtain control features; Using the diffusion network, the content feature, the style feature and the control feature are diffused to obtain a migrated feature; Decoding the migrated features to obtain a predicted image; Based on the predicted image and the true value image, construct a target loss function; Model parameters of the diffusion network are adjusted based on the objective loss function.

8. The method according to claim 7, in, The image style transfer model further includes: a style adaptation network, wherein the image features at multiple levels of the original image sample are fused to obtain control features, including: Using the style adaptation network, extracting multiple levels of image features of the original image; Based on the weights corresponding to the true value images, weighted sum processing is performed on the image features of the multiple levels to obtain control features.

9. The method according to claim 7, in, The target loss function is a loss function of the diffusion network training phase, and the method further includes: In the training phase of the style adaptation network, the model parameters of the content extraction model, the style feature extraction, the decoder and the diffusion network are fixed, and the model parameters of the style adaptation network are adjusted based on the loss function of the style adaptation network training phase.

10. The method according to claim 7, in, The image style transfer model is used in the image style transfer process as described in any one of claims 1-6.

11. An image style transfer device, include: A content feature extraction module, used to perform content feature extraction processing on the original image to obtain the content features of the original image; A style feature extraction module, used to perform style feature extraction processing on the style image to obtain the style features of the style image; A fusion module, used for fusing the image features of multiple levels of the original image to obtain control features; A diffusion module, used for performing diffusion processing on the content feature, the style feature and the control feature to obtain a post-migration feature; A decoding module is used to decode the migrated features to obtain a style-migrated image; the content of the style-migrated image is consistent with the original image, and the style is consistent with the style image.

12. The device according to claim 8, in, The fusion module is further used for: Using a pre-trained style adaptation network to extract multiple levels of image features of the original image; Based on the weights input by the user, weighted sum processing is performed on the image features of the multiple levels to obtain the control features.

13. The device according to claim 8, in, The content feature extraction module is further used for: A pre-trained content feature extraction network is used to perform content feature extraction processing on the original image to obtain the content features of the original image.

14. The device according to claim 8, in, The style feature extraction module is further used for: A pre-trained style feature extraction network is used to perform style feature extraction processing on the style image to obtain style features of the style image.

15. The device according to claim 8, in, The diffusion module is further used for: A pre-trained diffusion network is used to perform diffusion processing on the content feature, the style feature and the control feature to obtain a migrated feature.

16. The device according to claim 8, in, The decoding module is further used for: A pre-trained decoding network is used to perform diffusion processing on the content features, the style features and the control features to obtain migrated features.

17. An image style transfer model training device, the image style transfer model include: Diffusion network, the device comprising: A content feature extraction module, used to perform content feature extraction processing on the original image sample to obtain the content feature of the original image sample; A style feature extraction module, used to perform style feature extraction processing on the style image sample to obtain the style feature of the style image sample; A fusion module, used for fusing the image features of multiple levels of the original image sample to obtain control features; A diffusion module, configured to use the diffusion network to perform diffusion processing on the content feature, the style feature and the control feature to obtain a post-migration feature; A decoding module, used for decoding the migrated features to obtain a predicted image; A construction module, used to construct a target loss function based on the predicted image and the true value image; An adjustment module is used to adjust the model parameters of the diffusion network based on the target loss function.

18. The device according to claim 17, in, The image style transfer model further includes: a style adaptation network, and the fusion module is further used for: Using the style adaptation network, extracting multiple levels of image features of the original image; Based on the weights corresponding to the true value images, weighted sum processing is performed on the image features of the multiple levels to obtain control features.

19. The device according to claim 18, in, The target loss function is a loss function of the diffusion network training phase, and the device further comprises: The adaptation module is used to fix the model parameters of the content extraction model, the style feature extraction, the decoder and the diffusion network during the training phase of the style adaptation network, and adjust the model parameters of the style adaptation network based on the loss function of the style adaptation network during the training phase.

20. The device according to claim 17, in, The image style transfer model is used in the image style transfer process as described in any one of claims 1-6.

21. An electronic device, include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 10.

22. A non-transitory computer-readable storage medium storing computer instructions, in, The computer instructions are used to cause the computer to execute the method according to any one of claims 1-10.

23. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 10.