Method, apparatus, and device for constructing cartoonization models, storage medium and program product

The cartoon transformation model addresses the limitations of StyleGAN2 by fine-tuning with cartoon data, weight interpolation, and data enhancement, resulting in robust and realistic cartoon image generation.

SA1120242545B1Active Publication Date: 2026-11-26BIGO TECH PTE LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
SA1120242545
Authority / Receiving Office
SA · SA
Patent Type
Patents
Current Assignee / Owner
Filing Date
2024-05-13
Publication Date
2026-11-26
Estimated Expiration
2042-11-16

AI Technical Summary

Technical Problem

Existing generative models like StyleGAN2 often produce images with blot-like effects and lack robustness in transforming real-world images into high-quality cartoon images.

Method used

A cartoon transformation model is developed by fine-tuning a pre-trained generative model using cartoon data, incorporating weight interpolation and data enhancement techniques, and utilizing a combination of loss functions to ensure accurate and realistic cartoon image generation.

Benefits of technology

The model achieves improved robustness and authenticity in transforming real-world images into high-quality cartoon images, maintaining consistency in specific features and enhancing generalization across various scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 42D33F19-8D59-47CB-988A-5C1D2946237A
    Figure 42D33F19-8D59-47CB-988A-5C1D2946237A
  • Figure 482F2AC4-67F9-46A7-B10C-A4C12BF7E45B
    Figure 482F2AC4-67F9-46A7-B10C-A4C12BF7E45B
  • Figure 7C51699B-8246-4403-8857-D398CB9D7B0E
    Figure 7C51699B-8246-4403-8857-D398CB9D7B0E
Patent Text Reader

Abstract

The present invention relates to a method, device, and electronic means for constructing cartoon models, a storage medium, and a computer software product, as it pertains to the field of image processing techniques. The method involves: generating (110) predetermined numbers of real sample images using a pre-trained first generative model; constructing (120) second generative models based on the first generative model; generating (120) cartoon image samples corresponding to each of the real sample images using the second generative model; obtaining (130) image sample pairs by assembling each of the real sample images with its corresponding cartoon image sample; and generating (140) cartoon transformation models to fully convert a target image into a cartoon image by preparing, on the basis of a sample set consisting of multiple image sample pairs, a predetermined initial cartoon transformation model with a weight corresponding to the second generative model as an initial weight. Figure 1
Need to check novelty before this filing date? Find Prior Art

Description

