A font style attribute quantitative editing method, device and computer storage medium

By using hidden space-based diffusion model LDM and font attribute encoder for quantitative editing in font style attribute editing, the problem of poor font style attribute editing performance in the existing technology is solved, and high-quality and highly controllable fonts are achieved Style attribute editing improves computing efficiency.

CN118333009BActive Publication Date: 2025-02-18BEIJING HANYI KEYIN INFORMATION TECH +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410509079.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-26
Publication Date
2025-02-18
Estimated Expiration
2044-04-26

AI Technical Summary

Technical Problem

The existing technology has performed poorly in the field of font style attribute editing, unable to generate high-quality and high-resolution font images, and has high calculation costs, so it is unable to effectively exert its ability to edit font style attributes.

Method used

By obtaining font image data and processing parameters, input the diffusion model LDM and font attribute encoder based on hidden space, perform iterative calculations for encoding, adding noise, denoising, and decoding, and using the DDIM model to complete the iterative calculation of noise, obtain the new quantized edit Font image.

Benefits of technology

It realizes high-quality and highly controllable font style quantitative editing, improves computing efficiency, and solves the problem of poor font style attribute editing performance in the existing technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118333009B_ABST
    Figure CN118333009B_ABST
Patent Text Reader

Abstract

The present invention provides a font style attribute quantization editing method, including: obtaining font image data, obtaining a font attribute encoder, a font attribute predictor, and an LDM, wherein the LDM includes a VAE and a U-Net network, obtaining processing parameters, inputting the processing parameters into the font attribute encoder, and obtaining a direction vector corresponding to the processing parameters; inputting the font image data into the VAE encoder to obtain an encoding result; adding noise to the encoding result to obtain a noisy encoding result; inputting the noisy encoding result and the direction vector into the U-Net network, and obtaining a denoised latent variable by iterative calculation using DDIM; decoding the denoised latent space variable to obtain a new font image that has been quantized and edited. The present invention also includes a font style attribute quantization editing device and a computer storage medium of the corresponding method. The font style attribute quantization editing method, device, and storage medium provided by the present invention have high computational efficiency, higher generation quality, and highly controllable font style effects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of artificial intelligence, and in particular relates to a font style attribute quantitative editing method, device and computer storage medium. Background Art

[0002] The diffusion model or diffusion probability model is a type of generative model in the field of deep learning. It is a type of latent variable model that uses a Markov chain trained by variational estimation. Its goal is to learn the latent structure of a data set by modeling the diffusion of data points in the latent space. Due to the stability of diffusion model training and the excellent generation quality, it has become the most popular generative model and is widely used in image generation, image restoration, image denoising, image super-resolution and other sub-fields.

[0003] In the field of font generation, vector fonts can be rendered into image formats, and then font images can be trained and generated based on this, and finally converted into vector fonts. Therefore, font generation can be regarded as a specific data domain in image generation. At present, the diffusion model has shown amazing capabilities in font expansion in the field of font generation. It can generate font images close to real font samples, but the diffusion model has not yet played its advantages in the field of font style attribute editing.

[0004] Font style attributes refer to a collection of properties that can change the font style, such as the weight, width, height, serifs, roundness, etc. Editing font style attributes can achieve controllable changes to existing font styles. For example, editing the weight attribute of a font style can obtain a new style font that is thicker or thinner than the original font style.

[0005] At present, the exploration of font style attribute editing is still in its early stages. Although a small amount of font style attribute editing can be achieved with the help of stylegan and unsupervised image editing methods in generative adversarial networks, due to the limitations of generative adversarial networks themselves, it is impossible to generate high-quality and high-resolution images. Its operation is at the pixel level, the quality of the edited font image is not high, and there are fewer editable attributes. The calculation process is complicated, and the cost of evaluation and reasoning is also extremely high, which cannot give full play to the ability of font style attribute editing.

