A font outline generation method and device

By generating and processing the semantic feature sequences and hidden spatial sequences of font outlines, and using the diffusion model to calculate the conditional noise prediction model, the problem of failing to effectively output font outline data in AI-generated fonts is solved, and fast and accurate font outline generation is achieved.

CN117689767BActive Publication Date: 2025-03-21BEIJING HANYI KEYIN INFORMATION TECH +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410037073.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-01-10
Publication Date
2025-03-21
Estimated Expiration
2044-01-10

AI Technical Summary

Technical Problem

The existing AI method of generating fonts fails to effectively output font outline data, resulting in a lengthy generation process and serious accuracy loss.

Method used

By obtaining the font outline sequence information, a font outline semantic feature sequence is generated, and a conditional noise prediction model is calculated using the hidden space sequence and diffusion model, and iteratively denoised to generate a complete font outline sequence.

Benefits of technology

It realizes the rapid generation of complete font outlines, avoids lengthy extraction processes and accuracy losses, and improves generation efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117689767B_ABST
    Figure CN117689767B_ABST
Patent Text Reader

Abstract

The present invention provides a font outline generation method, comprising: obtaining font outline sequence information; generating a font outline semantic feature sequence according to the font outline sequence information; calculating a latent space sequence and font outline sequence representation information according to the font outline semantic feature sequence; obtaining diffusion model parameters, and calculating a conditional noise prediction model based on the latent space sequence and the diffusion model parameters; iterating the conditional noise prediction model based on a number of new font outline samples to obtain a latent space sequence denoising model; obtaining random Gaussian noise, inputting the random Gaussian noise into the latent space sequence denoising model, and iteratively calculating to obtain a latent space coding sequence; and calculating a font outline sequence according to the latent space coding sequence. The present invention also includes a corresponding font outline generation device. The font outline generation method provided by the present invention has a high generation efficiency compared to existing font outline extraction algorithms.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of computer vision, and in particular relates to a font outline generation method and device. Background Art

[0002] At present, AI-generated Chinese font technology has made great progress and can generate fonts with certain aesthetics and practicality. For the font design industry, modern font formats such as TrueType and PostScript use vectorized graphic representations to present the outlines of glyphs. Specifically, the outline is usually represented by a series of lines or Bezier curves, which allows the glyphs to be scaled and rasterized to any desired size.

[0003] However, most of the current methods for generating AI-generated fonts only go so far as to generate font images using generative network models. The font images do not come with font outline data. To achieve complete outline output, it is usually necessary to use a font outline extraction algorithm to extract the font outline from the image. The entire processing chain from AI-generated fonts to font outline extraction algorithms is relatively lengthy and will result in a large loss of accuracy due to the existence of intermediate links.

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

[0005] In view of the scenario in which the AI-generated font in the prior art does not come with font outline data, the present invention provides a font outline generation method, which can be applied to extract fonts without font outline data, comprising the following steps:

[0006] Step S1, obtaining font outline sequence information;

[0007] Step S2, generating a font outline semantic feature sequence according to the font outline sequence information;

[0008] Step S3, calculating and obtaining latent space sequence and font outline sequence representation information according to the font outline semantic feature sequence;

[0009] Step S4, obtaining diffusion model parameters, and calculating a conditional noise prediction model based on the latent space sequence and the diffusion model parameters;

[0010] Step S5, iterating the conditional noise prediction model based on a number of new font outline samples to obtain a latent space sequence denoising model;

[0011] Step S6, obtaining random Gaussian noise, inputting the random Gaussian noise into the latent space sequence denoising model, and iteratively calculating to obtain a latent space coding sequence;

[0012] Step S7: Calculate and obtain a font outline sequence according to the latent space encoding sequence.

[0013] In a preferred embodiment of the present invention, step S3 includes:

[0014] Step S3.1, obtaining an encoder and a fixed-length encoding Query, and encoding the font outline semantic feature sequence through the encoder based on the font outline semantic feature sequence and the fixed-length encoding Query to obtain a latent space sequence;

[0015] Step S3.2, obtaining a decoder, decoding the latent space sequence x0, and obtaining font outline sequence representation information;

[0016] Wherein, the decoder adopts autoregressive decoding.

[0017] In a specific embodiment of the present invention, the encoding and decoding steps of step S3 include content reconstruction loss and rendering perception loss, wherein:

[0018] The content reconstruction loss is calculated as: L R =L cls +L pos , L pos is the regression loss of coordinate information, L cls is the classification loss of discrete information, where represents the coordinate prediction obtained by the decoder model, is the real coordinate of the input data, represents the category prediction of the decoder model, y i,l is the true category of the input data, N seq is the length of the font outline semantic feature sequence, i refers to the font outline semantic feature sequence length index, j refers to the font outline semantic feature sequence dimension index, K refers to the font outline semantic feature sequence dimension value, L R Refers to the content reconstruction loss function;

[0019] The formula for calculating rendering perceptual loss is: represents the image output after differentiable rendering based on the parameters output by the decoder. The coordinate information in the output result of the decoder is x, the category information is p, and the superscript θ is used to represent the output of the decoder and the actual real sequence; f(·) refers to the use of convolutional neural network to extract the visual features of the image; L lpips Refers to the perceptual loss of two images.

[0020] In a specific embodiment of the present invention, step S4 includes:

[0021] Step S4.1, randomly select diffusion number t and calculate the diffusion coefficient corresponding to t t is a positive integer;

[0022] Step S4.2: Perform diffusion and noise calculation on the latent space sequence information.

[0023] In a specific embodiment of the present invention, in step S4,

[0024] Diffusion coefficient The calculation formula is:

[0025] The calculation formula of diffusion noise is: ∈ is a random Gaussian distribution, T is the total number of diffusion steps, s is 0.008, t≤T.

[0026] In a specific embodiment of the present invention, the conditional noise prediction model ∈ θ The training steps include:

[0027] Step A1: Build a conditional noise prediction model ∈ θ And initialize the conditional noise prediction period model parameters;

[0028] Step A2: Obtain the latent space sequence x after diffusion and noise addition t , the style encoding vector z corresponding to the actual font style id s The content encoding vector z corresponding to the content id c , the latent space sequence x after adding noise t , style encoding vector z s and content encoding vector z c Input the conditional noise prediction model ∈ θ ;

[0029] Step A3: Conditional noise prediction model ∈ θ Output prediction result ∈ θ (x t ,z t ,z s ,z c ), z t Encode vector for diffusion model time step;

[0030] Step A4: According to the prediction result ∈ θ (x t ,z t ,z s ,z c), calculate the prediction loss, perform gradient descent processing according to the prediction loss function, and update the conditional noise prediction model ∈ θ , where the prediction loss function is L = ||∈ θ (x t ,z t ,z s ,z c )-∈|| 2 .

[0031] Step A5: Repeat steps S3.1, S3.2, A2, A3, and A4 in sequence until the conditional noise prediction model ∈ θ Converge, and obtain the trained conditional noise prediction model ∈ θ .

[0032] In a specific embodiment of the present invention, step S5 further includes:

[0033] Step S5.1: Obtain the randomly initialized style vector parameter z′ s , a font outline data training set and new font outline data, wherein the new font outline samples are font outline samples corresponding to the font samples input by the user, and the number of font samples is relatively small relative to all characters of the font;

[0034] Step S5.2: Randomly initialize the style vector parameter z′ s , font outline data training set and new font outline sample data execute step S3 to obtain mixed input data x0′ and latent space sequence x′ t ;

[0035] Step S5.3: Mix the input data x0′ and the latent space sequence x′ t is the conditional noise prediction model ∈ θ 'Input, loop steps A3-A5 for conditional noise prediction model ∈ θ 'Fine-tune until the conditional noise prediction model ∈ θ 'Converge and obtain the latent space sequence denoising model.

[0036] In a specific embodiment of the present invention, step S6 further includes:

[0037] Perform T conditional noise reduction cycle calculations, the conditional noise reduction cycle calculation is: Among them, β t is the variance parameter of the diffusion step, whose value is determined by the diffusion coefficient The calculation results in: Get the latent space encoding sequence

[0038] In a specific embodiment of the present invention, step S7 includes:

[0039] The latent space encoding sequence Input the decoder and obtain the outline font sequence through decoding calculation.

[0040] The present invention also provides a font outline generating device, comprising:

[0041] An acquisition module, used to obtain font outline sequence information;

[0042] An outline feature backbone module, used for generating a font outline semantic feature sequence according to the font outline sequence information;

[0043] A coding and decoding module calculates a latent space sequence and font outline sequence representation information according to the font outline semantic feature sequence, and calculates a font outline sequence according to the latent space coding sequence;

