Style image generation method and device based on style paradigm, equipment and medium
By extracting features from identity and style example images and fusing them to generate stylized images, this technology overcomes the limitations of existing stylized face image generation, enabling flexible generation of images of any style and simplifying deployment and maintenance.
Patent Information
- Application Number
- CN202210800432.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-06
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2042-07-06
AI Technical Summary
Existing stylized face image generation technologies can only generate images of a specific style, and the generated style depends on the style in the training set. This makes it difficult to flexibly meet new requirements in actual use, resulting in inconvenience in deployment and maintenance.
By acquiring identity images and style example images, features are extracted using the coding unit, features are fused using the feature fusion unit, and the multi-stylized image generation unit generates the target stylized image, thus achieving the unification of style and identity. The model parameters are updated using training samples to generate images of any specified style.
It enables the generation of stylized images in any specified style without the need to train an algorithm model for each style, supporting new requirements in practical use and simplifying deployment and maintenance.
Smart Images

Figure CN117423141B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to a method, apparatus, device and medium for stylized image generation based on style paradigms. Background Technology
[0002] In scenarios such as video conferencing and online teaching, service providers have a significant need to reduce network bandwidth costs, while users' demands for privacy and entertainment are also constantly increasing. Therefore, portrait editing and stylization technologies are becoming increasingly important, especially stylization techniques based on ordinary 2D portraits, which have received widespread attention because they can protect user privacy while maintaining identity similarity.
[0003] Due to the high cost of annotation, face image stylization is generally treated as an unsupervised problem. Currently, existing face image stylization solutions can be broadly categorized into two technical approaches. The first is U-GAT-IT (an unsupervised image-to-image translation method), which is primarily based on the CycleGAN framework (a well-known algorithm that applies GANs to unsupervised image-to-image translation). It uses cycle loss to constrain the correlation between the input face image and the output stylized face image. The second is Toonify (a set of AI-driven tools for face transformation), which is mainly based on the StyleGAN (generative face image) framework. It uses interpolation between network layers to constrain the correlation between the input face image and the output stylized face image.
[0004] The two technical solutions mentioned above share a common problem: they can only generate stylized portraits of a specific style, and the generated style is strongly dependent on the style in the training set; if you want to generate portraits with more styles, you have to collect new portrait styles for training, and one algorithm model corresponds to one style, which is not convenient for supporting new needs in actual use and for deployment and maintenance. Summary of the Invention
[0005] The main purpose of this application is to provide a stylized image generation method, apparatus, device, and medium based on style paradigms, aiming to solve the technical problem that current stylized face image solutions can only generate stylized portraits of a specific style, and the generated style is strongly dependent on the style in the training set. If more styles of portraits are to be generated, new portrait styles must be collected for training. One algorithm model corresponds to one style, which is not convenient for supporting new requirements in actual use and for deployment and maintenance.
[0006] To achieve the aforementioned objectives, this application proposes a stylized image generation method based on style paradigms, the method comprising:
[0007] Obtain the identity image and style example image;
[0008] The identity image and the style example image are input into a preset stylized image generation model to generate a stylized image, thereby obtaining a target stylized image. The stylized image generation model includes, in sequence, an encoding unit, a feature fusion unit, and a multi-stylized image generation unit.
[0009] Further, the step of inputting the identity image and the style example image into a preset stylized image generation model to generate a stylized image to obtain the target stylized image includes:
[0010] The identity image is input into the coding unit for latent space feature extraction to obtain the first latent space feature;
[0011] The style example image is input into the coding unit for latent space feature extraction to obtain the second latent space feature;
[0012] The first latent space feature and the second latent space feature are input into the feature fusion unit for feature fusion to obtain the target feature;
[0013] The target features are input into the multi-stylized image generation unit to generate a stylized image, thereby obtaining the target stylized image. The style of the target stylized image is the same as that of the style example image, and the identity of the object in the target stylized image is the same as that of the object in the identity image.
[0014] Furthermore, the calculation formula Z for the target feature is:
[0015] Z = z x W+z S (1-W)
[0016] Among them, z x It is the first latent space feature, z S is the second latent space feature, and W is the network parameter of the feature fusion unit.
[0017] Further, the step of inputting the identity image and the style example image into a preset stylized image generation model to generate a stylized image to obtain the target stylized image includes:
[0018] An initial model and multiple training samples are obtained, wherein the initial model includes: an initial encoding unit, an initial feature fusion unit, and the multi-stylized image generation unit;
[0019] The initial model is trained using each of the training samples to update the network parameters of the initial encoding unit and the initial feature fusion unit, and the initial model after training is used as the stylized image generation model.
[0020] Further, the step of training the initial model using each of the training samples to update the network parameters of the initial encoding unit and the initial feature fusion unit, and using the trained initial model as the stylized image generation model, includes:
[0021] Choose any one of the training samples as the target sample from each of the training samples;
[0022] The identity sample image and style example sample image in the target sample are input into the initial model to generate a stylized image, thus obtaining the stylized image to be analyzed;
[0023] The stylized image to be analyzed is input into the multi-stylized image discriminator corresponding to the multi-stylized image generation unit to perform stylized image discrimination, and the stylized image discrimination result is obtained.
[0024] The identity sample image in the target sample is input into a preset object feature extraction model for feature extraction to obtain the first object feature;
[0025] The stylized image to be analyzed is input into the object feature extraction model for feature extraction to obtain the second object features;
[0026] The target loss value is calculated based on the stylized image discrimination result, the first object feature, the second object feature, the stylized image to be analyzed, and the stylized image labels in the target sample;
[0027] Update the network parameters of the encoding initialization unit and the feature fusion initialization unit according to the target loss value;
[0028] Repeat the step of obtaining any one of the training samples as the target sample from each of the training samples until the preset model training termination condition is reached, and use the initial model that has reached the model training termination condition as the stylized image generation model.
[0029] Further, the step of calculating the target loss value based on the stylized image discrimination result, the first object feature, the second object feature, the stylized image to be analyzed, and the stylized image labels in the target sample includes:
[0030] The first object feature and the second object feature are input into a preset distance loss function to calculate the loss value, and a first loss value is obtained;
[0031] The stylized image to be analyzed and the stylized image labels in the target sample are input into a preset stylized image loss function to calculate the loss value and obtain the second loss value;
[0032] The target loss value is obtained by fusing the stylized image discrimination result, the first loss value, and the second loss value.
[0033] The formula L for calculating the target loss value is:
[0034] L = log(s) D )-s id / 2-λs pair
[0035] Where log is a logarithmic function, s D The stylized image discrimination result, s id It is the first loss value, s pair This is the second loss value, and λ is a constant.
[0036] Furthermore, the calculation formula E for the network parameters of the newly updated encoding initial unit is... i for:
[0037]
[0038] The updated formula for calculating the network parameters W of the initial feature fusion unit is as follows: i for:
[0039]
[0040] Among them, E i-1 The network parameters W of the encoding initial unit after the last update. i-1 These are the network parameters of the initial feature fusion unit after the last update, where α is the first learning rate (α is constant), β is the second learning rate (β is constant), and L is the target loss value. It involves taking the derivative of L. For E i-1 Perform differentiation calculations. It is for W i-1 Perform differentiation calculations.
[0041] This application also proposes a stylized image generation apparatus based on style paradigms, the apparatus comprising:
[0042] The image acquisition module is used to acquire identity images and style example images;
[0043] The target stylized image determination module is used to input the identity image and the style example image into a preset stylized image generation model to generate a stylized image, thereby obtaining a target stylized image. The stylized image generation model includes, in sequence, an encoding unit, a feature fusion unit, and a multi-stylized image generation unit.
[0044] This application also proposes a computer device including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of any of the methods described above.
[0045] This application also proposes a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the methods described above.
[0046] This application discloses a stylized image generation method, apparatus, device, and medium based on style paradigms. The method generates a stylized image by inputting an identity image and a style paradigm image into a preset stylized image generation model. Specifically, an encoding unit extracts features from both the identity image and the style paradigm image, a feature fusion unit fuses the extracted features, and a multi-stylized image generation unit generates the stylized image based on the fused features. This generates a stylized image with the same style as the style paradigm image and the same identity as the object in the identity image. This allows for the generation of images in any specified style without requiring a separate algorithm model for each style, making it very convenient for supporting new requirements and for deployment and maintenance in practical applications. Attached Figure Description
[0047] Figure 1 This is a schematic flowchart of a stylized image generation method based on style paradigms according to an embodiment of this application;
[0048] Figure 2 This is a schematic block diagram of a stylized image generation apparatus based on a style paradigm according to an embodiment of this application;
[0049] Figure 3 This is a schematic block diagram of the structure of a computer device according to an embodiment of this application.
[0050] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0051] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0052] Reference Figure 1 This application provides a stylized image generation method based on style paradigms, the method comprising:
[0053] S1: Obtain the identity image and style example image;
[0054] S2: Input the identity image and the style example image into a preset stylized image generation model to generate a stylized image, thereby obtaining a target stylized image. The stylized image generation model includes, in sequence, an encoding unit, a feature fusion unit, and a multi-stylized image generation unit.
[0055] This embodiment generates a stylized image by inputting the identity image and the style example image into a preset stylized image generation model. Specifically, an encoding unit extracts features from both the identity image and the style example image, a feature fusion unit fuses the extracted features, and finally, a multi-stylized image generation unit generates a stylized image based on the fused features. This results in a stylized image with the same style as the style example image and the same identity as the object in the identity image. This allows for the generation of images in any specified style without requiring a separate algorithm model for each style, making it very convenient for supporting new requirements and for deployment and maintenance in practical applications.
[0056] It is understood that the stylized image generation technology contained in this application can be applied in scenarios such as virtual customer service, pre-recorded lectures, virtual lecturers, intelligent teaching assistants, virtual coaches, and virtual meetings.
[0057] Understandably, this application can be used in general facial image cartoonization scenarios. For example, it can generate cartoon-style facial videos based on images from educational, meeting, customer service, and fitness scenarios, increasing fun while protecting the privacy of facial identities. Another example is its use in remote video conferencing scenarios, where participants' facial images can be cartoonized to protect privacy while increasing the fun of communication, and preserving visual interaction information such as eye contact and facial expressions between participants.
[0058] For S1, it can obtain the identity image and style example image input by the user, or obtain the identity image and style example image from the database, or obtain the identity image and style example image from a third-party application.
[0059] An identity image is an image representing the identity of the object you want to use. The object can be a human, an animal, or an item. An identity image can be a human face, a full-body image of a human, a human face, or a full-body image of an animal.
[0060] A style example image is an image representing the style you want to use. A style example image can be a cartoon image.
[0061] For S2, the identity image and the style example image are input into a preset stylized image generation model to generate a stylized image, and the generated stylized image is used as the target stylized image. Specifically, the features of the identity image and the style example image are extracted by an encoding unit, then the extracted features are fused by a feature fusion unit, and finally, a multi-stylized image generation unit generates the stylized image based on the fused features.
[0062] It is understandable that if the style example image is a cartoon image and the identity image is a face image, then the target stylized image is a cartoonish face image, and the face in the target stylized image and the face in the identity image are the same person.
[0063] The encoding unit is used to extract features. The encoding unit is a unit obtained based on encoder training.
[0064] The feature fusion unit is used to perform feature fusion.
[0065] The multi-stylized image generation unit is used to generate stylized images in multiple styles. The multi-stylized image generation unit is based on a model trained using a deep learning neural network (CNN).
[0066] This process involves acquiring multiple sets of cartoon face image samples; using these samples, adversarial training is performed on a generator and a pre-defined discriminator derived from a deep learning neural network. The generator, after adversarial training, serves as the multi-stylized image generation unit, and the discriminator, also after adversarial training, serves as the multi-stylized image discriminator corresponding to the multi-stylized image generation unit. The multi-stylized image generation unit can generate images in multiple styles. The multi-stylized image discriminator corresponding to the multi-stylized image generation unit is used to determine whether the style of the input image falls within the various styles corresponding to the multiple sets of cartoon face image samples.
[0067] In one embodiment, the step of inputting the identity image and the style example image into a preset stylized image generation model to generate a stylized image and obtain the target stylized image includes:
[0068] S21: Input the identity image into the coding unit to extract latent space features and obtain the first latent space features;
[0069] S22: Input the style example image into the coding unit to extract latent space features and obtain the second latent space features;
[0070] S23: Input the first latent space feature and the second latent space feature into the feature fusion unit to perform feature fusion and obtain the target feature;
[0071] S24: Input the target features into the multi-stylized image generation unit to generate a stylized image, thereby obtaining the target stylized image, wherein the style of the target stylized image is the same as the style of the style example image, and the identity of the object in the target stylized image is the same as the identity of the object in the identity image.
[0072] This embodiment extracts features from the identity image and the style example image through an encoding unit, then fuses the extracted features using a feature fusion unit, and finally generates a stylized image based on the fused features using a multi-stylized image generation unit. This generates a stylized image with the same style as the style example image and the same identity as the object in the identity image. This allows for the generation of images of any specified style without the need to train an algorithm model for each style, making it very convenient for supporting new requirements and for deployment and maintenance in practical use.
[0073] For S21, the identity image is input into the coding unit for latent space feature extraction, and the extracted latent space features are used as the first latent space features.
[0074] For S22, the style example image is input into the coding unit for latent space feature extraction, and the extracted latent space features are used as the second latent space features.
[0075] For S23, the first latent space feature and the second latent space feature are input into the feature fusion unit for linear feature fusion, and the feature obtained by linear feature fusion is used as the target feature.
[0076] For S24, the target features are input into the multi-stylized image generation unit to generate a stylized image, and the generated stylized image is used as the target stylized image, so that the style of the target stylized image is the same as the style of the style example image, and the identity of the object in the target stylized image is the same as the identity of the object in the identity image.
[0077] In one embodiment, the formula Z for calculating the above target feature is:
[0078] Z = z x W+z S (1-W)
[0079] Among them, z x It is the first latent space feature, z Sis the second latent space feature, and W is the network parameter of the feature fusion unit.
[0080] This embodiment uses W to input the first latent space feature and the second latent space feature into the feature fusion unit for linear feature fusion, thereby providing a foundation for generating a stylized image with the same style as the style example image and the same identity of the object as the object in the identity image.
[0081] W can be a numerical value or a matrix. If W is a matrix, then the size of W, z... x Size and z S All of them are the same size.
[0082] Optionally, W is a value between 0 and 1, which can be either 0 or 1.
[0083] Optionally, W is a matrix whose elements have values from 0 to 1, and the values of the elements can be either 0 or 1.
[0084] In one embodiment, the step of inputting the identity image and the style example image into a preset stylized image generation model to generate a stylized image and obtain the target stylized image includes:
[0085] S31: Obtain an initial model and multiple training samples, wherein the initial model includes: an initial encoding unit, an initial feature fusion unit, and the multi-stylized image generation unit;
[0086] S32: The initial model is trained using each of the training samples to update the network parameters of the initial encoding unit and the initial feature fusion unit, and the initial model after training is used as the stylized image generation model.
[0087] This embodiment achieves fine-tuning training of the encoding initial unit and the feature fusion initial unit while fixing the network parameters of the multi-stylized image generation unit. This allows the features input to the multi-stylized image generation unit to be fused with identity and style features, providing a foundation for generating stylized images with the same style as the style example image and the same identity of the object as the object in the identity image.
[0088] For S31, it can obtain the initial model and multiple training samples from user input, or it can obtain the initial model and multiple training samples from a database, or it can obtain the initial model and multiple training samples from a third-party application.
[0089] The initial encoding unit is an encoder.
[0090] The initial unit for feature fusion is a network layer that employs a linear fusion algorithm.
[0091] Each of the plurality of training samples includes: an identity sample image, a style example sample image, and a stylized image label. The identity sample image is an image representing the identity of the object to be used. The style sample image is an image representing the style to be used. The stylized image label is the exact result of the stylized image corresponding to the identity sample image and the style example sample image. The style of the stylized image label is the same as the style of the style example sample image. The identity of the object in the stylized image label is the same as the identity of the object in the style example sample image.
[0092] Understandably, stylized image tags are artificially created stylized images.
[0093] For S32, the initial model is trained using each of the training samples to update the network parameters of the initial encoding unit and the initial feature fusion unit. That is, the initial model is trained using each of the training samples to update the network parameters of the initial encoding unit and the initial feature fusion unit. This achieves the goal of fixing the network parameters of the multi-stylized image generation unit while fine-tuning the initial encoding unit and the initial feature fusion unit.
[0094] The initial model after training achieves the expected performance target; therefore, it is directly used as the stylized image generation model. That is, the initial encoding unit of the initial model after training is directly used as the encoding unit of the stylized image generation model, the initial feature fusion unit of the initial model after training is directly used as the feature fusion unit of the stylized image generation model, and the multi-stylized image generation unit of the initial model after training is directly used as the multi-stylized image generation unit of the stylized image generation model.
[0095] In one embodiment, the step of training the initial model using each of the training samples to update the network parameters of the initial encoding unit and the initial feature fusion unit, and using the trained initial model as the stylized image generation model, includes:
[0096] S321: Obtain any one of the training samples as the target sample from each of the training samples;
[0097] S322: Input the identity sample image and style example sample image from the target sample into the initial model to generate a stylized image, thereby obtaining the stylized image to be analyzed;
[0098] S323: Input the stylized image to be analyzed into the multi-stylized image discriminator corresponding to the multi-stylized image generation unit to perform stylized image discrimination and obtain the stylized image discrimination result;
[0099] S324: Input the identity sample image in the target sample into a preset object feature extraction model to extract features and obtain the first object feature;
[0100] S325: Input the stylized image to be analyzed into the object feature extraction model to extract features and obtain the second object features;
[0101] S326: Calculate the target loss value based on the stylized image discrimination result, the first object feature, the second object feature, the stylized image to be analyzed, and the stylized image labels in the target sample;
[0102] S327: Update the network parameters of the encoding initial unit and the feature fusion initial unit according to the target loss value;
[0103] S328: Repeat the step of obtaining any one of the training samples from each of the training samples as the target sample until the preset model training termination condition is reached, and use the initial model that has reached the model training termination condition as the stylized image generation model.
[0104] This embodiment calculates the target loss value based on the stylized image discrimination result, the first object feature, the second object feature, the stylized image to be analyzed, and the stylized image labels in the target sample. This achieves loss value calculation based on discriminator evaluation, unsupervised training, and supervised training, thereby improving the accuracy of the trained stylized image generation model.
[0105] For S321, any one of the training samples is selected as the target sample from each of the training samples, so that the initial model is trained using one of the training samples each time.
[0106] It is understood that, in another embodiment of this application, the initial model can be trained using a batch of training sample sets at a time. For example, a batch of training sample sets may include 32 training samples. Or, for example, a batch of training sample sets may include 64 training samples.
[0107] For S322, the identity sample image and style example sample image in the target sample are input into the initial model to generate a stylized image. The generated stylized image is used as the stylized image to be analyzed. In this process, the features of the identity sample image in the target sample are extracted by the encoding initial unit, and the features of the style example sample image in the target sample are extracted by the encoding initial unit. Then, the features extracted from the identity sample image and the features extracted from the style example sample image are fused by the feature fusion initial unit. Finally, the multi-stylized image generation unit generates a stylized image based on the fused features, and the generated stylized image is used as the stylized image to be analyzed.
[0108] For S323, the stylized image to be analyzed is input into the multi-stylized image discriminator corresponding to the multi-stylized image generation unit for stylized image discrimination, so as to determine whether the style corresponding to the stylized image to be analyzed is located in each style corresponding to the multiple cartoon face image sample sets, and the probability obtained by discrimination is used as the stylized image discrimination result.
[0109] For S324, the identity sample image in the target sample is input into a preset object feature extraction model for feature extraction, and the extracted features are used as the first object features.
[0110] The object feature extraction model is used to extract features from an object, and the extracted features are used for object recognition. For example, if this application is used for face image processing, the object feature extraction model is used to extract features from a face, and the extracted features are used for face recognition.
[0111] For S325, the stylized image to be analyzed is input into the object feature extraction model for feature extraction, and the extracted features are used as the second object features.
[0112] For S326, the target loss value is calculated based on the stylized image discrimination result, the first object feature, the second object feature, the stylized image to be analyzed, and the stylized image label in the target sample, thereby realizing the calculation of loss value based on discriminator evaluation, unsupervised training, and supervised training.
[0113] For S327, the steps of updating the network parameters of the encoding initial unit and the feature fusion initial unit according to the target loss value are not described in detail here.
[0114] For S328, the step of obtaining any one of the training samples from each of the training samples as the target sample is repeated, that is, steps S321 to S328 are repeated until the preset model training termination condition is reached; when the preset model training termination condition is reached, it means that the performance of the initial model has reached the expected requirements, at which point the repeated execution of steps S321 to S328 is stopped, and the initial model that has reached the model training termination condition is used as the stylized image generation model.
[0115] Optionally, the model training termination condition refers to the target loss value corresponding to the initial model converging to a preset value.
[0116] In one embodiment, the step of calculating the target loss value based on the stylized image discrimination result, the first object feature, the second object feature, the stylized image to be analyzed, and the stylized image labels in the target sample includes:
[0117] S3261: Input the first object feature and the second object feature into a preset distance loss function to calculate the loss value and obtain the first loss value;
[0118] S3262: Input the stylized image to be analyzed and the stylized image label in the target sample into a preset stylized image loss function to calculate the loss value and obtain the second loss value;
[0119] S3263: The stylized image discrimination result, the first loss value, and the second loss value are fused and calculated to obtain the target loss value;
[0120] The formula L for calculating the target loss value is:
[0121] L = log(s) D )-s id / 2-λs pair
[0122] Where log is a logarithmic function, s D The stylized image discrimination result, s id It is the first loss value, s pair This is the second loss value, and λ is a constant.
[0123] In this embodiment, the first object feature and the second object feature are input into a preset distance loss function to calculate the loss value, realizing the loss value calculation for unsupervised training. The stylized image to be analyzed and the stylized image labels in the target sample are input into a preset stylized image loss function to calculate the loss value, realizing the loss value calculation for supervised training. By fusing the stylized image discrimination result, the first loss value and the second loss value, the loss value calculation based on discriminator evaluation, unsupervised training and supervised training is realized, thereby improving the accuracy of the trained stylized image generation model.
[0124] For S3261, the first object feature and the second object feature are input into a preset distance loss function to calculate the loss value, and the calculated loss value is used as the first loss value, thereby realizing the loss calculation of identity consistency between the identity sample image in the target sample and the stylized image to be analyzed.
[0125] Optionally, the formula for calculating the first loss value is s. id for:
[0126]
[0127] Where F(x) is the first object feature, is It is the second object feature. It is a calculation The norm of .
[0128] For S3262, the stylized image to be analyzed and the stylized image label in the target sample are input into a preset stylized image loss function to calculate the loss value. The calculated loss value is used as the second loss value, thereby realizing the loss calculation of the consistency between the stylized image label in the target sample and the stylized image to be analyzed.
[0129] Optionally, the formula for calculating the second loss value is:
[0130]
[0131] in, Let y be the stylized image to be analyzed, and y be the stylized image label in the target sample. It is a calculation The absolute value of.
[0132] For S3263, the stylized image discrimination result, the first loss value and the second loss value are fused and calculated, and the calculated loss value is used as the target loss value, thus realizing the calculation of the loss value of the initial model based on discriminator evaluation, unsupervised training and supervised training.
[0133] In one embodiment, the calculation formula E for the network parameters of the newly updated encoding initial unit is as follows: i for:
[0134]
[0135] The updated formula for calculating the network parameters W of the initial feature fusion unit is as follows: i for:
[0136]
[0137] Among them, E i-1 The network parameters W of the encoding initial unit after the last update. i-1 These are the network parameters of the initial feature fusion unit after the last update, where α is the first learning rate (α is constant), β is the second learning rate (β is constant), and L is the target loss value. It involves taking the derivative of L. For E i-1 Perform differentiation calculations. It is for W i-1 Perform differentiation calculations.
[0138] In this embodiment, the network parameters of the initial encoding unit are determined based on maximizing the target loss value, and the network parameters of the initial feature fusion unit are determined based on maximizing the target loss value.
[0139] The network parameters of the initial encoding unit updated in this training are the parameters that need to be updated for the initial encoding unit in this training.
[0140] The network parameters of the feature fusion initial unit updated in this training are the parameters that need to be updated for the feature fusion initial unit in this training.
[0141] Reference Figure 2 This application also proposes a stylized image generation apparatus based on style paradigms, the apparatus comprising:
[0142] Image acquisition module 100 is used to acquire identity images and style example images;
[0143] The target stylized image determination module 200 is used to input the identity image and the style example image into a preset stylized image generation model to generate a stylized image and obtain a target stylized image. The stylized image generation model includes, in sequence, an encoding unit, a feature fusion unit, and a multi-stylized image generation unit.
[0144] This embodiment generates a stylized image by inputting the identity image and the style example image into a preset stylized image generation model. The encoding unit extracts features from both the identity image and the style example image, then a feature fusion unit fuses the extracted features. Finally, a multi-stylized image generation unit generates a stylized image based on the fused features. This generates a stylized image with the same style as the style example image and the same identity as the object in the identity image. This allows for the generation of images in any specified style without requiring a separate algorithm model for each style, making it very convenient for supporting new requirements and for deployment and maintenance in practical use.
[0145] Reference Figure 3 This application also provides a computer device, which may be a server, and its internal structure may be as follows: Figure 3 As shown. The computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage medium. The database stores data such as a stylized image generation method based on style paradigms. The network interface communicates with external terminals via a network connection. When the computer program is executed by the processor, it implements a stylized image generation method based on style paradigms. The stylized image generation method based on style paradigms includes: acquiring an identity image and a style paradigm image; inputting the identity image and the style paradigm image into a preset stylized image generation model to generate a stylized image, obtaining a target stylized image, wherein the stylized image generation model sequentially includes an encoding unit, a feature fusion unit, and a multi-stylized image generation unit.
[0146] This embodiment generates a stylized image by inputting the identity image and the style example image into a preset stylized image generation model. The encoding unit extracts features from both the identity image and the style example image, then a feature fusion unit fuses the extracted features. Finally, a multi-stylized image generation unit generates a stylized image based on the fused features. This generates a stylized image with the same style as the style example image and the same identity as the object in the identity image. This allows for the generation of images in any specified style without requiring a separate algorithm model for each style, making it very convenient for supporting new requirements and for deployment and maintenance in practical use.
[0147] An embodiment of this application also provides a computer-readable storage medium storing a computer program thereon. When the computer program is executed by a processor, it implements a stylized image generation method based on style paradigms, including the steps of: acquiring an identity image and a style paradigm image; inputting the identity image and the style paradigm image into a preset stylized image generation model to generate a stylized image, thereby obtaining a target stylized image. The stylized image generation model sequentially includes: an encoding unit, a feature fusion unit, and a multi-stylized image generation unit.
[0148] The above-described stylized image generation method based on style paradigms generates stylized images by inputting the identity image and the style paradigm image into a preset stylized image generation model. Specifically, an encoding unit extracts features from both the identity image and the style paradigm image, a feature fusion unit fuses the extracted features, and a multi-stylized image generation unit generates the stylized image based on the fused features. This generates a stylized image with the same style as the style paradigm image and the same identity as the object in the identity image. This method enables the generation of images in any specified style without requiring a separate algorithm model for each style, making it very convenient for supporting new requirements and for deployment and maintenance in practical applications.
[0149] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media provided in this application and in the embodiments may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual-speed SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0150] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, apparatus, article, or method. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, apparatus, article, or method that includes that element.
[0151] The above description is only a preferred embodiment of this application and does not limit the patent scope of this application. Any equivalent structural or procedural changes made based on the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. A stylized image generation method based on style paradigms, characterized in that, The method includes: Obtain the identity image and style example image; The identity image and the style example image are input into a preset stylized image generation model to generate a stylized image, resulting in a target stylized image, including: The identity image is input into the encoding unit for latent space feature extraction to obtain the first latent space feature; The style example image is input into the coding unit for latent space feature extraction to obtain the second latent space feature; The first latent space feature and the second latent space feature are input into the feature fusion unit for feature fusion to obtain the target feature. The calculation formula Z of the target feature is: in, This is the first latent space feature. W is the second latent space feature, and W is the network parameter of the feature fusion unit; The target features are input into a multi-stylized image generation unit to generate a stylized image, thereby obtaining the target stylized image. The style of the target stylized image is the same as that of the style example image, and the identity of the object in the target stylized image is the same as that of the object in the identity image. The stylized image generation model comprises, in sequence, an encoding unit, a feature fusion unit, and a multi-stylized image generation unit. The multi-style image generation unit is predetermined in the following way: a variety of cartoon face image sample sets are obtained, and the generator and the preset discriminator obtained based on the deep learning neural network are subjected to adversarial training using the variety of cartoon face image sample sets. The generator after the adversarial training is completed is used as the multi-style image generation unit, and the multi-style image generation unit is used to generate images of various styles. The stylized image generation model is obtained by: acquiring an initial model and multiple training samples. The initial model includes an initial encoding unit, an initial feature fusion unit, and the multi-stylized image generation unit. With the network parameters of the multi-stylized image generation unit fixed, the initial encoding unit and the initial feature fusion unit are fine-tuned using each of the training samples. Each of the multiple training samples includes: an identity sample image, a style example sample image, and a stylized image label. The stylized image label is a manually created stylized image.
2. The stylized image generation method based on style paradigms according to claim 1, characterized in that, The step of inputting the identity image and the style example image into a preset stylized image generation model to generate a stylized image and obtain the target stylized image includes: An initial model and multiple training samples are obtained, wherein the initial model includes: an initial encoding unit, an initial feature fusion unit, and the multi-stylized image generation unit; The initial model is trained using each of the training samples to update the network parameters of the initial encoding unit and the initial feature fusion unit, and the initial model after training is used as the stylized image generation model.
3. The stylized image generation method based on style paradigms according to claim 2, characterized in that, The step of training the initial model using each of the training samples to update the network parameters of the initial encoding unit and the initial feature fusion unit, and using the trained initial model as the stylized image generation model, includes: Choose any one of the training samples as the target sample from each of the training samples; The identity sample image and style example sample image in the target sample are input into the initial model to generate a stylized image, thus obtaining the stylized image to be analyzed; The stylized image to be analyzed is input into the multi-stylized image discriminator corresponding to the multi-stylized image generation unit to perform stylized image discrimination, and the stylized image discrimination result is obtained. The identity sample image in the target sample is input into a preset object feature extraction model for feature extraction to obtain the first object feature; The stylized image to be analyzed is input into the object feature extraction model for feature extraction to obtain the second object features; The target loss value is calculated based on the stylized image discrimination result, the first object feature, the second object feature, the stylized image to be analyzed, and the stylized image labels in the target sample; Update the network parameters of the encoding initialization unit and the feature fusion initialization unit according to the target loss value; Repeat the step of obtaining any one of the training samples as the target sample from each of the training samples until the preset model training termination condition is reached, and use the initial model that has reached the model training termination condition as the stylized image generation model.
4. The stylized image generation method based on style paradigms according to claim 3, characterized in that, The step of calculating the target loss value based on the stylized image discrimination result, the first object feature, the second object feature, the stylized image to be analyzed, and the stylized image labels in the target sample includes: The first object feature and the second object feature are input into a preset distance loss function to calculate the loss value, and a first loss value is obtained; The stylized image to be analyzed and the stylized image labels in the target sample are input into a preset stylized image loss function to calculate the loss value and obtain the second loss value; The target loss value is obtained by fusing the stylized image discrimination result, the first loss value, and the second loss value. The formula L for calculating the target loss value is: in, It is a logarithmic function. This is the stylized image discrimination result. It is the first loss value. It is the second loss value. It is a constant.
5. The stylized image generation method based on style paradigms according to claim 4, characterized in that, The updated formula for calculating the network parameters of the initial coding unit. for: The updated formula for calculating the network parameters of the feature fusion initial unit. for: in, These are the network parameters of the encoding initial unit after the last update. These are the network parameters of the initial unit for feature fusion after the last update. It is the first learning rate. It is a constant. It is the second learning rate. It is a constant. It is the target loss value. It involves taking the derivative of L. Yes Perform differentiation calculations. Yes Perform differentiation calculations.
6. A stylized image generation apparatus based on style paradigms, characterized in that, The device includes: The image acquisition module is used to acquire identity images and style example images; The target stylized image determination module is used to input the identity image and the style example image into a preset stylized image generation model to generate a stylized image and obtain a target stylized image. The stylized image generation model includes, in sequence, an encoding unit, a feature fusion unit, and a multi-stylized image generation unit. The multi-style image generation unit is predetermined in the following way: a variety of cartoon face image sample sets are obtained, and the generator and the preset discriminator obtained based on the deep learning neural network are subjected to adversarial training using the variety of cartoon face image sample sets. The generator after the adversarial training is completed is used as the multi-style image generation unit, and the multi-style image generation unit is used to generate images of various styles. The stylized image generation model is obtained by: acquiring an initial model and multiple training samples. The initial model includes an initial encoding unit, an initial feature fusion unit, and the multi-stylized image generation unit. With the network parameters of the multi-stylized image generation unit fixed, the initial encoding unit and the initial feature fusion unit are fine-tuned using each of the training samples.
7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Image processing method and device, computer equipment and storage medium
CN111127378A
Model training method and device, image processing method and device, electronic equipment and medium
CN114187173A