[0006] Based on the above, this application provides a technical solution to solve the above technical problems. Summary of the invention

[0007] In view of the fact that the font style attribute editing performance in the prior art is poor and there is a blank in the field of font style attribute quantitative editing, the present invention provides a font style attribute quantitative editing method, comprising the following steps:

[0008] Step S1, obtaining font image data, obtaining a font attribute encoder, a font attribute predictor, and a latent space-based diffusion model LDM, wherein the LDM includes a variational autoencoder VAE and a U-Net network, and the VAE includes a VAE encoder and a VAE decoder;

[0009] Step S2, obtaining processing parameters, inputting the processing parameters into the font attribute encoder, and obtaining a direction vector corresponding to the processing parameters;

[0010] Step S3, inputting the font image data into a VAE encoder to obtain an encoding result;

[0011] Step S4, adding noise to the encoding result based on a denoising diffusion implicit model DDIM Inversion to obtain a noisy encoding result;

[0012] Step S5, inputting the noise-added coding result and the direction vector into the U-Net network, and using the denoising diffusion implicit model DDIM to iteratively calculate and obtain the denoising latent variable;

[0013] Step S6: input the denoised latent space variables into the VAE decoder, and decode to obtain a new font image that has been quantized and edited.

[0014] In a specific embodiment of the present invention, the processing parameters include a font style attribute index and an editing strength, and the U-Net network includes a U-Net0 module and a U-Net1 module;

[0015] Wherein, step S2 comprises:

[0016] Step S2.1, converting the font style attribute index into a corresponding initial vector, wherein the initial vector is one-hot encoded;

[0017] Step S2.2: multiply the initial vector by the editing strength, and input the product into the font attribute encoder to obtain a direction vector.

[0018] In a specific embodiment of the present invention, inputting the direction vector into the U-Net network in step S5 specifically includes:

[0019] Obtaining an intermediate layer feature vector h output by the U-Net0 module; adding the intermediate layer feature vector h to the direction vector f to obtain an edit vector;

[0020] The edit vector is input into the U-Net1 module.

[0021] In a specific embodiment of the present invention, the training steps of the font attribute encoder and the font attribute predictor include:

[0022] Step A1, obtaining a training font image data sample, inputting the training font image data sample into a VAE encoder, obtaining an encoding result, and adding noise to the encoding result to obtain a noisy encoding result;

[0023] Step A2: randomly sample a font style attribute index k and obtain the editing strength ω, and convert the font style attribute index k into a corresponding initial vector, wherein the initial vector is one-hot encoded;

[0024] Step A3, multiplying the initial vector and the editing strength ω, and inputting the product into the font attribute encoder to obtain a direction vector f;

[0025] Step A4: Obtain the intermediate layer feature vector h output by the U-Net0 module;

[0026] Step A5: Add the intermediate layer feature vector h to the direction vector f to obtain the edit vector h e , the edit vector h e Input U-Net1 module, U-Net1 module outputs quantized edited noise and the noise ∈ t , t represents the number of time steps for adding noise to the encoding result in step A1;

[0027] Step A6: based on the noise after quantization editing Noise without quantization editing ∈ t and the noise-added coding result, using the LDM to predict x'0 and x'0 represents the predicted latent variable without attribute editing, Represents the predicted latent variable after attribute editing;

[0028] Step A7: Replace x'0 and Input font attribute predictor and calculate k pre and ω pre , k pre represents the predicted font style attribute index, ω pre represents the predicted editing intensity;

[0029] when The training of the font attribute encoder and the font attribute predictor is completed when .

[0030] In a specific embodiment of the present invention, the cross entropy loss function is used to calculate k and k pre The loss k loss , using the mean square error loss function to calculate ω and ω pre The loss of ω loss , k loss Loss and ω lossThe losses are added together to obtain the overall loss, and then the parameters of the font attribute encoder and font attribute predictor are updated through the back-propagation algorithm.