[0044] A diffusion module, which obtains diffusion model parameters and calculates a conditional noise prediction model based on a latent space sequence and the diffusion model parameters;

[0045] A fine-tuning module, iterating the conditional noise prediction model based on a number of font outline parameters to obtain a latent space sequence denoising model;

[0046] The font outline expansion module obtains random Gaussian noise, inputs the random Gaussian noise into the latent space sequence denoising model, and iteratively calculates to obtain the latent space coding sequence.

[0047] The present invention can bring at least one of the following beneficial effects: the font outline generation method and device proposed in the present invention are based on latent space sequences, and do not need to use a font outline extraction algorithm to extract and calculate all fonts in a whole set of fonts. It only needs to fine-tune the trained conditional noise prediction model to generate a complete vectorized font outline corresponding to the whole set of fonts based on a small part of the outline data samples, thereby realizing rapid font outline generation for the whole set of fonts. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] 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.

[0049] Figure 1 A schematic diagram of the steps of the font outline generation method proposed in the first embodiment of the present invention;

[0050] Figure 2 Schematic diagram of the training steps of the conditional noise prediction model in the first embodiment of the present invention;

[0051] Figure 3This is a schematic diagram of step S5 in the first embodiment of the present invention;

[0052] Figure 4 This is a schematic diagram of the structure of a font outline generating device proposed in Embodiment 2 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] The following is an explanation of the invention:

[0066] Latent variable diffusion model: A diffusion model generated in the latent variable space. The training is divided into two stages. The first stage trains the auto-encoder model that compresses the input into the latent variable space. The second stage trains the denoising model in the latent variable space.

[0067] Model fine-tuning: Model fine-tuning refers to further training on a specific task or data based on an already trained model to improve the performance of the model on the task and data domain.

[0068] Differentiable renderer: The traditional rendering process is not differentiable, so it is difficult to use gradient descent to optimize the rendering results. Differentiable renderer or differentiable rasterizer achieves high-quality rasterization of vector images through pre-filtering technology, so that gradient descent can be used to optimize the rendering results of vector graphics. It connects the fields of vector graphics and raster images, enabling raster-based loss functions, optimization processes, and machine learning techniques to edit and generate vector content.

[0069] Perceptual loss: also known as LPIPS loss, is a loss function used to measure the similarity between two images. It is based on human perception and can better capture human subjective judgment of image similarity.

[0070] Embodiment 1

[0071] In view of the scenario in which AI-generated fonts in the prior art do not come with font outline data, the present invention provides a font outline generation method that can be used to extract fonts that do not come with font outline data. Figure 1 , including the following steps:

[0072] Step S1, obtaining font outline sequence information;

[0073] Step S2, generating a font outline semantic feature sequence according to the font outline sequence information;

[0074] Step S3, calculating and obtaining latent space sequence and font outline sequence representation information according to the font outline semantic feature sequence;

[0075] Step S4, obtaining diffusion model parameters, and calculating a conditional noise prediction model based on the latent space sequence and the diffusion model parameters;

[0076] Step S5, iterating the conditional noise prediction model based on a number of new font outline samples to obtain a latent space sequence denoising model;

[0077] Step S6, obtaining random Gaussian noise, inputting the random Gaussian noise into the latent space sequence denoising model, and iteratively calculating to obtain a latent space coding sequence;

[0078] Step S7: Calculate and obtain a font outline sequence according to the latent space encoding sequence.

[0079] Specifically, the font outline sequence information in step S1 includes coordinate information representing the positions of outline points and discrete information of outline parameters, and the font outline semantic feature sequence in step S2 can represent the outline.

[0080] In a preferred embodiment of the present invention, step S3 includes:

[0081] Step S3.1, obtaining an encoder and a fixed-length encoding Query, and encoding the font outline semantic feature sequence through the encoder based on the font outline semantic feature sequence and the fixed-length encoding Query to obtain a latent space sequence;

[0082] Step S3.2, obtaining a decoder, decoding the latent space sequence x0, and obtaining font outline sequence representation information;

[0083] Wherein, the decoder adopts autoregressive decoding.

[0084] Preferably, the fixed length in step S3.1 is a hyperparameter, and its value can be taken as 100. The latent space sequence preferably limits the output value to between -1 and 1 through the tanh activation function; the font outline sequence representation information in step S3.2 includes coordinate information and discrete information.