Figure 1 is a flowchart of a method model for building cartoon models according to some current detection models. In some models, the method is implemented via a cartoon modeling device. In other models, the cartoon modeling device is installed on a server or client, where it is not bound to the models. The cartoon transformation model can be applied in scenarios such as image processing, short videos, film production, live streaming, and 3D animation. It is used to transform an image from these scenarios into a fully cartoon image. In some models, as shown in Figure 2, an image is given and fed into Cartoon Transform Model 201, which then outputs a fully cartoon image. The content of the fully cartoon image remains the same as the input image, but its style is changed to a cartoon style; that is, all elements in the input image are transformed into cartoons. In other models, a short video is presented, and each frame of the short video is fed into the Cartoon Transform Model. The Cartoon Transform Model then outputs fully cartoon images corresponding to multiple frames, thus achieving a cartoon transformation of the entire image for each frame in the input short video. In some models, the cartoon-based conversion model is incorporated into applications or web pages according to the development documentation. As shown in Figure 1, the models include the following operations. In operation 110, a predetermined number of real-world sample images are generated using a pre-trained generative first model. Generative models represent an important class of models in probability statistics and machine learning, referring to models used to generate randomly observable data. In some models, the first generative model is a StyleGAN2 model, and a predetermined number of real-world sample images are randomly generated by StyleGAN2. Here, a real-world sample image refers to images that are not cartoonized, such as images containing a real person. Generative Adversarial Networks (GANs) are a type of deep learning model, specifically a type of generative model capable of generating new content. StyleGAN is one type of GAN, a pattern-based generative model. StyleGAN is an advanced method for compositing high-resolution images that has proven effective and reliable across diverse datasets. In addition to realistic images, StyleGAN is used to create animals, cars, and even other types of rooms. However, StyleGAN is not perfect; its most noticeable drawback is that the generated images sometimes contain blot-like effects. This flaw was overcome by StyleGAN2, thus improving the quality of the generated images. Figure 3 illustrates the model structure for the StyleGAN2 model. StyleGAN2 consists of two parts, including the 301 layout network on the left side and the synthesis network on the right side, as shown in Figure 3. The planning network can better isolate the inputs. As shown in Figure 3, the planning network consists of eight fully connected layers (FC) 302 using Gaussian obfuscation (latency Z∈Ƶ) 303 as inputs, and a latent variable (W∈W) 304 is obtained through the planning network. The synthesis network consists of modules that include a learnable asymptotic transformation (A) 305, a modulation and demodulation module (Mod-Demod) 306 to 307, an upsample module (Upsample) 308, and other modules. In addition to these modules, the synthesis network also includes a weight (w), a bias (b), and a constant input (c, i.e., Const4*4*512, representing a learnable constant). The Leaky ReLU activation function is always applied directly during the addition of a bias. In some models, the learnable asymptotic transformation (A) consists of a fully connected layer. In some models, Upsample performs a sampling process by removing image distortion (also referred to as convolutional switching). The processing flow in the Mod-Demod unit is as follows: . Where the input feature map scaling factor is represented by number i. During scaling and twisting, the adjustment of the convolutional layer weight is cancelled, and the standard deviation for output activation is as follows: . Removing the weight adjustment aims to return the output to the standard deviation unit, i.e., the new weight of the convolutional layer is as follows: . In the equation above, the addition is to avoid having a denominator of zero. At the far right of Figure 3, the random noise injection 309 is shown. 310 represents a learnable noise variant. Random noise is introduced to make the generated images more realistic. In some models, this noise generates subtle features on human faces during generation, such as facial spots. In process 120, a second generative model is built based on the first generative model, and a cartoon image sample is generated that corresponds to each of the real sample images using the second generative model. In this process, the second generative model is also a StyleGAN2 model in some instances. The model structure of the first and second generative models is similar, except that their training objectives differ, resulting in different model weights. The first generative model is used to train real-world sample images, i.e., non-cartoon images. The second generative model is used to train cartoon sample images, i.e., cartoon images. In some models, a second generative model designed for cartoon transformation is obtained by fine-tuning the weight of the first generative model, which is pre-trained using cartoon data as the training target. The second generative model is then used to generate a cartoon image sample corresponding to each of the real-world sample images. In operation 130, a sample image pair is obtained by combining the real sample image with the corresponding cartoon image sample. In this process, where a predetermined number of real sample images and their corresponding cartoon sample images are generated, a picture-to-picture (P2P) sample pair is obtained based on each real sample image and its corresponding cartoon sample image. Each of these sample pairs forms a sample set for processing the next model. It should be noted that, in some models, the predefined number is a trial value, and a specific value for this predefined number is determined according to the required accuracy of the model. In some models, the predefined number is 150,000, meaning the generation of 150,000 sample image pairs. In operation 140, a cartoon transformation model is generated to fully cartoonize a target image by equipping, on the basis of a sample set consisting of multiple image sample pairs, a predefined initial cartoon transformation model with a weight corresponding to the second generative model as an initial weight. In this process, by obtaining a sample set consisting of pairs of sample images, a cartoon transformation model is generated. This is achieved by preparing a predefined initial cartoon transformation model using the real sample images in the sample set as training data, the corresponding weight of the final generative model as the initial weight, and the corresponding cartoon image for each real sample image as the target for optimization. The cartoon transformation model is designed to fully transform a target image into a cartoon image. In modeling, when constructing a cartoonization model to fully cartoonize a target image, a predefined number of real-world sample images are first randomly generated using a pre-trained generative model. A second generative model is then built to generate cartoon sample images based on the first. A corresponding cartoon sample image is then generated using the second generative model. Furthermore, a sample set is obtained by pairing the real-world sample image with its corresponding cartoon sample image. Finally, the predefined initial cartoonization model is adjusted using the sample set with the weight corresponding to the second generative model's initial weight. The resulting model is the cartoonization model, capable of performing a complete cartoonization process.In these models, the second generative model is linked to the first generative model, and the weight of the second generative model acts as the initial weight of the cartoon transformation model. The cartoon transformation model is prepared using training data consisting of image pairs obtained through image mating, allowing the resulting cartoon transformation model to have better robustness, overall performance, and an improved cartoon transformation effect for the entire image. Furthermore, these models require less data compared to other solutions. Figure 4 is a flowchart of a model method for constructing cartoon models based on some existing detection models. These models, building upon previous models, provide a more detailed explanation of the process for constructing the second generative model. As illustrated in Figure 4, the models involve the following processes. In operation 410, a predetermined number of real-world sample images are generated using a pre-trained generative first model. In process 420, an intermediate cartoon model is generated by adjusting the weight of the first generative model. In the models, the training target for the first generative model is the original non-cartoon images, while the training target for the intermediate cartoon model is the cartoon images that have been converted into cartoons. Therefore, the intermediate cartoon model is generated using the weight of the first generative model as the initial weight of the intermediate cartoon model and using the cartoon images as the training target. In this way, the weight of the intermediate cartoon model is obtained by adjusting the weight of the first generative model. In operation 430, a second generative model is generated by replacing the weight corresponding to a partially defined layer in the intermediate cardboard model with the weight corresponding to the partially defined layer in the first generative model and performing weight interpolation. To ensure that certain specific features of the final cartoon images remain consistent with certain specific features of the original images created by the first generative model, during the generation of the intermediate cartoon model, the weight corresponding to a partially defined layer in the intermediate cartoon model is replaced by the weight corresponding to a partially defined layer in the first generative model, and weight interpolation is performed to generate the second generative model. In some models, a partially defined layer includes at least one of the following: the layer that controls a character's pose or the layer that controls the character's skin tone. In other words, to ensure that the pose and skin tone of the cartoon character remain consistent with the pose and skin tone of the real person in the original image, the weights of the pose and skin tone layers in the intermediate cartoon model are replaced with the weights of the pose and skin tone layers in the first generative model, and weight interpolation is performed within the intermediate cartoon model to ultimately obtain the weight of the second generative model. Weight interpolation refers to the process of calculating a new weight between two weights using an interpolation algorithm and inserting the new weight between the two. Models limit the specific interpolation algorithm used for weight interpolation. In some models, the internal interpolation algorithm includes the Inverse Distance Weighted Interpolation (IDW) method for weight interpolation. IWD is also referred to as the Inverse Distance to Power Method, meaning it is a weighted average interpolation method that can perform interpolation accurately or smoothly. IWD explicitly assumes that objects closer together are more similar than objects farther apart. When predicting values ​​for any unmeasured location, IWD uses measured values ​​around the prediction location. Compared to measured values ​​farther from the prediction location, measured values ​​closer to the prediction location have a greater influence on the predicted value. IWD assumes that each measurement point has a local influence that decreases with increasing distance.Because this method assigns a greater weight to points closer to the prediction location, and the weight decreases as a function of distance, the method is referred to as the Inverse Distance Measurement (IDW) method. In addition, those skilled in the field can also use a covariance-based interpolation and weighting algorithm, Kriging interpolation method, etc., to perform weight interpolation. In operation 440, a cartoon image sample is generated that corresponds to each of the real sample images using the second generative model. In operation 450, a sample image pair is obtained by combining the real sample image with the corresponding cartoon image sample. In operation 460, a cartoon transformation model is generated to fully cartoonize a target image by equipping, on the basis of a sample set consisting of multiple image sample pairs, a predefined initial cartoon transformation model with a weight corresponding to the second generative model as an initial weight. In the models, when building the second generative model, an intermediate cartoon model is obtained, based on the pre-trained first generative model, by modifying the weight of the first generative model through capturing cartoon images as the training target. After obtaining the final weight of the second generative model by performing weight substitution and weight interpolation on the sublayers of the intermediate cartoon model, the construction of the second generative model is completed. Compared to training the second generative model by simply capturing cartoon images as the training target, the second generative model built using the above method in the models has higher robustness and improved cartoon image authenticity. Figure 5 is a flowchart of a model method for constructing cartoon models based on some existing detection models. These models, building upon previous models, provide a more detailed explanation of the process for handling training samples. As shown in Figure 5, the models include the following processes. In operation 510, a predetermined number of real-world sample images are generated using a pre-trained generative first model. In process 520, a second generative model is built based on the first generative model, and a cartoon image sample is generated that corresponds to each of the real sample images using the second generative model. In operation 530, a sample image pair is obtained by combining the real sample image with the corresponding cartoon image sample. In operation 540, data enhancement is performed on a sample set consisting of multiple image sample pairs. Data enhancement involves randomly performing at least one random rotation, random cropping, random zooming, random zooming, or similar operation on both the real sample image and the cartoon sample image. In this process, all pairs of sample images are grouped together to form the sample set, and data enhancement is applied to the real sample images and cartoon sample images in the sample set to increase the size of the training data and improve the robustness and generalizability of the model. When implemented in some models, data enhancement involves at least one of the following methods: different noise enhancement, enhancement during sample reduction and then sample increase, data enhancement for sample image pairs, etc. In some models, data enhancement for sample image pairs includes, but is not limited to, random implementation of random rotation, random cropping, random zooming, random zooming, or the like on real sample images and / or cartoon sample images. In operation 550, a cartoon transformation model is used to fully cartoonize a target image by preparing, based on the sample set, a predefined initial cartoon transformation model with the corresponding weight to the second generative model in the form of the initial weight. In some models, by obtaining the sample set through data enhancement, the carton transformation model is generated by preparing, based on the sample set, the initial carton transformation model predetermined with the weight corresponding to the second generative model in the form of the initial weight. In the modeling process, image sample pairs, obtained by combining real-world sample images with corresponding cartoon image samples, are used as training data to form a sample set. Various data enhancement methods are then applied to this sample set. During data enhancement, the sample set is used to train the cartoon transformation model, thereby achieving full-image cartoon transformation. This process enhances the robustness of the cartoon transformation model, ensuring it exhibits better object-oriented performance (such as human bodies) at random angles and strong generalization performance under various scenarios, while maintaining good full-image cartoon transformation effects for various low-quality images. Figure 6 is a flowchart of a model method for constructing cartoon models based on some existing detection models. These models, building upon previous models, provide a more detailed explanation of the process for constructing the cartoon transformation model. As illustrated in Figure 6, the models include the following processes. In operation 610, a predetermined number of real-world sample images are generated using a pre-trained generative first model. In process 620, a second generative model is built based on the first generative model, and a cartoon image sample is generated that corresponds to each of the real sample images using the second generative model. In operation 630, a sample image pair is obtained by combining the real sample image with the corresponding cartoon image sample. In operation 640, a corresponding feature map and pattern attribute information are obtained by executing, by means of the encoder in a predefined initial cartoon transformation model, a feature is extracted on a real-world sample image in the sample set, and the feature map and pattern attribute information are output to the decoder in the initial cartoon transformation model. In some models, the initial cartoon transformation model includes an encoder and a decoder. As shown in Figure 7, the dashed left box represents the encoder, and the dashed right box represents the decoder. The encoder extracts information from several real-world sample images and outputs the extracted feature map and pattern attribute information to the decoder. The decoder then combines the feature map and pattern attribute information to output the complete cartoon image. In the models, the initial weight of the encryption tool is the weight of an encryption tool in which several real images of a person have been previously edited. In some models, the encoder includes an input layer, several residual layers, and a fully connected layer. The multiple residual layer is designed to extract a feature map from a real-world sample image and output the feature map to a corresponding layer of the decoder; the fully connected layer is designed to extract pattern feature information from the real-world sample image and output the pattern feature information to the multiple layers of the decoder. In some models, the architecture of the encryption tool is shown in Table 1 below. In Table 1, there are five ResBlock layers, and the size of the Featuremap output is determined by each ResBlock layer, such as, as shown in Table 1, 512*512*3, 256*256*32, etc. The fully connected FC layer outputs pattern feature information with a size of 16 × 512. encryption tool Input, 512 × 512 × 3 ResBlock, 256 × 256 × 32 ResBlock, 128 × 128 × 128 ResBlock, 64 × 64 × 256 ResBlock, 32 × 32 × 512 ResBlock16×16×512 Featuremap FC(16×512) Latend Code Table 1 As illustrated in Figure 7, the extracted feature map from each remaining layer is output, on one side, to the next processing layer, and on the other side, the feature map also needs to be output to the corresponding layer in the decoder (except for the last remaining layer, which only outputs the results to the corresponding layer in the decoder). In this case, the corresponding layer refers to the decoder layer that matches the size of the current output feature map. In some models, if the size of the current output feature map is 32 × 32 × 512, the corresponding layer in the decoder refers to the decoder layer capable of processing feature maps of a size of 32 × 32 × 512. In Figure 7, there are two output layers on the far right side of the encoder. The one at the top is the last remaining layer (ResBlock) 701, which outputs a feature map of size 16 × 16 × 512; and the layer at the bottom is the fully connected layer (FC) 702, which outputs pattern feature information of size 16 × 512. The fully connected layer (FC) outputs pattern feature information for each layer in the decoder, so that the decoder can perform the full-image cartoon transformation processing based on the pattern feature information. In operation 650, the cartoon transformation model is obtained by training, by a decoder using a cartoon image sample in the sample set as the training target and the second generative model weight as the initial weight, feature map and pattern attribute information using a predefined loss function. In some models, the decoder has the same synthesizing network structure as the StyleGAN2 generative model, and the weight used is the initial weight of the generative model for training. As illustrated in Figure 7, each decoding layer, using a decoder, obtains the input feature map and pattern attribute information from the decoder, decodes and synthesizes the feature map and pattern attribute information, and outputs the decoding result to the next layer. This process continues until the final decoding layer outputs the complete cartoon result. In some models, the loss function used to train the cartoon transformation model includes a combination of: a hostile network loss function, a perceptual loss function, and a receding loss function, namely: Loss = + + ; The hostile network loss function is a type of classification loss function designed to determine the authenticity of the entire cartoon image generated by the cartoon transformation model, and calculate a loss based on the result of the determination, making the cartoon sense of the entire cartoon image generated by the cartoon transformation model more realistic. In some models, it is calculated using the following equation: ; Where D represents the discriminant, E represents the intermediate value, and represents the output of the entire cartoon image by the cartoon transformation model. The perceptual loss function for the discrete input of the cartoon image output is designed entirely by the cartoon transformation model and a corresponding cartoon sample image in the sample set in a predefined neural network model to obtain the outputs of a first feature map and a corresponding second feature map by the neural network model, and to calculate the L2 loss (least squared error) between the first feature map and the second feature map. In some models, the predefined neural network model is a VGG model, such as VGG-19 or VGG-16. In some models, it is calculated using the following equation: ; Where E represents the median value, represents the output of the entire cartoon image by the cartoon transformation model, and x represents the cartoon sample image, corresponding to the original sample image, input into the cartoon transformation model. The L1 loss between the output of the full cartoon image is calculated using the cartoon transformation model and the corresponding cartoon image sample in the sample set, which is represented using the following equation: It should be noted that in models, in addition to the three loss functions mentioned above, the loss function design can also incorporate other loss functions based on actual optimization goals, which are not restricted in models. In the models, the initial cartoon transformation model includes an encoder and a decoder. When preparing the initial cartoon transformation model, the initial weight of the encoder is the weight of a pre-processed encoder based on several real-world images of a person, and the initial weight of the decoder is the weight of the second generative model. By adopting the model structure described above, taking the paired data of the original image sample and the cartoon image sample as training data, and fitting the cartoon transformation model based on a combination of three loss functions—namely, the hostile network loss function, the perceptual loss function, and the receding loss function—the prepared cartoon transformation model can effectively extract the feature map and model attribute information from the images using the encoder, and perform the full-image cartoon transformation on the feature map and model attribute information using the decoder.In this way, the cartoonish feel of the full cartoon images produced by the cartoon transformation model is enhanced, and the full cartoon content is more consistent with real images, thus effectively improving the power and generalization ability of the cartoon transformation model, and making the cartoon transformation model applicable to low-quality images and complex scenarios. Figure 8 is a flowchart of a model method for constructing cartoon models based on some existing detection models. These models, building upon previous models, provide a more detailed explanation of the cartoon transformation model inference process. As illustrated in Figure 8, the models involve the following operations. In operation 810, a predetermined number of real-world sample images are generated using a pre-trained generative first model. In process 820, a second generative model is built based on the first generative model, and a cartoon image sample is generated that corresponds to each of the real sample images using the second generative model. In operation 830, a sample image pair is obtained by combining the real sample image with the corresponding cartoon image sample. In process 840, a cartoon transformation model is obtained by processing, on the basis of a sample set consisting of multiple image sample pairs, a predefined initial cartoon transformation model with a weight corresponding to the second generative model as an initial weight. In operation 850, a target image is obtained, and the target image is entered into the cartoon transformation model. In some models, the target image includes image input via an image editing page. In other models, if the image editing page is opened in an image editing application or an application with image editing functionality, the user-imported image is used as the target image. If the user enables the full-image cartooning function in the image editing page, the full-image cartooning technology is used to detect the current image and perform the full-image cartooning processing on the image. In some models, the target image also includes multiple frames from a target video. In some models, in a live streaming scenario, if the user activates the full-image cartooning function in the live streaming interface, the current detection full-image cartooning technique is used to perform full-image cartooning processing on multiple frames from the live video. In some models, in a short video or video playback scenario, if the user activates the full-image cartooning function in the playback interface, the current detection full-image cartooning technique is used to perform full-image cartooning processing on multiple frames from the video. In operation 860, a target feature map and target pattern attribute information are extracted for the target image by performing, by means of the encoder in the cartoon transformation model, feature extraction on the target image, and the target feature map and target pattern attribute information are fed into the decoder; a corresponding full cartoon image is generated by the decoder based on the target feature map and the target pattern attribute information, and the full cartoon image are output. In the models, where the cartoon transformation model obtains the target image through the input layer of the encoder, the input layer feeds the target image into the first residual layer of the encoder, as shown in Figure 7. The first residual layer extracts the feature map of the target image and feeds the feature map into the next residual layer and the corresponding layer of the decoder. The next residual layer then continues to extract features. This process continues until the last remaining layer and the fully connected (FC) layer complete processing, indicating that the encoder has finished. The decoder then begins operation. In each decoder layer, cartoon transformation processing is performed based on the received target feature map and target pattern attribute information, and the processed result is sent to the next processing layer. This process continues until the last decoder layer outputs a fully cartoon image to the output layer, and the output layer outputs the fully cartoon image, indicating that the decoder has finished.Then, the process continues to deal with the next target image. In the models, the full-image cartoon transformation technique is achieved through the encoder and decoder of the cartoon transformation model, which preserves the original image pattern, while simultaneously intensifying the cartoon transformation style of the entire image, ensuring a realistic cartoon feel, providing a high level of immersion, and applicable to a variety of different cartoon transformation styles. Figure 9 is a schematic diagram of a device model for constructing cardboard models based on some current detection models. The device includes the following units: The 910 Real Sample Image Generator is designed to generate a predefined number of real sample images using a pre-trained generative first model; The 920 Generative Model II Building Unit is designed to build a generative model II based on the generative model I; The 930 cartoon image sampler generation unit is designed to generate a cartoon image sample that corresponds to each of the real sample images using the second generative model; The 940 image pairing unit is designed to obtain an image sample pair by assembling a real-life sample image with a corresponding cartoon image sample; and The 950 Cartoon Transformation Model Processing Unit is designed to generate a cartoon transformation model to fully transform a target image into a cartoon image by processing, based on a sample set consisting of multiple image sample pairs, a predefined initial cartoon transformation model with a weight corresponding to the second generative model as an initial weight. In some models, the 920 generative second-generation model building unit is designed to: Generate an intermediate cartoon model by adjusting the weight of the initial generative model; and Generate the second generative model by replacing the weight corresponding to a partially defined layer in the intermediate cardboard model with the weight corresponding to the partially defined layer in the first generative model, and perform weight interpolation. In some models, the selected layer partially includes at least one of: a layer that controls a character's posture or a layer that controls a character's skin color. In some models, the initial cartoon conversion model includes an encryption tool and a decryption tool. The 950 carton conversion form processing unit includes the following modules: A sub-encryption unit, designed to obtain a corresponding feature map and pattern attribute information by performing, via the encryptor, feature extraction on a real-world sample image in the sample set, and outputting the feature map and pattern attribute information to the decryptor; and A sub-decoding unit, designed to obtain the cartoon transformation model by training, by the decoding tool using a cartoon image sample from the sample set as the training target and the second generative model weight as the initial weight, feature map and pattern attribute information using a predefined loss function. In some models, the loss function includes a combination of: a hostile network loss function, a perceptual loss function, and an L1_loss loss function. The hostile network loss function is designed to determine the authenticity of the entire cartoon image generated by the cartoon transformation model, and calculates a loss based on the determination result. The cognitive loss function is designed to obtain the outputs of a first feature map and a corresponding second feature map by a predefined neural network model by separately inputting the outputs of the entire cartoon image by the cartoon transformation model and a corresponding cartoon sample image into the sample set in the predefined neural network model, and calculating the L2 loss between the first feature map and the second feature map. L1_loss is designed to calculate the L1 loss between the output of the full cartoon image by the cartoon transformation model and the corresponding cartoon image sample in the sample set. In some models, the encryption tool includes: An input layer, a multi-residue layer, and a fully connected layer, where the multi-residue layer is designed to extract the feature map from the real-sample image and output the feature map to a corresponding layer of the decoder; and the fully connected layer is designed to extract the pattern attribute information from the real-sample image and output the pattern attribute information to the multi-layers of the decoder. In some models, the initial weight of the encryption tool is the weight of an encryption tool in which several real images of a person have been previously edited. In some models, the second generative model is a StyleGAN2 model, and the decoder has the same artificial network architecture as the StyleGAN2 model. In some models, the device also includes the following units: The target image acquisition module is designed to acquire the target image and input the target image into the cartoon conversion model; and A full-image cartooning subprocessing unit, designed to extract, in the cartooning model, a target feature map and target pattern attribute information for the target image by performing, by means of the encoder, feature extraction on the target image, and inputting the target feature map and target pattern attribute information into the decoder; and generating, by means of the decoder, a corresponding full-image cartoon based on the target feature map and target pattern attribute information, and outputting the full-image cartoon. In some models, the target image includes at least one of the following: Image input via the image editing page; or A collection of image frames from a targeted video. In some models, the device also includes the following units: A data enhancement module, designed to perform data enhancement on a sample set before a model is prepared using the sample set, where data enhancement involves the random execution of at least one random rotation, random cropping, random zooming, random zooming, or similar on real sample images and cartoon sample images. The cartoon model building device, according to the current detection models, is capable of implementing the method for building cartoon models in the above models of the current detection, and includes the corresponding functional units to implement the method and achieve the corresponding beneficial effects. Figure 10 is a schematic diagram of an electronic device according to some current detection models. As shown in Figure 10, the electronic device includes a 1010 processor, 1020 memory, an 1030 input device, and a 1040 output device. The number of 1010 processors in the electronic device is one or more; for example, one 1010 processor is shown in Figure 10. The 1010 processor, 1020 memory, 1030 input device, and 1040 output device are connected in the electronic device by a bus or other means; for example, the 1010 processor, 1020 memory, 1030 input device, and 1040 output device are connected by a bus in Figure 10. Memory 1020, designed as a computer-readable storage medium, stores computer programs, computer-executable programs, and modules, such as program instructions / modules corresponding to any of the models in the current report. When the computer programs, instructions, or modules stored in memory 1020 are loaded and executed, the processor 1010 performs the various functional applications and processes the electronic media data, thus executing the methods provided by any of the models in the aforementioned method models. The 1020 memory primarily consists of program storage and data storage. The program storage holds the operating system and at least one application required for functionality; the data storage holds data generated on a terminal basis, or similar. In addition, the 1020 memory includes high-speed RAM and non-vanishing memory, such as at least one magnetic disk memory device, a flash memory device, or another non-vanishing solid-state memory device. In some models, the 1020 memory includes memory designed remotely for the 1010 processor, and this remote memory is connected to a device / terminal / server via a network. The networks listed above include, but are not limited to, the internet, intranet, local area network, mobile network, and combinations thereof. The 1030 input device is designed to receive numerical or personal data inputs and generates the main signal inputs related to receiver settings and control of the electronic device's functions. The 1040 output device includes display devices such as a monitor. Current detection models also provide a storage medium that stores one or more computer-executable instructions. When one or more of these instructions are loaded and executed by a computer processor, the computer executes the method provided by any of the models described above. In some models, the computer-readable storage medium is a non-transient computer-readable storage medium. In addition, in the storage medium that stores one or more computer-executable instructions provided by the current detection models, the one or more computer-executable instructions are not bound by the operations of the method described above, but can be used to perform the relevant operations in the method provided by any model with the current detection. Current detection models also present a computer program product that includes one or more computer-executable instructions. When one or more of these instructions are loaded and executed by a computer processor, the computer executes the method as defined in any of the models above. In addition, in a computer program product provided by the current detection models, one or more of the computer-executable instructions are not bound by the operations of the method described above, but can also be used to perform related operations in the method provided by any of the current detection models. Based on the above model descriptions, those skilled in the field can clearly understand that the current detection can be implemented through a necessary general-purpose software component or a hardware component. Based on this understanding, the technical solutions for the current detection, or the parts that contribute significantly to the relevant field, can be incorporated as a software product. In some models, the computer software product is stored on a computer-readable storage medium, such as a floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard drive, or optical disc, and includes several instructions to enable an electronic device (such as a personal computer, server, or network device) to implement the methods detected in various models of the current detection. It should be noted that in the above device models, the various modules and units are divided only according to their functional logic, but this division is not limited to the above as long as the corresponding functions can be achieved. Furthermore, the specific names used for the various functional units are for ease of differentiation and do not restrict the scope of current detection protection.