[0031] In a specific embodiment of the present invention, step S5 comprises:

[0032] DDIM includes S denoising steps;

[0033] Among them, in the first step, the encoding result Input DDIM and calculate the first intermediate latent variable

[0034] In the second step, Input DDIM and calculate the second intermediate latent variable This calculation step is iterated S times to obtain the denoised latent variable

[0035] In a specific embodiment of the present invention, VAE, font attribute encoder, and font attribute predictor all include a fully connected layer, a LayerNorm function, and an activation function; VAE also includes a residual module and a convolution module.

[0036] In a specific embodiment of the present invention, U-Net also includes font content representation information z c and font style information s , z c and z s It is the conditional information used in LDM to guide the generated font images, which are merged and input into U-Net.

[0037] The present invention also provides a font style attribute quantitative editing device, comprising:

[0038] An acquisition module, used for acquiring font image data, a font attribute encoder, a font attribute predictor and a latent space-based diffusion model LDM, wherein the LDM includes a variational autoencoder VAE and a U-Net network and diffusion model parameters, and the VAE includes a VAE encoder and a VAE decoder;

[0039] A parameter processing module, used for obtaining processing parameters, inputting the processing parameters into a font attribute encoder, and obtaining a direction vector corresponding to the processing parameters;

[0040] A VAE encoder, used for encoding the font image data to obtain an encoding result;

[0041] A VAE decoder, used for decoding the denoised latent space variables to obtain a font image;

[0042] DDIM Inversion, used to add noise to the encoding result to obtain a noisy encoding result;

[0043] U-Net network, used for iteratively calculating denoising latent variables according to the denoising coding result and the direction vector;

[0044] A font attribute predictor is used to predict the font style attribute index and editing strength in the processing parameters.

[0045] The present invention also provides a computer storage medium, which is stored in a computer. The computer storage medium stores a computer program executable by the computer. When the computer program is executed by the computer, the computer implements any of the aforementioned font style attribute quantitative editing methods.

[0046] The present invention can bring at least one of the following beneficial effects: The present invention proposes a font style attribute quantitative editing method, device and computer storage medium, by inputting font image data and processing parameters into a latent space-based diffusion model LDM and a font attribute encoder, performing encoding, denoising, denoising and decoding iterative calculations, and obtaining a new font image quantitatively edited according to the processing parameters, and using the DDIM model to complete the noise iterative calculation step, further improving the calculation efficiency, and also achieving high-quality and highly controllable font style quantitative editing of font style attributes. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] The preferred implementation scheme will be described below in a clear and understandable manner with reference to the accompanying drawings to further illustrate the above-mentioned characteristics, technical features, advantages and their implementation methods.

[0048] Figure 1 A schematic diagram of the steps of a font style attribute quantitative editing method provided in the first embodiment of the present invention;

[0049] Figure 2 Schematic diagram of the structure of VAE in Embodiment 1 of the present invention;

[0050] Figure 3 It is a schematic diagram of the structure of the U-Net network, the font attribute encoder, and the font attribute predictor in the first embodiment of the present invention;

[0051] Figure 4 Schematic diagram of the steps of U-Net network training in Embodiment 1 of the present invention;

[0052] Figure 5 A schematic diagram of the structure of a font style attribute quantitative editing device provided in the second embodiment of the present invention. DETAILED DESCRIPTION

[0053] Various aspects of the present invention are described in further detail below.

[0054] Unless otherwise defined or indicated, all professional and scientific terms used herein have the same meanings as those familiar to those skilled in the art. In addition, any methods and materials similar or equivalent to those described herein can be applied to the present invention.

[0055] The following is an explanation of the terms.

[0056] Unless otherwise clearly specified and limited, the "or" mentioned in the present invention includes the relationship of "and". The "and" is equivalent to the Boolean logic operator "AND", the "or" is equivalent to the Boolean logic operator "OR", and "AND" is a subset of "OR".