[0085] In a preferred embodiment of the present invention, the encoding and decoding steps of step S3 include content reconstruction loss and rendering perception loss, wherein:

[0086] The content reconstruction loss is calculated as: L R =L cls +L pos , L pos is the regression loss of coordinate information, L cls is the classification loss of discrete information, where represents the coordinate prediction obtained by the decoder model, is the real coordinate of the input data, represents the category prediction of the decoder model, y i,l is the true category of the input data, N seq is the length of the font outline semantic feature sequence, i refers to the font outline semantic feature sequence length index, j refers to the font outline semantic feature sequence dimension index, K refers to the font outline semantic feature sequence dimension value, L R Refers to the content reconstruction loss function;

[0087] The formula for calculating rendering perceptual loss is: represents the image output after differentiable rendering according to the parameters output by the decoder. The coordinate information in the output result of the decoder is x, the category information is p, and the superscript θ is used to represent the output of the decoder and the actual true sequence; f(·) refers to the visual features of the image extracted by the convolutional neural network.

[0088] Preferably, the aforementioned convolutional neural network can be vgg, resnet, etc.

[0089] The structural differences between the rendering results and the real images are captured through neural network matching, thereby constraining the encoding and decoding model to obtain more accurate and reasonable prediction results.

[0090] Preferably, the content reconstruction loss and rendering perception loss are considered in a weighted manner, that is, the weights Total loss L = w p L p +L R , the model gradient descent iterative optimization is performed with the total loss function, and a codec model that can realize the conversion of font outline sequence to latent space sequence is trained.

[0091] In a preferred embodiment of the present invention, step S4 comprises:

[0092] Step S4.1, randomly select diffusion number t and calculate the diffusion coefficient corresponding to t t is a positive integer;

[0093] Step S4.2: Perform diffusion and noise calculation on the latent space sequence information.

[0094] Preferably, in step S4,

[0095] Diffusion coefficient The calculation formula is:

[0096] The calculation formula of diffusion noise is: ∈ is a random Gaussian distribution, T is the total number of diffusion steps, s is 0.008, t≤T.

[0097] Preferably, the T value can be set to 1000.

[0098] In a preferred embodiment of the present invention, see the attached Figure 2 , the conditional noise prediction model ∈ θ The training steps include:

[0099] Step A1: Build a conditional noise prediction model ∈ θ And initialize the conditional noise prediction period model parameters;

[0100] Step A2: Obtain the latent space sequence x after diffusion and noise addition t, the style encoding vector z corresponding to the actual font style id s The content encoding vector z corresponding to the content id c , the latent space sequence x after adding noise t , style encoding vector z s and content encoding vector z c Input the conditional noise prediction model ∈ θ ;

[0101] Step A3: Conditional noise prediction model ∈ θ Output prediction result ∈ θ (x t ,z t ,z s ,z c ), z t Encode vector for diffusion model time step;

[0102] Step A4: According to the prediction result ∈ θ (x t ,z t ,z s ,z c ), calculate the prediction loss, perform gradient descent processing according to the prediction loss function, and update the conditional noise prediction model ∈ θ , where the prediction loss function is L = ||∈ θ (x t ,z t ,z s ,z c )-∈|| 2 .

[0103] Step A5: Repeat steps S3.1, S3.2, A2, A3, and A4 in sequence until the conditional noise prediction model ∈ θ Converge, and obtain the trained conditional noise prediction model ∈ θ .

[0104] Preferably, the conditional noise prediction model ∈ θ A multi-layer transformer network structure designed with self-attention.

[0105] In a preferred embodiment of the present invention, see the attached Figure 3 , step S5 further includes:

[0106] Step S5.1: Obtain the randomly initialized style vector parameter z′ s , a font outline data training set and new font outline data, wherein the new font outline samples are font outline samples corresponding to the font samples input by the user, and the number of font samples is relatively small relative to all characters of the font;

[0107] Step S5.2: Randomly initialize the style vector parameter z′ s , font outline data training set and new font outline sample data execute step S3 to obtain mixed input data x0′ and latent space sequence x′ t ;

[0108] Step S5.3: Mix the input data x0′ and the latent space sequence x′ t is the conditional noise prediction model ∈ θ 'Input, loop steps A3-A5 for conditional noise prediction model ∈ θ 'Fine-tune, the number of cycles is preferably 5000 steps, until the conditional noise prediction model ∈ θ 'Converge and obtain the latent space sequence denoising model.