Claims

1. A method for building image-to-cartoon conversion models involves the following: generating a predefined number of original images using a pre-trained generative model; building a second generative model based on the first; generating a cartoon image for each original image using the second generative model; obtaining a pair of images by combining each original image with its corresponding cartoon image; and generating an image-to-cartoon conversion model to fully convert the target image into a cartoon image. This is achieved by training a predefined initial conversion model based on a sample set consisting of multiple image pairs, with an initial weight matching the second generative model. The initial conversion model consists of an encoder and a decoder. The process of creating a fully cartoon image-to-target conversion model, by matching the predefined initial cartoon conversion model based on a sample set consisting of multiple image pairs, with the second generative model as the initial weight, involves: obtaining a feature map and corresponding stylistic feature information by having the encoder extract features from theThe original image in the sample set, the feature map, and the style attribute information are output to the decoder. The cartoon transformation model is obtained by training the decoder using the cartoon image in the sample set as the training target, the second generative model weight as the initial weight, the feature map, and the style attribute information, using a predefined loss function.

2. The method according to safeguard element 1, where the construction of the second generative model, based on the first generative model, involves: creating an intermediate cartoon model by modifying the weight of the first generative model; and creating the second generative model by replacing a weight corresponding to a partially defined layer in the intermediate cartoon model with a weight corresponding to a partially defined layer in the first generative model, and performing weight interpolation.