[0057] It is to be understood that although the terms "first", "second", etc. may be used herein to describe different elements, these elements should not be limited by these terms. These terms are only used to distinguish one element from another element. Therefore, the first element may be referred to as the second element without departing from the teachings of the present invention.

[0058] In the present invention, the terms "comprising", "including" or "comprising" indicate that various components can be applied together in the mixture or composition of the present invention. Therefore, the term "consisting mainly of..." is included in the terms "comprising", "including" or "comprising".

[0059] Unless otherwise clearly specified and limited, the terms "connected", "connected" and "connection" in the present invention should be understood in a broad sense, for example, it can be a fixed connection, or it can be connected through an intermediary medium, it can be the internal connection of two elements or the interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances.

[0060] For example, if an element (or component) is referred to as being on, coupled to, or connected to another element, the element may be directly formed on, coupled to, or connected to the other element, or there may be one or more intervening elements between them. In contrast, if the expressions "directly on," "directly coupled to," and "directly connected to" are used herein, then no intervening elements are indicated. Other words used to describe the relationship between elements should be similarly interpreted, such as "between" and "directly between," "attached" and "directly attached," "adjacent" and "directly adjacent," and the like.

[0061] It should also be noted that the words "front", "rear", "left", "right", "upper" and "lower" used in the following description refer to directions in the drawings. The words "inner" and "outer" used refer to directions toward or away from the geometric center of a particular component, respectively. It can be understood that these terms are used here to describe the relationship of one element, layer or region relative to another element, layer or region as shown in the drawings. In addition to the orientations described in the drawings, these terms should also include other orientations of the device.

[0062] Other aspects of the present invention will be apparent to those skilled in the art in view of the disclosure herein.

[0063] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the specific implementation methods of the present invention will be described below with reference to the accompanying drawings. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings and other implementation methods can be obtained based on these drawings without creative work.

[0064] It should also be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present application. The drawings only show the components related to the present application and are not drawn according to the number, shape and size of the components in actual implementation. The type, quantity and proportion of each component in actual implementation may be changed arbitrarily, and the component layout may also be more complicated. For example, the thickness of the components in the drawings may be exaggerated for the sake of clarity.

[0065] Specific term explanation:

[0066] LDM (Latent Diffusion Model): A diffusion model based on latent space, which is the current mainstream basic model. LDM uses autoencoders to concentrate the calculation of diffusion in latent space, reducing the computational complexity, thereby greatly saving computing power and maintaining image quality and flexibility.

[0067] Font attribute index: Since it is impossible to directly obtain the attribute label of the font, font attribute editing can only be performed in an unsupervised or self-supervised manner. Therefore, in training, the total number of font attributes K can only be set first, and then the font attribute index k is sampled. k represents the kth attribute of the font. After training, it is necessary to observe and determine the specific attribute represented by index k. For example, assuming that when index k = 1, the observed value is the thickness attribute.

[0068] Font content: The characters of a font. Font content shows the character information of the font and has nothing to do with the font style information. For example, the Chinese characters "你", "我", "他" are all font content. Regardless of whether they are displayed in bold, Song typeface, etc., the font content is the same.

[0069] Font style: Font style represents the style information of a set of fonts. For example, Song typeface, boldface, etc. are called font styles. For example, in the training dataset of the present invention, there are 6763 font contents under a set of font styles, and the font images visually displayed are composed of font content and font style.

[0070] Embodiment 1

[0071] In view of the poor performance of font style attribute editing in the prior art and the blank in the field of quantitative editing of font style attributes, the present invention provides a method for quantitative editing of font style attributes. As shown in the appendix Figure 1 The method for quantitative editing of font style attributes includes the following steps:

[0072] Step S1: Obtain font image data, obtain a font attribute encoder 3, a font attribute predictor 4, and a latent space-based diffusion model LDM. As shown in the appendix Figure 2 The LDM includes a variational autoencoder VAE and a U-Net network. The VAE includes a VAE encoder 1 and a VAE decoder 2;