[0109] Preferably, in step S5.3, a smaller learning rate is used for the conditional noise prediction model ∈ θ 'Make fine adjustments.

[0110] In a preferred embodiment of the present invention, step S6 further includes:

[0111] Perform T conditional noise reduction cycle calculations, the conditional noise reduction cycle calculation is: Among them, β t is the variance parameter of the diffusion step, whose value is determined by the diffusion coefficient The calculation results in: Get the latent space encoding sequence

[0112] In a specific embodiment of the present invention, step S7 includes:

[0113] The latent space encoding sequence Input the decoder and obtain the outline font sequence through decoding calculation.

[0114] Embodiment 2

[0115] See attached Figure 4 , is a schematic diagram of a font outline generating device according to another specific embodiment of the present invention, comprising:

[0116] An acquisition module, used to obtain font outline sequence information;

[0117] An outline feature backbone module, used for generating a font outline semantic feature sequence according to the font outline sequence information;

[0118] A coding and decoding module calculates a latent space sequence and font outline sequence representation information according to the font outline semantic feature sequence, and calculates a font outline sequence according to the latent space coding sequence;

[0119] A diffusion module, which obtains diffusion model parameters and calculates a conditional noise prediction model based on a latent space sequence and the diffusion model parameters;

[0120] A fine-tuning module, iterating the conditional noise prediction model based on a number of font outline parameters to obtain a latent space sequence denoising model;

[0121] The font outline expansion module obtains random Gaussian noise, inputs the random Gaussian noise into the latent space sequence denoising model, and iteratively calculates to obtain the latent space coding sequence.

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

[0123] The font outline generation method and device proposed in the present invention are based on latent space sequences. There is no need to use a font outline extraction algorithm to extract and calculate all the fonts in a whole set of fonts. It only needs to fine-tune the trained conditional noise prediction model. It is then possible to generate a complete vectorized font outline corresponding to the whole set of fonts based on a small part of the outline data samples, thereby realizing rapid font outline generation for the whole set of fonts.

[0124] 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.

[0125] 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.

[0126] 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.

[0127] 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 outline generation method, characterized in that: The following steps are involved: Step S1, obtaining font outline sequence information, wherein the font outline sequence information includes coordinate information representing the position of outline points and discrete information of outline parameters; Step S2, generating a font outline semantic feature sequence according to the font outline sequence information, wherein the font outline semantic feature sequence represents an outline; Step S3, calculating and obtaining latent space sequence and font outline sequence representation information according to the font outline semantic feature sequence; Step S3 includes: Step S3.1, obtaining an encoder and a fixed-length encoding Query, and encoding the font outline semantic feature sequence through the encoder based on the font outline semantic feature sequence and the fixed-length encoding Query to obtain a latent space sequence; Step S3.2: Obtain a decoder to decode the latent space sequence Perform decoding processing to obtain font outline sequence representation information; Wherein, the decoder adopts autoregressive decoding; Step S4, obtaining diffusion model parameters, and calculating a conditional noise prediction model based on the latent space sequence and the diffusion model parameters, wherein the conditional noise prediction model adopts a multi-layer transformer network structure designed with self-attention; Step S5, iterating the conditional noise prediction model based on a number of new font outline samples to obtain a latent space sequence denoising model; Step S6, obtaining random Gaussian noise, inputting the random Gaussian noise into the latent space sequence denoising model, and iteratively calculating to obtain a latent space coding sequence; Step S7: Calculate and obtain a font outline sequence according to the latent space encoding sequence.

2. The method for generating a font outline according to claim 1, characterized in that: The encoding and decoding steps of step S3 include content reconstruction loss and rendering perception loss, where: The content reconstruction loss calculation formula is: , , ; is the regression loss of coordinate information, is the classification loss of discrete information, where represents the coordinate prediction obtained by the decoder model, is the real coordinate of the input data, represents the category prediction of the decoder model, is the true category of the input data, is the length of the font outline semantic feature sequence, i Refers to the length index of the font outline semantic feature sequence, j Refers to the font outline semantic feature sequence dimension index, K Refers to the dimension value of the font outline semantic feature sequence. Refers to the content reconstruction loss function; The formula for calculating rendering perceptual loss is: It represents the image output after differentiable rendering according to the parameters output by the decoder. The coordinate information in the output result of the decoder is x , the category information is p , superscript θ Used to represent the output of the decoder and the actual true sequence; f (·) refers to the use of convolutional neural networks to extract visual features of images; Refers to the perceptual loss of two images.