3. The method according to safeguard element 2, where the partially defined layer includes at least one of the following: a layer that controls the character's posture or a layer that controls the character's skin tone.

4. The method according to safeguard element 1, where the loss function includes a combination of: a competitive network loss function, a perception loss function, and a functionRegression loss L1_loss: The competitive network loss function is initialized to determine the accuracy of the full cartoon image generated by the animation model, and the loss is calculated based on this determination. The perceptual loss function is initialized to obtain two symmetrical feature maps, the first and second, from a predefined neural network model. This is achieved by inputting a full cartoon image from the cartoon model and a corresponding typical cartoon image from the sample set into the predefined neural network model, and calculating the L2 loss between the first and second feature maps. The regression loss function L1_loss is initialized to calculate the L1 loss between the full cartoon image from the cartoon model and the corresponding typical cartoon image from the sample set.

5. The method, according to protection element 1, involves an encoder consisting of an input layer, multiple residual layers, and a fully connected layer. The multiple residual layers are initialized to extract the feature map from the original typical image and output it to a corresponding layer in the decoder. The fully connected layer is initialized to extract pattern feature information from the image.

6. The method according to security element 5, where the initial weight of the encoder is that of an encoder in which different real-life images have been previously modified.

7. The method according to security element 1, where the second generative model is StyleGAN2, and the decoder has the same synthesized network architecture as the StyleGAN2 model.