[0073] Step S2: Obtain processing parameters, input the processing parameters into the font attribute encoder 3, and obtain a direction vector corresponding to the processing parameters;

[0074] Step S3: Input the font image data into the VAE encoder 1 to obtain an encoding result;

[0075] Step S4: Add noise to the encoding result based on the denoising diffusion implicit model DDIM Inversion to obtain a noise-added encoding result;

[0076] Step S5: Input the noise-added encoding result and the direction vector into the U-Net network, and use the denoising diffusion implicit model DDIM to iteratively calculate to obtain a denoised latent variable;

[0077] Step S6: Input the denoised latent space variable into the VAE decoder 2 to decode and obtain a newly quantized and edited font image.

[0078] Preferably, the font image data includes existing Chinese font data on the market. The present invention has collected 651 sets of Chinese font styles, and each set of font styles has 6763 common Chinese character glyphs.

[0079] Preferably, the LDM also includes diffusion model parameters, and the diffusion model is calculated based on the diffusion model parameters.

[0080] In a preferred embodiment of the present invention, the processing parameters include font style attribute index and editing strength, as shown in the attached Figure 3 As shown, the U-Net network also includes a U-Net0 module and a U-Net1 module;

[0081] Wherein, step S2 comprises:

[0082] Step S2.1, converting the font style attribute index into a corresponding initial vector, wherein the initial vector is one-hot encoded;

[0083] Step S2.2: multiply the initial vector by the editing strength, and input the product into the font attribute encoder to obtain a direction vector.

[0084] In a preferred embodiment of the present invention, inputting the direction vector into the U-Net network in step S5 specifically includes:

[0085] Obtaining an intermediate layer feature vector output by the U-Net0 module; adding the intermediate layer feature vector to the direction vector to obtain an edit vector;

[0086] The edit vector is input into the U-Net1 module.

[0087] In a preferred embodiment of the present invention, see the attached Figure 4 , the training steps of the font attribute encoder and the font attribute predictor include:

[0088] Step A1, obtaining a training font image data sample, inputting the training font image data sample into a VAE encoder 1, obtaining an encoding result, and adding noise to the encoding result to obtain a noisy encoding result;

[0089] Step A2: randomly sample a font style attribute index k and obtain the editing strength ω, and convert the font style attribute index k into a corresponding initial vector, wherein the initial vector is one-hot encoded;

[0090] Step A3, multiplying the initial vector and the editing strength ω, and inputting the product into the font attribute encoder 3 to obtain a direction vector f;

[0091] Step A4: Obtain the intermediate layer feature vector h output by the U-Net0 module;

[0092] Step A5: Add the intermediate layer feature vector h to the direction vector f to obtain the edit vector h e , the edit vector he Input U-Net1 module, U-Net1 module outputs quantized edited noise and the noise ∈ t , t represents the number of time steps for adding noise to the encoding result in step A1;

[0093] Step A6: based on the noise after quantization editing Noise without quantization editing ∈ t and the noise-added coding result, using the LDM to predict x'0 and x'0 represents the predicted latent variable without attribute editing, Represents the predicted latent variable after attribute editing;

[0094] Step A7: Replace x'0 and Input font attribute predictor 4 and calculate k pre and ω pre , k pre represents the predicted font style attribute index, ω pre represents the predicted editing intensity;

[0095] when The training of the font attribute encoder and the font attribute predictor is completed when .

[0096] Among them, k∈[1,K], K represents the total number of font style attributes, and K is a positive integer.

[0097] Preferably, it is also necessary to set the interval of ω in advance according to actual font style requirements, for example, ω∈[-1,1].