3. The method for generating a font outline according to claim 2, wherein: The step S4 comprises: Step S4.1: Randomly extract diffusion sequence number t ,calculate t The corresponding diffusion coefficient , t is a positive integer; Step S4.2: Perform diffusion and noise calculation on the latent space sequence information.

4. The method for generating a font outline according to claim 3, characterized in that: In the step S4, Diffusion coefficient The calculation formula is: , 2 , The calculation formula of diffusion noise is: , is a random Gaussian distribution, T is the total number of diffusion steps, s Take 0.008, t ≤ T .

5. The method for generating a font outline according to claim 4, characterized in that: The conditional noise prediction model The training steps include: Step A1: Build a conditional noise prediction model And initialize the conditional noise prediction model parameters; Step A2: Obtain the latent space sequence after diffusion and noise addition , the style encoding vector corresponding to the actual font style id The content encoding vector corresponding to the content id , the latent space sequence after noise is , style encoding vector and content encoding vector Input the conditional noise prediction model ; Step A3: Conditional noise prediction model Output prediction results , Encode vector for diffusion model time step; Step A4: Based on the prediction results , calculate the prediction loss, and perform gradient descent processing based on the prediction loss function to update the conditional noise prediction model , where the prediction loss function is ; Step A5: Repeat steps S3.1, S3.2, A2, A3, and A4 in sequence until the conditional noise prediction model is Convergence, get the trained conditional noise prediction model .

6. The method for generating a font outline according to claim 5, characterized in that: Step S5 also includes: Step S5.1: Obtain random initialization style vector parameters , a font outline data training set and a new font outline sample, wherein the new font outline sample is a font outline sample corresponding to the font sample input by the user; Step S5.2: Randomly initialize the style vector parameters , the font outline data training set and the new font outline sample perform step S3 calculation to obtain the mixed input data and latent space sequence ; Step S5.3: Mixing input data and latent space sequence Conditional noise prediction model ' Input, loop steps A3-A5 for conditional noise prediction model ' Fine-tune until the conditional noise prediction model ' Converge, and get the latent space sequence denoising model.

7. The method for generating a font outline according to claim 5, characterized in that: Step S6 also includes: Perform T conditional noise reduction cycle calculations, the conditional noise reduction cycle calculation is: ,in, is the variance parameter of the diffusion step, whose value is determined by the diffusion coefficient The calculations show that: , and get the latent space encoding sequence .

8. The method for generating a font outline according to claim 7, characterized in that: Step S7 includes: The latent space encoding sequence Input the decoder and obtain the outline font sequence through decoding calculation.

9. A font outline generating device, characterized in that: include: An acquisition module, used for acquiring font outline sequence information, wherein the font outline sequence information includes coordinate information representing the position of outline points and discrete information of outline parameters; An outline feature backbone module, used to generate a font outline semantic feature sequence according to the font outline sequence information, wherein the font outline semantic feature sequence represents an outline; The encoding and decoding module calculates the latent space sequence and the font outline sequence representation information according to the font outline semantic feature sequence; wherein, an encoder and a fixed-length encoding Query are obtained, and based on the font outline semantic feature sequence and the fixed-length encoding Query, the font outline semantic feature sequence is encoded by the encoder to obtain a latent space sequence; a decoder is obtained to encode the latent space sequence Performing decoding processing to obtain font outline sequence representation information; the decoder uses autoregressive decoding; A diffusion module obtains diffusion model parameters, and calculates a conditional noise prediction model based on a latent space sequence and the diffusion model parameters, wherein the conditional noise prediction model adopts a multi-layer transformer network structure designed with self-attention; A fine-tuning module, iterating the conditional noise prediction model based on a number of new font outline samples to obtain a latent space sequence denoising model; The font outline expansion module obtains random Gaussian noise, inputs the random Gaussian noise into the latent space sequence denoising model, iteratively calculates to obtain a latent space coding sequence, and calculates a font outline sequence based on the latent space coding sequence.

Citation Information

Patent Citations

  • Aptamer generation method based on conditional discrete diffusion model

    CN116631499A

  • Font generation method and device based on diffusion model

    CN117057310A