8. The method according to security element 1, which also includes: obtaining the target image and inputting it into the image-to-cartoon model; extracting the target image's feature map and style feature information from the image-to-cartoon model by having the encoder extract features from the target image and input the feature map and style feature information into the decoder; and then having the decoder generate a complete, matching cartoon image based on the feature map and style feature information, and output this cartoon image.

9. The method according to security element 8, where the target image includes at least one of the following: an image input via an image editing page; or a set of image frames from a target video. 10.The method, according to safeguard element 1, also includes the following: performing a data augmentation operation on the sample set before fitting the model using the sample set. This data augmentation operation includes performing at least one random rotation, cropping, zooming, or zooming operation on the original sample image and the cartoon sample image.

11. A device for generating image-to-animation models, comprising: a sample original image generator unit, configured to generate a predefined number of original images using a pre-trained first generative model; a second generative model generator unit, configured to generate a second generative model based on the first generative model; a cartoon sample image generator unit, configured to generate a corresponding cartoon sample image for each original sample image using the second generative model; an image pooling unit, configured to obtain a pair of sample images by combining each original sample image with its corresponding cartoon sample image; and an image-to-animation model unit, configured to generate a fully cartoonized image of a target image by fitting based onA sample set consisting of several pairs of sample images, a predefined initial cartoon image conversion model with a weight corresponding to the second generative model as the initial weight; the initial cartoon conversion model includes an encoder and a decoder; and the image-to-animation conversion model compatibility unit comprises: an encoder subunit, configured to obtain a feature map and matching stylistic feature information by having the encoder extract features from a sample original image in the sample set and output the feature map and stylistic feature information to the decoder; and a decoder subunit, configured to obtain the animation conversion model by training, using a sample cartoon image from the sample set as the training target, the second generative model's initial weight, the feature map, and stylistic feature information using a predefined loss function.

12. An electronic device for creating animation models, comprising: one or more processors; and memory configured to store one or more programs; where one or more processors, when one or more programs are loaded and run, execute the method specified in any of the componentsProtections 1 through 10.

13. A computer-readable storage medium containing a computer program, which, when loaded and executed by a processor, performs the method specified in any of the protections 1 through 10.

14. A computer program product that includes one or more computer-executable instructions, which, when loaded and executed by a processor, perform the method specified in any of the protections 1 through 10.