[0098] Furthermore, the cross entropy loss function is used to calculate k and k pre The loss k loss , using the mean square error loss function to calculate ω and ω pre The loss of ω loss , k loss Loss and ω loss The losses are added to obtain the overall loss, and then the parameters of the font attribute encoder 3 and the font attribute predictor 4 are updated through the back propagation algorithm.

[0099] In a preferred embodiment of the present invention, step S5 comprises:

[0100] DDIM includes S denoising steps;

[0101] Among them, in the first step, the encoding result Input DDIM and calculate the first intermediate latent variable

[0102] In the second step, Input DDIM and calculate the second intermediate latent variable Since DDIM includes S denoising steps, the calculation step is iterated S times to obtain the final denoising latent variable

[0103] In a preferred embodiment of the present invention, VAE, font attribute encoder 3, and font attribute predictor 4 all include fully connected layers, LayerNorm functions, and activation functions. Preferably, VAE also includes a residual module and a convolution module.

[0104] In a preferred embodiment of the present invention, U-Net also includes font content representation information z c and font style information s , z c and z s It is the conditional information used in LDM to guide the generated font images, which are merged and input into U-Net.

[0105] Furthermore, c and z s The font image generation effect generated as conditional information in LDM, z c and z s Obtained by embedding the font content tag and the font style tag.

[0106] The font style attribute quantitative editing method proposed in this embodiment inputs the font image data and processing parameters into the diffusion model LDM based on the latent space and the font attribute encoder, performs encoding, denoising, denoising and decoding iterative calculations, obtains a new font image quantitatively edited according to the processing parameters, and uses the DDIM model to complete the noise iterative calculation step, thereby further improving the calculation efficiency and realizing high-quality and highly controllable font style attribute quantitative editing.

[0107] Embodiment 2

[0108] See attached Figure 5 , is a schematic diagram of the structure of a font style attribute quantization editing device according to another specific embodiment of the present invention, which comprises:

[0109] An acquisition module, used for acquiring font image data, a font attribute encoder, a font attribute predictor and a latent space-based diffusion model LDM, wherein the LDM includes a variational autoencoder VAE and a U-Net network, and the VAE includes a VAE encoder and a VAE decoder;

[0110] A parameter processing module, used for obtaining processing parameters, inputting the processing parameters into a font attribute encoder, and obtaining a direction vector corresponding to the processing parameters;

[0111] A VAE encoder, used for encoding the font image data to obtain an encoding result;

[0112] A VAE decoder, used for decoding the denoised latent space variables to obtain a font image;

[0113] DDIM Inversion, used to add noise to the encoding result to obtain a noisy encoding result;

[0114] U-Net network, used for iteratively calculating denoising latent variables according to the denoising coding result and the direction vector;

[0115] A font attribute predictor is used to predict the font style attribute index and editing strength in the processing parameters.

[0116] Embodiment 3

[0117] The present invention also provides a computer storage medium, which is stored in a computer. The computer storage medium stores a computer program that can be executed by the computer. When the computer program is executed by the computer, the computer implements the font style attribute quantitative editing method described in Example 1.

[0118] In summary, the present invention has achieved the following effects:

[0119] The present invention proposes a font style attribute quantitative editing method, device and computer storage medium. The method inputs font image data and processing parameters into a latent space-based diffusion model LDM and a font attribute encoder, performs encoding, denoising, denoising and decoding iterative calculations, obtains a new font image quantitatively edited according to the processing parameters, and uses a DDIM model to complete the noise iterative calculation step, thereby further improving the calculation efficiency and achieving high-quality and highly controllable font style quantitative editing of font style attributes.

[0120] Based on this application, it should be understood by those skilled in the art that one aspect described herein can be implemented independently of any other aspect, and two or more of these aspects can be combined in various ways. For example, any number and aspect described herein can be used to implement the device and / or practice the method. In addition, other structures and / or functionalities other than one or more of the aspects described herein can be used to implement this device and / or practice this method.

