A universal cross-domain image conversion method and system
By using a dual-branch structure and a CLIP2P mapper in the StyleGAN network, combined with a hybrid training strategy of optimization and learning, the flexibility and computational overhead problems of image conversion methods in the existing technology are solved, and efficient, efficient switching between multiple domains is achieved. Flexible image conversion and improved conversion quality.
Patent Information
- Application Number
- CN202410763708.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-14
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2044-06-14
AI Technical Summary
Existing image conversion methods have deficiencies in flexibility, versatility, and computational overhead. It is difficult to perform flexible image conversion between multiple domains, and the conversion effect is poor when the domains are widely different.
Using the fixed network parameters and dual-branch structure of the StyleGAN network, the cross-domain correspondence is established through CLIP latent coding and decoupling modules, and the CLIP latent coding is mapped to the StyleGAN latent space using the CLIP2P mapper. A hybrid training strategy combining optimization and learning is generated. Target domain image.
It achieves seamless image conversion from any source domain image to a specified target domain, reduces computational overhead and training data requirements, improves the flexibility and quality of image conversion, and can handle conversion tasks with large differences between domains.
Smart Images

Figure CN118334458B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of image processing, and in particular relates to a universal cross-domain image conversion method and system. Background Art
[0002] With the advancement of software and hardware computing equipment and related background technologies, as well as the growing demand for artificial intelligence generation tools in the cultural and entertainment industry, image generation has become one of the most popular research tasks. In addition to being able to directly generate a rich variety of high-definition images, image generation models can also assist the development of other related technologies with their powerful generation capabilities and superior generation quality. How to make full use of the generation capabilities of image generation models to achieve universal cross-domain image conversion. The structure and operation principle of the generation model are now analyzed.
[0003] The generative model is a style-based generative adversarial network (StyleGAN), and its generator structure is mainly divided into a mapping network and synthetic networks Two parts, where the mapping network It is composed of 8 layers of MLP, a synthetic network It is composed of stacked synthetic blocks that process spatial information at different levels. After large-scale adversarial training using a large number of training images from a certain domain, the Hidden noise in the sampling , which is input into the mapping network and mapped into a highly decoupled Hidden codes in space , and then By inputting it into the synthesis network, high-quality images in the corresponding domain can be synthesized.
[0004] In addition to its powerful generation capabilities, StyleGAN also has many superior features, such as semantic editing capabilities (to be The code moves along a certain direction in space, and the generated image will show the corresponding semantic change). In order to fully apply its generation ability and various characteristics to the processing of real images, the inversion technology was introduced. The process of GAN generating images is to input the hidden code into the generator to obtain the generated image; and inversion means to obtain a specific hidden code corresponding to a real image in some way. By inputting the hidden code obtained by inversion into the generator, the real image can be reconstructed to obtain the reconstructed result.
[0005] The current mainstream inverse methods are mainly divided into four categories: optimization-based inverse methods, inverse methods using encoders to establish inverse mapping, hybrid inverse methods based on optimization and encoders, and inverse methods that re-fine-tune the generator. Among them, the optimization-based inverse method includes: first randomly initialize a hidden code and set it as a learning parameter, use an optimizer (such as SGD, Adam, etc.) to directly optimize the hidden code, and use the reconstruction loss to minimize the difference between the image generated by the hidden code and the real image. When the loss value is less than a certain threshold, the corresponding hidden code is the inverse result. Using the inverse technology, the real image can be embedded into the hidden space of the generator more accurately, and a highly abstract representation of the real image can be obtained. The advantages of this optimization-based inverse method are that it requires fewer parameters to be optimized, less computational overhead, and high reconstruction accuracy. It can be inverted only for a single image, without the need for large-scale training, and is more flexible and simple.
[0006] In terms of image conversion, traditional conversion methods often use a large number of paired source-target domain images and directly use the conversion network to learn the mapping from the source domain to the target domain. In order to relax the need for paired data and further improve the flexibility of conversion, two types of methods, learning-based unsupervised image conversion methods and small sample domain adaptive generation methods, have achieved outstanding results in recent years.
[0007] Unsupervised image conversion methods based on learning often design new self-supervised constraints or new training processes based on traditional conversion methods. For example, CycleGAN once designed a cycle-consistent loss. The image in the domain is converted to The corresponding image in the domain, in addition to directly establishing the mapping In addition, we need to establish an inverse mapping , the cycle-consistent loss will constrain the mapping relationship when the training data is unpaired, as follows:
[0008] ;
[0009] in, , Source domain , target domain Samples in. Although CycleGAN can establish inter-domain mapping when the source domain and target domain data are unpaired, it can only convert images of two domains. If it is necessary to convert between multiple domains, it is necessary to learn the mapping between each two domains one by one, which is cumbersome. In contrast, StarGAN attempts to learn the mapping between multiple domains at the same time during a training process, integrating the information of multiple domains into a single model. StarGAN uses category vectors to identify the labels of each domain involved, and achieves the above goals by training a multi-task conditional generative adversarial network. During training, the conditional generator not only receives input images from a source domain, but also needs to input the category vector of the corresponding target domain, and generates the conversion result based on the input image and category vector; in addition to judging the true or false of the conversion result, the conditional discriminator also needs to perform domain classification on the conversion result.
[0010] In addition to the above two representative methods, GP-UNIT is a learning-based cross-domain image conversion method proposed in 2022. Previous image conversion methods can only perform conversion when the difference between the source domain and the target domain is small (for example, zebra), while GP-UNIT can convert when the difference between domains is large (e.g., human Cat). Since it is difficult to find correspondences between domains with large differences, this method uses the abstract semantic correspondences contained in different categories of data generated by the large-scale conditional generative adversarial network BigGAN to build a conversion model. Specifically, GP-UNIT designs a two-stage learning strategy from coarse to fine. In the first stage, the highly abstract coarse-grained cross-domain semantic correspondence prior from BigGAN is distilled, and in the second stage, adversarial training is used to build correspondences at more levels.
[0011] The small sample domain adaptive generation method is another important method for inter-domain conversion. This type of method is inspired by transfer learning. The main idea is that the source domain generation model trained by a large amount of source domain data contains rich and diverse prior knowledge from the source domain. A small number (<10) of samples from the target domain are used to transfer part of the source domain prior knowledge to the target domain to obtain the target domain generation model. Subsequently, the inverse technique is used to obtain the hidden code corresponding to the real source domain image to be converted, and then the hidden code is input into the target domain generator to obtain the conversion result. Since this type of method only requires a small amount of training data in the target domain, it is more flexible and simple.
[0012] Furthermore, although current image conversion methods have gradually made considerable progress, these methods are still limited in flexibility, versatility, conversion effect, etc. The specific shortcomings are as follows:
[0013] First, these methods all need to determine the types of source and target domains to be converted before starting training, and then they can start learning the mapping between domains. If the user wants to change the domains involved after training is completed, the model needs to be retrained laboriously, which seriously limits the flexibility and applicability of the model. Even though StarGAN uses a single model to handle the conversion relationship between multiple domains, its processing power is limited. When the number of domains involved increases (>5), StarGAN still has difficulty handling it.
[0014] Secondly, training or retraining learning-based transformation networks requires a large amount of training data and computational overhead. For training data, even though current unsupervised transformation methods have relaxed the requirements for training data, it is still difficult to collect a large amount of data in certain domains, such as artistic creations of a specific style or professional medical images; for computational overhead, the number of parameters and capacity of today's transformation models continue to rise, and ordinary users cannot afford the expensive training costs of such computationally intensive tasks, which limits the popularity and application of existing technologies.
[0015] Furthermore, as a method of using generative models for image conversion, small sample domain adaptive generation methods based on generative adversarial networks or diffusion models have greatly reduced the demand for training data and computing resources, but such methods rely heavily on the effect of knowledge transfer between the source domain and the target domain. This method is only applicable to situations where the source domain and the target domain are relatively similar. However, there are more heterogeneous or asymmetric domains in the real world. When the difference between the source domain and the target domain increases, the effect of knowledge transfer will quickly degrade, and the effectiveness of image conversion will be severely weakened.
[0016] Finally, GP-UNIT, as a method that specifically handles image conversion in the case of a certain gap between domains, has initially explored the establishment of connections between highly heterogeneous domains. However, while GP-UNIT inherits the cross-domain semantic correspondence prior of BigGAN, it also inherits its inherent limitations, that is, the medium- and fine-grained correspondence between images of each domain generated by BigGAN using the same hidden code is insufficient, so GP-UNIT has not successfully constructed the correspondence at the medium- and fine-grained levels.
[0017] Through the above analysis, the problems and defects of the existing technologies are as follows: In recent years, in order to realize the application of generative intelligence in complex scenarios in the real world, the versatility of generative models or other models based on generative models has received increasing attention. Although many existing technologies have constructed cross-domain correspondences using content correlations between different domains and achieved cross-domain image conversion under different settings, these methods are mostly cumbersome and inefficient from the perspective of versatility and flexibility that facilitates users' actual use in the real world. Summary of the invention
[0018] In order to overcome the problems existing in the related art, the disclosed embodiments of the present invention provide a general cross-domain image conversion method and system. In order to better model a more general conversion problem, the purpose of the present invention is to first define the universality of the cross-domain image conversion model: the ability to convert various real-world images (multiple source domain images) from any domain to a specific target domain. This definition meets the usage requirements of generative applications in real-world scenarios. For example, when a user uploads an image to an application (such as Snapchat, Tik Tok, etc.), the developer often cannot forcibly restrict the type of image uploaded by the user, but the developer can preset the special effects type or conversion type for the user to use. Therefore, this definition only limits the target domain to be specific, but not the source domain type.
[0019] The technical solution is as follows: A general cross-domain image conversion method, comprising:
[0020] S1, fixed network parameters: search for z hidden codes from the Z space of the StyleGAN network to keep the subsequent training parameters of the StyleGAN network fixed;
[0021] S2, fixed z latent code: for a single given source domain image, the first branch decoupling module in the dual-branch structure is used to find the optimal CLIP latent code in the target domain. The optimal CLIP latent code uses the learning objective of the decoupling module to make the CLIP latent code in the target domain latent space while maintaining the cross-domain correspondence with the source domain image; the second latent space mapping branch in the dual-branch structure is used to map the CLIP latent code to the latent space of StyleGAN through the CLIP2P mapper; there is an inherent gap between the CLIP latent space and the StyleGAN latent space encoding representation, and a new nonlinear mapping function is used to bridge the two spaces, and iterative optimization is performed to obtain the loss term, and then the generator generates the target domain image;
[0022] S3, based on the learning objectives and loss terms of the decoupling module, combined with the auxiliary loss function, obtains the total loss function and updates the network parameters;
[0023] S4, perform multiple iterations of training on the above steps to obtain the final universal cross-domain image.
[0024] In step S1, the z latent code is searched from the Z space of the StyleGAN network, including:
[0025] Randomly sampled from a standard Gaussian distribution The latent code is converted into CLIP code, and multiple target domain images are generated in each user-specified target domain. The above images are input into the image encoder of CLIP respectively. In the code, we get a corresponding set of CLIP codes; calculate its standard deviation and mean ,Will Implicit coding is converted to CLIP space Encoding, the expression is:
[0026] ;
[0027] In the formula, For CLIP coding, is the standard deviation of the CLIP code, is the hidden code, is the mean of the CLIP codes.
[0028] In step S2, the input of the decoupling module is: CLIP code , the source domain image as a reference , source domain and target domain category text , and sentence templates; the above data are respectively input into two submodules of the decoupling module, each of which contains two multi-layer perceptrons MLPs, and the two MLPs share parameters across branches;
[0029] Source domain image of the first submodule CLIP-pretrained image encoder Processing to obtain semantic representation ; After the first MLP processing, a 1024-dimensional vector is obtained; the 1024-dimensional vector includes two independent 512-dimensional source domain related information Information not related to the source domain ;
[0030] The input of MLP1 of the second submodule is first processed by CLIP spatial statistics to obtain the CLIP code , used to represent the final target domain image semantics; output a 1024-dimensional vector including two independent 512-dimensional semantic representations of target domain related information Information not related to the target domain .
[0031] In step S2, the first branch decoupling module in the dual-branch structure is used to find the optimal CLIP hidden code in the target domain, so that the optimal CLIP hidden code maintains the cross-domain correspondence relationship with the source domain image and obtains the learning objectives of the decoupling module. For the semantic representation obtained by the first submodule and the second submodule, the first loss function The expression is:
[0032] ;
[0033] Using cosine similarity to measure domain-related information , Domain-independent information , The corresponding degree of coupling, minimized The domain-independent representation and the domain-dependent representation will be made orthogonal to each other;
[0034] According to the categories of the source domain and the target domain, the text encoder of CLIP Generate text encodings of source and target domains and ; The domain related information of the two domains and Respectively, the text encoding representing domain-specific information and Alignment, which is achieved through the loss function The constraints provided are complete and the expression is:
[0035] ;
[0036] This formula uses cosine similarity to measure domain related information , and text encodings representing domain-specific information , The corresponding distance is ensured by minimizing the cosine distance , Correctly represent domain-related information;
[0037] The obtained text encoding is the average of the CLIP encodings obtained by embedding the category cue words of the source domain or target domain into all sentence templates;
[0038] exist and Under the constraint of and It will contain domain-independent information in the source domain and the target domain; use the loss function By constraining the similarity between the two and excluding the interference of category feature information, a cross-domain correspondence is constructed, as shown in the following formula (5):
[0039] ;
[0040] The L1 loss is used to measure the distance between the source domain and the target domain, by minimizing , the domain-independent information of the two domains will present a correspondence, so that the final conversion result will show the semantic correspondence of the homologous domain input while ensuring that it belongs to the category range of the target domain;
[0041] The two parts of information representing the target domain conversion result, target domain related information Information not related to the target domain concatenated and fed into the second MLP to reconstruct a 512-dimensional CLIP representation; the source domain information is processed in the same way; the reconstruction process is based on the L1 loss The constraints are formally expressed as follows:
[0042] ;
[0043] ;
[0044] in, represents the concatenation operation of features of the same dimension; in the process of learning network parameters, this loss can prevent domain-related and domain-independent representations from becoming redundant as the learning process progresses, and maintain image semantic encoding through formula (6) , And the reconstruction results , When optimizing When encoding, the characteristics of the domain category and the target domain are integrated. Serves as a guide to lead optimization; is the second multilayer perceptron in the decoupling module, It is a 1-norm operation;
[0045] By using the learning objectives of the decoupling module, the optimal CLIP hidden code maintains the cross-domain correspondence with the source domain image. The learning objectives of the decoupling module are as follows:
[0046] .
[0047] In step S2, the second latent space mapping branch in the dual-branch structure is used, and the CLIP2P mapper is used to map the CLIP latent code to the latent space of StyleGAN, and iterative optimization is performed to obtain the loss term, including:
[0048] right The characteristics of space ,in and is the latent code sampled in the corresponding latent space, Space is space activation space; if The space is Gaussian distributed, and the following relationship (8) holds:
[0049] ;
[0050] In the formula, and represents the standard deviation and mean of a Gaussian distribution;
[0051] Learning with a linear layer The distribution of the space does not change the Gaussianity of the CLIP single domain space, as shown in the following equation (9):
[0052] ;
[0053] Add a new nonlinear function after the linear layer Let's learn unimodal Distribution, the new nonlinear mapping function is defined as , The expression is as follows:
[0054] ;
[0055] in, , , are all learning parameters, is Euler's constant.
[0056] Furthermore, the latent space mapper consists of a linear layer and a nonlinear mapping function, denoted as CLIP2P ; The mapper is based on The Gaussian distribution constructed by the distribution statistics is used for learning, and the corresponding loss function The definition is as follows:
[0057] ;
[0058] In the formula, , is the output of the CLIP2P mapper; It does not change the inherent nonlinear properties of the CLIP2P mapper, nor does it change the output distribution;
[0059] As needed, Hyperparameters Set as a learning parameter to adaptively adjust The degree of constraint, loss term The formal expression of is as follows:
[0060] .
[0061] In step S3, combining the auxiliary loss function includes: using and to strengthen cross-domain relationships in terms of visual and perceptual quality; The source domain image and the target domain image are constrained from the perspective of Euclidean distance, as shown in the following formula (13):
[0062] ;
[0063] and:
[0064] ;
[0065] In the formula, It is a pre-trained StyleGAN generator; The perceptual correspondence between the source domain and the target domain images using the deep feature is as follows (15):
[0066] ;
[0067] in stands for Perceptual Feature Extractor.
[0068] In step S3, in combination with the auxiliary loss function, it also includes: cycle loss , and get the target domain conversion result After that, the circulation loss Image encoder fed into CLIP , and get the CLIP encoding of the result, namely ;Will Input to the CLIP2P mapper, and finally get the new output, denoted as ; Use cycle loss constraint and The consistency of is formally expressed as formula (16):
[0069] ,
[0070] .
[0071] In step S3, the total loss function The expression is as follows (17):
[0072] ;
[0073] In the formula, Represents the hyperparameter used to weigh the various loss terms.
[0074] Another object of the present invention is to provide a universal cross-domain image conversion system, which implements the universal cross-domain image conversion method, and the system comprises:
[0075] Fixed network parameter module, used to obtain the StyleGAN network Search in space Hidden coding keeps the subsequent training parameters of the StyleGAN network fixed;
[0076] fixed Hidden coding module, used for finding the optimal CLIP hidden coding in the target domain for a single given source domain image using the first branch decoupling module in the dual-branch structure, and using the learning objective of the decoupling module to make the optimal CLIP hidden coding maintain the cross-domain correspondence between the optimal CLIP hidden coding and the source domain image; using the second latent space mapping branch in the dual-branch structure, using the CLIP2P mapper, mapping the CLIP hidden coding to the latent space of StyleGAN, and performing iterative optimization to obtain the loss term, and then the generator generates the target domain image;
[0077] The total loss function acquisition module is used to obtain the total loss function based on the learning objectives and loss terms of the decoupling module and the sum of the auxiliary loss functions to update the network parameters;
[0078] Iteration module, used to fix the network parameter module, fixed The processing flow of the latent coding module and the total loss function acquisition module is trained iteratively for multiple times to obtain the final universal cross-domain image.
[0079] Combining all the above technical solutions, the beneficial effects of the present invention are as follows: the present invention proposes a universal and novel cross-domain image conversion method, which can convert a single input image from any source domain to a specified target domain. In view of the problem that the existing models are not flexible and applicable enough, the present invention will use the generative model StyleGAN pre-trained on the target domain to simulate the target domain manifold, and use the hybrid training strategy based on optimization and learning to process a single input image from any domain without specifying the source domain in advance, thereby improving its flexibility; for the problem that the existing technology has a large computational overhead, the present invention will design a lightweight conversion framework with only a small number of learning parameters, which can effectively establish the correspondence between domains without large-scale training or collecting a large number of training images in advance, thereby lowering the threshold for using image conversion methods; for the problem that the conversion effect of existing methods is seriously reduced when there are certain differences between the source domain and the target domain, on the one hand, the present invention will make full use of the generation ability of StyleGAN to enhance the quality of the conversion results, and on the other hand, the present invention will design a decoupling module to use the adaptability of the image-language model CLIP pre-trained on open world data to any domain to align the feature representations of the source domain and the target domain, and establish correspondence at the coarse, medium and fine levels. BRIEF DESCRIPTION OF THE DRAWINGS
[0080] The accompanying drawings herein are incorporated in and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description, serve to explain the principles of the present disclosure;
[0081] Figure 1 is a flow chart of a general cross-domain image conversion method provided by an embodiment of the present invention;
[0082] Figure 2 It is an overall framework principle diagram of a general cross-domain image conversion method provided by an embodiment of the present invention;
[0083] Figure 3 It is a principle diagram of the main steps of the general cross-domain image conversion method provided by an embodiment of the present invention;
[0084] Figure 4 It is a partial simulation generation result diagram of the method of the present invention provided by the embodiment of the present invention on various domains;
[0085] Figure 5 is a qualitative comparison diagram between the method provided by the embodiment of the present invention and the comparative method;
[0086] Figure 6 is a qualitative ablation experiment result diagram provided by an embodiment of the present invention;
[0087] Figure 7 It is a quantitative ablation result diagram of the method provided by the embodiment of the present invention under different settings. DETAILED DESCRIPTION
[0088] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific embodiments of the present invention are described in detail below in conjunction with the accompanying drawings. In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without violating the connotation of the present invention, so the present invention is not limited by the specific implementation disclosed below.
[0089] The innovation of the present invention is that the present invention aims to perform representation conversion between cross-domain images when the training data is limited and the visual difference is significant, and then proposes a generation framework that can achieve seamless image conversion from any source domain from the real world to a specified target domain, and only requires a single source domain image for training. The innovation of the method of the present invention is to use the CLIP model as a bridge channel, and use a separate decoupling module to extract abstract and domain-independent semantics from the embedded codes of the source domain and the target domain. These abstract semantics are fused with the specific semantics of the target domain to form a conversion embedding in the CLIP space. In order to bridge the difference in latent space distribution between CLIP and StyleGAN, the present method introduces a new nonlinear mapper, called CLIP2P mapper. This module uses CLIP encoding as a sampling sample and is designed to approximate the potential distribution in the P space of StyleGAN, effectively acting as a connector between the two latent spaces. The method of the present invention is versatile and can perform a variety of tasks, including style mixing, stylization and image conversion, and is still effective even when processing source domain images with degraded quality. Finally, the results produced by the method of the present invention have obvious advantages in image quality, visual correspondence and diversity.
[0090] The present invention proposes a training mechanism that combines optimization and learning: it combines the optimization-based method and the learning-based method, and improves the training efficiency and usage flexibility of the model by alternately optimizing latent codes and network parameters.
[0091] The specific implementation methods of the hybrid learning strategy are analyzed, including the steps of the optimization process, parameter updating rules, and how to dynamically adjust the learning strategy according to the training progress.
[0092] This paper proposes the design and implementation of a decoupling module: the decoupling module can separate domain-related information and domain-irrelevant information in the feature representation of an image, realize feature alignment when the gap between domains is large, and improve the image conversion effect. The structural design of the decoupling module, the method of decoupling domain-related and domain-irrelevant information, and how to use the module to optimize the process of cross-domain image conversion are analyzed.
[0093] This paper proposes the design and implementation of the CLIP2P mapper: CLIP2P mapper, as a bridge connecting the CLIP space and the StyleGAN latent space, can effectively convert semantic information into high-quality images in the target domain, ensuring the quality of image conversion. The design principle of the mapper, the parameter learning mechanism, and how to combine the CLIP model and the StyleGAN generator to achieve cross-domain image conversion are analyzed.
[0094] Embodiment 1, as Figure 1 As shown, the general cross-domain image conversion method provided by the embodiment of the present invention
[0095] S1, fixed network parameters: search for z hidden codes from the Z space of the StyleGAN network to keep the subsequent training parameters of the StyleGAN network fixed;
[0096] S2, fixed z latent code: for a single given source domain image, the first branch decoupling module in the dual-branch structure is used to find the optimal CLIP latent code in the target domain. The optimal CLIP latent code uses the learning objective of the decoupling module to make the CLIP latent code in the target domain latent space while maintaining the cross-domain correspondence with the source domain image; the second latent space mapping branch in the dual-branch structure is used to map the CLIP latent code to the latent space of StyleGAN through the CLIP2P mapper; there is an inherent gap between the CLIP latent space and the StyleGAN latent space encoding representation, and a new nonlinear mapping function is used to bridge the two spaces, and iterative optimization is performed to obtain the loss term, and then the generator generates the target domain image;
[0097] S3, based on the learning objectives and loss terms of the decoupling module, combined with the auxiliary loss function, obtains the total loss function and updates the network parameters;
[0098] S4, perform multiple iterations of training on the above steps to obtain the final universal cross-domain image.
[0099] Example 2, as another embodiment of the present invention, Figure 2 As shown, the overall framework principle of the general cross-domain image conversion method provided by the embodiment of the present invention includes:
[0100] For a single given source domain image (reference image), two goals are used to convert it to the target domain:
[0101] Find the optimal CLIP hidden code in the target domain so that the code maintains the cross-domain correspondence with the source domain image.
[0102] The CLIP latent code is mapped to the latent space of StyleGAN, and the generator generates the target domain image.
[0103] Specifically, first from StyleGAN The hidden code is searched in the space, and then a two-branch structure is used to achieve the above two goals respectively. The first branch is a decoupling module, which extracts domain-independent information from the two domains and establishes cross-domain correspondence without ignoring category information. The second branch aims to make full use of the superior generation ability of StyleGAN to enhance the quality and diversity of the conversion results. The key component here is the CLIP2P mapper proposed in this invention, which is used to connect the CLIP space and StyleGAN. space.
[0104] Example 3, as another embodiment of the present invention, Figure 3 As shown, the main steps and principles of the general cross-domain image conversion method provided by the embodiment of the present invention include:
[0105] Use a hybrid learning strategy for alternating training. In each iteration, learning is performed in two steps. In step 1, only optimize Hidden coding keeps the subsequent trainable parameters of the network fixed and uses the guidance information inherent in the parameters to guide Optimize the encoding; in step 2, fix the optimized code in step 1 Encode, update the network parameters in the decoupling module and CLIP2P mapper. The following will analyze each branch.
[0106] (I) Branch 1: Decoupling branch.
[0107] First, we need to randomly sample from a standard Gaussian distribution The implicit coding is converted into CLIP coding. Corgi implicitly assumed that each individual domain conforms to a high-dimensional Gaussian distribution, so the present invention generates 5,000 target domain images in each specific target domain, and then inputs these images into the CLIP image encoder respectively. Then, we calculate the standard deviation of and mean , and then according to the following formula Encoding converted to CLIP space coding:
[0108] ;
[0109] This formula is based on Gaussian distribution and uses the statistics of CLIP space to construct The calculation method of the encoding.
[0110] In the structure of the decoupling module of the present invention, the input of the module is: the above CLIP code , the source domain image as a reference , source domain and target domain category text , And sentence templates. These inputs will be fed into two submodules, one for processing source domain information and the other for processing target domain information. Each submodule contains two multi-layer perceptrons (MLPs), and the two MLPs share parameters across branches.
[0111] For the first submodule, the source domain image CLIP-pretrained image encoder Processing to obtain semantic representation . Subsequently, the representation is processed by the first MLP to obtain a 1024-dimensional vector. In order to obtain domain-independent information, the vector is divided into two parts, namely two 512-dimensional representations and , representing domain-related information and domain-irrelevant information respectively. This module hopes and Independent of each other.
[0112] The second submodule is processed in a similar way. The main difference of the first module is that the input of MLP1 is the CLIP code obtained by the previous CLIP spatial statistics processing. , the encoding will be used to represent the final target domain image semantics. Finally, the second submodule will also obtain two 512-dimensional semantic representations and .
[0113] For the semantic representation obtained by the two branches, the first loss function of this framework is as follows:
[0114] ;
[0115] This formula uses cosine similarity to measure domain related information , Domain-independent information , The corresponding degree of coupling, minimized The domain-independent representation and the domain-dependent representation will be made orthogonal to each other, ensuring the independence of the two parts.
[0116] Then, according to the category cues of the source and target domains, the text encoder of CLIP Generate text encodings of source and target domains and . Then, the domain related information of the two domains and Respectively, the text encoding representing domain-specific information and Alignment, which is achieved through the loss function The constraints provided are accomplished by:
[0117] ;
[0118] This formula uses cosine similarity to measure domain related information , and text encodings representing domain-specific information , The corresponding distance is ensured by minimizing the cosine distance , Domain-related information is correctly represented.
[0119] Similar to the approach of Radford et al., 80 different sentence templates were used to obtain text encoding using CLIP, such as "a photo of the {}", "a photo of my {}", "a good photo of a {}", etc. These sentence templates are semantically neutral and have no bias towards the source or target domain. The final text encoding is the average of the CLIP encodings obtained by embedding the category cue words of the source or target domain into all sentence templates.
[0120] exist and Under the constraint of and The domain-independent information in the source domain and the target domain will be contained. To constrain the similarity between the two, and to construct a cross-domain correspondence relationship while excluding the interference of category feature information, as shown in the following formula (5):
[0121] ;
[0122] Formula (5) uses L1 loss to measure the distance between the source domain and the target domain, by minimizing , the domain-independent information of the two domains will show a certain correspondence, so that the final conversion result will show the semantic correspondence of the homologous domain input (reference image) while ensuring that it belongs to the target domain category.
[0123] So far, there are two parts of information representing the target domain conversion results, target domain related information Information not related to the target domain , have been obtained. The two parts are then concatenated and input into the second MLP (MLP2) to reconstruct the 512-dimensional CLIP representation. The source domain information is processed in the same way. The reconstruction process is based on the L1 loss The constraints are formally expressed as follows:
[0124] ;
[0125] ;
[0126] in, Represents the concatenation operation of features of the same dimension. In the process of learning network parameters, this loss can prevent domain-related and domain-independent representations from becoming redundant as the learning progresses, and avoid the representation function of the module from degenerating. In other words, the present invention maintains the image semantic encoding through formula (6) , And the reconstruction results , When optimizing When encoding, the characteristics of the domain category and the target domain are integrated. It will serve as a guide to lead the optimization.
[0127] In summary, the learning objectives of the decoupling module are as follows:
[0128] ;
[0129] Each item in this learning objective is specially designed to achieve the purpose of maintaining cross-domain correspondence between decoupled modules.
[0130] (ii) Branch 2: latent space mapping.
[0131] The second branch aims to make full use of the generative power of StyleGAN to ensure high-quality conversion results by converting feature representations into a distribution that conforms to the original space of StyleGAN to ensure the generation quality.
[0132] As one of the original spaces of StyleGAN, the space is widely selected by many methods due to its superior decoupling characteristics. However, its distribution form is relatively complex and there is currently no method to model it. Therefore, this branch selects another original space—— Space is used as a bridge to convert the feature representation of CLIP space into In space.
[0133] II2S first The characteristics of space were observed and proposed ,in and is the hidden code sampled in the corresponding latent space, so Space can be seen as The activation space of the space. If we assume The space is Gaussian distributed, and the following relationship (8) holds:
[0134] ;
[0135] in and represents the standard deviation and mean of the Gaussian distribution. In fact, Menon et al. also used this formula in the open source code of PULSE.
[0136] Based on this assumption, the present invention first proposes formula (9), which can use the statistics previously calculated in CLIP space to construct this Gaussian distribution and use a linear layer to learn The distribution of the space does not change the Gaussianity of the CLIP single domain space, as shown in the following equation (9):
[0137] ;
[0138] However, II2S points out that The distribution of the latent space is only a unimodal distribution with a probability density shape similar to the Gaussian distribution, rather than a strict Gaussian distribution. The degree of deviation from the Gaussian distribution varies in different target domains. Therefore, using the above formula to convert on some domains may cause the conversion result to fall outside the latent space of StyleGAN, ultimately leading to conversion failure. To prevent this, this branch adds a new nonlinear function after the linear layer. Let's learn unimodal Distribution, in order to make up for the imprecision of the above formula. This invention is the first to The definition is as follows:
[0139] ;
[0140] in, , , are all learning parameters, is Euler's number. This function (10) includes:
[0141] (1) This function introduces nonlinearity to make the transformed distribution deviate from the Gaussian distribution. This function also remains monotonic, so that the Gaussian distribution transformed by the linear layer remains a unimodal distribution after being processed by the nonlinear function.
[0142] (2) By introducing the learning parameters , , , introduces a certain degree of freedom into the function, which is suitable for different degrees of deviation brought by different target domains. Controls the position of the peak of the unimodal distribution, and The curvature on both sides of the peak is controlled, bringing a certain asymmetry to the distribution.
[0143] (3) In order to maintain the continuity of the function, the two ends of the piecewise function are biased by +1 and -1 respectively.
[0144] So far, the latent space mapper consists of a linear layer and a nonlinear mapping function, denoted as CLIP2P The mapper is based on The Gaussian distribution constructed by the distribution statistics is used for learning, and the corresponding loss function The definition is as follows:
[0145] ;
[0146] in , is the output of the CLIP2P mapper. It does not change the inherent nonlinear properties of the CLIP2P mapper, nor does it change the output distribution. On the contrary, this loss can improve the stability of the training process.
[0147] In addition, since the distribution of CLIP in different domains is related to The distribution of the distribution is different, and the conversion difficulty is also different. Adjust the conversion difficulty adaptively according to the needs. The present invention will Hyperparameters Set as a learning parameter to adaptively adjust Ultimately, The formal expression of is as follows:
[0148] ;
[0149] In the actual optimization process, it was observed that Sometimes it converges to 0. This means that CLIP2P can still learn effectively without Gaussian supervision; however, in some cases, Gaussian supervision will greatly help the stable training of CLIP2P. Will be dynamically adjusted to an appropriate non-zero value for the target domain.
[0150] 3. Overall objective and loss function
[0151] In addition to the above losses and In addition, the present invention also uses three additional loss functions , and To assist in the training of this model.
[0152] In order to maintain cross-domain semantic connections, the present invention uses and to strengthen cross-domain relationships in terms of visual and perceptual quality. The source domain image and the target domain image are constrained from the perspective of Euclidean distance, as shown in the following formula (13):
[0153] ;
[0154] and:
[0155] ;
[0156] in is the pre-trained StyleGAN generator. On the other hand, The perceptual correspondence between the source domain and the target domain images using the deep feature is as follows (15):
[0157] ;
[0158] in stands for Perceptual Feature Extractor.
[0159] The last loss term is the cycle loss , as a design based on the cycle consistency idea proposed by Zhu et al. in CycleGAN. The target domain conversion result obtained by the present invention is Then, it is fed into the image encoder of CLIP , and get the CLIP encoding of the result, namely . Then, Input to the CLIP2P mapper and repeat the following transformation process to finally get a new output, denoted as The present invention uses loss To constrain and The consistency of is formally expressed as formula (16):
[0160] ;
[0161] ;
[0162] This loss has two main effects. First, It is guaranteed that the CLIP2P mapper can transform the semantic space (from CLIP space to First, the way of expressing semantics is only transformed according to the semantic space type before and after the transformation, without changing the specific semantic content; second, the assumption that the CLIP distribution of each individual domain conforms to the high-dimensional Gaussian distribution may not be strictly true. Can be constrained Carry sufficient semantics of the CLIP space to mitigate the risk of assumptions that do not necessarily hold strictly.
[0163] Finally, the total loss function of the present invention is It can be expressed as formula (17):
[0164] ;
[0165] in Represents a hyperparameter for weighing each loss term. For each input image, the present invention iterates approximately 35 times, which takes about 20 to 45 seconds on a PC equipped with an Nvidia GeForce RTX 3090 graphics card.
[0166] Example 4, as a preferred embodiment, the present invention is implemented based on a pre-trained StyleGAN generator, which may be replaced by a higher-performance conditional generator, such as a larger-capacity generative adversarial network, an implicit diffusion model, an implicit consistency model, etc.
[0167] Example 5, as a preferred embodiment, the decoupling module in the present invention is constructed based on the visual-text representation model CLIP pre-trained using large-scale data. With the development of multimodal learning technology, more advanced representation models can be used to replace CLIP, such as text encoding learned using Stable Diffusion.
[0168] Embodiment 6, the embodiment of the present invention provides a universal cross-domain image conversion system, including:
[0169] Fixed network parameter module, used to obtain the StyleGAN network Search in space Hidden coding keeps the subsequent training parameters of the StyleGAN network fixed;
[0170] fixed Hidden coding module, used for finding the optimal CLIP hidden coding in the target domain for a single given source domain image using the first branch decoupling module in the dual-branch structure, and using the learning objective of the decoupling module to make the optimal CLIP hidden coding maintain the cross-domain correspondence between the optimal CLIP hidden coding and the source domain image; using the second latent space mapping branch in the dual-branch structure, using the CLIP2P mapper, mapping the CLIP hidden coding to the latent space of StyleGAN, and performing iterative optimization to obtain the loss term, and then the generator generates the target domain image;
[0171] The total loss function acquisition module is used to obtain the total loss function based on the learning objectives and loss terms of the decoupling module and the sum of the auxiliary loss functions to update the network parameters;
[0172] Iteration module, used to fix the network parameter module, fixed The processing flow of the latent coding module and the total loss function acquisition module is trained iteratively for multiple times to obtain the final universal cross-domain image.
[0173] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0174] Since the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present invention, their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0175] This paper re-examines the image conversion task from the perspective of universality. The focus on universality is conducive to eliminating the barriers between different domains on the one hand, and can provide valuable technical support for various real-world applications on the other hand. For example, universal cross-domain image conversion can assist various artistic creations such as anthropomorphic or skeuomorphic design, and can also promote the development of the entertainment industry of streaming media platforms, such as the generation of customized effects on various platforms. Some conversion results are shown in Figure 2. Figure 4 As shown in the partial generation results of the method of the present invention on various domains, the present invention can not only successfully convert when the gap between domains is small, but also cope with the situation where the gap between domains is large.
[0176] The present invention designs an image conversion method that uses a hybrid learning strategy to perform reasoning on a single image. This method does not require large-scale targeted training, can significantly reduce the time, data, and computing resource overhead of image conversion, and lowers the threshold for using image conversion methods.
[0177] Table 1 shows the comparison of the running time of the present invention with the advanced image conversion methods in recent years, which shows that the present method has strong flexibility.
[0178] Table 1 Comparison of the running time of the present invention and the advanced image conversion methods in recent years:
[0179]
[0180] In order to further illustrate the superiority of the present method over the comparative method in other aspects, the present invention also constructs a comparative experiment, and the qualitative evaluation results are as follows Figure 5(Qualitative comparison of this method with the comparison method, where the target domains are: first row: E621Faces; second row: Anime; third row: LSUN-church) as shown. The conversion quality of the learning-based conversion methods (VQ-I2I, StarGAN2 and GP-UNIT) is poor. Even if the results of these methods contain specific patterns in the target domain, the synthesized images have more unnatural defects and lack visual appeal. The main reason for this phenomenon is that the feature extraction mechanism of these methods is only effective between visually similar domains. VQ-I2I and StarGAN2 lack high-level correspondence between domains, which limits their conversion ability between domains with large visual differences. GP-UNIT uses the generative prior of BigGAN and can perform conversion between domains with large visual deviations, but the decoupling ability of BigGAN latent space itself is limited, and it is difficult to establish the relationship between the contours and color blocks of the source domain image, resulting in the lack of authenticity of the final output of GP-UNIT. In addition, when the domain of the input image does not belong to the domain involved in the training of GP-UNIT's pose encoder, GP-UNIT's generalization performance is poor, which further weakens its performance. In contrast, the method of the present invention also performs well when only one source domain image is required, and is not affected by the difference between domains. On the one hand, benefiting from the ability of the decoupling module to accurately extract domain-independent features, the present method establishes stable inter-domain correspondences in multiple aspects such as pose, contour and hue; on the other hand, the present invention utilizes the rich generation priors of StyleGAN, so that the output always has a high degree of authenticity. The domain adaptive generation method DiFa and the diffusion model-based methods DiffusionCLIP and DiffuseIT did not successfully convert the image to the target domain, but the result was very similar to the input image. These methods directly use CLIP loss and pre-trained models for cross-domain conversion, but the results show that directly using this type of loss is not suitable for bridging large domain gaps. The method of the present invention uses the CLIP2P mapper to search in the target domain manifold of StyleGAN, ensuring that the output image must fall into the target domain. The image super-resolution method PULSE, which is similar to the method of the present invention, also uses the generative prior of StyleGAN, but still generates categorically ambiguous results. This is because PULSE only uses pixel-level constraints based on downsampled images to guide the search process. This strategy is very suitable for image super-resolution, but it is obviously too simple to handle cross-domain conversion tasks. The method of the present invention considers both cross-domain correspondence and generation quality at the same time, and can effectively handle image conversion tasks.
[0181] The quantitative comparison results of the present invention are as follows: the quantitative comparison of the present method and the comparative method on the NIQE index to measure the quality of the results, the lower the score, the better, as shown in Table 2; the quantitative comparison of the present method and the comparative method on the LPIPS index to measure the correspondence before and after the conversion, the lower the score, the better, as shown in Table 3.
[0182] As shown in Table 2 and Table 3, the best results are emphasized in bold. The quantitative comparison of the method and the comparison method on the NIQE index is used to measure the quality of the results, and the lower the score, the better, as shown in Table 2; the quantitative comparison of the method and the comparison method on the LPIPS index is used to measure the correspondence before and after the conversion, and the lower the score, the better, as shown in Table 3.
[0183] Table 2 shows the NIQE index of the conversion results of this method and various comparison methods on various types of source domain-target domain pairs. The lower the score, the better. It can be seen that this method performs well under different inter-domain gaps, indicating that this method can generate better high-quality conversion results than various comparison methods. Table 3 shows the LPIPS index of the conversion results of this method and various comparison methods on various types of source domain-target domain pairs. The higher the score, the better. It can be seen that this method can achieve the best conversion results compared with the comparison methods under different inter-domain gaps, indicating that this method can maintain strong perceptual correlation between domains. In addition, since the conversion results of DiFa and DiffusionCLIP are still in the source domain (the conversion results are very similar to the input image, that is, a completely failed conversion result is produced, such as Figure 5 As shown in Table 2, the quantitative comparison between this method and the comparison method on the NIQE indicator is used to measure the quality of the results. The lower the score, the better, as shown in Table 2. The quantitative comparison between this method and the comparison method on the LPIPS indicator is used to measure the correspondence before and after the conversion. The lower the score, the better, as shown in Table 3.
[0184] Table 2 Quantitative comparison of this method and the comparison method on NIQE index:
[0185]
[0186] Table 3 Quantitative comparison of this method and the comparison method on LPIPS index:
[0187]
[0188] In order to verify the role of each module and each loss function in this method, the present invention also designs qualitative and quantitative ablation experiments, and the results are as follows: Figure 6(Qualitative ablation experiment results, first row: AFHQ-cat→E621Faces; second row: AFHQ-cat→LSUN-church) and Figure 7 (Quantitative ablation results of this method under different settings) are shown.
[0189] (1) In order to verify the effectiveness of the CLIP2P mapper, the present invention removes the nonlinear mapping function in the mapper. , directly use the output of the linear layer to replace the Encoding, the result is Figure 6 As shown in the seventh column of . Removing this function leads to a serious degradation of the conversion results when E621Faces and LSUN-church are used as the target domains. However, when FFHQ is used as the target domain, removing this function has only a slight impact on the result quality. This is because the real The difference between the distribution and the Gaussian distribution varies. In domains where the distribution is similar to the Gaussian distribution, such as FFHQ, only one extra linear layer is needed to make Coding close Encoding, without the assistance of nonlinear mapping; on the contrary, when the real When the distribution deviates greatly from the Gaussian distribution, the What I Learned The encoding will be more complicated and require the assistance of nonlinear mapping functions.
[0190] (2) In order to verify the effectiveness of the decoupling module, the present invention analyzes the impact of removing the module on the results. The results are as follows: Figure 6 The full model results ( Figure 6 This shows that the disentangled module can effectively use semantic information to establish semantic connections in various aspects such as pose, contour, and fine-grained attributes.
[0191] (3) The present invention performs an ablation analysis on each loss function in the present method. First, the present invention removes ,like Figure 6 As shown in column 5. When the target domain is E621Faces or LSUN-church, removing this item will cause the result to deviate almost completely from the target domain; secondly, the present invention also analyzes the removal of The impact on the results. Figure 6 As shown in the fourth column, removing this term will weaken the correspondence between the source domain and the target domain image. This is because when the cycle consistency constraint is removed in step 2, not only the distribution, and will also change The semantics carried by this erroneous change conflicts with the optimization goal of step 1, resulting in the failure of the hybrid learning strategy and ultimately a suboptimal solution; finally, the present invention also verifies that and Such as Figure 6 As shown in the second and third columns of It mainly affects the consistency of the conversion result relative to the input image in the color space; It mainly affects the establishment of perceptual correspondence.
[0192] (4) The quantitative ablation results of the above settings are as follows Figure 7 As shown, it can be found that the nonlinear mapping function designed by the present invention has the greatest impact on the conversion quality of the present method. In addition, when LSUN-church is the target domain, It also plays a key role, because LSUN-church The distribution is quite different from the Gaussian distribution, so It becomes the key constraint that guides the conversion of CLIP encoding into 𝒫 encoding.
[0193] The present invention can also be applied to various application tasks, such as image stylization, style mixing, etc.; it also has strong robustness and can cope with various complex visual scenes, such as low-quality input scenes. In terms of image stylization, a typical application of the present method is to convert real portraits into the style of artists' works of art, thereby showing unique aesthetic value. In this type of conversion, the present method can successfully capture the fine details in the source domain image, indicating that the present method can also produce high-quality output when the gap between domains is small. In addition, the method of the present invention can generate hidden codes that can perform detailed style mixing without compromising the generation quality. Finally, the present method can implement image conversion in complex scenes (when the input image is a low-resolution image or a defective image). The motivation of this type of task is to deploy image conversion applications in the real world, and a perfect processing mechanism should be provided for user input. When it is impossible to forcibly restrict user operations, the input may not only come from an uncertain source domain, but also have uncertain image quality. The user may input some low-quality images or defective images. Therefore, the present invention evaluates the robustness of the present method in two cases: low-resolution input and defective input. For low-resolution input, the present invention uses a low-resolution image with a resolution of 32×32 as input, and can generate a high-resolution conversion result of 1024×1024 (32 times). The processing capacity of the comparative methods is limited, and most of them can only perform low-multiple super-resolution (8 times, 16 times). Therefore, the present method can produce high-resolution output while successfully converting. The present invention also randomly adds masks to the input image to simulate incomplete images. When processing such images, the loss term of the present method is , and It is only used to constrain the parts not covered by the mask. Under these extremely challenging settings, the method of the present invention can still perform stably and adaptively, demonstrating its ability to handle various unpredictable real-world inputs.
[0194] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any modifications, equivalent substitutions and improvements made by any technician familiar with the technical field within the technical scope disclosed by the present invention and within the spirit and principles of the present invention should be covered within the protection scope of the present invention.
Claims
1. A general cross-domain image conversion method, It is characterized in that The method includes: S1, fixed network parameters: search for z hidden codes from the Z space of the StyleGAN network to keep the subsequent training parameters of the StyleGAN network fixed; S2, fixed z latent code: for a single given source domain image, the first branch decoupling module in the dual-branch structure is used to find the optimal CLIP latent code in the target domain. The optimal CLIP latent code uses the learning objective of the decoupling module to make the CLIP latent code in the target domain latent space while maintaining the cross-domain correspondence with the source domain image; the second latent space mapping branch in the dual-branch structure is used to map the CLIP latent code to the latent space of StyleGAN through the CLIP2P mapper; there is an inherent gap between the CLIP latent space and the StyleGAN latent space encoding representation, and a new nonlinear mapping function is used to bridge the two spaces, and iterative optimization is performed to obtain the loss term, and then the generator generates the target domain image; S3, based on the learning objectives and loss terms of the decoupling module, combined with the auxiliary loss function, obtains the total loss function and updates the network parameters; S4, perform multiple iterations of training on the above steps to obtain the final universal cross-domain image; In step S2, the first branch decoupling module in the dual-branch structure is used to find the optimal CLIP hidden code in the target domain, so that the optimal CLIP hidden code maintains the cross-domain correspondence relationship with the source domain image and obtains the learning objectives of the decoupling module. For the semantic representation obtained by the first submodule and the second submodule, the first loss function The expression is: Using cosine similarity to measure domain-related information Domain-independent information The corresponding degree of coupling, minimized The domain-independent representation and the domain-dependent representation will be made orthogonal to each other; According to the categories of the source domain and the target domain, the text encoder E of CLIP T Generate text encodings of source and target domains and The domain related information of the two domains and Respectively, the text encoding representing domain-specific information and Alignment, which is achieved through the loss function The constraints provided are complete and the expression is: This formula uses cosine similarity to measure domain related information and text encodings representing domain-specific information The corresponding distance is ensured by minimizing the cosine distance Correctly represent domain-related information; The obtained text encoding is the average of the CLIP encodings obtained by embedding the category cue words of the source domain or target domain into all sentence templates; exist and Under the constraint of and It will contain domain-independent information in the source domain and the target domain; use the loss function By constraining the similarity between the two and excluding the interference of category feature information, a cross-domain correspondence is constructed, as shown in the following formula (5): The L1 loss is used to measure the distance between the source domain and the target domain, by minimizing The domain-independent information of the two domains will be presented in correspondence, so that the final conversion result will show the semantic correspondence of the homologous domain input while ensuring that it belongs to the category range of the target domain; The two parts of information representing the target domain conversion result, target domain related information Information not related to the target domain concatenated and fed into the second MLP to reconstruct a 512-dimensional CLIP representation; the source domain information is processed in the same way; the reconstruction process is based on the L1 loss The constraints are formally expressed as follows: in, represents the concatenation operation of features of the same dimension; in the process of learning network parameters, this loss prevents domain-related and domain-independent representations from becoming redundant as the learning process progresses, and maintains the image semantic encoding v through formula (6). And the reconstruction results When optimizing z-coding, the characteristics of the domain category and the target domain are integrated. As a guide to guide optimization; MLP2 is the second multi-layer perceptron in the decoupling module, || || 1 It is a 1-norm operation; By using the learning objectives of the decoupling module, the optimal CLIP hidden code maintains the cross-domain correspondence with the source domain image. The learning objectives of the decoupling module are as follows:
2. The universal cross-domain image conversion method according to claim 1, It is characterized in that In step S1, the z latent code is searched from the Z space of the StyleGAN network, including: Convert the z latent code randomly sampled from the standard Gaussian distribution into CLIP code, generate multiple target domain images in each user-specified target domain, and input the above images into the CLIP image encoder E I In the above example, we get a corresponding set of CLIP codes; calculate its standard deviation σ CLIP and mean μ CLIP , convert the z latent code into the v code in CLIP space, the expression is: v=σ CLIP z+μ CLIP (2) Where v is the CLIP code, σ CLIP is the standard deviation of CLIP encoding, z is the hidden encoding, μ CLIP is the mean of the CLIP codes.
3. The universal cross-domain image conversion method according to claim 1, It is characterized in that In step S2, the input of the decoupling module is: CLIP code v, the source domain image I as a reference src , the category text T of the source domain and the target domain src , T tar and sentence templates; the above data are respectively input into two submodules of the decoupling module, each of which contains two multi-layer perceptrons MLPs, and the two MLPs share parameters across branches; The source domain image I of the first submodule src CLIP pre-trained image encoder E I Processing to obtain semantic representation After the first MLP processing, a 1024-dimensional vector is obtained; this 1024-dimensional vector contains two independent 512-dimensional source domain related information Information not related to the source domain The input of the second submodule MLP1 is first processed by CLIP spatial statistics to obtain the CLIP code v, which is used to represent the final target domain image semantics; the output is a 1024-dimensional vector consisting of two independent 512-dimensional semantic representations of target domain related information Information not related to the target domain 4. The universal cross-domain image conversion method according to claim 1, It is characterized in that In step S2, the second latent space mapping branch in the dual-branch structure is used, and the CLIP2P mapper is used to map the CLIP latent code to the latent space of StyleGAN, and iterative optimization is performed to obtain the loss term, including: right The characteristics of the space are p = LeakyReLU 5.0 (w), where and is the hidden code sampled in the corresponding hidden space, and the w space is space activation space; if The space is Gaussian distributed, and the following relationship (8) holds: in=LeakyReLU 0.2 (σ P with+μ P )(8) In the formula, σ P and μ P represents the standard deviation and mean of a Gaussian distribution; Learning with a linear layer The distribution of the space does not change the Gaussianity of the CLIP single domain space, as shown in the following equation (9): w=LeakvReLU 0.2 (Linear(v))(9) Add a new nonlinear function after the linear layer Let's learn unimodal Distribution, the new nonlinear mapping function is defined as The expression is as follows: Among them, h, j, μ are all learning parameters, and e is the Euler constant.
5. The universal cross-domain image conversion method according to claim 1, It is characterized in that The latent space mapper consists of a linear layer and a nonlinear mapping function, denoted as CLIP2P(·); the mapper is based on The Gaussian distribution constructed by the distribution statistics is used for learning, and the corresponding loss function The definition is as follows: In the formula, is the output of the CLIP2P mapper; It does not change the inherent nonlinear properties of the CLIP2P mapper, nor does it change the output distribution; As needed, The hyperparameter λ p Set as a learning parameter to adaptively adjust The degree of constraint, loss term The formal expression of is as follows:
6. The universal cross-domain image conversion method according to claim 1, It is characterized in that In step S3, combining the auxiliary loss function includes: using and to strengthen cross-domain relationships in terms of visual and perceptual quality; The source domain image and the target domain image are constrained from the perspective of Euclidean distance, as shown in the following formula (13): and: I tar =G(LeakyReLU 0.2 (q))(14) Where G(·) is the pre-trained StyleGAN generator; The perceptual correspondence between the source domain and the target domain images using the deep feature is as follows (15): where F(·) represents the perceptual feature extractor.
7. The universal cross-domain image conversion method according to claim 1, It is characterized in that In step S3, in combination with the auxiliary loss function, it also includes: cycle loss Get the target domain conversion result I tar After that, the circulation loss The image encoder E is fed into CLIP I , and get the CLIP encoding of the result, namely v tar =E I (I tar ); v tar Input to the CLIP2P mapper, and finally get a new output, denoted as I cycle ; Use cycle loss Constraint I tar and I cycle The consistency of is formally expressed as formula (16): I cycle =G(LeakyReLU 0.2 (CLIP2P(v tar ))), 8. The universal cross-domain image conversion method according to claim 1, It is characterized in that In step S3, the total loss function The expression is as follows: In the formula, {λ i } represents the hyperparameter used to weigh the various loss terms.
9. A universal cross-domain image conversion system, It is characterized in that The system implements the universal cross-domain image conversion method according to any one of claims 1 to 8, and the system comprises: The fixed network parameter module is used to search for z latent codes in the Z space of the StyleGAN network and keep the subsequent training parameters of the StyleGAN network fixed; The fixed z latent coding module is used to find the optimal CLIP latent coding in the target domain for a single given source domain image using the first branch decoupling module in the dual-branch structure, and use the learning objective of the decoupling module to make the optimal CLIP latent coding maintain the cross-domain correspondence between the optimal CLIP latent coding and the source domain image; the second latent space mapping branch in the dual-branch structure is used, using the CLIP2P mapper, to map the CLIP latent coding to the latent space of StyleGAN, and iteratively optimize to obtain the loss term, and then the generator generates the target domain image; The total loss function acquisition module is used to obtain the total loss function based on the learning objectives and loss terms of the decoupling module and the sum of the auxiliary loss functions to update the network parameters; The iterative module is used to perform multiple iterative training on the processing flow of the fixed network parameter module, the fixed z latent encoding module, and the total loss function acquisition module to obtain the final universal cross-domain image.
Citation Information
Patent Citations
Target domain oriented unsupervised image conversion method based on generative adversarial network
CN110335193A
Self-adaptive image editing method based on hidden space operation and text guidance
CN115797503A
Image-text retrieval method and system based on cross-modal cross guidance
CN116186317A
Self-supervised human body posture conversion method and system and readable storage medium
CN116416677A
Image conversion method and system, electronic equipment and computer storage medium
CN117314738A
