A single-sample handwritten text copying method based on diffusion model
By introducing style enhancement modules, door control mechanisms, and comparison learning frameworks in the diffusion model, extract and integrate high -frequency and airspace style characteristics, solve the problem of single -sample handwriting text copying medium style extraction and noise processing, and realize high -quality handwriting Text image generation.
Patent Information
- Application Number
- CN202411240512.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-05
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2044-09-05
AI Technical Summary
The prior art is difficult to accurately extract and imitate the handwriting style of an unseen writer from a single sample, especially when dealing with noise background information.
Designed a single -sample handwriting text based on the diffusion model, reference the style and high -frequency component of the parallel processing style through the style enhancement module, the door control mechanism suppress the background noise, use the comparative learning framework to extract the characteristics of the style of strong dedication, and and use the comparative learning framework to extract the characteristics of style characteristics, and and also use the comparative learning framework to extract the characteristics of the style characteristics of strong dedication. Through the fusion of the adaptive fusion module and content characteristics, the guidance conditions diffusion model generates a real and diverse handwriting text image.
A high -quality extraction style of writing is realized from a single sample, a handwriting text image with real and diverse style is generated, and the problem of low traditional method complexity and efficiency is solved. It provides a more convenient and efficient single sample copy method.
Smart Images

Figure CN118762103B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of image processing and artificial intelligence, and in particular relates to a single-sample handwritten text copying method based on a diffusion model. Background Art
[0002] In the digital age, handwriting copying combines the personalization of traditional handwriting with the efficiency of automated processes, providing a digital format that is easy to store to preserve the authenticity of personal handwriting. The task aims to automatically generate handwritten text images that conform to specific text content while imitating the calligraphy style of the writer of a given example (e.g., character tilt, joint strokes, stroke thickness, and ink color). This not only provides great convenience for people with hand disabilities, but also helps designers speed up the process of handwritten font design.
[0003] Previous work on handwriting imitation introduced generative adversarial networks (GANs) for text image synthesis. Using random noise as the style input and conditioning the content input on character-level labels enables the synthesis of handwritten words with randomly sampled styles. In a recent study, diffusion models such as the Denoising Diffusion Probabilistic Model (DDPM) even outperformed GANs in image generation quality. This has inspired several attempts, with some methods conditioning the denoising process on a fixed writer ID to generate handwritten text images with controllable style. However, the main limitation of these methods is that they cannot imitate the handwriting style of unseen writers.
[0004] In order to imitate any given handwriting style, some previous methods (called few-shot copying methods) require users to provide a small number of samples (usually 15) as style references. These methods use a style encoder to extract the writing style from a given sample, thereby providing flexible control over the style of the generated samples. However, the traditional few-shot generation process is complex, inefficient, and time-consuming. Users prefer methods that only require a single sample to be provided as a style reference, called single-shot copying methods, because they are more convenient, efficient, and easy to use. Therefore, it is of great practical value to study the more challenging single-shot copying task, where users only need to provide a single sample to obtain high-quality handwritten text images with the desired style and content.
[0005] The main challenge of the single-sample handwriting copying task is how to accurately extract the user's handwriting style from only one style reference image. As an abstract symbol, characters usually only occupy a small part of the reference image. In addition, the reference image is often messy and full of noisy background information, which poses a major obstacle to extracting personal handwriting style. Summary of the invention
[0006] In view of this, it is necessary to provide a new single-sample handwritten text copying method based on a diffusion model to address the above technical issues. The method proposes a style enhancement module to process the style reference image and its high-frequency components in parallel; a gating mechanism is designed to suppress the influx of background noise in the style reference image; and a contrastive learning framework is used to further obtain highly discriminative style features from the high-frequency components to guide the synthesis of handwritten text with realistic and diverse styles. Subsequently, the style features extracted from the two branches are adaptively fused with specific content features in an adaptive fusion module. Finally, the fused style and content features are used as conditional inputs to guide the denoising process of the conditional diffusion model and gradually synthesize stylized handwritten text images.
[0007] The present invention discloses a single-sample handwritten text copying method based on a diffusion model, comprising the following steps:
[0008] Step 1: construct a style diffusion model generation network that can imitate any handwriting, including a style feature enhancement module, a content encoder, an adaptive fusion module, and a conditional diffusion model;
[0009] Step 2: Using the handwriting sample image and the standard font image as the style input and content input respectively, the style feature enhancement module and the content encoder are used to extract the style feature and content feature respectively, and then the style feature and content feature are fused by the adaptive fusion module and input into the conditional diffusion model to generate a handwriting style text image with the target style and content;
[0010] Step 3, training the diffusion model generation network capable of copying any handwriting style;
[0011] Step 4: Use the trained entire diffusion model to generate a network to generate a handwritten style text image that satisfies both the target style and the target content.
[0012] Specifically, the style feature enhancement module includes a high-frequency filter, a high-frequency style encoder, a spatial style encoder and a gating layer, and the style features include high-frequency style features and spatial style features;
[0013] The high-frequency filter extracts high-frequency information from the handwriting sample image, comprising the following steps: using the Laplacian operator as a high-frequency filter to extract high-frequency information of the image from the handwriting sample image, wherein the high-frequency information comprises a single-channel tensor having the same size as the handwriting sample image, and the single-channel tensor comprises contour and edge information of the handwriting sample image;
[0014] The high-frequency style encoder and the spatial-domain style encoder have the same network structure, both of which are sequentially connected by a convolutional neural network and a two-layer transformer, and are used to extract high-frequency style features and spatial-domain style tensors from the high-frequency information and the handwritten sample image, respectively;
[0015] Among them, the gating layer includes a fully connected layer and a nonlinear activation layer, which is used to map the spatial style tensor into a weight vector, and then multiply the weight vector and the spatial style tensor, perform impurity filtering on the spatial style tensor, and finally output a clean spatial style feature.
[0016] Preferably, the content encoder is formed by sequentially connecting a convolutional neural network and three transformer layers. The content encoder encodes the input standard font image into content features, which are then sent to the adaptive fusion module.
[0017] Furthermore, the adaptive fusion module comprises two cross attention modules. The first attention module utilizes The mechanism integrates content features, spatial style features and high-frequency style features, and the mathematical expression is as follows:
[0018] ;
[0019] in, It is the content feature with sinusoidal position encoding. represents the high-frequency style features extracted by the high-frequency style encoder, represents the spatial style features output by the gating layer, yes and The result after adding, Content characteristics Add sinusoidal position encoding to represents the attention mechanism, , , Represents the QKV weight in cross attention; represents the output of the first attention module;
[0020] The second attention module aims to fully integrate and , the specific mathematical expression is as follows:
[0021] ;
[0022] Represents the output of the adaptive fusion module, which serves as the guiding condition of the conditional diffusion model.
[0023] Optionally, the conditional diffusion model The goal is to Under the guidance of , realistic handwritten text images are generated. Specifically, Execute a file containing The denoising generation process of the first step is to obtain a handwritten style text image containing a lot of noise from the sampling First, gradually denoise to get a clean, noise-free handwritten style text image. ; The mathematical expression of this process is as follows:
[0024] ;
[0025] in, express Conditional diffusion model Generate handwritten text images , represents the bootstrap condition of the conditional diffusion model, represents a noisy handwritten text image, represents the current diffusion time step, represents the total number of diffusion time steps, Represents the conditional diffusion model The factorial of the step, represents a normal distribution, express The mean of express The standard deviation of represents the parameters of the conditional diffusion model;
[0026] Preferably, construct the Laplace contrastive learning loss function , guiding the high-frequency style encoder to learn more discriminative high-frequency style features from the handwritten sample image, mathematically expressed as follows:
[0027] ;
[0028] in, Is the size of The set of elements of yes Any element in express Medium Other elements besides yes Any element in Indicates the use of Anchor samples for learning and optimizing the high-frequency style features, wherein is a learnable multilayer perceptron , , and represents the anchor sample, and Indicates the writer, Belongs to the writer Anchor samples of yes The positive sample set is required and have the same writer tag, yes Any element in is a scalar temperature parameter, The symbol represents the inner product.
[0029] Optionally, construct a reconstruction loss to guide the conditional diffusion model Generate high-quality handwritten text images. The reconstruction loss is to force Learn how to reverse a predefined forward denoising process and apply it to realistic handwritten style text images. The forward process is modeled as a fixed Markov chain, where noise that conforms to the normal distribution is gradually added to To get The noise adding process can be formally expressed as follows:
[0030] ;
[0031] represents the conditional probability, noise The changes caused by Control, from Increase linearly to During training, a variational bound is applied on the maximum likelihood objective to guide the generation process from handwritten style text images that contain a lot of noise and are close to standard Gaussian noise Recover clean, noise-free handwritten text images , represents the mean of the normal distribution, represents the standard deviation of the normal distribution, represents the identity matrix; the training objectives are as follows:
[0032] ;
[0033] in, Express expectations, and denote the means of the normal distribution in the forward process and the reverse process, respectively. express The control factor, Represents the time step To time step The factorial of all control factors, where Represents a real handwritten style text image, Represents a handwritten style text image synthesized after adding noise.
[0034] Preferably, a single handwritten sample image is used as the style input, and the conditional diffusion model A U-Net architecture with a transformer module is used to transform the sampled noise With boot conditions Fusion, and use the denoising diffusion implicit model DDIM to accelerate the generation process in the process of generating handwritten style text images.
[0035] Compared with the prior art, the present invention has the following beneficial effects:
[0036] The method of the present invention proposes a novel conditional diffusion model for single-sample handwritten text copying. The model only needs one reference sample as style input and can imitate its writing style with high quality to generate handwritten text with arbitrary content.
[0037] The method of the present invention introduces high-frequency components of reference samples to enhance the extraction of handwriting style. The proposed style enhancement module can process the style reference image and its high-frequency components in parallel; a gating mechanism is designed to suppress the influx of background noise in the style reference image; and a contrastive learning framework is used to further obtain highly discriminative style features from the high-frequency components to guide the synthesis of handwritten text with realistic and diverse styles. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 A schematic flow chart of an implementation method of the present invention is shown;
[0039] Figure 2 A schematic diagram showing the structure of each module in an embodiment of the present invention. DETAILED DESCRIPTION
[0040] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0041] For the purpose of reference and clarity, the technical terms, abbreviations or acronyms used below are summarized and explained as follows:
[0042] Transformer: An attention-based neural network architecture for processing sequence data.
[0043] SinPositionEmbedding: A positional encoding method that uses sine and cosine functions to generate unique embeddings for each position in a sequence, helping the model capture sequential information.
[0044] GELU / Sigmoid / ReLU: non-linear activation function.
[0045] ResNet18: A convolutional neural network that belongs to the residual network family and consists of 18 layers, including convolutional layers, batch normalization layers, ReLU activation functions, and fully connected layers.
[0046] Attention: An attention mechanism that allows the model to dynamically focus on different parts of the input when processing it.
[0047] DDIM: A diffusion generative model that enables efficient image generation by introducing a deterministic mapping on the reverse path of the diffusion process.
[0048] The invention discloses a single-sample handwritten text copying method based on a diffusion model to solve many problems existing in the prior art.
[0049] Figure 1 A single-sample handwritten text copying method based on a diffusion model is characterized by comprising the following steps:
[0050] Step 1: construct a style diffusion model generation network that can imitate any handwriting, including a style feature enhancement module, a content encoder, an adaptive fusion module, and a conditional diffusion model;
[0051] Step 2: Using the handwriting sample image and the standard font image as the style input and content input respectively, the style feature enhancement module and the content encoder are used to extract the style feature and content feature respectively, and then the style feature and content feature are fused by the adaptive fusion module and input into the conditional diffusion model to generate a handwriting style text image with the target style and content;
[0052] Step 3, training the diffusion model generation network capable of copying any handwriting style;
[0053] Step 4: Use the trained entire diffusion model to generate a network to generate a handwritten style text image that satisfies both the target style and the target content.
[0054] Specifically, Figure 2As shown, the style feature enhancement module in step 2 is a style feature extraction network, including a high-frequency filter, a high-frequency style encoder, a spatial style encoder and a gating layer, and the style features include high-frequency style features and spatial style features. The specific steps are: first, using the Laplacian operator as a high-frequency filter, extracting the high-frequency information of the reference image from the handwritten reference sample image provided by the user, including outputting a single-channel tensor with the same size as the original sample. Secondly, the high-frequency information and the handwritten sample image are respectively input into the high-frequency encoder and the spatial style encoder to obtain the high-frequency style features and the spatial style tensor respectively;
[0055] Then, the spatial style tensor is input into the gating layer, and the weight vector is output. Next, the weight vector is multiplied by the spatial style tensor, the impurities in the spatial style tensor are filtered, and the clean spatial style features are output. Finally, the high-frequency style features and the clean spatial style features are output to the adaptive fusion module as part of the conditional input, guiding the conditional diffusion model to gradually generate handwritten style text images that meet specific content and style.
[0056] Furthermore, the specific operation steps of step 2 in this embodiment are as follows:
[0057] Step 201: using a standard Unifont font image with symmetrical glyphs as the content input, and using a handwriting sample image provided by a user as the style input; wherein, in order to improve the recognition progress, the style input image is proportionally scaled to a fixed height of 64;
[0058] Step 202: Building a style feature enhancement module as a style feature extraction network, wherein the style feature enhancement module includes a high-frequency filter, a high-frequency style encoder, a spatial domain style encoder, and a gating layer;
[0059] The steps of extracting the style features are specifically as follows:
[0060] Step 20201: Use the Laplacian operator as a high-frequency filter to extract high-frequency information of the image from the handwriting sample image, including a single-channel tensor of the same size as the handwriting sample image, and the single-channel tensor includes the contour and edge information of the handwriting sample image;
[0061] Step 20202: input the high-frequency information into the high-frequency style encoder to obtain the high-frequency style feature;
[0062] It should be noted that the high-frequency style encoder and the spatial domain style encoder have the same network structure, both of which are composed of Resnet18 as the convolutional base network and 2 layers of standard transformers connected in sequence;
[0063] The Resnet18 network has a depth of 18 layers, including convolutional layers, batch normalization layers, ReLU activation functions, and fully connected layers.
[0064] Step 20203: input the handwritten sample image into the spatial style encoder to obtain a spatial style tensor, input the spatial style tensor into the gating layer, output a weight vector, then multiply the weight vector by the spatial style tensor, filter impurities in the spatial style tensor, and output a clean spatial style feature;
[0065] The first layer of the gating layer is a connection layer, followed by a Sigmoid layer.
[0066] Step 2204: finally, output the high-frequency style features and the clean spatial style features to an adaptive fusion module for fusion;
[0067] It should be noted that, in step 20204, the unfiltered spatial style tensor and the high-frequency style feature can also be input into the adaptive fusion module for fusion, and the spatial style tensor can be filtered using the gating layer before input, in order to improve the purity of the spatial style tensor and convert it into a cleaner spatial style feature.
[0068] Step 203. Build a content encoder, which is composed of Resnet18 as a convolutional basic network and three layers of transformers connected in sequence. The content encoder encodes the input standard Unifont font into 512-dimensional content features, which are then sent to the adaptive fusion module for fusion;
[0069] Step 204. Construct an adaptive fusion module, which includes two cross-attention modules. The first attention module uses The mechanism integrates content features, spatial style features and high-frequency style features, and the mathematical expression is as follows:
[0070] ;
[0071] in, It is the content feature with sinusoidal position encoding. represents the high-frequency style features extracted by the high-frequency style encoder, represents the spatial style features output by the gating layer, yes and The result after adding, Content characteristics Add sinusoidal position encoding to represents the attention mechanism, , , Represents the QKV weight in cross attention; represents the output of the first attention module;
[0072] in, , , It is a set of weight matrices representing input data, which is mainly used to measure the similarity and correlation between different data elements;
[0073] The query matrix is used to represent the input data vector to be compared, and its correlation with other vectors is determined by comparing it with other data vectors;
[0074] The key matrix represents the features of the input data and is used to match the query vector. By calculating the dot product between the query and the key, their similarity score is obtained;
[0075] The value matrix contains the actual content or information of the input data, which indicates the final result to be obtained under the influence of the weights associated with the query and key;
[0076] The second attention module aims to fully integrate and , the specific mathematical expression is as follows:
[0077] ;
[0078] represents the output of the adaptive fusion module, which serves as the guiding condition of the conditional diffusion model;
[0079] Step 205. Conditional Diffusion Model The goal is to Under the guidance of , realistic handwriting style text images are generated;
[0080] Among them, the conditional diffusion model The U-Net architecture of the transformer module is used, and the output of each layer of the U-Net is used as , using the output of the adaptive fusion module As and ,exist Complete information fusion in the mechanism;
[0081] Specifically, the conditional diffusion model Execute a file containing The denoising generation process of the first step is to obtain a handwritten style text image containing a lot of noise from the sampling First, gradually denoise to get a clean, noise-free handwritten style text image. ; The mathematical expression of this process is as follows:
[0082] ;
[0083] in, Indicated in Conditional diffusion model Generate handwritten style text images , represents the bootstrap condition of the conditional diffusion model, represents a noisy handwritten text image, represents the current diffusion time step, represents the diffusion time step or the total number of denoising steps, Represents the conditional diffusion model The factorial of the step, represents a normal distribution, express The mean of express The standard deviation of represents the parameters of the conditional diffusion model;
[0084] The denoising process is based on the sampling Based on Perform gradual denoising to get a cleaner image , and finally Perform denoising prediction to get the final handwritten style text image .
[0085] Step 206. Construct Laplace contrastive learning loss function The high-frequency style encoder is guided to learn more discriminative high-frequency style features from the handwriting sample image. This function aims to bring the high-frequency style features belonging to the same writer closer together, while pushing the high-frequency style features of different writers further apart. The specific mathematical expression is as follows:
[0086] ;
[0087] in, Is the size of The set of elements of yes Any element in express Medium Other elements besides yes Any element in Indicates the use of Anchor samples for learning and optimizing the high-frequency style features, wherein is a learnable multilayer perceptron , , and represents the anchor sample, and Indicates the writer, Belongs to the writer Anchor samples of yes The positive sample set is required and have the same writer tag, yes Any element in is a scalar temperature parameter, The symbol represents the inner product;
[0088] Step 207. Construct reconstruction loss to guide the conditional diffusion model Generate high-quality handwritten style text images. The reconstruction loss is to force Learn how to reverse a predefined forward denoising process and apply it to realistic handwritten style text images. The forward process is modeled as a fixed Markov chain, where noise that conforms to the normal distribution is gradually added to To get The noise adding process can be formally expressed as follows:
[0089] ;
[0090] represents the conditional probability, and the change of noise is given by Control, from Increase linearly to During training, a variational bound is applied on the maximum likelihood objective to guide the generation process from handwritten style text images that contain a lot of noise and are close to standard Gaussian noise Recover clean, noise-free handwritten text images , represents the mean of the normal distribution, represents the standard deviation of the normal distribution, represents the identity matrix; the training objectives are as follows:
[0091] ;
[0092] in, Express expectations, and denote the means of the normal distribution in the forward process and the reverse process, respectively. express The control factor, Represents the time step To time step The factorial of all control factors, where Represents a real handwritten style text image, Represents a handwritten style text image synthesized after adding noise;
[0093] The noise adding process is based on the real handwriting style text image Based on Gradually add noise and synthesize the handwritten style text image after noise addition Comparison operation obtains , and finally from Recover from the clean , and finally Make a prediction to get the final handwritten style text image The purpose of the noise addition process is to train the network with real images so that the handwritten style text images generated by the network are Handwritten style text images that are closer to the real target style.
[0094] In this invention, a single handwriting sample image is used as the style input for network training. During the training process, the optimizer uses AdamW, the learning rate is 0.0001, the batch size is set to 448, and 700 epochs are trained on four RTX3090 GPUs. In the process of generating handwriting style text images, each handwriting sample image is randomly sampled from the target writer and used A step-wise denoising diffusion implicit model is used to accelerate the generation process.
[0095] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0096] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0097] The technical features of the above embodiments can be combined arbitrarily. At the same time, the number of each step is not used to constrain the order of the steps. As long as there is no strict order constraint between the steps, the order is allowed to be adjusted and changed. In order to make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0098] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A single-sample handwritten text copying method based on a diffusion model, characterized in that: The following steps are involved: Step 1: construct a style diffusion model generation network that can imitate any handwriting, including a style feature enhancement module, a content encoder, an adaptive fusion module, and a conditional diffusion model; Step 2: Using the handwriting sample image and the standard font image as the style input and content input respectively, the style feature enhancement module and the content encoder are used to extract the style feature and content feature respectively, and then the style feature and content feature are fused by the adaptive fusion module and input into the conditional diffusion model to generate a handwriting style text image with the target style and content; Step 3, training the diffusion model generation network capable of copying any handwriting style; Step 4, using the trained diffusion model capable of copying any handwriting style to generate a network to synthesize a handwriting style text image that satisfies both the target style and the target content; The style feature enhancement module includes a high-frequency filter, a high-frequency style encoder, a spatial style encoder and a gating layer; wherein the style features include high-frequency style features and spatial style features; The high-frequency filter extracts high-frequency information from the handwriting sample image, and the specific steps are: using the Laplacian operator as a high-frequency filter to extract the high-frequency information of the image from the handwriting sample image, the high-frequency information includes a single-channel tensor with the same size as the handwriting sample image, and the single-channel tensor includes the contour and edge information of the handwriting sample image; The high-frequency style encoder and the spatial-domain style encoder have the same network structure, both of which are sequentially connected by a convolutional neural network and a two-layer transformer, and are used to extract high-frequency style features and spatial-domain style tensors from the high-frequency information and the handwritten sample image, respectively; The gating layer includes a fully connected layer and a nonlinear activation layer, which is used to map the spatial style tensor into a weight vector, and then multiply the weight vector and the spatial style tensor, perform impurity filtering on the spatial style tensor, and finally output a clean spatial style feature; The content encoder is composed of a convolutional neural network and three transformer layers connected in sequence. The content encoder encodes the standard font image into content features and then sends them to the adaptive fusion module.
2. According to the single-sample handwritten text copying method based on the diffusion model of claim 1, it is characterized in that: The adaptive fusion module includes two cross-attention modules. The first attention module uses The mechanism integrates the content features, spatial style features and high-frequency style features, and the expression is: ; in, It is the content feature with sinusoidal position encoding. represents the high-frequency style features extracted by the high-frequency style encoder, represents the spatial style features output by the gating layer, yes and The result after adding, Content characteristics Add sinusoidal position encoding to represents the attention mechanism, , , Represents the QKV weight in cross attention; represents the output of the first attention module; The second attention module aims to fully integrate and , the expression is: ; Represents the output of the adaptive fusion module, which serves as the guiding condition of the conditional diffusion model.
3. The single-sample handwritten text copying method based on a diffusion model according to claim 2, characterized in that: Conditional Diffusion Model The goal is to Under the guidance of , realistic handwritten text images are generated; Execute a file containing The denoising generation process of the first step is to obtain a handwritten style text image containing a lot of noise from the sampling Start by denoising to get a clean handwritten style text image ; The mathematical expression of this process is as follows: ; in, Indicated in Conditional diffusion model Generate handwritten text images , represents the bootstrap condition of the conditional diffusion model, represents a noisy handwritten text image, represents the current diffusion time step, represents the total number of diffusion time steps, Represents the conditional diffusion model The factorial of the step, represents a normal distribution, express The mean of express The standard deviation of represents the parameters of the conditional diffusion model.
4. The single-sample handwritten text copying method based on a diffusion model according to claim 3, characterized in that: Constructing Laplace Contrastive Learning Loss Function , guiding the high-frequency style encoder to learn more discriminative high-frequency style features from the handwritten sample image, the formula is as follows: ; in, Is the size of The set of elements of yes Any element in express Medium Other elements besides yes Any element in Indicates the use of Anchor samples for learning and optimizing the high-frequency style features, wherein is a learnable multilayer perceptron , , and represents the anchor sample, and Indicates the writer, Belongs to the writer Anchor samples of yes The positive sample set is required and have the same writer tag, yes Any element in is a scalar temperature parameter, The symbol represents the inner product.
5. The single-sample handwritten text copying method based on diffusion model according to claim 3 is characterized in that: Constructing reconstruction loss to guide conditional diffusion model Generate the handwritten text image with style and high quality; the reconstruction loss is to force Learn how to reverse a predefined forward noise addition process; The forward process is modeled as a stationary Markov chain where normally distributed noise is gradually added to To get ; The noise addition process is expressed as follows: ; represents the conditional probability, and the change of noise is given by Control, from Increase linearly to ; During training, a variational bound is applied on the maximum likelihood objective to guide the generation process from noisy handwritten style text images. Restore clean handwriting style text images , represents the mean of the normal distribution, represents the standard deviation of the normal distribution, represents the identity matrix, express Handwritten style text images that always contain noise, represents a normal distribution; the training objectives are as follows: ; in, Express expectations, and denote the means of the normal distribution in the forward process and the reverse process, respectively. express The control factor, Represents the time step To time step The factorial of all control factors, where Represents a real handwritten style text image, Represents a handwritten style text image synthesized after adding noise.
6. The single-sample handwritten text copying method based on a diffusion model according to claim 3, characterized in that: Using a single handwritten sample image as style input, conditional diffusion model A U-Net architecture with a transformer module is used to transform the sampled noise With boot conditions Fusion, and use the denoising diffusion implicit model DDIM to accelerate the generation process in the process of generating handwritten style text images.
Citation Information
Patent Citations
Individualized handwritten character generation method based on adversarial decoupling
CN114495118A
Single sample font generation method based on multi-scale style fusion and font control
CN118365744A
Cited By
Online handwriting sequence generation system and method based on diffusion model, and storage medium
CN120599097A