[0121] Those skilled in the art know that, in addition to realizing the system and its various devices, modules, and units provided by the present invention in a purely computer-readable program code, it is entirely possible to realize the same functions in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, the system and its various devices, modules, and units provided by the present invention can be considered as a hardware component, and the devices, modules, and units included therein for realizing various functions can also be regarded as structures within the hardware component; the devices, modules, and units for realizing various functions can also be regarded as both software modules for realizing the method and structures within the hardware component.

[0122] It should be noted that the above embodiments can be freely combined as needed. 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, and these improvements and modifications should also be considered as the protection scope of the present invention.

[0123] All documents mentioned in the present invention are cited as references in this application, just as each document is cited as reference separately. In addition, it should be understood that after reading the above content of the present invention, those skilled in the art can make various changes or modifications to the present invention, and these equivalent forms also fall within the scope defined by the claims attached to this application.

Claims

1. A font style attribute quantitative editing method, characterized in that: The following steps are involved: Step S1, obtaining font image data, obtaining a font attribute encoder, a font attribute predictor, and a latent space-based diffusion model LDM, wherein the LDM includes a variational autoencoder VAE and a U-Net network, the VAE includes a VAE encoder and a VAE decoder, the font attribute predictor is used to predict the font style attribute index and editing strength in the processing parameters, and the U-Net network includes a U-Net0 module and a U-Net1 module; Step S2, obtaining processing parameters, wherein the processing parameters include a font style attribute index and an editing strength, and inputting the processing parameters into a font attribute encoder to obtain a direction vector corresponding to the processing parameters; Step S3, inputting the font image data into a VAE encoder to obtain an encoding result; Step S4, adding noise to the encoding result based on a denoising diffusion implicit model DDIM Inversion to obtain a noisy encoding result; Step S5, inputting the noise-added coding result and the direction vector into the U-Net network, and obtaining the denoising latent variable by iterative calculation using DDIM; Step S6, inputting the denoising latent variable into the VAE decoder, and decoding to obtain a new font image that has been quantized and edited; The training steps of the font attribute encoder and the font attribute predictor include: Step A1, obtaining a training font image data sample, inputting the training font image data sample into a VAE encoder, obtaining an encoding result, and adding noise to the encoding result to obtain a noisy encoding result; Step A2: randomly sample a font style attribute index k and obtain the editing strength ω, and convert the font style attribute index k into a corresponding initial vector; Step A3, multiplying the initial vector and the editing strength ω, and inputting the product into the font attribute encoder to obtain a direction vector f; Step A4: Obtain the intermediate layer feature vector h output by the U-Net0 module; Step A5: Add the intermediate layer feature vector h to the direction vector f to obtain the edit vector h e , the edit vector h e Input U-Net1 module, U-Net1 module outputs quantized edited noise and the noise ∈ t , t represents the number of time steps for adding noise to the encoding result in step A1; Step A6: based on the noise after quantization editing Noise without quantization editing ∈ t and the noise-added coding result, using the LDM to predict x'0 and x'0 represents the predicted latent variable without attribute editing, Represents the predicted latent variable after attribute editing; Step A7: Replace x'0 and Input font attribute predictor and calculate k pre and ω pre , k pre represents the predicted font style attribute index, ω pre represents the predicted editing intensity; when The training of the font attribute encoder and the font attribute predictor is completed when .

2. The font style attribute quantitative editing method according to claim 1, characterized in that: The processing parameters include the font style attribute index and the editing strength, wherein step S2 includes: Step S2.1, converting the font style attribute index into a corresponding initial vector, wherein the initial vector is one-hot encoded; Step S2.2: multiply the initial vector by the editing strength, and input the product into the font attribute encoder to obtain a direction vector.

3. The font style attribute quantitative editing method according to claim 2, characterized in that: Inputting the direction vector into the U-Net network in step S5 specifically includes: Obtaining an intermediate layer feature vector h output by the U-Net0 module; adding the intermediate layer feature vector h to the direction vector f to obtain an edit vector; The edit vector is input into the U-Net1 module.

4. The font style attribute quantitative editing method according to claim 3, characterized in that: Using the cross entropy loss function to calculate k and k pre The loss k loss , using the mean square error loss function to calculate ω and ω pre The loss of ω loss , k loss Loss and ω loss The losses are added together to obtain the overall loss, and then the parameters of the font attribute encoder and font attribute predictor are updated through the back-propagation algorithm.

5. The font style attribute quantitative editing method according to claim 1, characterized in that: The step S5 comprises: DDIM includes S denoising steps; Among them, in the first step, the encoding result Input DDIM and calculate the first intermediate latent variable In the second step, Input DDIM and calculate the second intermediate latent variable This calculation step is iterated S times to obtain the denoised latent variable 6. The font style attribute quantitative editing method according to claim 1, characterized in that: VAE, font attribute encoder, and font attribute predictor all include fully connected layers, LayerNorm functions, and activation functions; VAE also includes residual modules and convolution modules.

7. The font style attribute quantitative editing method according to claim 3, characterized in that: U-Net also includes font content representation information z c and font style information s , z c and z s It is the conditional information used in LDM to guide the generated font images, which are merged and input into U-Net.

8. A font style attribute quantitative editing device, characterized in that: include: An acquisition module, used for acquiring font image data, a font attribute encoder, a font attribute predictor and a latent space-based diffusion model LDM, wherein the LDM includes a variational autoencoder VAE and a U-Net network, and the VAE includes a VAE encoder and a VAE decoder; A parameter processing module is used to obtain processing parameters, wherein the processing parameters include a font style attribute index and an editing strength, and input the processing parameters into a font attribute encoder to obtain a direction vector corresponding to the processing parameters; A VAE encoder, used for encoding the font image data to obtain an encoding result; VAE decoder, used to decode the denoised latent variables to obtain the font image; DDIM Inversion, used to add noise to the encoding result to obtain a noisy encoding result; A U-Net network, including a U-Net0 module and a U-Net1 module, for iteratively calculating a denoising latent variable according to the denoising encoding result and a direction vector; a font attribute predictor for predicting font style attribute index and editing strength in processing parameters; The training steps of the font attribute encoder and the font attribute predictor include: Step A1, obtaining a training font image data sample, inputting the training font image data sample into a VAE encoder, obtaining an encoding result, and adding noise to the encoding result to obtain a noisy encoding result; Step A2: randomly sample a font style attribute index k and obtain the editing strength ω, and convert the font style attribute index k into a corresponding initial vector; Step A3, multiplying the initial vector and the editing strength ω, and inputting the product into the font attribute encoder to obtain a direction vector f; Step A4: Obtain the intermediate layer feature vector h output by the U-Net0 module; Step A5: Add the intermediate layer feature vector h to the direction vector f to obtain the edit vector h e , the edit vector h e Input U-Net1 module, U-Net1 module outputs quantized edited noise and the noise ∈ t , t represents the number of time steps for adding noise to the encoding result in step A1; Step A6: based on the noise after quantization editing Noise without quantization editing ∈ t and the noise-added coding result, using the LDM to predict x'0 and x'0 represents the predicted latent variable without attribute editing, Represents the predicted latent variable after attribute editing; Step A7: Replace x'0 and Input font attribute predictor and calculate k pre and ω pre , k pre represents the predicted font style attribute index, ω pre represents the predicted editing intensity; when The training of the font attribute encoder and the font attribute predictor is completed when .

9. A computer storage medium, wherein the computer storage medium is stored in a computer, wherein the computer storage medium stores a computer program executable by the computer, wherein: When the computer program is executed by a computer, the computer implements the font style attribute quantitative editing method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Multi-style font generation method of variational auto-encoder based on vector quantization

    CN111161266A

  • Form and meaning character generation method and device, equipment and medium

    CN116630142A